Jump to page: 1 24  
Page
Thread overview
toString in Object
Feb 20, 2005
Derek
Feb 20, 2005
Andrew Fedoniouk
Feb 20, 2005
Derek
Feb 20, 2005
Chris Sauls
Feb 20, 2005
Ben Hinkle
Feb 20, 2005
Chris Sauls
Feb 20, 2005
Sebastian Beschke
Feb 20, 2005
Regan Heath
Feb 20, 2005
xs0
Feb 20, 2005
Regan Heath
Feb 20, 2005
Derek
Feb 20, 2005
Ben Hinkle
Feb 20, 2005
Derek
Feb 20, 2005
Derek
Feb 20, 2005
Brad Anderson
Feb 20, 2005
Thomas Kühne
Feb 20, 2005
uframer
Feb 20, 2005
Sebastian Beschke
Feb 20, 2005
Thomas Kühne
Feb 20, 2005
John Reimer
Feb 20, 2005
Derek
Feb 20, 2005
Derek
February 20, 2005
Walter,
can you please confirm or deny that 'char[] toString()' will be removed
from the Object class. And if so, when?

Because it exists, I cannot create a 'dchar[] toString()' in my classes, as I get the dreaded "overrides but is not covariant with object.Object.toString" message!

-- 
Derek
Melbourne, Australia
February 20, 2005
Hi, Derek,

I guess that toUTF32() or toDChars() names would be better...
Strictly speaking there are no such entity as String in D so name toString
is misleading a bit.
IMHO.

Andrew Fedoniouk.
http://terrainformatica.com


"Derek" <derek@psych.ward> wrote in message news:1h9qh6scvt40n$.1mp0213bpkkpm.dlg@40tude.net...
> Walter,
> can you please confirm or deny that 'char[] toString()' will be removed
> from the Object class. And if so, when?
>
> Because it exists, I cannot create a 'dchar[] toString()' in my classes,
> as
> I get the dreaded "overrides but is not covariant with
> object.Object.toString" message!
>
> -- 
> Derek
> Melbourne, Australia


February 20, 2005
On Sat, 19 Feb 2005 22:25:03 -0800, Andrew Fedoniouk wrote:

> Hi, Derek,
> 
> I guess that toUTF32() or toDChars() names would be better...
> Strictly speaking there are no such entity as String in D so name toString
> is misleading a bit.
> IMHO.

LOL, yes I guess that is just an opinion. But true, there is no 'official' formal string type or class, and even in spite of that, strings are widely used in the phobos library and most all our programs. So I think its okay to talk about the informal string types that are in use with D programming.

I suspect, that when D was just a twinkle in Walter's eye, the char[] type was the only available string type (borrowed no doubt from C), and it was not until later that wchar[] and dchar[] arrived. But by that time, char[] was being assumed as the common type of string and thus nearly all of phobos assumes char[].

Yes, it is annoying that we don't have an official string type, but it is not a death sentence for the language. It just means that instead of the compiler doing some of the work for us, we coders need to do a bit more. Oh well, maybe one day Walter will give in and try to help out us poor coders a bit.

-- 
Derek
Melbourne, Australia
February 20, 2005
Derek wrote:

> Walter,
> can you please confirm or deny that 'char[] toString()' will be removed
> from the Object class. And if so, when?
> 
> Because it exists, I cannot create a 'dchar[] toString()' in my classes, as
> I get the dreaded "overrides but is not covariant with
> object.Object.toString" message!

Why can't you just use char[] toString() with std.utf.toUTF8 ?

IMHO, the method that really needs to die in Object is "print()"

--anders
February 20, 2005
On Sun, 20 Feb 2005 13:44:51 +0100, Anders F Björklund wrote:

> Derek wrote:
> 
>> Walter,
>> can you please confirm or deny that 'char[] toString()' will be removed
>> from the Object class. And if so, when?
>> 
>> Because it exists, I cannot create a 'dchar[] toString()' in my classes, as I get the dreaded "overrides but is not covariant with object.Object.toString" message!
> 
> Why can't you just use char[] toString() with std.utf.toUTF8 ?

I assume you mean I can code ...

    x = std.utf.toUTF32( myClass.toString() );

Of course I can, but that's not the point.

In the general case, if the Object class contains *any* function, it means that no other class can contain a method with the same name that returns a different data type. And that is not all that reasonable, let alone polite Object behaviour.

> IMHO, the method that really needs to die in Object is "print()"

Oh yes, and there is reasonable arguments for removing the other offenders too. But for now, I'm unhappy about toString() only ever being allowed to return a char[].

-- 
Derek
Melbourne, Australia
February 20, 2005
"Derek" <derek@psych.ward> ??????:1h9qh6scvt40n$.1mp0213bpkkpm.dlg@40tude.net...
> Walter,
> can you please confirm or deny that 'char[] toString()' will be removed
> from the Object class. And if so, when?
>
> Because it exists, I cannot create a 'dchar[] toString()' in my classes,
> as
> I get the dreaded "overrides but is not covariant with
> object.Object.toString" message!
>
> -- 
> Derek
> Melbourne, Australia
Oh, i'm tired of these chars(char wchar dchar).Why can't we just have "one" standard codepage, just like what java does? I mean the Object should only support Unicode, so as Andrew said, toUTF32() or toDchars() is really a good choice.And for D, unicode should be the mainstream, while others as utilities for compatibility .


February 20, 2005
Derek wrote:

>>Why can't you just use char[] toString() with std.utf.toUTF8 ?
> 
> I assume you mean I can code ...
> 
>     x = std.utf.toUTF32( myClass.toString() );
> 
> Of course I can, but that's not the point.

Okay, then I missed the point... Do you want to override
methods with different return types ? Or do you just wish
that D should default to UTF-32 instead of UTF-8 like now ?

--anders
February 20, 2005
uframer schrieb:
> Oh, i'm tired of these chars(char wchar dchar).Why can't we just have "one" standard codepage, just like what java does? I mean the Object should only support Unicode, so as Andrew said, toUTF32() or toDchars() is really a good choice.And for D, unicode should be the mainstream, while others as utilities for compatibility . 

The problem here is that char[], wchar[] and dchar[] are *all* unicode, but in different encodings.

-Sebastian
February 20, 2005
> can you please confirm or deny that 'char[] toString()' will be removed from the Object class. And if so, when?

Am I REALLY this invisible??!

I just posted the SAME THREAD yesterday!  Yes, in fact, it's two down from this one!


February 20, 2005
What I'd personally like to see is something similar to what Sofu's Value class exposes.  It could still 'default' to class name.

# class Object {
#   // ...
#   char[]  toUTF8()  { return this.classinfo.name;     }
#   wchar[] toUTF16() { return .toUTF16(this.toUTF8()); }
#   dchar[] toUTF32() { return .toUTF32(this.toUTF8()); }
#   // ...
# }

But maybe I'm crazy.

-- Chris S
« First   ‹ Prev
1 2 3 4