Ah, those steeped in functional programming might say, but maybe this is the wrong way to look at it. Because if we represent the represent the functions with explicit continuations, we can say that they have N arguments and pass N arguments to their continuations, and then they are symmetric.
It seems like this has fertile overlap with Scheme and the (concurrent computatation) Actor model.
Of course, I can imagine the Execution control library authors know full well about those, with existing C++ goals and designs making that a bridge too far.
// In typescript const [a, b, c] = foo(d, e, f)
You could even pass this to itself
foo(…foo(d, e, f))
Also one definition of a function is a map from a domain to a range. There’s nothing that forbids multiple values, or is there?
Monty Python fan detected :D
d_tr•4d ago
Mathematicians have been packing all this stuff nicely for a couple of centuries now, maybe we could use more of their work on mainstream computing, and it could also be a nice opportunity to get more people to appreciate math and structure.
Something that has side effects all over the place should just not be called a function, but something else, maybe "procedure" would be an appropriate, clear term.
agumonkey•3h ago
paulddraper•3h ago
C++ sort of has this, with const.
hardlianotion•3h ago
WJW•2h ago
In this case it's almost the opposite of most programming languages. In (say) Ruby or Java, any function or method can do anything; write to stdout, throw exceptions, access the network, mutate global state, etc. In haskell, a function can only do calculations and return the result by default. All the other things are still possible, but you do have to encode it in the type of the function.
EDIT: The annotations you mention with regards to identity elements etc do exist, but they live mostly on the data structures rather than on the functions that operate on those data structures.
defanor•1h ago
[1] https://github.com/stefan-hoeck/idris2-algebra
noelwelsh•1h ago