Lambda syntax, etc
Nick Sabalausky
a at a.a
Wed Feb 4 22:20:07 PST 2009
"Bill Baxter" <wbaxter at gmail.com> wrote in message
news:mailman.651.1233813474.22690.digitalmars-d at puremagic.com...
> On Thu, Feb 5, 2009 at 2:56 PM, Bill Baxter <wbaxter at gmail.com> wrote:
>> On Thu, Feb 5, 2009 at 2:30 PM, Nick Sabalausky <a at a.a> wrote:
>>>>> 2) A ruby-like syntax for delegate literals : {|a,b| return a+b;}
>>>>
>>>> I don't like that
>>>>
>>>
>>> The thing I like about that is that it makes it much more clear at a
>>> glance
>>> that the "a,b" or "int a, int b" is associated with the code block (but
>>> without the problem some languages have of making it hard to distinguish
>>> from the block's body).
>>
>> I agree. Putting the args inside the { } is much more readable to me
>> too.
>> Even just putting the parens inside rather than outside seems an
>> improvement.
>>
>> Or how about
>>
>> { int x; int y :: return x+y; }
I'd be fine with that. Actually, I think I like that a little better (for a
couple of reasons which I seem to be finding difficult to put into words.
It's like, making a clear "split" or division in the block instead of having
what looks like this thing that's just kind of floating around, and forever
having those two "grouping openers" right next to each other, ie, "{ (" or
"{ |" . )
But I'm not sure about replacing the commas with semicolons, unless it meant
you could do:
{ int x, y :: return x+y; }
But then, I'm not sure how I feel about that either.
>
> K&R was like
> int add(x,y)
> int x;
> int y;
> { return x+y }
>
Oh that's right, I knew it was something funky like that. (That would be a
"bad redundancy". /me nods to Walter's Dobbs article.)
>
> Oh, and last semicolon of a function should be optional :-)
>
> { int x; int y :: return x+y }
>
Now there's a language war waiting to happen ;)
More information about the Digitalmars-d
mailing list