4 ms·
My impression sometimes is that RPN (like in Forth) could be used as well and do with parenthesis altogether But of course, Forth has a stack, Lisp does not ne
by raverbashing 14y ago
My impression sometimes is that RPN (like in Forth) could be used as well and do with parenthesis altogether
But of course, Forth has a stack, Lisp does not need one
To write 5 * (2 + 3)
Lisp: ( * 5 (+ 3 2))
Forth (ignore the dot): 2 3 + 5 * .
- akkartik 14y agoCheck out nokolisp for the opposite of your idea! http://koti.welho.com/tnoko/Nokolisp.htm http://koti.welho.com/tnoko/Nokolisp.htm
- RodgerTheGreat 14y agoForth actually has two stacks. Lisp has garbage-collected storage and environment structures, and Forth does not need them. :) Logo is a Lisp-like language which uses prefix notation but does not require parentheses surrounding every procedure invocation. Your example could be written as: product 5 sum 3 2 Parens are allowed for adding clarity and are only required for a vararg-style invocation. The main downside of this approach is that it is necessary to know the arity of every procedure in an expression to unambiguously parse it- Logo implementations typically either defer some safety checks to runtime or compile in two passes. Forth doesn't have this problem because it doesn't parse expressions per se- it compiles and interprets as it goes along.
- eru 14y agoLisp needs the parenthesis not because it lacks a stack, but because functions (like +) can take a variable number of arguments.
- darkf 14y agoI made a parentheses-less Lisp-inspired language a while back by using prefix (polish) notation with fixed-arity functions. You can find it here: https://github.com/darkf/possumv2 https://github.com/darkf/possumv2