Minor feature request

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 28 04:22:38 PDT 2016


On 6/28/16 2:13 AM, Superstar64 wrote:
> Right now, D functions expect a Block Statement
> (https://dlang.org/spec/function.html#FunctionBody) as their function
> body. Changing that to allow any statement
> (https://dlang.org/spec/statement.html#Statement) would provide a few
> new syntactic sugars like:
> ---
> auto func(MyObj obj) with(obj)
> {
>     //...
> }
>
> auto func(int arg) return arg;

We pretty much have this with lambda syntax:

(int arg) => arg

Would be nice to be able to use this to define functions...

However, I don't want to change the definition of functions to allow 
non-blocks. It harms readability. The lambda syntax is different enough 
and restricted enough to stand out.

-Steve


More information about the Digitalmars-d mailing list