Thread overview
[Issue 13451] Lambda syntax with explicit return type not documented
Sep 09, 2014
Jakob Ovrum
Sep 19, 2014
Kenji Hara
Sep 19, 2014
Kenji Hara
September 09, 2014
https://issues.dlang.org/show_bug.cgi?id=13451

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--- Comment #1 from hsteoh@quickfur.ath.cx ---
I had no idea this syntax was supported. Is it intentional, or is it an oversight in the implementation?

--
September 09, 2014
https://issues.dlang.org/show_bug.cgi?id=13451

--- Comment #2 from briancschott@gmail.com ---
https://github.com/D-Programming-Language/dmd/blob/master/test/runnable/funclit.d#L258

I would not be surprised if it started off as an oversight and was then added to the test suite.

We should never break the promises we never made, right?

--
September 09, 2014
https://issues.dlang.org/show_bug.cgi?id=13451

Jakob Ovrum <jakobovrum@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakobovrum@gmail.com

--- Comment #3 from Jakob Ovrum <jakobovrum@gmail.com> ---
(In reply to hsteoh from comment #1)
> I had no idea this syntax was supported. Is it intentional, or is it an oversight in the implementation?

It's a hold-over from the other function literal syntax:

auto fp = function int(int a) { return a; };

It's just as useful whether it's using lambdas or the old syntax, so I suggest we reconcile the grammar with DMD in this case.

--
September 19, 2014
https://issues.dlang.org/show_bug.cgi?id=13451

--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to briancschott from comment #0)
> ---
> fp = function int(int a) => a;
> ---

When I cleaned up parser code for lambdas, the syntax was intentional as that
is a combination of:
  - the keyword "function" for function literals
  - optional return type specification
  - parameter list
  - lambda style function literal body ("=>" with one AssignExpression)

So, I'd fix the grammar to fit accepted code by dmd, like follows.

Lambda:
    function Type(opt) ParameterAttributes => AssignExpression
    delegate Type(opt) ParameterAttributes => AssignExpression
    ParameterAttributes => AssignExpression
    Identifier => AssignExpression

--
September 19, 2014
https://issues.dlang.org/show_bug.cgi?id=13451

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dlang.org/pull/656

--
September 23, 2014
https://issues.dlang.org/show_bug.cgi?id=13451

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org

https://github.com/D-Programming-Language/dlang.org/commit/54a1e7e04e9576f3c08bf41ac3fad721366eee60 fix Issue 13451 - Lambda syntax with explicit return type not documented

https://github.com/D-Programming-Language/dlang.org/commit/d4c0a53c2b123e46bfc9dba2ec75b608f6f44769 Merge pull request #656 from 9rnsr/fix13451

Issue 13451 - Lambda syntax with explicit return type not documented

--