Re: enum to string

2009-03-14 Thread bearophile
Daniel Keep: > template Range(int n) If some of you needs a version that takes 1 or 2 or 3 arguments, for the start, stop and stride, take a look at my dlibs: http://www.fantascienza.net/leonardo/so/dlibs/templates.html Bye, bearophile

Re: enum to string

2009-03-13 Thread Daniel Keep
Ary Borenszweig wrote: > Lionello Lunesu wrote: >> >> "Brad Roberts" wrote in message >> news:alpine.deb.2.00.0903121755240.4...@bellevue.puremagic.com... >>> That said, I don't think this really helps the desired usecase much. >>> It's >>> useful, don't get me wrong, but still requires code to

Re: enum to string

2009-03-13 Thread Ary Borenszweig
Lionello Lunesu wrote: "Brad Roberts" wrote in message news:alpine.deb.2.00.0903121755240.4...@bellevue.puremagic.com... That said, I don't think this really helps the desired usecase much. It's useful, don't get me wrong, but still requires code to build up the bi-directional translations.

Re: enum to string

2009-03-12 Thread Lionello Lunesu
"Brad Roberts" wrote in message news:alpine.deb.2.00.0903121755240.4...@bellevue.puremagic.com... That said, I don't think this really helps the desired usecase much. It's useful, don't get me wrong, but still requires code to build up the bi-directional translations. Or am I missing somethi

Re: enum to string

2009-03-12 Thread Brad Roberts
On Thu, 12 Mar 2009, BCS wrote: > Reply to Lionello, > > > cr*p, I've pasted too little. Try this one instead.. > > > > I'll use a proper diff tool next time.. > > > > you client is messing with you, paste-bin the sucker or add it to a bugzilla > item Just to be sure the two don't get combine

Re: enum to string

2009-03-12 Thread Lionello Lunesu
//src\dmd\mtype.c, line 5025 (in TypeEnum::dotExp, after the #endif): /* If e.tupleof */ if (ident == Id::tupleof) { /* Create a TupleExp out of the fields of the struct e: * (e.field0, e.field1, e.field2, ...) */ e = e->semantic(sc); // do this before turning o

Re: enum to string

2009-03-12 Thread BCS
Reply to Lionello, cr*p, I've pasted too little. Try this one instead.. I'll use a proper diff tool next time.. you client is messing with you, paste-bin the sucker or add it to a bugzilla item

Re: enum to string

2009-03-12 Thread Lionello Lunesu
Nick Sabalausky wrote: "Lionello Lunesu" wrote in message news:gpc4j3$30a...@digitalmars.com... Oops, sorry, I didn't notice this was the .learn newsgroup. I guess a patch to the DMD source was not really what you expected. I just got so anxious! L. Hey, solutions are solutions :) In fact

Re: enum to string

2009-03-12 Thread Lionello Lunesu
cr*p, I've pasted too little. Try this one instead.. I'll use a proper diff tool next time.. /* If e.tupleof */ if (ident == Id::tupleof) { /* Create a TupleExp out of the fields of the struct e: * (e.field0, e.field1, e.field2, ..

Re: enum to string

2009-03-12 Thread Lionello Lunesu
Your attachment is zero-byte. Oops... Try this one.. /* Create a TupleExp out of the fields of the struct e: * (e.field0, e.field1, e.field2, ...) */ e = e->semantic(sc);// do this before turning on noaccesscheck

Re: enum to string

2009-03-12 Thread Nick Sabalausky
"Lionello Lunesu" wrote in message news:gpc4es$30a...@digitalmars.com... > Nick Sabalausky wrote: >> Is there any way to do this (preferably in D1) with reflection? (ie, >> without >> having to manually create a conversion func/lookup for every value of >> every >> enum.) >> >>

Re: enum to string

2009-03-12 Thread Nick Sabalausky
"Lionello Lunesu" wrote in message news:gpc4j3$30a...@digitalmars.com... > Oops, sorry, I didn't notice this was the .learn newsgroup. I guess a > patch to the DMD source was not really what you expected. I just got so > anxious! > > L. Hey, solutions are solutions :) In fact I may very well

Re: enum to string

2009-03-12 Thread Lionello Lunesu
Oops, sorry, I didn't notice this was the .learn newsgroup. I guess a patch to the DMD source was not really what you expected. I just got so anxious! L.

Re: enum to string

2009-03-12 Thread Lionello Lunesu
Nick Sabalausky wrote: Is there any way to do this (preferably in D1) with reflection? (ie, without having to manually create a conversion func/lookup for every value of every enum.) -- enum Shape { Square, Circle } char[] foo(Shape s) { // ? } // Either one of

Re: enum to string

2009-03-12 Thread Robert Fraser
Jarrett Billingsley wrote: There's also std.typecons which has an enum generator that will create toString and I think fromString functions as well. Which should be easily portable to D1.

Re: enum to string

2009-03-10 Thread Jarrett Billingsley
On Tue, Mar 10, 2009 at 9:54 PM, Nick Sabalausky wrote: > "MIURA Masahiro" wrote in message > news:gp730i$30e...@digitalmars.com... >> In D2: >> >> enum Shape: string >> { >>    Square = "Square", >>    Circle = "Circle", >> } >> >> void main() >> { >>    assert(cast(string) Shape.Square == "Squa

Re: enum to string

2009-03-10 Thread Nick Sabalausky
"MIURA Masahiro" wrote in message news:gp730i$30e...@digitalmars.com... > In D2: > > enum Shape: string > { >Square = "Square", >Circle = "Circle", > } > > void main() > { >assert(cast(string) Shape.Square == "Square"); > } So there's no built-in way to do this with compile-time refl

Re: enum to string

2009-03-10 Thread Daniel Keep
Nick Sabalausky wrote: > Is there any way to do this (preferably in D1) with reflection? (ie, without > having to manually create a conversion func/lookup for every value of every > enum.) > > -- > enum Shape > { > Square, Circle > } > char[] foo(Shape s) > { > // ?

Re: enum to string

2009-03-10 Thread MIURA Masahiro
In D2: enum Shape: string { Square = "Square", Circle = "Circle", } void main() { assert(cast(string) Shape.Square == "Square"); }