in reply to Re: Re3: : Accessing Other Globals?
in thread Accessing Other Globals?

*laughs* I am for intelligently-designed limited use of goto statements in non-production code. Just so you know.

As for global variables making sense ... Yes, it is theoretically possible that a global variable is the "best" way to design a solution to a given problem. However, it has been my experience (and the experience of every skilled programmer I have ever talked to about this issue) that there has always been a better design solution.

Now, if you're talking about hacking something together really quickly ... sure. Use all the globals you want! But, if you're working on designing something intended for longterm use, especially in OO, you'd have to talk really fast to convince me that globals are the best design solution.

Just so you know, the solution I gave you involved what are called "symbolic references". They are, like globals and goto statements, considered to be almost universally bad. In fact, one monk has (had?) a sig that said you should never use symrefs unless you know why you shouldn't use symrefs. I've used symrefs in production code exactly once. In 6 years of programming Perl. Take that for what it's worth. (I've never needed to use goto in production code, and I've spent weeks encapsulating global variables into Exporter-driven modules.)

------
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.

Replies are listed 'Best First'.
Re: Re5: Accessing Other Globals?
by chip (Curate) on Dec 15, 2001 at 08:10 UTC
    It occurs to me, dragonchild, that the application in question might be reasonably sane ... if the global array in question is @ISA.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Re (tilly) 6: Accessing Other Globals?
by tilly (Archbishop) on Dec 15, 2001 at 20:59 UTC
    Universal pronouncements are generally more effective when you suggest possible solutions. In this case if the object wants the data publically available, then it should define accessor methods for it. (And, of course, functions outside of its class should not assume that they know how said accessor methods work...)