4 ms·
First example: x(x - k a) where x = b + 2c Now imagine ‘+’ and ‘-’ have side-effects, like a log message. What would the output be? ‘+-’, ‘++-’ or ‘+-+’?
by remcob 9y ago
First example:
x(x - k a)
where x = b + 2c
Now imagine ‘+’ and ‘-’ have side-effects, like a log message. What would the output be? ‘+-’, ‘++-’ or ‘+-+’? Certainly not the ‘-+’ order as they appear in the code, which is causally impossible.
The paper restricts to pure functions, where this is not an issue. But it does seem to violate a widely followed implicit rule that lines of code are in strict causal order, with well-defined explicit exceptions for control flow.
- theoh 9y agoI'm not sure "violate" is the right word, given Landin's objectives. If the where-clause offends you, use a let-clause instead?
- abiox 9y agothis already happens: in a variety of languages, x could just be an ordinary function with the body defined below any given usage. here, `where` could be replaced with a standard function definition, and it's `+` would still be textually below the usage's `-`.