[Top][All Lists]

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

Re: Injecting variables into closures.

From: Ludovic Courtès
Subject: Re: Injecting variables into closures.
Date: Thu, 29 Nov 2007 17:02:13 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)


"Kjetil S. Matheussen" <address@hidden> writes:

> By the way. I'm quite surprised the environments consist
> of linked lists. Wouldn't it be much faster using hash
> tables instead? Perhaps the variables are cached or something?

Yes, variable references are "cached" ("memoized") so that actual
variable lookup occurs only once.  So, for instance, in the following
piece of code:

  (let ((x 1)(y 2))
    (foo y))

the reference to "y" in "(foo y)" is replaced by an "iloc" that says
"this is a reference to the second variable in the first frame".  When
that iloc is encountered, the variable's value is fetched by doing
(roughly) two `list-ref's: one to get the frame and then one to get the
variable within the frame.

Clearly, a vector-like data structure (i.e., with O(1) access to
individual elements) would help here.


reply via email to

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