foo!(bar) ==> foo{bar}

Simen Kjaeraas simen.kjaras at gmail.com
Tue Oct 7 12:44:40 PDT 2008


On Mon, 06 Oct 2008 23:24:01 +0200, superdan <super at dan.org> wrote:

> Nick Sabalausky Wrote:
>
>> "Walter Bright" <newshound1 at digitalmars.com> wrote in message
>> news:gcdqa4$qas$1 at digitalmars.com...
>> > The foo.(bar) syntax seems to be sinking. The foo{bar} seems to be the
>> > most practical alternative. So, how about putting it in the next D2
>> > release on a trial basis, so people can try it out and see how it  
>> looks?
>>
>> I would like to eventually be able to have a function like this (trivial
>> contrived example):
>>
>> repeat(int times, void delegate() d)
>> {
>>     foreach(int i; 0..times)
>>         d();
>> }
>>
>> And call it like this:
>>
>> repeat(3)
>> {
>>     // Do stuff
>> }
>>
>> Instead of needing to use the current awkwardness of:
>>
>> repeat(3,
>> {
>>     // Do stuff
>> });
>>
>> If changing "foo!(bar)" to "foo{bar}" would cause problems with that,  
>> then
>> I'd be against it. Otherwise, I'd be ok with the change, provided that  
>> it
>> didn't end up becoming visually confusing in terms of "Is that a big
>> template parameter list, or a statement block?"
>
> nagonna be a problem. it's been discussed. id { stuff }is instantiation.  
> id(optional stuff) { stuff } is that thing yer talkin' about.

Not necessarily. Consider

   repeat(int times = 3, void delegate() d){...}

   repeat
   {
     foo();
   }

-- 
Simen



More information about the Digitalmars-d mailing list