Post #2598509
2023-03-19 10:02 UTC
@saagar@federated.saagarjha.com Thanks for the concrete example.
If do_expensive_thing() has no observable side effects in this context (i.e. nothing but its return value), then a compiler could still do that. If it has observable side effects then I would argue that allowing the compiler to reorder randomly is a worse outcome than specifying an order. Apart from reproduceability of the the side effects in different environments and with different compilers / compiler flags, you probably don't want the runtime of your application to depend on such a brittle optimization.
But I can see that someone else might have a different opinion on that. I hope I don't have to ever deal with bugs in their code though 😅
Replies (1)
-
@saagar@federated.saagarjha.com 2023-03-19 10:05
@slomo@toot.cat The runtime of your application probably already depends on more brittle optimizations than this, it’s just much easier to justify them (people like fast arrays and strings) and they get fixed immediately when they break because when that happens it is extremely obvious