3 ms·
Wow can you really write val e = p | e in Scala? How does that work with eager evaluation?
by chrisseaton 11y ago
Wow can you really write
val e = p | e
in Scala? How does that work with eager evaluation?
- hrjet 11y agoIt's not eager. The | combinator takes lazy parameters (called pass-by-name in scala). So it essentially gets translated to: val e = operator_pipe(() => p, () => e) Note that the operator_pipe() itself returns a function, which gets assigned as a value to `e`. So there is lots of implicit laziness.