|
|
|
|
|
by loup-vaillant
4869 days ago
|
|
Verb vs nouns. Well, what are objects in OO? They're things that do this, and change that… This is a lot about what objects do, and what we do to them. On the other hand, in FP, one "does" only one thing: create new values. There is a lot of verbs in FP, but they don't do anything… Anyway, I guess I'll need to review that. Instruction sequence vs Expression tree It's jot just Lisp. Ocaml and Haskell apply as well. We don't manipulate the syntax tree, but it doesn't mean it isn't there. For instance, the following is a valid Ocaml or Haskell expression: if condition
then foo
else bar (if condition2
then baz
else wiz)
This is not unusual code. Here is the C equivalent: condition
? foo
: bar(condition2 ? baz : wiz)
This is a tree of nested expressions.Functions as ordinary mathematical objects. I'm just saying that functions belong to the bucket of mathematical objects. As are integers. And sets. And lists… "First class" just mean we treat them as such. From https://en.wikipedia.org/wiki/First-class_function > In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type. |
|
This is both misleading and false. Functions, by their very nature, "do something."
Perhaps you're referring to the immutability of data in a functional language? If so, say so.
"We don't manipulate the syntax tree, but it doesn't mean it isn't there."
A statement so ambiguous as to be meaningless. All compiled languages have a "syntax tree" lurking in the background. It just so happens that Lisp and its variants let you manipulate that tree directly, rather than writing in code that gets converted to that tree at compile time.
Perhaps you're referring to the fact that in Haskell, you often don't control the order in which code is executed, unlike in an imperative language where you have explicit control?
"...just saying that functions belong to the bucket of mathematical objects. As are integers. And sets."
Nope. The quote you use has it right. The names of functions are variables, whose value is looked up like any variable. This lets you pass functions as arguments to other functions, or use functions as the return value for other functions. Functions are most definitely not just like integers in a functional language.