Adriaan van Os wrote:
The variable-records discussion on this list has revealed the difficulties of checks on variable records. As a sidebar, I recall that Niklaus Wirth has replaced variant records later (in Oberon) with the much more powerful notion of type extensions. Type extensions can easily be checked, both compile-time and run-time.
True. In fact they're very similar to BP's object (which GPC supports) if you don't use any methods (and write `object' instead of `record', of course). Even the type test (`is') is the same in GPC. Only the syntax for the type guard is different:
t' := t(T') (p' := p(P'))
GPC: t' := t as T'
Supporting `t(T')' would conflict with BP style type-casts which are explicitly "unguarded".
The rule of assignment compatibility states that values of an extended type are assignable to variables of their base types.
GPC doesn't allow this yet, but I'll fix it when I get to it. Though I haven't found much practical use of this feature ...
The class facility stipulates that all procedures applicable to objects of the class be defined together with the data definition. This dogma stems from the notion of abstract data type, but it is a serious obstacle in the development of large systems, [...]
Well, in BP's OOP model, this "dogma" is not so absolute and in fact not enforced at all.
So I think one can use objects as extensible records. Maybe it is possible (already now) to rewrite all applications of variant records by them.
Of course, we can't drop variant records, and sooner or later we'll probably add the runtime checks. But those who want the checks now (and even better, compile-time checks) might want to try it, indeed.
Frank