. the object notation: "( object`operation )
is saying that the given object is modifying itself;
whereas, if no modification was expected,
the preferred syntax would be "( operation(object) ).
6.12: review of terminology:
"surtype" is the system's typeclass
(pointer, valuetype, subprogram, aggregate, ...);
because, a surtype can classify
every object found in a programming environment .
. a polymorphic typeclass like number.type
is an example of a "polymorphtype" .
. the numeric types (real, integer, fractions, complex, symbolic)
are all the "morphtypes" of number;
"morphsubtypes" are constrained subtypes of morphtypes;
"infratypes" are implementations of a morphtype,
eg, the machine type Z32 (32-bit integer)
may implement a subrange of morphtype Z .
. "multi-object dispatch" is defined as
an operation with 2 or more operandsall of which will have the same polymorphtype
but may have a variety of morphtypes;
eg, the operation number+number
may include an instance of ( real + integer )
since reals and integers are morphtypes of number.type;
eg, z`= x+y where x, y and z can be
any morphtype of number.type .
. the multi-object modification looks like this:
(x,y)`exchange; -- in that example,
an exchange of 2 objects assigns each
the value of the other .
[6.12: in most other oop languages,
your exchange operation would look like
"( X`exchange(Y) ) or
"( X.exchange(Y) );
but in adda we make it clear with this syntax:
(V,W)`operation(A,B),
that V and W are references to modifiables (variables)
whereas A and B are only copies,
or references to read-only objects .
. that way it's easy for the reader to see
where the program is functional;
ie, not modifying its operands .]
. like multi-object dispatch
a speedy look-up for mult-object modifications
depends upon all operands sharing the same polymorphtype;
(and that is the case oop is most concerned with,
as subprogram overloading is a comparative luxury); [6.12:
a 3rd case is Any.type, a surtype with 3 fields:
the object, its morphtype, and its polymorphtype .
. so, in the case of (string, integer)`exchange,
we need to know both types are Any,
and that their polymorphtypes both define assignment;
then when the swap occurs, it also swaps their type-tags .]
No comments:
Post a Comment