Type Conversions
What conversions are
Given an object of a particular type and and encoding, a conversion
will produce another object of a different type or encoding,
corresponding in some way to the original object.
Conversions are similar to methods, except that they are defined for a
type and encoding, whereas methods are simply defined for types.
Conversions also do not take any additional arguments; methods can. Like
other TOP operations, conversions do not actually mutate objects, but
produce new ones.
How conversions are defined
Conversions can be registered in the type
description object for the type being converted from (the "original"
type). They do not,
however, form part of the type
definition
of that object. They are not inherited in subtypes.
The following information is part of a conversion definition:
- The name of the conversion. This should be a legal C identifier
name, and should not conflict with the names of other conversions for the
original type.
- The type and encoding names of the object being converted from.
- The type and encoding names of the object that will be the result of
the conversion. The encodings should be sufficient to render the object
as a sequence of bytes.
- An optional "top" type, used as a measure of lossiness in
conversions. The top type is a type that the original object and the
result object both conform to, and which has an interface through which
the two objects appear identical. All conversions have a top type of
"e:obj" at least, since all types are subtypes of "e:obj", and that type
has an empty interface. Conversions between two encodings of the same
type usually have that type as their "top". The "top" attribute does not
have to be explicitly noted at registry; it will be assumed to be "e:obj"
by default.
- Whether the conversion is "trivial"; that is, can be done by a simple
relabeling of type and encoding, without changing any bytes in the
representation or checking to see if the conversion is allowed. This is
a boolean attribute which does not have to be explicitly noted at
registry. The default
is false.
In addition, the description of a conversion can identify known agents that can carry out the conversion.
(Semantics as such is not in there. It probably should be. The closest
thing I have now is "top".)
Compound conversions
Trivial conversions
spok@cs.cmu.edu (Last updated 4-Jan-95)