refined sugar (was DMD 0.165 release)

Carlos Santander csantander619 at gmail.com
Tue Aug 22 20:48:52 PDT 2006


Pragma escribió:
> 
> I'm not too crazy about '=>' but something like using {} without an 
> embedded return (as others have mentioned) might be the right trick.  As 
> long as it has the same behavior as the explicit cast() above, it has my 
> vote.
> 
> foobar("value");
> foobar({"value"});
> 
> It's subtle, yet impossible to confuse for anything else.
> 

I also want it to be explicit someway, and I liked {} but what if struct 
initializers get added? (did I get my wording right?)

struct A { char [] txt; }

void foo (char [] txt) {} // #1
void foo (char [] delegate () dg) {} // #2
void foo (A a) {} // #3

...

foo ({"hi!"});

How does the compiler know which one we want? Casting would be an option, but I 
think it'd be too verbose most of the time.

So, while I don't like => either, some other operator along those lines maybe 
better. Following the previous example:

foo ("hi!") // calls #1
foo ({"hi!"}); // calls #3
foo (=> "hi!"); // calls #2

Ok, maybe => doesn't look so bad after all :P

-- 
Carlos Santander Bernal



More information about the Digitalmars-d-announce mailing list