Re: Re: vote on prop keyword

"Mark Hahn" <[email protected]> Thu, 15 Jul 2004 11:46:20 -0700
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
Paul Prescod wrote:

> What I'm trying to accomplish here is to say X is a property for Y
> rather than "X is a property." X could be a property of Y and just a
> plain old attribute of Z.

I agree that my proposal needs to be fixed.

I've given a lot of thought to your counter-proposal and it has several
problems:

1) It is more complex.  It adds an extra level of depth to the nesting of
the attributes and it puts all the props together off to one side.  This by
itself is not a big deal.

2) It is much more expensive to implement.  It doubles the attribute lookups
in the prototype chain.  Again, this isn't supposed to matter at this point
since magic caches are supposed to fix all performance problems.

3) It allows a regular attribute and a property to exist with the same name.
This is a messy problem.

How about this compromise.  I keep the current implementation and add an
attribute to the Prototype object call propSelf_ which specifies the outer
container "self" object for the property.  When the property is used this
will be checked and if it doesn't match the property mechanism will not be
used.

object Widget:
      def init_(price):
           self.price = price
      price = 3.75
      object tax(Property):
              propSelf_ = Widget
              def get_():
                     return self.price * 0.03
              def set_(tax):
                     self.tax = tax