Suggestion: shortcut for 'new X'

"Rémy J. A. Mouëza" ray.jay.ay.moueza at do.not.spam.gmail.com
Fri Aug 25 01:38:18 PDT 2006


>> Kristian wrote:
>> Consider the following:
>>
>> Obj func2() {...}
>>
>> void func() {
>>      auto obj = func2();
>> }

For such cases, there is the typeof() operator :

Obj func2 () { ... }

void func ()
{	typeof ( func2 ) obj = func2 ();
}

And one knows exactly that obj's type is the same as func2 return type, 
and there is no mistake possible with an auto type, althought it becomes
redundant.
It does not matter that much in a dynamically typed language :

def func2 (): return Something ()

def func ():
     obj = func2 ()

It seems that there will always be some redundancy in a typed language à 
la C, nonetheless D has made great improvement.



More information about the Digitalmars-d mailing list