Welcome to Web-News
A Web-based News Reader
Subject toString ugliness
From Jerry <jlquinn@optonline.net>
Date Sat, 06 Dec 2008 11:21:11 -0500
Newsgroups digitalmars.D

toString() doesn't work inside a class member function.

import std.string;
class A {
  void f() {
    string s = toString(5);
  }
}

This errors with junk.d(19): function object.Object.toString () does not match parameter types (int)

This is a nuisance and a wart (though not a bug per-se).

If the language really can't handle distinguishing this.toString() from toString(int), then std.string.toString really should have a different name.

It can be solved somewhat by documenting clearly that to!(string)(int)
be used instead, which seems silly to me.  I'm irritated by the 3 extra chars required to type a to!(type) template.

.toString() works around the problem, but why should it be needed?  This is unfortunate.

Does this bother anyone else?  If not, I'll return to my lurking cave :-)

Recent messages in this thread
 
-# toString ugliness (Current message) Jerry 06-Dec-2008 11:21 am
.-# Re: toString ugliness Jarrett Billingsley 06-Dec-2008 11:45 am
.|-# Re: toString ugliness Jerry 06-Dec-2008 12:11 pm
.|.-# Re: toString ugliness Jarrett Billingsley 06-Dec-2008 01:04 pm
.|.|-# Re: toString ugliness Ary Borenszweig 07-Dec-2008 07:12 am
.|.||-# Re: toString ugliness Jarrett Billingsley 07-Dec-2008 10:27 am
.|.||.-# Re: toString ugliness Ary Borenszweig 07-Dec-2008 01:17 pm
.|.||..-# Re: toString ugliness Christopher Wright 07-Dec-2008 03:29 pm
.|.||...-# Re: toString ugliness Nick Sabalausky 07-Dec-2008 05:29 pm
.|.||....\# Re: toString ugliness bearophile 07-Dec-2008 05:49 pm
.|.|-# Re: toString ugliness Sergey Gromov 07-Dec-2008 05:54 pm
.|.|.|# Re: toString ugliness Christopher Wright 07-Dec-2008 06:42 pm
.|.|.\# Re: toString ugliness Jarrett Billingsley 07-Dec-2008 06:59 pm
.|.\# Re: toString ugliness Jarrett Billingsley 06-Dec-2008 01:04 pm
.|# Re: toString ugliness Steve Schveighoffer 06-Dec-2008 10:55 pm
.-# Re: toString ugliness Ary Borenszweig 07-Dec-2008 07:10 am
..\# Re: toString ugliness bearophile 07-Dec-2008 07:59 am