[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] making lambdas more introspective
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] making lambdas more introspective |
Date: |
Mon, 30 May 2005 09:01:24 +0200 |
On 5/30/05, Michele Simionato <address@hidden> wrote:
>
> Are you saying that extended procedures cannot be optimized in general?
Well, more precisely, the compiler can not infer from
(define foo
(extend-procedure
(lambda ...)
...))
that `foo' is actually bound to the inner lambda. The `extend-procedure'
may (from the compilers point of view) return anything. And extend-procedure
may be redefined too...
On the other hand,
(define foo (lambda ...))
shows the compiler that foo is bound to the lambda and allows
inlining, etc.
>
> BTW, I was trying to see if I could redefine "lambda" with tricks like
> this:
>
> (define-macro (original-lambda formals . body)
> `(lambda ,formals ,@body))
>
> (define-macro (introspective-lambda formals . body)
> `(extend-procedure
> (original-lambda ,formals ,@body) '((formals . ,formals))))
>
> (define-macro lambda introspective-lambda)
>
> But it seems I am entering in an infinite loop somewhat ...
Yes, your new lambda refers to itself. That will need a more
primitive lambda form.
cheers,
felix