On Fri, Apr 27, 2012 at 11:38 AM, Chris Angelico <ros...@gmail.com> wrote:
> On Sat, Apr 28, 2012 at 3:33 AM, Adam Skutt <ask...@gmail.com> wrote:
>> I think you misunderstood me.  Define a Borg class where somehow
>> identity is the same for all instances.  Inherit from that class and
>> add per-instance members.  Now, identity can't be the same for all
>> instances.  As a result, you've just violated the Liskov Substituion
>> Principal: code that relies on all Borg class instances having the
>> same identity will fail when passed an instance of the subclass.
>
> Why would you subclass a Borg?

For the same reasons one might want to subclass a Singleton.  One of
the big advantages of Borg is that it makes this easier, and it also
allows the option of either having instances of subclasses share the
same state as instances of base classes (usually preferred, because it
preserves LSP) or of allowing each individual subclass to have its own
unique shared state.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to