May 23, 2010
----
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 (){
	writefln( toString(3) );
	writefln( toString(ENUM.A) );
	writefln( toString(ENUM_2.D) );
}
----
3
ENUM
ENUM_2

Yep seems to work like that.
May 23, 2010
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;
import b;
import std.math;
import std.stdio;

string toString(double){ return "you want to use this function";}

void main(){ writeln(toString(cos(1.0)); }

module b;
string toString(real){ return "covert ninja you don't know about"; }


I tried telling walter that enums don't and won't suffer from this problem.
May 23, 2010
== Quote from Ellery Newcomer (ellery-newcomer@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 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;
> import b;
> import std.math;
> import std.stdio;
> string toString(double){ return "you want to use this function";}
> void main(){ writeln(toString(cos(1.0)); }
> module b;
> string toString(real){ return "covert ninja you don't know about"; }
Yep, tricky one. I wouldn't be mad at the compiler to use the ninja one as I do understand the reasoning (using D1 that is)

> I tried telling walter that enums don't and won't suffer from this problem.

May 23, 2010
Ellery Newcomer <ellery-newcomer@utulsa.edu> 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
May 23, 2010
On 05/23/2010 02:05 PM, Simen kjaeraas wrote:
> Ellery Newcomer <ellery-newcomer@utulsa.edu> 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 portion of D is bad.

Seriously, there's all kinds of crap revolving around the basic types. Those are the special cases, not enums
1 2
Next ›   Last »