3 ms·
> The very fact that you must write (function sin), or #'sin, or use funcall is a way that it treats functions differently than normal values. Look closer. I h
by lispm 9y ago
> The very fact that you must write (function sin), or #'sin, or use funcall is a way that it treats functions differently than normal values.
Look closer. I have not used FUNCTION in 1), 2) or 3). Common Lisp does not treat functions different from other values. They are first class values.
These are the three operations which define whether functions are first class values:
( https://en.wikipedia.org/wiki/First-class_function https://en.wikipedia.org/wiki/First-class_function ) :
1) passing a function
2) returning a function
3) assigning them to variables or storing them in data structures
None of that requires anything special for functions in Common Lisp.
What you need to do in Common Lisp, is to use FUNCTION to get a function from a lexical name and you need to call such a function via FUNCALL, but that has nothing to do with the requirements for a 'first class datatype', which is defined by the three requirements above (passing, returning, assigning).
- db48x 9y ago> What you need to do in Common Lisp, is to use FUNCTION to get a function from a > lexical name and you need to call such a function via FUNCALL, but that has nothing > to do with the requirements for a 'first class datatype', which is defined by the > three requirements above (passing, returning, assigning). And I'm saying that in practice, regardless of any technical definitions you'll find in a textbook, this need to treat functions specially is exactly what makes people who learn Common Lisp wonder why people say that functions are first class values. You don't have to look up the value of a variable by writing (variable foo), but you do have to use (function foo). Clojure goes one step further and lets you treat non-functions as if they were functions, by using them in the function positions of expressions.
- lispm 9y ago> regardless of any technical definitions you'll find in a textbook It's the definition of first-class values. You may have your own, but then you need to tell us what you mean first. Communication by redefining established terms is getting painful... > why people say that functions are first class values Because you can pass functions, return functions and store functions. That's what "first-class datatype" means. > You don't have to look up the value of a variable by writing (variable foo), but you do have to use (function foo) Only if you want to get the function from the function namespace. If the function is already referenced in the value namespace, then you don't have to do it. > Clojure goes one step further and lets you treat non-functions as if they were functions, by using them in the function positions of expressions. Which existed long before Clojure in Lisp. For example Lisp Machine Lisp had callable arrays 4 decades ago. Features like these make it a good write-only language.
- db48x 9y ago> Communication by redefining established terms is getting painful... And here I thought I was telling you that not everybody uses "first-class" (or even "first-class values") in precisely the same way. I agree that the strictest definition only deals with how you use the various types of values you might have in your program, and not with the types of names you can give them. I hope you can also agree that not everyone limits themselves to just the values; they see the differences in how functions get stored in the environment, and recalled from it, and see this as treating the functions differently than the variables. This does mean that many people are operating with a broader definition of what "first-class" means. It would be perfectly clear to call it "first-class naming", for example, but polysemy is not unique to software engineering; we must allow for it in all fields of endeavour. My only point all along was merely that when someone hyperbolically calls Common Lisp a "Jim Crow" language, they are not wrong merely because they are talking about names instead of values. As an aside, I didn't mean to imply that Clojure invented callable arrays, merely that Clojure programs use them frequently; probably just as frequently as they use higher-order functions. I take no position on whether any language is "write-only" or not; that would be nearly as productive as talking about "virtue signalling". ;)
- lispm 9y ago> And here I thought I was telling you that not everybody uses "first-class" (or even "first-class values") in precisely the same way. I know of no other definition of 'first-class value', which is an established concept since at least Scheme was invented in the mid 70s, which made functions true first class values. The idea that procedures in some programming languages were not first-class seem to come from C. Stratchey from the mid 60s, where functions in Algol can't be the result of compound expressions, can't be stored in variables and data structures. > It would be perfectly clear to call it "first-class naming" If someone would define it and give it some useful semantics, it might be clear. > I didn't mean to imply that Clojure invented callable arrays, merely that Clojure programs use them frequently; probably just as frequently as they use higher-order functions. This podcast speaks exactly how an error introduced by callable data influenced the developer leave Clojure for Haskell: https://building.fireside.fm/37 https://building.fireside.fm/37