Suggestion: Change precedence of 'new'

bearophile bearophileHUGS at lycos.com
Thu Apr 10 03:23:07 PDT 2008


Bill Baxter Wrote:
> Sometimes it's handy to invoke a function on a class right after 
> creating it:
>      new Thread(&func).run();

The syntax of the new operator can be improved.
Here Python syntax can't be used (in Python the () operator of the *class* object creates the object instance. In Python classes are objects of a metaclass).
Ruby uses a syntax similar to this, and I think it may be fit for D too, solving your problem (that I share with you):

Thread(&func).new.run();

Do you see problems with this syntax?

Bye,
bearophile



More information about the Digitalmars-d mailing list