Re: Re: vote on prop keyword
Paul Prescod <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
Mark Hahn wrote:
>...
>
> Why are you using myprop.foo as a protoype? Myprop.foo works fine for
> me:
>
> O>> import myprop
> O>> print myprop.foo
> Get foo
Good point. Do I understand that in the future my error would raise an
exception? If an object is not explicitly marked as a prototype then I
guess it won't be callable, right?
> I didn't look at your proposal because I assumed it was to fix my
> non-existant problem. Do you still want me to give it a look?
#1. I think it is slightly un-Prothonic and un-Pythonic to have magic
base classes. Magic properties are more common in the language.
#2. When it is a property of the object you have to be careful with
those objects if you want to pass them around in various contexts. For
instance a pickler might have code like:
#!/usr/local/bin/prothon
object pickler:
object_I_am_working_with = None
def init_(obj):
self.object_I_am_working_with = obj
def pickle():
# would of course do something more interesting
print self.object_I_am_working_with.protos_
p = pickler(5)
p.pickle()
If obj happens to be a property then it will start to have "property
behaviour" in this context just because it happens to be stored in an
attribute on an object. The code will work great until "obj" happens to
be a property.
object problem(Prop):
pass
p = pickler(problem)
p.pickle()
This would not be a problem with my proposal. The code would only take
on property behaviour in a context where you explicitly tell it to.
Paul Prescod