[plt-scheme] Closures

From: hendrik at topoi.pooq.com (hendrik at topoi.pooq.com)
Date: Mon Nov 5 15:41:54 EST 2007

On Mon, Nov 05, 2007 at 02:40:52PM -0500, Joel J. Adamson wrote:
> hendrik at topoi.pooq.com writes:
> 
> > Ah.  Let's say you're a function.
> 
> "Your immune system is like an army..."
> 
> > Now this package of code-plus-environment, which closes off all the 
> > dangling reference a function might have, is called a closure.  
> > Abd indeed, because it is the closure of a function you can call it.
> 
> Okay, I have not read the materials Matthias or Shriram suggested, so
> I'm still naïve about this: this makes sense, however, from your
> description you (the programmer) call the function, right?  The
> environment exists (it's there), but you don't invoke an environment.
> If you can, however, that's pretty cool and please tell me about it ;)

Don't know about Scheme, but there have been proposals for modules 
system where a module evaluates to an environment and then somewhere 
else you import that environment.  Usually the environment is trimmed to 
make available just those names the module is willing to export.

This was in a module system proposed for Algol 68; I think something 
like it is in ML.  Adapting this idea to a statically-typed 
language works.  I suspect it would feel like unhygienic macros if done 
in something like Scheme.

> 
> > I don't even know if Scheme has any kinds of closures that can't be 
> > called.  I don't know of any.  So if your frame-sets are different 
> > (you seem to think they can't be called) perhaps you could give me an 
> > intuitive explanation what *they* are.
> 
> Just to clarify, I'm not dealing with a specific problem, I'm just
> always looking for more ways to "think in Scheme."
> 
> Thanks, this definitely helps,
> Joel
> 
> 
> -- 
> Joel J. Adamson
> Biostatistician
> Pediatric Psychopharmacology Research Unit
> Massachusetts General Hospital
> Boston, MA  02114
> (617) 643-1432
> (303) 880-3109
> 
> 
> The information transmitted in this electronic communication is intended only for the person or entity to whom it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this information in error, please contact the Compliance HelpLine at 800-856-1983 and properly dispose of this information.


Posted on the users mailing list.