3 ms·
Would Scheme count as a functional programming language by this definition? On one hand, the idiomatic emphasis on tail calls (supported by tail call optimizat
by canjobear 11y ago
Would Scheme count as a functional programming language by this definition?
On one hand, the idiomatic emphasis on tail calls (supported by tail call optimization in the language) makes it easy to avoid stateful for and while loops.
On the other hand, most nontrivial code has plenty of `set!`s.
- davexunit 11y agoScheme is a multi-paradigm programming language. Functional is one such paradigm that it supports. It also supports imperative, object-oriented, relational, and probably others that I don't even know about. In Scheme, one can build functional systems on top of imperative building blocks. For example, memoization can be implemented as a higher-order procedure that uses a mutable hash table as the cache. A memoized function is still pure, despite the use of local state, because it retains the crucial property of referential transparency. Anyway, I guess my point is that the use of 'set!' or 'hash-table-set!' or whatever else doesn't mean that a program is no longer using the functional paradigm. To quote from a Clojure web page[0], "if a pure function mutates some local data in order to produce an immutable return value, is that ok?" [0] http://clojure.org/transients http://clojure.org/transients