by Sibers CTO Andrey Gavrilov
After revising my ideas on writing functions from the previous post, I came to the conclusion that previously described function arguments could still cause problems. First of all, the lines with supposedly defined iterators will suffer. Even if we create some additional iterators, anyway func val and func (val) being not identical will be troublesome.
Another idea, a crazier one, dawned upon me – that parentheses are optional as they function as a grouping operator as in expressions. Then the arguments in writing without parentheses are still divided by comas. To avoid errors we introduce the following conventions:
•Expression interpretation doesn’t depend on defining functions. Which argument belongs to which function is defined only by calling the function. It will let us avoid errors in calls while changing the function format.
•Expression interpretation should be such as to obtain any variants of argument distribution between functions by means of parentheses.
Hence we assume that the absence of parentheses is identical with the widest parentheses.
Examples:
func1 func2 arg are interpreted only as func1(func2(arg)) as they don’t include a coma;
func1 func2 arg1, arg2 are interpreted as func1(func2(arg1), arg2).
In order to transmit arg2 to func2, it should be explicitly shown with parentheses:
func1 func2 (arg1, arg2)
Seems to work correctly, doesn’t it?