in reply to Re (tilly) 2: Use globals or pass around everything under the sun?
in thread Use globals or pass around everything under the sun?

When I supported the use of singletons in that thread, it was to say that anything is better than a bunch of globals. What I was proposing was exporting wrapper functions using Exporter. I also don't know the definition of a singleton, so I was guessing from context. I think I guessed wrong. :-)

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

  • Comment on Re: Re (tilly) 2: Use globals or pass around everything under the sun?

Replies are listed 'Best First'.
Re (tilly) 4: Use globals or pass around everything under the sun?
by tilly (Archbishop) on Dec 04, 2001 at 18:40 UTC
    The Singleton pattern is really quite simple. What you do is have a class with a private constructor that nobody ever calls. The public constructor calls the private constructor only on the first time it is called, memoizes the answer, and hands it back every time after that.

    The result is a class which will only have a single instance no matter how many places you ask for it. (The trick isn't in figuring out how to do it, it is in figuring out when doing it is a really useful thing...)