[Top][All Lists]

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

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

From: Thomas Chust
Subject: Re: [Chicken-users] possible lazy-let macro?
Date: Fri, 18 Nov 2005 00:42:51 -0000
User-agent: Opera M2/8.02 (MacPPC, build 2148)

Am 17.11.2005, 23:18 Uhr, schrieb Daishi Kato <address@hidden>:

I cannot think of an easy way to fix this without having to make the
macro quite syntax-aware, though. Therefore I would rather suggest to
implement the whole thing for regular let forms in one of the compiler's
optimization passes ;)

I first thought this was an optimization issue in the complier,
but it might be not, because in some case there is a side effect,
while assigning let variables.  If it is possible for the compiler
to optimize with the normal let, I would prefer it.

Right, with sideeffects this can get quite nasty... So optimization by
default is not really possible :(

Would it be worth improving the lazy-let macro
so that it understands at least let and quote forms?

I think it is rather complicated. Maybe that's worth it -- but it depends
on what you want to use it for. If you are careful about what you are doing,
the present version can be useful as well...

By the way, another thing that is problematic except let constructs and
quotes are lambda expressions. If I write something like
  (let ((a (get-a)))
    (lambda (blubb) (work-with a blubb)))
I do that because I want (get-a) to be called only once and the result stored in a to be part of the anonymous procedure's environment. However, replacing
let with lazy let in the above snippet will cause it to macroexpand into
    (lambda (blubb)
      (work-with (get-a) blubb)))
On the other hand
  (lazy-let ((a (get-a)))
    (lambda (blubb)
      (work-with a blubb)))
expands into
  (let ((a (get-a)))
      (lambda (blubb)
        (work-with a blubb))))
And so we encounter the philosophical question which one is the desired
behaviour and the technical question how to make it consistent :)


reply via email to

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