Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

local variables in Perl and Lua

Name: Anonymous 2011-07-22 21:32

I didnt get an answer for this in the Python thread, so I'll ask here: Why do variables have to have the local keyword to make their scope local? Why cant it just use implicit lexical scope like most any other languages?

Name: Anonymous 2011-07-23 11:46

>>20
But local is too long for the most common scope.

Explicit scope is a good thing for scripting languages. Having either as a default is not my cup of tea, because it's better to always see where the variable is introduced in a given scope, and which scope it is introduced to (eg my vs. our in Perl.)

In languages like C it's not such a big deal. If you're writing one of those you will be avoiding globals much more eagerly.

>>26
You think JS is bad for dynamic scope? Try writing bash sometime. Loop constructs all introduce dynamic scope, so good luck using data you've accumulated/processed in a loop.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List