On 05/09/2011 16:51, Uri Guttman wrote:
there is no such thing as module scope. our declares package globals and give them a short name in a lexical scope.
All software comcepts exist only in someone's imagination. Brandon and I can imagine what 'module scope' means and I am surprised that you cannot. In the end there are only global declarations and scoped declarations, and I believe you are wrong to pick holes in people's terminology when it is quite clear what they mean, and that meaning is correct.
BM> 'local', but I'm not going to attempt to explain how that works so BM> early in the morning. You should be able to learn about each using BM> perldoc -f though. To be safe and clear you shouldn't use the names $a BM> and $b unless you are actually using them within a sort. single letter variable names are bad in general. they tell you nothing about the use and content of the variable. about the only exception are $i and $j for array/matrix indexing and the aforementioned $a and $b for scoping.
Fortran tradition has us use 'i' .. 'n' for integer values - often counters - and everything else for floats, of which 'x' .. 'z' are familiar in mathematical and graphical programming. Outside that, qw/Y M D h m s/ are universal, $c is an undimensioned constant, $e is exp(1), $f is a file or a format, $g is the gravitational constant, $h would be height, hours, Henries, and so on. I know I have said something very similar before, but those who disagree with me are forgetting Perl's legacy. It is a language that is intended to cope with ambiguity by context, and can tell the difference between the equivalents of there, their and they're; and even its, it's and it's. So yes, we are free to use single-character variable names if that use is unambiguous in context. Unfortunately most people have a history of writing software that looks like bricklaying: every stroke and placement has its own independent purpose. So we get C programmers, Fortran programmers, and possibly COBOL programmers, each writing Perl code where every single line will stand unambiguously on its own. That is not what Perl is for, and it goes a long way to explaining the controversy that it generates. The reason $a and $b are broken is because of a fix on top of a nice idea. There should be nothing wrong with names like that but, because no one thought of it sooner, it can be a better rule to prohibit single-character variable names altogether. My rule would be to write what you mean, all of the time. If for some defect in the language that doesn't work, then understand why and write what you mean in a different way. People will love you for it. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/