Re: enum overloading

2010-05-23 Thread Ellery Newcomer
On 05/23/2010 02:05 PM, Simen kjaeraas wrote: Ellery Newcomer wrote: I tried telling walter that enums don't and won't suffer from this problem. True. However, treating enums as special for this means another special case in the language. And special cases are bad. implying a very large p

Re: enum overloading

2010-05-23 Thread Simen kjaeraas
Ellery Newcomer wrote: I tried telling walter that enums don't and won't suffer from this problem. True. However, treating enums as special for this means another special case in the language. And special cases are bad. -- Simen

Re: enum overloading

2010-05-23 Thread strtr
== Quote from Ellery Newcomer (ellery-newco...@utulsa.edu)'s article > On 05/23/2010 07:35 AM, strtr wrote: > > Did I miss it or should I add a bug report? > http://www.digitalmars.com/d/2.0/hijack.html That's not really the D1 spec.. a bug report it is :D > > > >> (it strikes me that this is a ne

Re: enum overloading

2010-05-23 Thread Ellery Newcomer
On 05/23/2010 07:35 AM, strtr wrote: Did I miss it or should I add a bug report? http://www.digitalmars.com/d/2.0/hijack.html (it strikes me that this is a necessary product of a loose type system) It is? :) yes. here's an example which acts differently if you don't have it: module a;

Re: enum overloading

2010-05-23 Thread strtr
module e2_def; import std.string; static enum ENUM_2 { D, E, F }; char[] toString(ENUM_2) { return "ENUM_2"; } -- module main; import std.string : toString; import std.stdio; import e2_def : ENUM_2, toString; enum ENUM { A,B } char[] toString(ENUM e_){return "ENUM";} void main ()

Re: enum overloading

2010-05-23 Thread strtr
== Quote from Ellery Newcomer (ellery-newco...@utulsa.edu)'s article > That would work except > a) walter's hijacking fetish; if you want to overload a function with > one imported from an external module, you'd have to do something like > import std.string: toString; Nice, that seems to work. So

Re: enum overloading

2010-05-23 Thread strtr
== Quote from Ellery Newcomer (ellery-newco...@utulsa.edu)'s article > On 05/22/2010 08:20 PM, Ellery Newcomer wrote: > > > > From a discussion with walter a while back, I gathered not possible. > Strike this line, not sure what I was thinking of here Saves me a bit of parsing allocation ;)

Re: enum overloading

2010-05-22 Thread Ellery Newcomer
On 05/22/2010 08:20 PM, Ellery Newcomer wrote: From a discussion with walter a while back, I gathered not possible. Strike this line, not sure what I was thinking of here

Re: enum overloading

2010-05-22 Thread Ellery Newcomer
On 05/22/2010 05:08 PM, strtr wrote: == Quote from Ary Borenszweig (a...@esperanto.org.ar)'s article Ary Borenszweig wrote: strtr wrote: Sorry, should have included this :) module main; import std.string; import std.stdio; enum ENUM { A,B } char[] toString(ENUM e_){return "enum";} voi

Re: enum overloading

2010-05-22 Thread strtr
== Quote from Ary Borenszweig (a...@esperanto.org.ar)'s article > Ary Borenszweig wrote: > > strtr wrote: > >> Sorry, should have included this :) > >> > >> > >> module main; > >> import std.string; > >> import std.stdio; > >> > >> enum ENUM { A,B } > >> > >> char[] toString(ENUM e_){return "e

Re: enum overloading

2010-05-22 Thread Ary Borenszweig
Ary Borenszweig wrote: strtr wrote: Sorry, should have included this :) module main; import std.string; import std.stdio; enum ENUM { A,B } char[] toString(ENUM e_){return "enum";} void main (){ writefln( toString(3) ); writefln( toString(ENUM.A) ); } -- main.d(10): Error: funct

Re: enum overloading

2010-05-22 Thread Ary Borenszweig
strtr wrote: Sorry, should have included this :) module main; import std.string; import std.stdio; enum ENUM { A,B } char[] toString(ENUM e_){return "enum";} void main (){ writefln( toString(3) ); writefln( toString(ENUM.A) ); } -- main.d(10): Error: function main.toStrin

Re: enum overloading

2010-05-22 Thread strtr
Sorry, should have included this :) module main; import std.string; import std.stdio; enum ENUM { A,B } char[] toString(ENUM e_){return "enum";} void main (){ writefln( toString(3) ); writefln( toString(ENUM.A) ); } -- main.d(10): Error: function main.toString (ENUM) does n

Re: enum overloading

2010-05-22 Thread Robert Clipsham
On 22/05/10 18:46, strtr wrote: I wanted to overload toString for my enums. test.d(189): Error: toString (ENUM) does not match parameter types (int) not possible? enum ENUM { a, b, c } void toString(ENUM) { } It works here. Could you show an example of some code that isn't wo