List of Import References :
See Reflection
SIGNATURE ReflectionBuild [alpha] /$ DYNAMIC [alpha] $/ SORT alpha IMPORT Reflection ONLY value : SORT
Calling reflect
for a value will produce a reflection of that
value. The type of the value must be a single sort. For example, you
can reflect a value of type nat
. You can also reflect a value
of type seq[nat]
. However, you can not reflect a value of type
nat -> nat
which is a function type and no sort type. Likewise,
you cannot reflect a value of type nat ** nat
using
reflect
, as this, too, is no sort type but a product
type.
If you wish to reflect a value which has or contains a parametrized
type, you must declare the whole structure as dynamic (this is done by
adding the special pragma /$ DYNAMIC $/
to the signature right
after the structure parameters). For example, if your structure has a
parameter alpha
and somewhere you construct a list l
of
alpha
, then calling reflect (l)
requires you to declare
the structure as dynamic.
Calling reflect without a parameter will produce a reflection of the
sort with which you instantiate the structure. For example,
reflect[nat]
will produce a reflection of the type nat
.
FUN reflect : alpha -> value
The type reflection
is simply our way of describing the type
exists alpha. alpha
. Now, given an object of type
reflection
(and hence exists alpha. alpha
) you might
wish to instantiate this object with the correct type stored behind
the quantor. This is done by calling reflects?
for the
reflection. Note, that reflects?
takes only one argument (the
reflection). The type "argument" is given by the sort alpha
with which you instantiated the structure ReflectionBuild
(and
hence the type of the return value -- which is fortunately exactly
what we need). If the instantiation fails (because the type was not
correct) fail
is returned.
FUN reflects? : value -> bool
An example usage is given in PrettyPrint.
FUN content : value -> alpha
next node: MethodCompose,
prev node: ReflectionRepository,
up to node: User Subsystem : Reflections