Re:How Lisp Became God's Own Programming Language
by kazinator on Tuesday October 16, 2018 @08:36PM
(#18234550)
We can tell that 3 arguments are being applied to eql from that expression; when this is compiled, the generated call will pass 3 arguments, regardless of whether eql likes that, or whether such a function even exists. In the absence of any static checks, it will have to be caught at run time; but it will be caught.
Also, Lisp supports variadic functions with the same safety. Delimitation of arguments is necessary for variadic functions, like list.
The structure of every top-level form is an actual tree object in memory that is constructed before anything else happens. It can be walked by macros, or quoted so that the program accesses it as data directly.
Basically, nothing like Forth.
Re:How Lisp Became God's Own Programming Language
by thaumasiotes on Tuesday October 16, 2018 @10:44PM
(#18235711)
> Delimitation of arguments is necessary for variadic functions, like list.
This is not the case; you can easily have a Forth word that consumes however many arguments as are on the stack.
Re:How Lisp Became God's Own Programming Language
by kazinator on Wednesday October 17, 2018 @10:51AM
(#18239622)
Ah, but the argument was made that Forth code has an implicit tree structure based on looking up the arity of functions, in place of explicit delimitation with parentheses. How can that be if some function takes N arguments, where N is, say, a run-time value, itself on the stack.
That error also comes from the semantics. You can't tell that (eql 1 2 3) is a too-many-arguments error just by looking at the tokens. That could be a 3-ary function, or an "eql is not a function" error.
The parentheses in Lisp code certainly suggest a particular tree structure, but they don't require it by virtue of their graphical form. And once you're willing to look up the arity of functions, Forth is written directly in its own tree structure to exactly the same degree that Lisp is, just with structural markers elided.
Think about it another way: a classmate in compilers class asked me once how Lisp handled operator precedence. Obviously, with the tree structure of the code fully specified, Lisp doesn't handle operator precedence because the question can't arise.
Note that this is just as true of Forth.