>Choice #2, Uniform Function Call Syntax (UFCS), allows you to write `a.someFunc(b)` or `someFunc(a, b)` interchangeably.
Interesting idea.
The topic of function call syntax reminded me of something:
I'm not a language creator, but years ago, when I was fairly new to programming, I had this idea that it would be cool and maybe useful for a language to have function call syntax something like this, to more closely resemble English sentences:
hit_the_(ball)_with_the_(bat)
or just:
hit_(ball)_with_(bat)
where ball and bat are arguments. (Not too good an example, I know, because in a cricket or baseball game, the ball and bat would not vary at all, or not vary often, unlike arguments tend to do, on different calls. But I think people will get the idea.) IOW, instead of having all the arguments grouped together inside one set of parentheses, make it more like an imperative English sentence, by having multiple parentheses, one per argument, separated (if needed) by other words (which are part of the function name).
The above example would be for a language where types of function arguments are not specified. For a language where they are, it could be like this:
hit_(ball: Ball)_with_(bat: Bat)
Of course, I've left out the syntax for something like "def" (as in Python) to say that this is a function definition and for the return value/type, if any.
Don't know what the complexity of implementing something like that would be.
Interesting idea.
The topic of function call syntax reminded me of something:
I'm not a language creator, but years ago, when I was fairly new to programming, I had this idea that it would be cool and maybe useful for a language to have function call syntax something like this, to more closely resemble English sentences:
hit_the_(ball)_with_the_(bat)
or just:
hit_(ball)_with_(bat)
where ball and bat are arguments. (Not too good an example, I know, because in a cricket or baseball game, the ball and bat would not vary at all, or not vary often, unlike arguments tend to do, on different calls. But I think people will get the idea.) IOW, instead of having all the arguments grouped together inside one set of parentheses, make it more like an imperative English sentence, by having multiple parentheses, one per argument, separated (if needed) by other words (which are part of the function name).
The above example would be for a language where types of function arguments are not specified. For a language where they are, it could be like this:
hit_(ball: Ball)_with_(bat: Bat)
Of course, I've left out the syntax for something like "def" (as in Python) to say that this is a function definition and for the return value/type, if any.
Don't know what the complexity of implementing something like that would be.