Oil Reference Manual
The following is a complete OIL specification
which we will analyze more completely later (see Relating an OIL specification to library function calls.)
But we will briefly review it here to give an intuitive feel for
both the syntax and the semantics of the language.
In our example below is a specification
of Pascal's overloaded operator (`+'.)
It can be identified with either integer addition (iAdd),
real addition (rAdd) or set union (sUnion.)
And we define a coercion operator (Float) to allow integer values
to be used where real values may appear.
OPER iAdd( int_t, int_t ): int_t; /* the usual '+' operators for Pascal
*/
OPER rAdd( real_t, real_t ): real_t;
OPER sUnion( set_t, set_t ): set_t;
INDICATION Plus: iAdd, rAdd, sUnion; /* will be identified together */
COERCION Float( int_t ): real_t; /* usual Pascal coercion from int to real
*/
An OIL specification defines the identifiers for use in calls to the library
functions. The above specification defines these identifiers:
-
int_t , real_t , set_t to be type denotations.
-
iAdd , rAdd , sUnion
to be typed binary operator denotations with the expected functional signatures.
-
Plus to be an operator indication which may be identified with
iAdd , rAdd and sUnion .
-
Float is defined to be a coercion from int_t to real_t .
For a more in-depth examination of this specification see A simple example.
|