unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Re: Injecting variables into closures.
       [not found] <Pine.LNX.4.64.0711291458380.9048@ttleush>
@ 2007-11-29 14:54 ` Kjetil S. Matheussen
  2007-11-29 16:02   ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Kjetil S. Matheussen @ 2007-11-29 14:54 UTC (permalink / raw)
  To: guile-user, guile-devel



On Thu, 29 Nov 2007, Kjetil S. Matheussen wrote:

>
> (let ()
>   (display (defined? 'gakk))
>   (inject-variable gakk 90)
>   gakk)
> =>  #f90
>

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?




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Injecting variables into closures.
  2007-11-29 14:54 ` Injecting variables into closures Kjetil S. Matheussen
@ 2007-11-29 16:02   ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2007-11-29 16:02 UTC (permalink / raw)
  To: guile-user; +Cc: guile-devel

Hi,

"Kjetil S. Matheussen" <k.s.matheussen@notam02.no> 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.

Thanks,
Ludovic.



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-11-29 16:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.64.0711291458380.9048@ttleush>
2007-11-29 14:54 ` Injecting variables into closures Kjetil S. Matheussen
2007-11-29 16:02   ` Ludovic Courtès

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