refined sugar (was DMD 0.165 release)

Oskar Linde oskar.lindeREM at OVEgmail.com
Wed Aug 23 01:58:56 PDT 2006


Ivan Senji wrote:
> Carlos Santander wrote:
>> 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
>>
> 
> I have to agree with this, => does keep looking better and better..

Ideally, a syntax should also support declaring single expression 
delegates with arguments.

(int a){a+1}
(int a) => a+1

And in the future, possibly type inferred:
(a){a+1}
a => a+1

(a,b){a+b}
a,b => a+b

/Oskar



More information about the Digitalmars-d-announce mailing list