Micha Nelissen wrote:
Marco van de Voort wrote:
Changing type to something which is not a descendant (and thus
incompatible) seems useless and always dangerous to me, so should be
forbidden if possible.
I also considered it that way. But maybe the "absolute" keyword is then a
bit badly chosen, since it implies memory overlaying, no questions asked.

Yes, agree, but the way of use is so similar. Maybe the other usages
should get this checking as well ;-).

Maybe 'override' instead, but that one is so closely tied to functions,
and implies something 'virtual' as well.

Another suggestion: 'specialize'.

Regardless of the syntaxis, I'd like to have this feature very much as well. In 
my major FPC project it could save a lot of typecasts.

To be more specific: I have two similar class hierarchies, where each class in 
the second has a field refer to its 'conjugate' class in the first hierarchy. 
Like

type
 TA = class end;
 TB = class(TA) end;

 TAConjugate = class Conjugate:TA; end;
 TBConjugate = class(TAConjugate) end;

I'd like to be able to write instead one of

 TBConjugate = class(TAConjugate) Conjugate:TB; end;
 TBConjugate = class(TAConjugate) Conjugate:TB; override; end;
 TBConjugate = class(TAConjugate) Conjugate:TB; specialize; end;
 ... (other syntaxis) ...

One small request: if time and resources are conflicting, please finish generic 
support before going into this ;) Generics are needed much harder (for type 
safety/reducing type casts).

Regards,

Bram

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to