Here’s a goofy topic for a rainy Sunday. I was pondering this morning how it would look if a function could accept arguments in more than one place, like the following
rather than the current
This for sure would open up for some code that reads very much like natural language, but would there be significant downsides?
Some potential complications and comments:
- One could probably not allow two consequtive sets of
()()as that would make it hard to know the sematics of
fun1(a1)(a2)fun2, are these two functions or one with two args?
- I think one would have to require that at least one sets of
()end every function call, otherwise it would be difficult to understand what
()producefun()means, does it return and call a function like
producefun()()in todays semantics, or is it a single function call?
- All functions
(#1)some(#2)text(#3)could also automatically define
sometext(#1,#2,#3)as a fallback.
- This is in some sense a generalization of defining ones own infix operators, as
(a)isa(T)can already be expressed as
a isa T
Some nice examples
in(y)store(A)*(b) / store(A)mul(b)in(y)# Maybe difficult to make work with operators.