[iterate-devel] problem with maybe-quoted

Hoehle, Joerg-Cyril Joerg-Cyril.Hoehle at t-systems.com
Mon Nov 24 12:08:41 UTC 2008


Hi,

Vsevolod wrote:
>(defun split (seq pred)
>    (iter (for el in-sequence seq)
>           (if (funcall pred el)
>               (collect el into sat result-type (type-of seq))
>               (collect el into nsat result-type (type-of seq)))
>           (finally (return (values sat nsat)))))
>
>But such a construct won't work because result-type is recognized as a
>literal (not evaluated). I think it's rather a bug, than a feature,
>because this somewhat inhibits the possibilities of programmatic
>extension of the ITER macro. Isn't it?

To make such a statement, you have to come up with a better example.
Your DEFUN knows nothing about the type of the SEQ parameter which will
be supplied at run-time, so how do you expect Iterate to do something
particular depending on the type?

Iterate's design is to produce code at macroexpansion-time. (TYPE-OF
seq) inside DEFUN yields a type at run-time -- too late.

Generally, in CL forms, you'll see types not evaluated. Years ago, KMP
had a good posting about this topic in comp.lang.lisp.

BTW, Iterate's RESULT-TYPE does nothing more than a COERCE, so you could
just add it yourself. Or, if you don't like the presumable waste in
COERCE, write a TYPECASE for the few types where you expect that to make
a difference, and then do not forget to perform some benchmarking.

Regards,
	Jorg Hohle




More information about the iterate-devel mailing list