auto ref
Michel Fortin
michel.fortin at michelf.com
Thu Dec 17 03:44:58 PST 2009
On 2009-12-17 01:57:50 -0500, Pelle Månsson <pelle.mansson at gmail.com> said:
> On 12/17/2009 01:05 AM, Michel Fortin wrote:
>> Object? func(Object? o) {
>> writeln(o.toString());
>> return o;
>> }
>>
>> MyObject o = func(new MyObject);
>>
>> Here, "Object?" means Object or a derived type.
>>
> You know, just Object means Object or a derived type. That's what
> inheritance is.
The idea is to be able to say in the function signature that the same
type is returned, avoiding a cast that would be unnecessary otherwise.
It's the same principle as for "const?", or "inout".
But you're right that my definition isn't very good.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list