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

Richard A. O'Keefe ok at cs.otago.ac.nz
Sun Jun 22 22:23:26 EDT 2008


This is increasingly less relevant to Haskell, except
of course to demonstrate what a nice language Haskell is.
On 20 Jun 2008, at 11:34 pm, Jules Bean wrote:
> I think where I differ on you is how to map the semantics of a C- 
> like language to explicit references.
>
> I would argue that the glyph "c" in a C-like language denotes the  
> value of C, not the reference to it. C-like languages have, for the  
> most part, value semantics, and call-by-value.
>
> The exception of course is what C-like languages called "lvalues",  
> but lvalues are only really on the left of the = sign and a few  
> other special positions. I think that's the exception and not the  
> rule.

No, this is back to front.  C basically follows the Algol 68 idea that
the lvalue is the normative thing, and that there is an IMPLICIT  
COERCION
from a variable to its value in certain contexts.  C is full of implicit
coercions: perhaps the most famous is the one that says that in almost  
all
contexts an array is quietly coerced to a pointer to its first element.

The key observation is that an implicit coercion from a variable to its
contents is possible, whereas an implicit coercion from a value to "the"
variable that holds it is not.   Only the "a variable really stands for
its address" view is coherent.

> In C, of course, if you want to capture the reference you do it  
> explicitly with "&c".

If we can use evidence from a relative to probe such questions,
the fact that you *don't* need an explicit "&" in C++ (when you find a  
'reference'
to a variable, you use "c", not "&c") strongly suggests that the  
"variable stands
for location" view is the more useful one.

Thankfully, Haskell saves us these perplexities.
(And replaces them with other perplexities...)



More information about the Haskell-Cafe mailing list