Hacker News new | ask | show | jobs
by jimjimjim 3567 days ago
yep, c background here. it makes sense if you think about what instructions the code would get compiled to.

if it didn't reuse the var's memory other people would complain that go is inefficient in loops.

can't please everybody, somebody will always complain.

1 comments

I don't know enough about Go to be sure, but it seems that there are multiple possible semantics here, and the choice made by its designers does not seem to be inherently more efficient than the alternatives, except perhaps for some rarely-used cases.

Also (though this may be going off-topic), imagining what instructions might be emitted has been known to mislead, especially in the face of aggressive optimization (looking at the actual compiler output may give you insight into the language's semantics, but reading the language's specification is probably an easier, quicker and more reliable route.)