easy properties

[email protected]
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
>> it struck me that if you had set_(), get_() and del_() setup for
>> assignment in the root object, then you could streamline this example
>> and remove "prop", or am i missing something?
>>
>>
>> Proto1 = Object()
>> with Proto1:
>>     x=6
>>     with x:
>>         def get_():
>>             print "return ",super.x
>>             return super.x
>>         def set_(v):
>>             super.x = v
>>             print "set ",super.x,v
>>             return v
>>         def del_():
>>             print "attempt to delete (correct response)"

>When I originally proposed properties a long time ago in the mailing list
>this is exactly what I proposed.  You can check the archives.  I think it
>turned out to be too simple too implement.   You can either check the
>archives for the old discussion or you can try to work out the details for
>yourself.   I may be wrong but it didn't work for me when I went through >the exercise before.

>BTW: super doesn't do what you want here.  super works with prototype >links, not attribute ownership.  That is why my proto implementation >makes "self" point to the attribute owner (Proto1).   This way you can 
>just say self.x to get to that level.

actually, what i was thinking was 'super.x' finds x one layer up by searching up scopes, then does a get_ on the prototype of this, and so bypasses the redefinition, and actually returns x's value.

so, is it recursive prefixes you need for this?

ie 'super.self.x'

i had already been thinking that 'outer.outer.symbol' would be useful.

__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.