Nicer syntax for constructors

NoMoreBugs NoMoreBugs at
Mon Nov 19 12:30:20 UTC 2018

On Sunday, 18 November 2018 at 19:09:16 UTC, Trailzz wrote:
> I'm not sure exactly what the syntax would be like, but I just 
> wanted to know what other people think about this. Would it be 
> worth creating a DIP for this?

Well, let's step back a bit, from the so called 'code bloat', and 
have a look at the definition of a function:

return-type function-name(parameter declarations, if any)

What you are suggesting, is, in order to save a few keystrokes, 
that D changes the definition of a function (or a constructor 
function in this case).

No language that has functions allows you do initialize variables 
in the section where you declare your parameters - at least, no 
language that I am aware of.

Lets not surprise newcomers to D, anymore than they are already 
going to be surprised.

Its bad enough you can't have a private member within a module!

Initializing variables in the parameter section of the function 
would be a step too far.

More information about the Digitalmars-d mailing list