|
|
|
|
|
by gioscarab
1948 days ago
|
|
Thinking about it more in detail, functions require the parentheses to show where the call ends. I obviously could count the number of expected parameters as function is defined, but that leaves room for error, and a creepy syntax, ie: sum 2, multiply 2, 2, 2 for which function is the last parameter for? You are right about the function names, I am not forced to use the camel form which I do not love, it could be serial_write or even serial write |
|
This is basically how concatenative stack-based languages do it, although by convention they put the arguments before the function call. (Reverse Polish Notation) In Forth, your example would be written one of the following two ways, depending on whether multiply() or sum() is consuming the extra 2:
2 2 2 * 2 + +
> 8
2 2 2 * * 2 +
> 10
Also valid would be:
2 2 2 * 2 +
> 2 6
where the left-most 2 is not consumed, but rather is left in place.