Whiley / RFCs

Request for Comment (RFC) proposals for substantial changes to the Whiley language.
3 stars 2 forks source link

Statement Syntax for Lambdas #74

Open DavePearce opened 4 years ago

DavePearce commented 4 years ago

Currently, lambda's only support expression syntax, such as follows:

return &(int x -> x + 1)

However, it would be good on occasion to support some form of statement synax. Here's one possibility:

int x = &(int y):
    return y + 1

This offers the closest syntax to existing function and method declarations. Another option would be to exploit the semi-colon to help. For example:

return &(int x -> x = x + 1; return x)