unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Daniel Kraft <d@domob.eu>
To: "Marijn Schouten (hkBst)" <hkBst@gentoo.org>
Cc: Andy Wingo <wingo@pobox.com>, Ken Raeburn <raeburn@raeburn.org>,
	guile-devel <guile-devel@gnu.org>,
	Neil Jerram <neil@ossau.uklinux.net>
Subject: Re: Elisp lexical-let
Date: Wed, 22 Jul 2009 21:24:31 +0200	[thread overview]
Message-ID: <4A67676F.9010905@domob.eu> (raw)
In-Reply-To: <4A670D78.3040804@gentoo.org>

Hi Marijn,

Marijn Schouten (hkBst) wrote:
> Guile also has lexical and dynamic variables; the fluids[1]. Queinnec in his
> book LiSP also describes a system that has (default) lexical and dynamic
> variable, on page 44. In both cases to find the value of a non-default variable
> a function is used. Translated to elisp where the situation is dynamic by
> default you probably want something like `(lexical x)' to dereference the
> lexical variable `x' and also lexical-set(q).
> 
> It seems to me that only the dereferencing of variables is dynamic or lexical,
> not the binding. Thus you don't even need lexical-let and `(lexical x)' would be
> `x' found in the lexical environment (if it isn't found you can generate an
> error) and `x' would be searched for in the dynamic environment. Does that make
> sense?

not only the dereferencing, but also the setting must be of a dynamic or 
lexical value; and at least in my Lisp code, setting is mostly done with 
let's, so at the same time as the "binding".

So what you propose would then be to have a (lexical sym) for 
referencing and (lexical-set! sym value) for setting in lexical scope -- 
and then as a consequence also a lexical-let, that does let but sets to 
the provided values just as lexical-set! does...?  Well, that's how I 
see it, anyways.

And while your arguments seem quite reasonable (decide for each access 
of a symbol between lexical and dynamic), I think this creates a 
superfluous amount of confusion and "just" switching for certain 
variables to lexical binding within the scope of a lexical-let seems to 
me the better solution.

What's about this:

(defun test () a)
(let ((a 1))
   (print a) ; 1
   (print (test)) ; 1
   (lexical-set! a 2)
   (print a) ; 1?
   (print (test)) ; 1
   (print (lexical a)) ; 2
   )

I don't think it's good to have to "completely seperate" variables a and 
(lexical a).  And besides, here there's no way to decide that no fluids 
at all are needed for a, as the let construct itself (except the 
references following) still creates a with-fluids* call.

Yours,
Daniel

PS: From a performance point of view, I guess that the void checks on 
each variable access are far more expensive than the 
fluid/dynamic-scoping business.  But I'll report on this (performance) 
maybe in a seperate posting when I've done some experiments and real 
data as well as suggestions.

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




  reply	other threads:[~2009-07-22 19:24 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 [this message]
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
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=4A67676F.9010905@domob.eu \
    --to=d@domob.eu \
    --cc=guile-devel@gnu.org \
    --cc=hkBst@gentoo.org \
    --cc=neil@ossau.uklinux.net \
    --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).