in reply to Re: Problem with constant pragma and some hash definitions
in thread Problem with constant pragma and some hash definitions

Don't use globals. If you have a problem with constants, I would use a singleton or a globals hash. Single globals become a serious problem.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

  • Comment on Re: Re: Problem with constant pragma and some hash definitions

Replies are listed 'Best First'.
Re: Re: Re: Problem with constant pragma and some hash definitions
by sauoq (Abbot) on Jul 18, 2003 at 19:39 UTC

    Globals aren't that bad. They are package scoped afterall, and very efficient too. If you use a convention, like consistently using uppercase for constants, you shouldn't have many problems. If you want to keep the constants private, you can use file scoped lexicals instead of globals and protect yourself even further.

    A global hash isn't a terrible alternative, but the syntax is messy and you don't benefit from strict checking.

    But a singleton? Ugh...

    How about a tied scalar? (just kidding)

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Re: Re: Problem with constant pragma and some hash definitions
by perrin (Chancellor) on Jul 18, 2003 at 20:22 UTC
    I don't see a problem with using globals for constant values. They have the same scope as the subroutines created by the constant pragma.