toString not working... (a bug in D?)
Daniel Keep
daniel.keep+lists at gmail.com
Tue Jan 16 05:07:28 PST 2007
Ary Manzana wrote:
> That's not very intuitive :-(
>
> Can't this be fixed? toString methods should be easy to work since they
> are widely used.
I can think of two ways:
1) Allow for type extensions, or
2) require the use of "this" in front of all members -- hey, it works
for Python! :3
The problem here is that if called from an object instance,
"this.toString" shadows any global "toString"s. It's not so much a bug
as a consequence of how D's lookup rules work. Personally, I think #1
above is the best long-term solution to this, as it allows you to more
obviously disambiguate what you're trying to say.
-- Daniel
More information about the Digitalmars-d
mailing list