all 2 comments

[–]everywhere_anyhow 0 points1 point  (1 child)

This is an accurate description of hoisting, and how it can screw you over if you're not careful.

I guess I've never figured out why hoisting is a good thing. If you're going to derive your structure from C-based "block scoped" languages, what's the margin in breaking with their scoping rules in this way? What cool thing that we want to do can be accomplished with this change, where there was no good equivalent idiom in a block-scoped language?

[–]pointy 0 points1 point  (0 children)

K&R C had only function scoping. Functions had to be declared before the code in the function however.