3 ms·
My understanding is that Scheme is quite functional. So were the very first versions of Lisp. Common Lisp, on the other hand, strikes me as not very functional
by bradrn 5y ago
My understanding is that Scheme is quite functional. So were the very first versions of Lisp. Common Lisp, on the other hand, strikes me as not very functional at all (from what limited experience I have of the language). It does have first-class functions, and functions like ‘map’ and ‘reduce’, but that isn’t enough to make it truly functional — it seems to lack the characteristic approach of building functions from smaller functions that is so common in functional languages.
(Also, functionality is more of a continuum than a binary category. CL certainly is more functional than Python, but less functional than Scheme or SML. It all depends on where you draw the dividing line, though I’d argue that classifying CL as ‘non-functional’ makes for more meaningful categories.)
- lispm 5y agoThe very first versions of Lisp were less functional than Common Lisp: imperative, mutable data, mostly only dynamic scoping for variables, no lexical scope, first class data type of functions unclear, ... Common Lisp at least has lexical scope and first class functions.
- bradrn 5y ago> The very first versions of Lisp were less functional than Common Lisp: imperative, mutable data, mostly only dynamic scoping for variables, no lexical scope, first class data type of functions unclear, ... Hmm, perhaps I’m misremembering — I know very little about the history of Lisp. I was thinking specifically about the very beginning of the language, where it could be used to define ‘eval’ and nothing much else.
- lispm 5y agoThis is the manual of Lisp I, the first actual implementation of Lisp, from 1960: http://bitsavers.org/pdf/mit/rle_lisp/LISP_I_Programmers_Manual_Mar60.pdf http://bitsavers.org/pdf/mit/rle_lisp/LISP_I_Programmers_Man...
- hajile 5y agoCommon Lisp has lexical AND dynamic scoping. This is very nice with constants. A function can make a hard dependency on standard out for example. If I change that value locally then call the function, it will operate as expected while everything else using that variable name will continue using their own expected values too. Lexical scoping would instead require passing that value in every time it is used.
- dreamcompiler 5y agoScheme directly supports call-with-current-continuation (which CL doesn't) and it requires tail call elimination (which CL doesn't require but most CL implementations do it anyway). Scheme also has slightly easier syntax for dealing with functions in function position, at the cost of potential namespace clashes. Some schemes (e.g. Racket) provide immutable data structures. So I guess Scheme is slightly more functional than CL but with the exception of call/cc the differences are so minor that it doesn't matter.