34 points · by tosh · 9y ago · 28 comments
> It turns out there is very little code that would break if Emacs strings became immutable
Which means that very little Clojure code would break if they just went ahead and used Emacs strings.
> Common Lisp fans claim that lisp-2s have first-class functions, but the way they are kept separate from other first-class values in their own namespace ghetto brings to mind claims of "separate but equal"—at best it is Jim Crow functional programming.
Jim Crow functional programming?? The virtue signalling is strong in this one. He's wrong on the facts, too.
A Lisp-2 doesn't keep the function inside the ghetto, it keeps everyone else out. Functions can be everywhere, but a non-function can't be the value of a function binding. Function's aren't second class in this system, they're royal class.
As for the latter, it does occasionally feel like functions aren't truly first-class in a lisp-2 because you have to jump through hoops to pass them along as an argument (funcall, #'foo syntax, etc). In most lisps passing functions as arguments is just as common as "calling" non-function values is in Clojure. Anyway, I suspect that the "Jim Crow" dig was hyperbole, not intentional virtue signalling. :P
The definition of 'first class functions' is not a feeling, but three capabilities:
CL-USER 9 > (let ((sin-fn (function sin)))
(list
; 1) passing functions as arguments to other functions
(mapcar sin-fn '(1 2 3 4))
; 2) returning them as the values from other functions
((lambda () sin-fn))
; 3) and assigning them to variables or storing them in data structures
(let ((v #(1 2 3)))
(setf (aref v 1) sin-fn)
v)))
((0.84147096 0.9092974 0.14112 -0.7568025) ; 1)
#<Function SIN 410007BC14> ; 2)
#(1 #<Function SIN 410007BC14> 3)) ; 3)
As you can see, functions are first-class values in Common Lisp.> In most lisps passing functions as arguments is just as common as "calling" non-function values is in Clojure
Including Lisp-2s. Passing functions is completely normal and widely used in Common Lisp. The Common Lisp standard has literally zillions of functions where you pass one or more functions in.
Common Lisp also can make CLOS objects callable.
And just as we both agree that in Common Lisp passing functions in as arguments is very common, so in Clojure is "calling" a vector on a number to index into it, or "calling" a symbol to use it as an index into a alist or hash table, etc. Not only do you not have to type anything extra, you can treat all values as callable.
If strings in Emacs are mutated so rarely that making them immutable would cause almost no breakage, it logically follows that strings in Emacs are mutated so rarely that using them from Clojure as if they were immutable would cause almost no problem either.
What a gross metaphor, feels totally out of place.
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9...
Clojurescript uses this approach and probably it's ok.