On Sun, 1 Oct 2006, Micha Nelissen wrote:
> Michael Van Canneyt wrote: > >> is to be written in a certain format, so you tell the compiler that it > >> is like that. Why is this a hack ? > > > > Because you do a typecast just as if you would override a property using a > > read specifier and do the typecast there. Just the typecast is disguised > > as an 'absolute'... > > In this case I'm doing a typecast because the compiler is too 'stupid', > so the motivation for the typecast is different than in the general case. > > I have been thinking of another way, but it's more involved, but also > 'more correct'. The class A would specify for the 'Field: F' that it has > an overrideable type, maybe keyword 'virtual' or so. The compiler will > store the type in the RTTI of the class. Then, B can override the type, > and the compiler will rewrite the needed type (G) into the RTTI. Then at > runtime, whenever an assignment to A.Field is done, the compiler will > generate code that retrieves from the RTTI the 'needed' type, and will > check the type of the rightside expression to that needed type, like > 'as' operator does. I'm more in favour of this approach, actually. But I would do it at the property level, not at the field level. And only for classes. Michael. _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel