Re: Simple (?) fix for _call and _str

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

> There is no need to have a special isProto flag to tell str_ what to
> print. In Python classes have names. The Python class statement passes
> the class name to the class factory function. If Prothon's object or
> class statement did the same the name could be saved to a name_
> attribute of the prototype object. If str_ finds a name_ attribute in
> an object's dictionary it displays the object as a prototype,
> otherwise as an instance.

That is what I have been saying.  The name can act as the flag.

Your suggestion would need some special syntax to tell the parser it is a
prototype.  I don't want to use "object" because it can be used for
prototypes or objects and I don't want to use "class" because this "fix" is
less than class.  I guess we could add a keyword "proto", but I personally
would prefer the decorator approach with typeName_ = "name" or maybe even
just name_ = "name".  I think a keyword just to assign a name would be
overkill.

> My solution to call_ was to not adopt Python's instancd creation by
> class call aproach. Use a new() function or method instead.

Once you fix str_ with the name_ attribute you might as well use the same
fix for call_.
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.