Suggestion: Change precedence of 'new'

Georg Wrede georg at nospam.org
Thu Apr 10 08:51:54 PDT 2008


bearophile wrote:
> 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?

New vanishes in the foliage.

I think it is important that new is easy to spot when reading code.



More information about the Digitalmars-d mailing list