Hacker News new | past | comments | ask | show | jobs | submit login

> Most languages don't have references, and in those that do before the issue was understood, the explicitness made it a much smaller issue.

But Go and C++ do, where this issue arose with or without closures.

> Now try lowering to bytecode or assembly instead of high-level pseudocode.

It doesn't matter, because as I said, all that is already in the compiler.

It would be needlessly complex and error-prone for compilers to hardcode custom code generation for such abstractions; it's transformed to something else the compiler already understands at a far higher level. I know for a fact that in Rust, for-loops already desugar to a simple infinite loop construct with a break at the H.I.R. level and all further optimizations only happen from there.




Yup. C# likewise described the change in semantics as just a different de-sugaring of their for each loop when that happened.


Which makes it more confusing why it was originally as it was because it's really not harder to implement as any compiler implements it as desugaring before optimizations een occur and this form is simpler.

The only explanation I see is that they really gave it no thought at all whatsoever and it wasn't a tradeoff but simply not thinking clearly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: