shorter alternative of constructor with parameter

Kapps via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 22 12:58:36 PDT 2014


On Sunday, 22 June 2014 at 11:50:31 UTC, Shammah Chancellor wrote:
> I can't support this proposal.   Adds more syntax to a language 
> that is already becoming cramped.  I also don't see the purpose 
> of having simple constructors like this?  Are you going to add 
> (n choose k) simple constructors to a class?   I could get 
> behind field initializer syntax ala C# "with" modeling the 
> syntax we have for structures.
>
> new Person() {name: "Bob"};
>
> -Shammah

In theory, 'with' could be used for that if it returned the 
expression passed in:
auto a = with(new Person()) {
     Name = "Bob";
     Age = 27;
}


More information about the Digitalmars-d mailing list