[Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

Jules Bean jules at jellybean.co.uk
Thu Jun 19 01:53:47 EDT 2008

Richard A. O'Keefe wrote:

> - what you get is a reference to a variable (as you do in Scheme)
>   but loop variables really are variables, not names for values,
>   so lambdas created in different iterations of the same loop point
>   so the same loop variable, and do not remember the value it had
>   when they were created.  The proposal explains how to work around this.

This one trips everyone up in Javascript.

I think I'm of the opinion that variable capture from lambda formation 
should always be by value. However you can certainly make an argument 
that that's inconsistent in a language which generally has 
mutation/reference semantics. Whichever choice you make, though, 
document it loudly I predict it will be a source of confusion.


More information about the Haskell-Cafe mailing list