4 ms·
So now there is Clozure common lisp, Clojure for the JVM, and now Closure. I was already getting the first two mixed up.
by justinhj 17y ago
So now there is Clozure common lisp, Clojure for the JVM, and now Closure.
I was already getting the first two mixed up.
- DannoHung 17y agoI am never going to be able to refer to an actual closure again and have anyone understand what I'm talking about, am I?
- harto 17y agoI already find that hard enough - I've found that people tend to conflate first-class functions with closures.
- mjs 17y agoWell, is there any real different between a first-class function and a closure that closes over nothing? Is it possible for a language to support closures without first-class functions? How common is it to have first-class functions without closures? (I think Python sort of had this arrangement, but I think this is fixed now.)
- andreyf 17y agoA closure is just a (function, bindings) pair, so Python certainly has closures. The problem with Python is that there is no syntax for assigning to variables declared in an arbitrary scope, because there are no explicit declarations. As far as I understand, implicit local variables are what causes the problems in Python, not anything about closures, really. This causes other problems, too, such as those PG described here [1], under the heading "Implicit local variables conflict with macros". 1. http://www.paulgraham.com/arclessons.html http://www.paulgraham.com/arclessons.html
- mjs 17y agoInteresting. Thanks.
- micheles 17y agoPython 3 has read-write closures. Check out the nonlocal declaration.
- andreyf 17y agoThe nonlocal statement causes the listed identifiers to refer to previously bound variables in the nearest enclosing scope. [1] While certainly a big improvement, we still can't access variables in arbitrary scopes, just local, nearest non-local, and global. To me, this seems a significantly more complex way of specifying variable scope than just declaring it explicitly. 1. http://docs.python.org/dev/3.0/reference/simple_stmts.html#the-nonlocal-statement http://docs.python.org/dev/3.0/reference/simple_stmts.html#t...
- blasdel 17y agoHaskell does not semantically have closures at all, because functions have only their arguments -- no scope to close over. Lexically, there's where clauses to scope function definitions, but that gets desugared very early, and is really not the same thing at all anyway (the name binding is completely static).
- distortion 17y agoOf course Haskell has closures, there's always a scope to close over: f x = (\y -> x + y)
- blasdel 17y agoThat's still just high-level lexical sugar - the 'scope' is not captured, just rewritten. After desugaring, there is no scope left, even lexically. It's completely different from a 'closure' in a language that has variables.
- raju 17y agoUpvoted for two reasons - Making me laugh out loud, and for letting me know that I am not the only one getting confused. Other commentators have mentioned the confusion with Rich's Clojure, and despite Rich's stand that is be pronounced like you would pronounce "closure", I usually still say it with the emphasis on the "J", esp. to Lisp-savvy folks. [On a side note, and I am nitpicking here, but it's just Clojure, vs Clojure for the JVM, considering Clojure for the CLR is very close to 1.0]