Unified Type/class (Singleton)

Pedro Rodriguez pedro_rodriguez at club-internet.fr
Mon Jan 28 05:53:10 EST 2002


"Alex Martelli" <aleax at aleax.it> wrote:

> Pedro Rodriguez wrote:
>         ...
>> <wink>
>> Let me think.
>> I only have 2 wishes left...
>> Now I would like : the singleton, the enumeration metaclasses. Even the
>> Borg pattern will be meta-assimiled ;) ... correction, this has already
>> happened, in 'descrintro' </wink>
> 
> Actually, the (nice!) metaclass examples in descrintro are autoprop and
> autosuper -- the Singleton example is just a base class that overrides
> __new__ (and implements a "classic" Singleton, not a Borg), and I can't
> see anything there about enumerations.
> 
> 
Of course there is no enumeration example in descrintro, I should probably
try to improve my english and the way I express myself, before continuing
with python and design constructs ;)

> It's easy to write metaclasses
> for each of these purposes, of course -- the issue with autoenum is
> mostly one of defining what features you require and finding a syntax
> sugar you like, and similarly for autoborg.
> 
> 
Yes.


Borg vs. Singleton : I was just kiding, sort of... I wonder if it would be
good to provide a diagram when dealing with new concepts. Example :

Borg :
            1  1        1   n
   [State] <---- [Borg] <---- [BorgInstance]

   (What about replacing Borg with Collective, BorgInstance with Borg ;)


Singleton :
            1  1             1   1
   [State] <---- [Singleton] <---- [SingletonInstance]
                                ^^^
                                This is the difference.

Regards,
-- 

Pedro



More information about the Python-list mailing list