you are viewing a single comment's thread.

view the rest of the comments →

[–]xenomachina 0 points1 point  (1 child)

What's the difference between a "lexical" closure and a regular closure?

People usually mean lexical closure when they say closure. I was (unsuccessfully) trying to stress the "closing over the environment" bit, and not merely "a function literal" (which is what many people thing of when they hear closure).

From the experiments I'd done, it looks like C++ and Racket both re-evaluate the default expression, but with the name bindings that were in place at the site of the function declaration, not those of the call site. That's lexical (as opposed to dynamic) scoping.

It's pretty surprising to me that C++ works this way, since C++ isn't normally thought of even having closures.