Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D] Add short function definition syntax #3884

Closed
wants to merge 1 commit into from

Conversation

s-ludwig
Copy link

@s-ludwig s-ludwig commented Dec 9, 2023

The short function definition syntax was introduced with DMD 2.101.0 and replaces an ordinary block statement function body with a lambda-like construct (int foo(int x) => x + 1;).

Due to the structure of the syntax definition file, I'm unsure whether this is complete, but it appears to work fine for the cases that I've seen so far.

The short function definition syntax was introduced with DMD 2.101.0 and replaces an ordinary block statement function body with a lambda-like construct (`int foo(int x) => x + 1;`).
@s-ludwig
Copy link
Author

s-ludwig commented Dec 9, 2023

Corresponding part of the D spec: https://dlang.org/spec/function.html#function-bodies

@michaelblyons michaelblyons changed the title Add short function definition syntax [D] Add short function definition syntax Dec 9, 2023
@jrappen
Copy link
Contributor

jrappen commented Dec 15, 2023

Generally, I'd appreciate some tests with the changes.

@s-ludwig
Copy link
Author

Honestly, I'm just making educated guesses with the changes here, since the structure and some of the syntax of the syntax and test files is not really clear to me. It feels like this will take more time than I can currently spare for this. The two test cases this should cover would be these, though:

    int[] map(int[] array) => foo();
    int[] map(T)(int[] array) => foo();

I've opened an issue instead for now #3894

@s-ludwig s-ludwig closed this Dec 16, 2023
@deathaxe deathaxe added T: feature major update for a syntax to support new language features C: Syntax labels Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Syntax T: feature major update for a syntax to support new language features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants