Re: Re: proposal for call_ and str_
Paul Prescod <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
Mark Hahn wrote:
>
> I think I know what syntax sugar I'd like to use. It is a new keyword
> called "factory". It is a lot like object but is specifically generates the
> "attrProxy_" object and automatically generates a default call_() and str_()
> method that can be overriden. I've used the word "factory" instead of the
> word "class" that I used in class proposal 2 because "factory" works both in
> prototypes and in classes. Factory is general to the 2-tier concept. You
> can think of the factory as defining methods that are used when the object
> is "used as a factory" instead of as an instance.
What does the syntax look like if I want to use the default str_ and call_?
object Proto:
def str_():
return "foo"
def call_():
return "bar"
factory:
pass
Will this generate me an attrProxy.str_ and attrProxy.call_?
Have you considered having some syntax sugar for that case as I expect
it to be the most common (it is the default in Python). For instance:
factory Proto:
def str_():
return "foo"
def call_():
return "bar"
I always get confused with these proposals about what happens if you do
this:
object Proto1:
factory:
def str_(): ...
def call_(): ...
object Proto2(Proto1):
...
Does Proto2 inherit the attrProxy?
Paul Prescod