Lambda syntax, etc

Bill Baxter wbaxter at gmail.com
Wed Feb 4 21:56:58 PST 2009


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; }

> Or maybe parens instead of pipes (this is similar to K&R C, isn't it?):
>
> int add { (int x, int y)
>    return x+y;
> }

K&R was like
    int add(x,y)
       int x;
       int y;
    {  return x+y }

--bb



More information about the Digitalmars-d mailing list