2 ms·
The best arguments for do expressions I've seen are in recent versions of the Pipe Operator proposal which now suggests where do expressions can produce some go
by WorldMaker 4y ago
The best arguments for do expressions I've seen are in recent versions of the Pipe Operator proposal which now suggests where do expressions can produce some good simpler looking pipelines with the Pipe operator.
Aside from syntax sugar, it's also a tiny spot for some JIT compiler and garbage collector optimization. Arrow functions still create Function objects, which is a tiny bit of administrative overhead and possible garbage to collect. Most JIT engines are somewhat used to "IIFEs" and can optimize common patterns of that, but do notation possibly directly suggests "not a real Function" or "entirely inlinable function" to the JIT in ways that even arrow functions cannot.
I don't know if that sort of micro-optimization is a great argument for do expressions, however.