[Top][All Lists]

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

Re: [Chicken-users] hygienic named let

From: Jim Ursetto
Subject: Re: [Chicken-users] hygienic named let
Date: Mon, 1 Sep 2008 12:02:43 -0500

On Mon, Sep 1, 2008 at 2:34 AM, felix winkelmann <address@hidden> wrote:
> On Sun, Aug 31, 2008 at 7:28 AM, Jim Ursetto <address@hidden> wrote:

>>     #;3> (module foo (bar)
>>               (import scheme)
>>               (define-syntax bar (syntax-rules ()
>>                     ((_) (let loop ((x 3)) x)))))
>>     #;4> (module baz () (import foo) (bar))
>>     Warning: reference to possibly unbound identifier: loop
>>     Warning: reference to possibly unbound identifier: letrec

> Indeed, letrec is not detected to be a macro. The named let
> expansion is somewhat special in that it is the only core
> syntax that expands into the use of a macro. If that macro
> is not in the current import environment, it is treated just
> like a normal value-binding (and thus renamed).

But it is imported.  foo imports scheme and uses named let, baz
imports foo, therefore the expanded call to bar should see letrec via
foo's import environment.

> Right - scheme is not imported, so there's no way to detect whether
> letrec is a macro or not.

See above.

> Named let is handled specially by the expander - redefinitions
> of let will not help here (unless they exist in a surrounding local
> binding environment).

As I said, I modified the expander to stop handling named let (and let
in general) specially, and made LET a macro in the
default-macro-environment (which works fine).  I appended that code to
my original message.  LETREC is also contained in that environment.
So why doesn't it work there?

>> change ##core#app to ,(r 'apply), and you
>> will get an unbound identifier APPLY.

> I'm not sure about the 'apply thing as it works for me, if used
in a normal module-level macro.

It doesn't work in my er-transformer version of let I posted.

I don't understand why let needs to be handled specially, can you
explain?  Like I said, I stripped out the special let handling code in
##sys#expand-0 and made let a regular er-transformer macro, and it
works perfectly fine -- I can even recompile Chicken with it.  The
problem is that renames don't seem to work properly inside it.  If you
use ##core#app and ##core#letrec renames don't come into play, so why
is the special handling required in the first place?

reply via email to

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