2 ms·
> Parentheses allow you to leave out the commas between arguments. You compared the wrong things. The parentheses associated with myfunction aren't doing that.
by 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.