realbasic-nug
[Top] [All Lists]

Re: Constructors for Modules

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Constructors for Modules
From: Charles Yeomans <yeomans at desuetude dot com>
Date: Wed, 30 Jul 2003 16:41:44 -0400

On Wednesday, July 30, 2003, at 02:20 PM, Will Leshner wrote:

While not ideal, I've been experimenting with an approach. I create one module into which I put all of my singletons. In that one module I create one property and method. Say I want a singleton "Thing". I create a class CThing, then I create a property in my Singleton module called mThing and a Thing method. The Thing method looks something like:

function Thing() as CThing
        if not mThing then mThing = new CThing
        return mThing
end function

Then, in my code, I can do stuff like:

Thing.SomeMethod

And the right thing happens.

As long as multiple threads aren't calling Thing...

Charles Yeomans


---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
.


<Prev in Thread] Current Thread [Next in Thread>