unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Daniel Kraft <d@domob.eu>
To: Andy Wingo <wingo@pobox.com>
Cc: Ken Raeburn <raeburn@raeburn.org>, guile-devel <guile-devel@gnu.org>
Subject: Re: Elisp lexical-let
Date: Fri, 24 Jul 2009 09:08:17 +0200	[thread overview]
Message-ID: <4A695DE1.4010500@domob.eu> (raw)
In-Reply-To: <m3ws5zdny2.fsf@pobox.com>

Hi Andy,

thanks for the clarifications!

> It's actually fairly simple, imo. Alpha-equivalence says that
> (lexical-let ((x a)) x) is the same as (lexical-let ((y a)) y). (Note
> that this lexical-let corresponds to Scheme's let.) So your program is
> the same as:
> 
>> (lexical-let ((y 2))
>>   y ; -> 2
>>   (foo) ; -> 1
>>   (setq y 3)
>>   y ; -> 3
>>   (foo) ; -> 1
>>   (let ((x 4))
>>     x ; -> 4?
>>     (foo) ; -> 4
>>     (setq x 5)
>>     x ; -> 5
>>     (foo) ; -> 5
>>     ) ; end the let
>>   y ; -> 3?
>>   (foo) ; -> 4
>>   )
>> x ; -> 4
>> (foo) ; -> 4

Yes of course, my main question was how the inner let is handled, and 
what dynamic values x will attain (the results of (foo)) -- and here's 
this funny stuff that the inner let will be like lexical-let for those 
variables already lexically bound.

> I haven't reviewed your compiler yet, and for that I apologize. But. You
> need to make sure that when you compile, you build up a compile-time
> environment, mapping symbols to locations -- if a variable is free,
> lexically bound, or dynamically bound. When your compiler sees a lexical
> binding, replace that identifier with a gensym, and add an entry to your
> compile-time environment to map that identifier to that lexical gensym.
> That way you will effectively be processing my example, which is
> equivalent to yours, but perhaps clearer because the names have been
> uniquified. Then your problems go away.

This is how I was thinking about implementing the lexical-let semantics. 
  To give more details:

I want to keep track of identifiers that are lexically bound in the 
current scope while compiling as well as to what gensym they are, and 
then instead of the fluid-ref's just reference/set this 
gensym-identifier when I come across an access.  It seems this is 
exactly what you describe above :)

So, that's it with regards to messages from me :D  Thanks for all your 
comments again,

Daniel

-- 
Done:  Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri




  reply	other threads:[~2009-07-24  7:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-21 19:48 Elisp lexical-let Daniel Kraft
2009-07-21 21:46 ` Ken Raeburn
2009-07-22  9:11   ` Daniel Kraft
2009-07-22 13:00     ` Marijn Schouten (hkBst)
2009-07-22 19:24       ` Daniel Kraft
2009-07-23 15:24         ` Marijn Schouten (hkBst)
2009-07-23 16:13           ` Mark H Weaver
2009-07-23 20:53             ` Andy Wingo
2009-07-23 17:05           ` Daniel Kraft
2009-07-24 11:09             ` Marijn Schouten (hkBst)
2009-07-22 20:50     ` Ken Raeburn
2009-07-23 10:47       ` Daniel Kraft
2009-07-23 20:56         ` Andy Wingo
2009-07-24  6:50           ` Daniel Kraft
2009-07-23 20:49     ` Andy Wingo
2009-07-23 22:39 ` Andy Wingo
2009-07-24  7:08   ` Daniel Kraft [this message]
2009-07-24 11:42     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A695DE1.4010500@domob.eu \
    --to=d@domob.eu \
    --cc=guile-devel@gnu.org \
    --cc=raeburn@raeburn.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).