guile-devel
[Top][All Lists]
Advanced

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

Re: Elisp flet construct


From: Andy Wingo
Subject: Re: Elisp flet construct
Date: Fri, 24 Jul 2009 00:50:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

On Thu 23 Jul 2009 23:53, Ken Raeburn <address@hidden> writes:

> On Jul 23, 2009, at 16:46, Andy Wingo wrote:
>> On Tue 21 Jul 2009 15:10, Daniel Kraft <address@hidden> 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)))

Of course :) But with lexical scoping you can statically determine when
variables are assigned. The tree-il->glil compiler already does this.

> 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....)

If the continuation may be captured, you have to heap-allocate mutated
vars. So we just heap-allocate all mutated vars.

Cheers,

Andy
-- 
http://wingolog.org/




reply via email to

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