Description
This article is from the FAQ, by with numerous contributions by
others.
L10) What is the difference between a virtual binding, a further binding and a final binding (i.e. between :<, ::<, and ::)?
To illustrate the difference between new and further-bindings, consider
p: (# v:< (# do ...; inner #) #);
q: p(# v::< (# do ... #) #);
r: p(# v:< (# do ... #) #);
in which a pattern p with a virtual attribute v, and two subpatterns, q and
r, are declared. Pattern q further-binds p's virtual attribute, while
pattern r declares a new virtual attribute v which has no connection to p's
v, except that it happens to have the same name. [This may or may not be
what the programmer intended, so perhaps a warning should be issued in this
case.]
Thus, if rp is a pointer of type p, and rp happens to denote a q object,
then calling rp.v will cause q's v part to be executed in addition to p's
(because v has been further-bound in q). However, if rp denotes an r object,
then calling rp.v will cause only p's v part to be executed, not r's
(because p's v attribute has not been further-bound). [Of course, if rr
denotes a pointer of type r, then rr.v will cause r's v part to be
executed.]
A final binding has the same effect as a further-binding, except that it
specifies that the virtual may not be further-bound from this point on.
There are (at least) three different reasons why you might want to use final
bindings:
* Modelling: Final-bindings are often considered to be a nice feature
from a purely object-oriented modelling perspective since it indicates
that the model is no longer extensible with respect to this attribute.
* Efficiency: The compiler is able to generate tighter code when it is
known that a pattern is not virtual (any longer).
* Inheritance: It is not allowed to inherit from a virtual pattern; but
it is ok to inherit from a final-bound one.
 
Continue to: