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

Implicit declarations also mean the compiler is less likely to catch typoed names.

From the perspective of language design, attempts to improve upon explicitly declared block-scoped lexical variables generally fail.




Except in language(s) that default to the global scope without declaration. I admit it though - if the compiler doesn't, a static analysis tool will do my point is shaky.

I'm not passionately for implicit declarations. I just don't see it as a make or break, stupid idea that the OP made it out to be.

If I had a choice, I would prefer explicit, with compiler errors when not declared up scope as opposed to implicit declaration in the global scope.


While I do think it is a stupid idea, whether or not it's make or break will of course depend on what else the laguage has to offer and what the alternatives are.

I've used JavaScript and PHP in the past (and even enjoyed it!), never mind all the misfeatures of said languages. What bugs me though is that language designers keep making the same mistakes over and over again...


PHP scoping is what happens when each scope, including parent and child scopes are completely isolated (except 'superglobals', of which globals are within).

To create a closure, you must use "use" and specify the variables to close over. To use globals, you have to say "I want this to be from the global scope or make a global otherwise".

Leads to a lot of verbose code and cripples ability to really use FP ideas.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: