Why Ruby?

Nick Sabalausky a at a.a
Sun Dec 19 11:40:14 PST 2010


"Jacob Carlborg" <doob at me.com> wrote in message 
news:iel9p5$1goa$2 at digitalmars.com...
> On 2010-12-19 01:01, Nick Sabalausky wrote:
>> "Walter Bright"<newshound2 at digitalmars.com>  wrote in message
>> news:iejejo$pfr$1 at digitalmars.com...
>>> Nick Sabalausky wrote:
>>>> Any problem with the other Scala/C#-style one?:
>>>>
>>>> (x, y) =>   x * y
>>>>
>>>> // Lowered to:
>>>>
>>>> (x, y) { return x * y; }
>>>>
>>>> (Maybe that was rejected before due the the weird float operators that
>>>> are now being ditched?)
>>>
>>> The problem with the (x,y) parameter lists, where x and y are the
>>> parameters, is that it is ambiguous with the existing syntax of (x,y)
>>> where x and y are types and the parameters are omitted.
>>>
>>> For example:
>>>
>>> void foo(int);
>>
>> But we already have:
>>
>>      (x, y) { return x * y; }
>>
>> So either there aren't any problems with it after all, or D's existing
>> delegate syntax is already broken.
>>
>> To be clear, with what I'm trying to suggest, the *only* thing that would 
>> be
>> different from the current delegate literal syntax is that part *after* 
>> the
>> parameter list. Ie:
>>
>>      PARAM_LIST_HERE { return x * y; }
>>      // -->
>>      PARAM_LIST_HERE =>  x * y
>>
>> Or if there's a problem with =>, then ->, or -->, or ::>, or :>, or
>> whatever. I'm not suggesting the param list be different in any way 
>> fromhow
>> t is now. (Although proposals from other people might differ.)
>
> ^^ Exactly. I would also like to have type inference for the parameter 
> list, do we have that already in D2?
>

I know you can use "auto". I had thought you could also omit the type in a 
delegate literal's param list, but Walter's response above makes me think I 
might be mistaken. Even if so, as I was trying to say above, if delegate 
literals are indeed required to be (auto x, auto y) { return x * y; }, then 
I would be perfectly happy with lambdas that were the same: (auto x, auto y) 
=> x * y  I do think that's still far easier to read than the full delegate 
literal syntax.





More information about the Digitalmars-d mailing list