Expression evaluation
Posted: Fri Oct 04, 2013 6:16 pm
I am puzzled by the action of the type system in some respects and am seeking clarification. If you think this query would be better directed to Hugh Darwen, I will submit it on the TTM list.
I have defined two types, one inheriting from the other, and one operator on the parent type as follows:
Definition of these types automatically generates the operator:
There is no comparable operator generated for the child type.
if the following is entered at the command line of DBrowser,
then the response is:
This makes no sense at all to me - while the expression has been defined in terms of the parent type, and the values concerned do meet the constraints of the child type, why should an operator on a parent type return the child type?
I have defined two types, one inheriting from the other, and one operator on the parent type as follows:
Code: Select all
TYPE unbounded_integer
POSSREP {VALUE CHAR CONSTRAINT
(CAST_AS_INTEGER(VALUE) > 0) OR
(CAST_AS_INTEGER(VALUE) <= 0) OR
VALUE = "unbounded"};
Code: Select all
TYPE non_negative_ub_integer IS {
unbounded_integer CONSTRAINT
(CAST_AS_INTEGER(THE_VALUE(unbounded_integer)) >= 0) OR
THE_VALUE(unbounded_integer) = "unbounded"
POSSREP{X = THE_VALUE(unbounded_integer)}};
Code: Select all
unbounded_integer(CHARACTER) RETURNS unbounded_integer
Code: Select all
OPERATOR greater_than(P unbounded_integer, Q unbounded_integer) RETURNS BOOLEAN;
CASE;
WHEN Q = unbounded_integer("unbounded") THEN return FALSE;
WHEN P = unbounded_integer("unbounded") AND Q <> unbounded_integer("unbounded")
THEN return TRUE;
ELSE return
(CAST_AS_INTEGER(THE_VALUE(P)) > CAST_AS_INTEGER(THE_VALUE(Q)));
END CASE;
END OPERATOR;
Code: Select all
greater_than(unbounded_integer("1"),unbounded_integer("1"))
Code: Select all
non_negative_ub_integer("1")