I have been looking at how Dyalog does it, and their implementation is even more strange. I have to agree with your assessment.
Last night as I was about to go to sleep I thought about a change that could make the use of "side-effect-only" lambdas much more logical and functional. It sounded great to my inner mind before I went to sleep, so at least I feel it should be discussed here.
My suggestion is that niladic lambda functions will not be allowed at all. Instead, they will be interpreted as monadic functions that ignore their argument.
The justification for this is as follows:
- Niladic functions can't be passed to operators, so they are useless for that.
- If the niladic lambda is parsed as a monadic function, things like this would be possible again: {⎕←'hello'} REPEAT 10
- Thus, the only use for niladic lambdas would be to assign them to a name: foo←{2}
- To deal with the above, there are two different approaches:
- Such assignment will result in foo being a dyadic function, or
- A niladic lambda can remain niladic when assigned to a variable
Regards,
Elias