Re: two-tier class thoughts (part 2)
Serge Orlov <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
Mark Hahn wrote:
> The following is only meant to show the grouping, not be a syntax proposal:
> class Klass:
> object KlassFactory:
> blah blah blah
> object KLassProto:
> blah blah blah
> or maybe something like:
> class Klass(ancestor):
> instance:
> blah blah blah
> class:
> blah blah blah
> I also want the class object itself to be one self-contained
> object. In other words if you have a class object, a factory
> object, and an adaptor, then you'd end up with Klass, Klass.factory_, and
> Klass.adaptor_.
If we end up with a factory, how we are going to call factory
functions? Klass.factory_.fromString('...') ? I thought code block
under the word "class:" will be found right in the Klass object later.
> Note that if you accept this proposal, the differences
> between Paul's, Serge's, and my proposals start to dissapear.
> As a matter of fact, it seems to me that Paul's factory object
> could always be
> auto-generated and would not need to be part of the syntax. Plese
> correct me if I'm wrong.
Yes, you're right. That was my intention. I had those factories
in my head for a long time, but I didn't like them because they
are too verbose for simple cases. When you asked to propose syntax
then I suddenly realized that's what I missed. Syntax to generate
classes.
> I have a third guideline. I want this example to work by graceful
> degeneration of whatever syntax we come up with:
> class Square(Rectangle):
> def init_(wid):
> self.wid = wid
> def str_():
> print '<Square:'+self.wid+'>'
It will be like the following, right?
class Square(Rectangle):
class:
pass
instance:
def init_(wid):
self.wid = wid
def str_():
print '<Square:'+self.wid+'>'
> Comments? Votes?
Overall I like your changes but there is unresolved problem
with nested classes.
-- Serge