I know this isn't the identity function, but it's the same idea and a feeling I get when using Lisps that the language is kind of "complete". Including the identity function and having built in 0-ary functions where it makes sense are examples of this.
And whoever wrote it out took the time to follow syntax. Although I think this is actually Scheme? Defining a function in Lisp is slightly different if I recall.
it's not just the functionalness. you couldn't do it this way in Lisp/Scheme (I think?) because of the lack of multiple dispatch.
If you did (f 'x) for instance, you'd end up with things like (* 2 'x) which would blow up, since Lisp would try to compute the answer instead giving you '(* 2 x) back.
Paving over the difference could seem convenient but it smells like a possible source of non obvious coding errors. AFAIK it's still worthwhile to know the difference between function identity and the value that produces identities.
Though, lots of this is inherited from common lisp where the list operations have more to do with lambda calc and the physical construction of the old lisp machines than they do anything else.
I think the point to take home here is that LISP has a rich set of functions and building blocks around lists. Indeed, if you have something you want to do to a list, that function probably already exists.
Contrasted with many other languages that are catching up, but sometimes have surprising amount of boilerplate to process data.
You'd think this would be more understood given that pretty much the whole point of lisp is to be pretty close to just representing an AST without relatively few frills. The idea that we can represent most languages with a tree-like structure isn't particularly novel.
That's an interesting example. My first reaction was that one might be able to construct a similar anomaly by abusing optional arguments, but perhaps not: optional arguments to F don't get magically passed on to G. Still, I feel like I've seen function-signature constructs that would break the identity function similarly to how multiple-return does in your example. Maybe some twisted aspect of Common Lisp...
Neat! Reminds me of the Lisps around that still have f-exprs, like NewLisp (f-exprs are functions that take their arguments unevaluated, functions are mutable lists of code you can overwrite, etc)
I am more used to thinking of it in terms of having function values (closures), but I think you could argue the lexical scoping that leads to SSA is all that's necessary once you have closures.
In any case, the vast majority of the lisp code I've read has been imperative and non-functional.
Lisp idioms like (mapcar function list) replace both looping and recursion with an aggregate operation, similar to APL; it's just not obsessively condensed into a single character syntax.
reply