chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] possible lazy-let macro?


From: Alex Shinn
Subject: Re: [Chicken-users] possible lazy-let macro?
Date: Thu, 17 Nov 2005 19:19:46 -0600
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]