A 'Python like' language

Mark Hahn mark at prothon.org
Tue Mar 30 00:48:52 CEST 2004


>  So does "foo.bar = 5" add a "bar" slot to "foo" or does it change bar in
the parent object?

It took me great trouble to learn to use attribute instead of slot to keep
Prothon in sync with Python.  I even had to globally replace "slot" with
"attr" in all my code a week ago, so I'll be replacing your use of slot with
attribute.

"foo.bar = 5" will always add an attribute bar to foo.  You have to say
"parent.bar = 5", or if foo is the current self object, you would say "^bar
= 5".  The caret(^) prefix reads as "super" and replaces the period prefix
when you want atrribute lookup to start at the parent of self instead of at
self.  This was documented yesterday on the website.

I realize that there is not currently any automatic way to change a value
found by inheritance.  I'm open to suggestions.  None of the Prothon
features will be cast in stone until 7/04 so make your suggestions known at
Prothon mailing lists.

"Glenn Andreas" <gandreas at no.reply> wrote in message
news:gandreas-29DDCC.09162829032004 at news.mpls.visi.com...
> In article <BSR9c.57832$cx5.56065 at fed1read04>,
>  "Mark Hahn" <mark at prothon.org> wrote:
>
> > > Not quite the same, as with Prothon it looks like it always relates to
> > > the self object, whereas in a `with' clause you can make it relates to
> > > any object you wish.
> >
> > Just to confuse the issue, I'd like to point out that in Prothon, the
> > leading dot does always relate to the self object, but the 'with' clause
> > sets the self object to any object you want at any time.  So both
statements
> > above are true at once.  The concept of changing the self object on the
fly
> > is somewhat bizzare, much like changing the protoype on the fly, which
you
> > can also do.
> >
> Out of curiousity (and on a somewhat related topic), how do you handle
> "class variables" - i.e., variables that exist in the "super" object,
> and should be accessable by all "sub objects"?
>
> Accessing them is straightforward - for "foo.bar" if foo doesn't have
> bar, but it inherits from an object that does have bar, you get that,
> but what about foo.bar on the LHS of an expression?  So does "foo.bar =
> 5" add a "bar" slot to "foo" or does it change bar in the parent object?
>
> Self had a full blown system for variable access & setting, combined
> with its multiple inheritance for some pretty interesting abilities
> (essentially, all "getters" and "setters" were functions, so you could
> have something be a constant by only providing a getter, etc...)
>
> NewtonScript actually had two different assignment operators "=" and
> ":=" which determined how it behaved (though it got complex because it
> sort of had multiple inheritance - everything inherited from _two_
> parents, the "real" parent and a "_proto", which seems strange, but it
> made sense in the runtime of the Newton, but that's a bit off topic).





More information about the Python-list mailing list