[Cl-perec-devel] Optimization question
Attila Lendvai
attila.lendvai at gmail.com
Fri Oct 9 13:56:48 UTC 2009
> variant, but is it possible to optimize it so that it results in a
> single select like the first one?
someone somewhere needs to add a cond that dispatches on the interesting types.
perec has not much chance, because it doesn't really know what are the
possible/interesting types to dispatch on (and collecting runtime
information and dynamically recompiling is beyond the scope of a lib
without the environment supporting it)
so, i suggest to create a macro for which you can give a list of types
and a code body, and builds up the dispatch for you. something similar
to sb-imp::string-dispatch:
(defmacro string-dispatch ((&rest types) var &body body)
(let ((fun (sb!xc:gensym "STRING-DISPATCH-FUN")))
`(flet ((,fun (,var)
, at body))
(declare (inline ,fun))
(etypecase ,var
,@(loop for type in types
;; TRULY-THE allows transforms to take advantage of the type
;; information without need for constraint propagation.
collect `(,type (,fun (truly-the ,type ,var))))))))
--
attila
More information about the cl-perec-devel
mailing list