On Thu 23 Jul 2009 23:53, Ken Raeburn <raeb...@raeburn.org> writes: > 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)))
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/