Am 27.07.2016 21:04 schrieb "Maciej Izak" <hnb.c...@gmail.com>: > > > 2016-07-27 15:33 GMT+02:00 Jonas Maebe <jonas.ma...@elis.ugent.be>: >> >> It would seem better to me that you do have to add something after your proxy object (specify a field, call a method, use proxyobject[x], ...) to get the proxied value. Just like with a class, where "instance" by itself can never refer to the default property (it's always "instance[x]"). > > > In that case SmartPtr/SmartObj/Nullable type has no sense for me. The basic purpose is excluded. You can do that today by using for example proxyobject._.foo(); > > To get rid of @@/@@@ we can use typecast + new type kind. With "proxy" type, Sven proposition has more sense: > > === code begin === > {$MODE DELPHI} > > type > TRawSomeSmart<T> = record > private > Instance: T; > ... // normal record > end; > > TSomeSmart<T> = proxy to TRawSomeSmart<T>.Instance; > > var > ptr: pointer; > // PTypeInfo(TypeInfo(ni)).Kind = tkProxy > ni: TSomeSmart<Integer>; > np: TSomeSmart<TProcedure>; > begin > ptr := @ni; // pointer to ni.Instance > ptr := @TSomeSmart<Integer>(ni); // pointer to ni > > ptr := @@np; // pointer to np.Instance > ptr := @np // pointer to procedure > ptr := @TSomeSmart<TProcedure>(np); // pointer to np > end; > === code end ===
Hmm, not that bad either. At least then it would be absolutely clear that TSomeSmart is something special and not an ordinary record. Regards, Sven
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel