Re: Re: proposal for call_ and str_

"Mark Hahn" <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
"Paul Prescod" <[email protected]> wrote

> What does the syntax look like if I want to use the default str_ and
call_?
>
> object Proto:
>      def str_():        # str_ for instances
>          return "foo"
>
>      def call_():      # call_ for instances
>          return "bar"
>
>      factory:    # not needed
>          pass
>
> Will this generate me an attrProxy.str_ and attrProxy.call_?
>

If you only need instance methods then proxyObject_ is not needed.  Just
leave out the factory keyword.

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

No no no.  That would make people think the instance methods were for the
factory.

Don't forget that factory is only needed if you are defining seperate str_
and/or call_ for use in the prototype.

> 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?

Good question.  I had not considered this. I think there is a serious
problem with this idea.  As far a Proto1 is concerned Proto2 is an instance.
This is a case where you might need a class.  I will give this some more
thought.  I would hate to have a situation where you have to have a class.

Maybe this is one of those cases that Lenard talked about where prototypes
cannot handle metaclasses. He never got back to me on that claim.
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.