Re: How to implement lexical closures?

andy johnson <sleepdev@gmail.com>
Sun, 9 May 2010 10:45:07 -0700 (PDT)

          From comp.compilers

Related articles
How to implement lexical closures? grom358@gmail.com (grom) (2010-05-06)
Re: How to implement lexical closures? sleepdev@gmail.com (andy johnson) (2010-05-09)
Re: How to implement lexical closures? gneuner2@comcast.net (George Neuner) (2010-05-09)
Re: How to implement lexical closures? cr88192@hotmail.com (BGB / cr88192) (2010-05-09)
Re: How to implement lexical closures? torbenm@diku.dk (2010-05-10)
Re: How to implement lexical closures? grom358@gmail.com (grom) (2010-05-11)
Re: How to implement lexical closures? cr88192@hotmail.com (BGB / cr88192) (2010-05-12)
Re: How to implement lexical closures? gene.ressler@gmail.com (Gene) (2010-05-12)
[8 later articles]
| List of all articles for this month |
From: andy johnson <sleepdev@gmail.com>
Newsgroups: comp.compilers
Date: Sun, 9 May 2010 10:45:07 -0700 (PDT)
Organization: Compilers Central
References: 10-05-031
Keywords: design, storage
Posted-Date: 09 May 2010 16:08:05 EDT

In terms of performance, for stack based languages you might want to
take a look at a technique called lambda lifting (http://
en.wikipedia.org/wiki/Lambda_lifting). The effect of which is to
reduce a program with closures to a program without closures. However
it is nontrivial to implement(consider the case of functions that
return functions) and as such may be easier to take the memory and/or
performance hit and just pass around closures explicitly.


Explicit closure passing may be implemented as continuations:


abstract class Continuation
{
      Object[] closure;
      Object call(Object[] args);
}


it is important to note also that all top level functions would also
need to use this interface in order to normalize the calling
convention for first-class functions.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.