On Jul 23, 2009, at 16:46, Andy Wingo wrote:
On Tue 21 Jul 2009 15:10, Daniel Kraft <d...@domob.eu> writes:
Just a little addition to the subject of extensions: I'd very much like
to add lexical-let and lexical-let* as another set of extensions,
because this gives the possibility to use "fast" lexical variables
without the dynamic-scoping-fluid-pain.

Yes, yes. I totally agree. This allows stack allocation of the variables as well, which can be a significant speed win (because of not making so
much garbage).

In some cases, but not all. Consider the Lisp version of an example I remember from my Scheme intro class:

  (defun make-counter ()
    (lexical-let ((count 0))
      (lambda ()
         (setq count (+ 1 count))
         count)))

In the Scheme version, and in Emacs with the cl package, a separate binding of "count" exists for each generated counter "object", so you can create and use several counters independently. If we want this to work in Guile-Elisp too, I don't think "count" can live on the stack in this case, since it has to survive past the return from make- counter. The dynamic-scoping-fluid-pain is replaced by lambda- environment-tracking-pain. :)

Without lambda or defun forms inside the lexical-let, yes, I think stack slots can be used. (Well, I'm kind of fuzzy on the whole call/ cc thing, but I assume that's already addressed elsewhere....)

Ken


Reply via email to