easy properties

[email protected]
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
looking at the pretest examples; prop(erties)

#!/usr/bin/env prothon

object Proto1:
    x_ = 6
    prop x:
        def get_():
            print "return ",self.x_
            return self.x_
        def set_(v):
            self.x_ = v
            print "set ",self.x_,v
            return v
        def del_():
            print "attempt to delete (correct response)"

p = Proto1()
p.x = 3
print p.x
del p.x

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)"

__________________________________________________________________
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.