Semantics of toString
Justin Johansson
no at spam.com
Tue Nov 10 04:29:43 PST 2009
Bill Baxter Wrote:
> On Tue, Nov 10, 2009 at 3:59 AM, Justin Johansson <no at spam.com> wrote:
> > Lutger Wrote:
> >
> >> Don wrote:
> >> ...
> >> >
> >> > There is a definite use for such as thing. But the existing toString()
> >> > is much, much worse than useless. People think you can do something with
> >> > it, but you can't.
> >> > eg, people have asked for BigInt to support toString(). That is an
> >> > over-my-dead-body.
> >>
> >> Since you are in the know and probably the biggest toString() hater around:
> >> are there plans (or rejections thereof) to change toString() before D2 turns
> >> gold? Seems to me it could break quite some code.
> >>
> >
> > I have a feeling (and I may well be wrong) that toString might be used in
> > relation to associative arrays. I implemented an AA recently based upon
> > a struct key (I think). Though I cannot remember the exact details I do
> > remember DMD saying something about toString not implemented and
> > so without thinking I gave the struct a toString and that kept DMD happy.
> > Since the code was throw-away I didn't bother to investigate.
> >
> > Like I say, I cannot remember the details but others may recall some similar
> > experience. For all I know it may be a case of RTFM?
>
> Shouldn't be the case. From TFM:
> """
> Classes can be used as the KeyType. For this to work, the class
> definition must override the following member functions of class
> Object:
>
> hash_t toHash()
> bool opEquals(Object)
> int opCmp(Object)
> """
>
> --bb
I think you are right; if I can dig up what it was, and if relevant to this discussion,
I'll post it. Ignore what I said for mom.
Just wondering now though and in reference to Lutger's comment
> >> Since you are in the know and probably the biggest toString() hater around:
> >> are there plans (or rejections thereof) to change toString() before D2 turns
> >> gold? Seems to me it could break quite some code.
how much core code would be broken if toString was actually banished?
More information about the Digitalmars-d
mailing list