Jump to page: 1 2
Thread overview
Type.stringof
Feb 21, 2007
Michiel
Feb 22, 2007
Walter Bright
Feb 22, 2007
Michiel
Feb 22, 2007
Lionello Lunesu
Feb 22, 2007
Michiel
Feb 22, 2007
Deewiant
Feb 22, 2007
Michiel
Feb 22, 2007
Lionello Lunesu
Feb 22, 2007
BCS
Feb 22, 2007
Max Samukha
Feb 22, 2007
Michiel
Feb 22, 2007
torhu
Feb 22, 2007
Walter Bright
Feb 22, 2007
Lionello Lunesu
Feb 22, 2007
Leandro Lucarella
Feb 22, 2007
renoX
February 21, 2007
The documentation sais that all types should have the property .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't it exist (anymore)?

Thanks,

-- 
Michiel
February 22, 2007
Michiel wrote:
> The documentation sais that all types should have the property
> .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't
> it exist (anymore)?

In what case does it not work?
February 22, 2007
Walter Bright wrote:

>> The documentation sais that all types should have the property .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't it exist (anymore)?
> 
> In what case does it not work?

Any case. I tried this:

------------------------------------------
module test;

import std.stdio;

struct Foo { }

enum Enum { RED }

typedef int myint;

void main()
{
    writefln((1+2).stringof);       // "1 + 2"
    writefln(Foo.stringof);         // "Foo"
    writefln(test.Foo.stringof);    // "test.Foo"
    writefln(int.stringof);         // "int"
    writefln((int*[5][]).stringof); // "int*[5][]"
    writefln(Enum.RED.stringof);    // "Enum.RED"
    writefln(test.myint.stringof);  // "test.myint"
    writefln((5).stringof);         // "5"
}
------------------------------------------

And got these errors:

------------------------------------------
main.d(13): Error: no property 'stringof' for type 'int'
main.d(14): Error: no property 'stringof' for type 'Foo'
main.d(15): Error: no property 'stringof' for type 'Foo'
main.d(16): Error: no property 'stringof' for type 'int'
main.d(17): Error: no property 'stringof' for type 'int*[5][]'
main.d(18): Error: no property 'stringof' for type 'int'
main.d(19): Error: no property 'stringof' for type 'int'
main.d(20): Error: no property 'stringof' for type 'int'
------------------------------------------


-- 
Michiel
February 22, 2007
Michiel wrote:
> Walter Bright wrote:
> 
>>> The documentation sais that all types should have the property
>>> .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't
>>> it exist (anymore)?
>> In what case does it not work?
> 
> Any case. I tried this:
> 
> ------------------------------------------
> module test;
> 
> import std.stdio;
> 
> struct Foo { }
> 
> enum Enum { RED }
> 
> typedef int myint;
> 
> void main()
> {
>     writefln((1+2).stringof);       // "1 + 2"
>     writefln(Foo.stringof);         // "Foo"
>     writefln(test.Foo.stringof);    // "test.Foo"
>     writefln(int.stringof);         // "int"
>     writefln((int*[5][]).stringof); // "int*[5][]"
>     writefln(Enum.RED.stringof);    // "Enum.RED"
>     writefln(test.myint.stringof);  // "test.myint"
>     writefln((5).stringof);         // "5"
> }

That works just fine here, DMD 1.007

L.
February 22, 2007
Lionello Lunesu wrote:

>>>> The documentation sais that all types should have the property .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't it exist (anymore)?
>>> In what case does it not work?
>>
>> Any case. I tried this:
> 
> That works just fine here, DMD 1.007

Ah, I have DMD 1.003. Would that make the difference?

-- 
Michiel
February 22, 2007
Michiel wrote:
> Lionello Lunesu wrote:
> 
>>>>> The documentation sais that all types should have the property .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't it exist (anymore)?
>>>> In what case does it not work?
>>> Any case. I tried this:
>> That works just fine here, DMD 1.007
> 
> Ah, I have DMD 1.003. Would that make the difference?
> 

Seeing as .stringof was added in DMD 1.005, it might. ;-)

-- 
Remove ".doesnotlike.spam" from the mail address.
February 22, 2007
Deewiant wrote:

>>>>>> The documentation sais that all types should have the property .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't it exist (anymore)?
>>>>> In what case does it not work?
>>>> Any case. I tried this:
>>> That works just fine here, DMD 1.007
>> Ah, I have DMD 1.003. Would that make the difference?
>>
> 
> Seeing as .stringof was added in DMD 1.005, it might. ;-)

Strange. It wasn't even so long ago that I downloaded the compiler. Has stringof only existed for a month or so?

-- 
Michiel
February 22, 2007
Michiel wrote:
> Deewiant wrote:
> 
>>>>>>> The documentation sais that all types should have the property
>>>>>>> .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't
>>>>>>> it exist (anymore)?
>>>>>> In what case does it not work?
>>>>> Any case. I tried this:
>>>> That works just fine here, DMD 1.007
>>> Ah, I have DMD 1.003. Would that make the difference?
>>>
>> Seeing as .stringof was added in DMD 1.005, it might. ;-)
> 
> Strange. It wasn't even so long ago that I downloaded the compiler. Has
> stringof only existed for a month or so?

17 days to be exact :)
February 22, 2007
On Thu, 22 Feb 2007 14:33:00 +0100, Michiel <nomail@please.com> wrote:

>Deewiant wrote:
>
>>>>>>> The documentation sais that all types should have the property .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't it exist (anymore)?
>>>>>> In what case does it not work?
>>>>> Any case. I tried this:
>>>> That works just fine here, DMD 1.007
>>> Ah, I have DMD 1.003. Would that make the difference?
>>>
>> 
>> Seeing as .stringof was added in DMD 1.005, it might. ;-)
>
>Strange. It wasn't even so long ago that I downloaded the compiler. Has stringof only existed for a month or so?

Yes, it has not been announced as part of the language. Walter said it was because it didn't work correctly. And it really doesn't, at least for enums. For example, this gives int while Test is expected:

enum Test : int
{
	one
}

void main()
{
	pragma (msg, Test.stringof);
}
February 22, 2007
Max Samukha wrote:

>>>>>>>> The documentation sais that all types should have the property .stringof, but it doesn't seem to work. Has it been renamed? Or doesn't it exist (anymore)?
>>>>>>> In what case does it not work?
>>>>>> Any case. I tried this:
>>>>> That works just fine here, DMD 1.007
>>>> Ah, I have DMD 1.003. Would that make the difference?
>>>>
>>> Seeing as .stringof was added in DMD 1.005, it might. ;-)
>> Strange. It wasn't even so long ago that I downloaded the compiler. Has stringof only existed for a month or so?
> 
> Yes, it has not been announced as part of the language. Walter said it was because it didn't work correctly. And it really doesn't, at least for enums. For example, this gives int while Test is expected:

Well, it's handy nonetheless. I'm using it in some assert(0) error messages.

Thanks for the help, everyone. I'll update the compiler.

-- 
Michiel
« First   ‹ Prev
1 2