-
Notifications
You must be signed in to change notification settings - Fork 287
Description
"Thunky" is mostly borrowed from Rakudo sources and surrounding discussions.
It describes the general phenomenon including short-circuiting behavior.
The usual evaluation model of an operation is that you evaluate all operands, and then pass the values into the given operator. However, some operators (such as &&, ||, ~~, andthen, xx) follow a more customized model - they only evaluate some of the operands and use their results to determine the evaluation of the other operands. Hence the name thunky - these operators have some of their operands as thunks - expressions evaluated later, in a potentially different context.
This is a fairly important property that profoundly affects the behavior of operators - topicalization, short-circuiting and xxs re-evaluation of the operand of the left are all results of the "thunkiness" of these operators. However, importantly, this "thunkiness" cannot be mimicked with any userland function, and therefore calling out to the function variant of these operators won't have the right outcome.
I still believe there should be a larger operator overhaul but this is at least something concrete and addressable.