At Fri, 18 Nov 2005 08:18:11 +0900, Daishi Kato wrote:
>
> Would it be worth improving the lazy-let macro
> so that it understands at least let and quote forms?
Not let forms. Analyzing subforms of a macro is called code-walking,
and the first thing you then need to do is sc-expand the body or
lazy-let won't play well with other macros. At that point there are
no let's remaining, and everything is in terms of lambda.
But I think the problem you're trying to solve is in general
unsolvable. Consider the form:
(lazy-let ((a (get-a)))
(list (if (condition-1) a #f)
(if (condition-2) a #f)))
If you expand this to
(list (if (condition-1) (get-a) #f)
(if (condition-2) (get-a) #f))
then you may end up calling get-a twice. However, if you compute the
value once outside the nearest enclosing form for all occurances:
(let ((a (get-a)))
(list (if (condition-1) a #f)
(if (condition-2) a #f)))
then you always compute get-a even when it may not be needed.
--
Alex
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users