3 ms·
After having grokked Lisp, I think that parentheses provide a more elegant solution to the problem of parameter separation. Compare: myfunction(a, b, c) with
by vaylian 4y ago
After having grokked Lisp, I think that parentheses provide a more elegant solution to the problem of parameter separation. Compare:
myfunction(a, b, c)
with
(myfunction a b c)
Parentheses allow you to leave out the commas between arguments. I like that a lot.
- pg_1234 4y agoWhile C syntax requires commas, there's nothing about having the function name outside the parentheses that suddenly forces commas. Theoretically: (myfunction a b c) could be written as: myfunction(a b c)
- bradrn 4y agoML-family languages are similar: ‘myfunction a b c’. It definitely is nice.
- deleted 4y ago[deleted]
- avindroth 4y agoThe consequence of having the AST be explicit is profound.
- thaumasiotes 4y ago> Parentheses allow you to leave out the commas between arguments. You compared the wrong things. The parentheses associated with myfunction aren't doing that. The reason Lisp is better at passing arguments to functions is that it requires you to add parentheses to every function call. The C-style syntax in your first example is trying to let you do this: myfunction(a, a+b, c) In Lisp, you'd do this: (myfunction a (+ a b) c) C has "saved" you the work of putting parentheses around (a+b) at the cost of making you add commas to everything. Here that's a wash because you needed two commas. But C really did save you three spaces that are necessary in the Lisp. (They separate a from myfunction and + from a/b.) You could save two spaces while getting the same benefit of losing the commas if you went with myfunction(a +(a b) c)
- kazinator 4y ago> C has "saved" you the work of putting parentheses around (a+b) at the cost of making you add commas to everything. Not only that but also at the cost of putting a comma which is spelled + between all the terms of a addition: myfunction(a(),b()+c()+d()+e()+f(),g()) (myfunction(a)(+(b)(c)(d)(e)(f))(g))
- msk-lywenn 4y agocould just as well be myfunction(a() +(b() c() d() e() f()) g()) with the condition that there is no space between the symbol and the opening parenthesis
- rileyphone 4y agoI’m working on a syntax for an object oriented lisp-like thats basically this (the self receiver is implied) .myfunction(.a .b.+(.c).+(.d).+(.f) .g) though making binary arithmetic operations singly-dispatched methods of the number class may be a mistake.
- actionfromafar 4y agoYak-shaving away syntax always make me think of Forth. It's all a stack.