December 27, 2011
On 27-12-2011 21:32, Jacob Carlborg wrote:
> On 2011-12-27 05:25, Andrei Alexandrescu wrote:
>> https://github.com/D-Programming-Language/dmd/commit/675898721c04d0bf155a85abf986eae99c37c0dc
>>
>>
>>
>> Andrei
>
> Now that's very cool. Does it work for non-template arguments as well.
>

Nope. When passing such lambdas as regular arguments, there's no inference.

- Alex
December 27, 2011
On 12/27/2011 10:53 PM, Alex Rønne Petersen wrote:
> On 27-12-2011 21:32, Jacob Carlborg wrote:
>> On 2011-12-27 05:25, Andrei Alexandrescu wrote:
>>> https://github.com/D-Programming-Language/dmd/commit/675898721c04d0bf155a85abf986eae99c37c0dc
>>>
>>>
>>>
>>>
>>> Andrei
>>
>> Now that's very cool. Does it work for non-template arguments as well.
>>
>
> Nope. When passing such lambdas as regular arguments, there's no inference.
>
> - Alex

... yet.

http://d.puremagic.com/issues/show_bug.cgi?id=6714

Anyway, his question seemed to be about whether or not the '=>' syntax can be used for ordinary delegate literals, which it can: (int x) => x
December 27, 2011
On 12/27/2011 05:25 AM, Andrei Alexandrescu wrote:
> https://github.com/D-Programming-Language/dmd/commit/675898721c04d0bf155a85abf986eae99c37c0dc
>
>
> Andrei

Great! =)

What about making => syntax available to named functions as well?

class C{
    private int x;
    int getX() => x;
}


void main(){
    int[] arr;
    bool isOdd(int x) => x&1;
    writeln(arr.filter!isOdd());
}

December 27, 2011
On 12/27/2011 11:27 PM, Timon Gehr wrote:
> On 12/27/2011 05:25 AM, Andrei Alexandrescu wrote:
>> https://github.com/D-Programming-Language/dmd/commit/675898721c04d0bf155a85abf986eae99c37c0dc
>>
>>
>>
>> Andrei
>
> Great! =)
>
> What about making => syntax available to named functions as well?
>
> class C{
> private int x;
> int getX() => x;
> }
>
>
> void main(){
> int[] arr;
> bool isOdd(int x) => x&1;
> writeln(arr.filter!isOdd());
> }
>

Also,

=> expr

should imo be a shorthand for

() => expr.

It saves some ((())(()))().




December 27, 2011
On 27-12-2011 23:18, Timon Gehr wrote:
> On 12/27/2011 10:53 PM, Alex Rønne Petersen wrote:
>> On 27-12-2011 21:32, Jacob Carlborg wrote:
>>> On 2011-12-27 05:25, Andrei Alexandrescu wrote:
>>>> https://github.com/D-Programming-Language/dmd/commit/675898721c04d0bf155a85abf986eae99c37c0dc
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Andrei
>>>
>>> Now that's very cool. Does it work for non-template arguments as well.
>>>
>>
>> Nope. When passing such lambdas as regular arguments, there's no
>> inference.
>>
>> - Alex
>
> ... yet.
>
> http://d.puremagic.com/issues/show_bug.cgi?id=6714
>
> Anyway, his question seemed to be about whether or not the '=>' syntax
> can be used for ordinary delegate literals, which it can: (int x) => x

That bug needs very high priority.

- Alex
December 27, 2011
Timon Gehr:

> What about making => syntax available to named functions as well?
> 
> class C{
>      private int x;
>      int getX() => x;
> }
> 
> 
> void main(){
>      int[] arr;
>      bool isOdd(int x) => x&1;
>      writeln(arr.filter!isOdd());
> }

From the Ada 2012 changes: http://www.disca.upv.es/jorge/ae2010/slides/05-3_Language_Tech_Schonberg_Towards_Ada_2012.pdf

> To simplify the writing of pre/postconditions and predicates, allow parametrized expressions (aka function bodies in package specs):

function Cube (X : integer) is (X ** 3);

Bye,
bearophile
December 28, 2011
On Tuesday, December 27, 2011 14:07:25 Jakob Ovrum wrote:
> And it is indeed very important. It's one of the few syntax woes we have to deal with in D, it would be a shame to let the benefits of std.algorithm and any other functional D code be overshadowed by the powerful but often excessive syntax of anonymous functions.

I find this sort of discussion to be somewhat funny. I don't think that it's a problem that D has added a new lambda syntax, but what we've had _so_ much better than C++ 98 that I never really cared. Sure, putting the return in there and all that is a bit verbose, but at least we have lambdas! I almost never use the algorithms in C++, because you have to define separate functors elsewhere. You don't even get nested functions! So, I've never seen much reason to complain about D's verbose lambda syntax, because it's so nice to have what we have rather than be forced to create functors and the like.

So, this is certainly a welcome change, but I've also found it kind of odd that some people have been complaining about it so much. Most of them probably aren't C++ programmers.

- Jonathan M Davis
December 28, 2011
On Tuesday, December 27, 2011 18:43:14 Andrej Mitrovic wrote:
> Wouldn't it be great if Santa were to give us named arguments this year too? :)

Only if he hates me. But I guess that I'm in the minority around here in that I hate the idea of named arguments.

- Jonathan M Davis
December 28, 2011
On Wednesday, 28 December 2011 at 00:21:40 UTC, Jonathan M Davis wrote:
> On Tuesday, December 27, 2011 14:07:25 Jakob Ovrum wrote:
>> And it is indeed very important. It's one of the few syntax woes
>> we have to deal with in D, it would be a shame to let the
>> benefits of std.algorithm and any other functional D code be
>> overshadowed by the powerful but often excessive syntax of
>> anonymous functions.
>
> I find this sort of discussion to be somewhat funny. I don't think that it's a problem that D has added a new lambda syntax, but what we've had _so_ much better than C++ 98 that I never really cared. Sure, putting the return in there and all that is a bit verbose, but at least we have lambdas! I almost never use the algorithms in C++, because you have to define separate functors elsewhere. You don't even get nested functions! So, I've never seen much reason to complain about D's verbose lambda syntax, because it's so nice to have what we have rather than be forced to create functors and the like.
>
> So, this is certainly a welcome change, but I've also found it kind of odd that some people have been complaining about it so much. Most of them probably aren't C++ programmers.
>
> - Jonathan M Davis

So your argument basically boils down to: "I find it funny that car owners (Non C++ programmers) complain about bicycles not being fast enough. I mean, it's way better than walking (Programming in C++)"

I fail to understand what's odd about that.
December 28, 2011
On 27/12/11 8:40 PM, Andrei Alexandrescu wrote:
> On 12/27/11 2:38 PM, Walter Bright wrote:
>> On 12/27/2011 12:28 PM, Andrei Alexandrescu wrote:
>>> One good realization to make is how less efficient that makes you. You
>>> got used
>>> to that overhead so plentily, you consider it now par for the course.
>>
>> What takes time is running the unittests, not compiling dmd.
>
> Then _that_ is what you consider par for the course! :o)
>
> Andrei

Has anyone looked into what causes the unittests to take so long? I find it hard to believe that they need to take as long as they do.