possreps for system-defined types
Posted: Thu Mar 10, 2016 5:29 pm
I very much like Rel's support for selector invocations denoting values of system-defined types. For example INTEGER(-1) and BOOLEAN(TRUE) are equivalent to the literals -1 and TRUE, respectively. I also like the fact that such invocations can be nested, as in INTEGER(INTEGER(-1)) and so on, ad infinitum.
But the signature INTEGER(INTEGER) for an operator that has all the required properties of a selector, strongly suggests the existence of a possrep giving rise to that operator. That possrep would be named INTEGER, of course, and would have a single component. What might be the name of that component? Well, INTEGER seems the obvious choice, suggesting the following notional type definition:
TYPE INTEGER POSSREP INTEGER ( INTEGER INTEGER ) ;
which implies the existence of operator defined like this:
THE_INTEGER(INTEGER INTEGER) RETURNS INTEGER; RETURN INTEGER; END OPERATOR;
Of course the type definition and operator definition don't have to keep on repeating the name INTEGER in the way I've suggested, and in any case I'm not suggesting these imaginary definitions should appear anywhere. But I would like to be able to write THE_INTEGER(INTEGER(-1)), for example, and also, more importantly, to define a subtype of INTEGER such as this:
TYPE POSINT IS { INTEGER POSSREP POSINT ( INTEGER = THE_INTEGER(INTEGER) CONSTRAINT INTEGER > 0 } ;
That's because Tutorial D requires a nonempty <derived possrep def list> in subtype definitions (perhaps unfortunately).
Hugh
But the signature INTEGER(INTEGER) for an operator that has all the required properties of a selector, strongly suggests the existence of a possrep giving rise to that operator. That possrep would be named INTEGER, of course, and would have a single component. What might be the name of that component? Well, INTEGER seems the obvious choice, suggesting the following notional type definition:
TYPE INTEGER POSSREP INTEGER ( INTEGER INTEGER ) ;
which implies the existence of operator defined like this:
THE_INTEGER(INTEGER INTEGER) RETURNS INTEGER; RETURN INTEGER; END OPERATOR;
Of course the type definition and operator definition don't have to keep on repeating the name INTEGER in the way I've suggested, and in any case I'm not suggesting these imaginary definitions should appear anywhere. But I would like to be able to write THE_INTEGER(INTEGER(-1)), for example, and also, more importantly, to define a subtype of INTEGER such as this:
TYPE POSINT IS { INTEGER POSSREP POSINT ( INTEGER = THE_INTEGER(INTEGER) CONSTRAINT INTEGER > 0 } ;
That's because Tutorial D requires a nonempty <derived possrep def list> in subtype definitions (perhaps unfortunately).
Hugh