Suggestion: shortcut for 'new X'

Kristian kjkilpi at gmail.com
Thu Aug 24 08:06:30 PDT 2006


How about this:

     Obj obj1 = new Obj;
     Obj obj2 = new Obj(10);

could be reduced to:

     Obj obj1 = new;
     Obj obj2 = new(10);

This way only one class name would be required per variable. (That is, one  
at maximum: "Obj obj1 = new, obj2 = new(10);" is also valid of course.)  
Redundance would be reduced.

I know, it looked quite 'odd' for me too at first, but now it looks very  
natural, and even clearer than the longer way.


I'm not sure if using of this syntax should be possible outside the  
variable declarations. Later in a code "obj1 = new;" is less informative  
than "obj1 = new Obj;". However, someone may like it too... it's up to a  
programmer how to code (which is not always a good thing(tm) though).



More information about the Digitalmars-d mailing list