r/ProgrammingLanguages • u/jamiiecb • Apr 10 '26
Borrow-checking surprises
https://www.scattered-thoughts.net/writing/borrow-checking-surprises
52
Upvotes
r/ProgrammingLanguages • u/jamiiecb • Apr 10 '26
View all comments
Show parent comment
6
u/Huge-Albatross9284 Apr 11 '26 edited Apr 11 '26
If you don't define argument evaluation order, you must either randomize it at runtime or make programs with observable differences from eval order impossible to write.
Otherwise, programs will inevitably implicitly depend on the concrete evaluation order your compiler actually uses in practice.
You can see a version of this idea in how Go goes out of it's way to randomize map iteration order, to prevent reliance on behavior (consistent map ordering) that the language doesn't always provide. Actually, Rust does the same with a seed per HashMap instance.
If you don't, the de-facto implementation of the unspecified behavior eventually get's codified into the spec: Python dicts, JS object fields, probably some others.