in reply to Re^17: the "our" declaration ?!! (special vars)
in thread the "our" declaration ?!!

I never said that you can't use our for the same task. I said that it was worse.

In example 1, with our it is a lot easier to make and a lot harder to catch a mistake where in one file you have declared $with_foo while in the other you've named it $for_foo. This makes our worse.

In the second example, to avoid problems you are requiring people to have a habit that most people don't have. Furthermore it is not enough to put curlies around your package declarations, you also have to put curlies around your original program. However taking that step means that if you discover that you need a small auxiliary package, you have to make a much, much bigger change. Again our is worse.

Summary: from a software engineering standpoint, in Perl 5 our is the same or worse than vars. Its only win is a slight convenience/aesthetic advantage.

(My attitude is that Perl 6, if it ever arrives in production, will be a different language that needs to be judged on its principles.)

  • Comment on Re^18: the "our" declaration ?!! (special vars)