[Semi OT] Language for Game Development talk

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 27 17:51:45 PDT 2014


On 09/28/2014 01:55 AM, Walter Bright wrote:
> On 9/27/2014 4:20 PM, bearophile wrote:
>> Walter Bright:
>>
>>>> It could be nice to have a syntax like lambdas for small
>>>> struct/class methods:
>>>> https://issues.dlang.org/show_bug.cgi?id=7176
>>>>
>>>> struct Foo {
>>>>     int bar(int x) pure { return x * x; }
>>>> }
>>>>
>>>> Becomes something like::
>>>>
>>>> struct Foo {
 >>>>     int bar(int x) pure => x * x; // fixed
>>>> }
>>>
>>> I see no gain from that syntax.
>>
>> Issue 7176 has currently seven votes, so someone seems to like it.
>
> A feature without a solid rationale  is no good in spite of how many
> votes it has.

Uniform syntax for parameter list followed by function body.

              (int x){ return 2; }
      function(int x){ return 2; }
auto separate(int x){ return 2; }
              (int x) => 2;
      function(int x) => 2;
auto separate(int x) => 2;

auto curriedAdd(int x) => (int y) => x + y;

It is a simplification that is also convenient.


More information about the Digitalmars-d mailing list