digitalmars.D - Type.stringof
- Michiel <nomail please.com> Feb 21 2007
- Walter Bright <newshound digitalmars.com> Feb 22 2007
- Michiel <nomail please.com> Feb 22 2007
- Lionello Lunesu <lio lunesu.remove.com> Feb 22 2007
- Michiel <nomail please.com> Feb 22 2007
- Deewiant <deewiant.doesnotlike.spam gmail.com> Feb 22 2007
- Michiel <nomail please.com> Feb 22 2007
- Lionello Lunesu <lio lunesu.remove.com> Feb 22 2007
- BCS <BCS pathlink.com> Feb 22 2007
- Max Samukha <samukha voliacable.com> Feb 22 2007
- Michiel <nomail please.com> Feb 22 2007
- torhu <fake address.dude> Feb 22 2007
- Walter Bright <newshound digitalmars.com> Feb 22 2007
- Lionello Lunesu <lio lunesu.remove.com> Feb 22 2007
- Leandro Lucarella <llucarella integratech.com.ar> Feb 22 2007
- renoX <renosky free.fr> Feb 22 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
Feb 21 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?
Feb 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
Feb 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)?
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.
Feb 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)?
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
Feb 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)?
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.
Feb 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)?
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
Feb 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)?
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 :)
Feb 22 2007
Lionello Lunesu wrote: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?
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 :)
The bleeding edge doesn't last vary long around here. <g>
Feb 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)?
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); }
Feb 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)?
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
Feb 22 2007
Deewiant wrote:Michiel wrote:Ah, I have DMD 1.003. Would that make the difference?
Seeing as .stringof was added in DMD 1.005, it might. ;-)
I think that it would be good if the docs could mention with which compiler version a feature was added.
Feb 22 2007
torhu wrote:I think that it would be good if the docs could mention with which compiler version a feature was added.
It does in the changelog.
Feb 22 2007
Walter Bright wrote:torhu wrote:I think that it would be good if the docs could mention with which compiler version a feature was added.
It does in the changelog.
Not for .stringof it doesn't :) By the way, it would be nice if .stringof for an enum member would return the actual enum stringized. Will this be possible? L.
Feb 22 2007
Lionello Lunesu escribió:Walter Bright wrote:torhu wrote:I think that it would be good if the docs could mention with which compiler version a feature was added.
It does in the changelog.
Not for .stringof it doesn't :) By the way, it would be nice if .stringof for an enum member would return the actual enum stringized. Will this be possible?
And it's not very practical to read the doc and searching the changelog to see where that particular feature where added. -- Leandro Lucarella Integratech S.A. 4571-5252
Feb 22 2007
Lionello Lunesu a écrit :Walter Bright wrote:torhu wrote:I think that it would be good if the docs could mention with which compiler version a feature was added.
It does in the changelog.
Not for .stringof it doesn't :) By the way, it would be nice if .stringof for an enum member would return the actual enum stringized.
Note that Kevin Bealer has made two versions of a template for 'reflective enums'. I don't find the result totally satisfying as you loose the type safety in current version, but it's a good start. renoXWill this be possible? L.
Feb 22 2007









BCS <BCS pathlink.com> 