Is there a syntax to invoke an operator and obtain its value? My intended use of this is quick and dirty syntax testing while actually writing Rel code. The example I have is:
If
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;
is defined, I would like to write something like (in DBrowser):
greater_than(unbounded_integer("1"),unbounded_integer("1")) and get back the value of the operater, type boolean, (in this example) false.
If I understand what you want, type the following into DBrowser, making sure there's no ending semicolon (which makes it clear it's an expression to be evaluated rather than a statement to be executed), and press F5.
It's doing exactly what I would expect, though I should probably change Rel to treat it as an ordinary error rather than a fatal error.
The problem is that when you try to select unbounded_integer("unbounded"), the constraint tries to perform CAST_AS_INTEGER(VALUE) with VALUE = "unbounded". CAST_AS_INTEGER("unbounded") fails with a fatal error. You probably want to use something like IS_DIGITS() from OperatorsChar.d to avoid invoking CAST_AS_INTEGER when VALUE isn't a numeric string.
Thank you for your suggestion. Also in the interval between asking the question and receiving your reply, I thin I can attack this in an alternative way - define unbounded_integer etc as a union data type.