when should sends be virtual?

Urs Hoelzle urs at cs.ucsb.edu
Wed Jan 18 06:19:16 UTC 1995


Rainer Blome writes:

> did anybody ever see a treatise about where and when it should be
> specified that a message send should be virtual?  at the send site?
> or at the declaration/implementation of a method?
> ever seen one of these answered?

One problem with letting the sender decide whether a call is virtual
(dispatched) or not is that it breaks encapsulation.  The receiver
should decide what happens with a message send, and statically binding
the send (e.g. to invoke an overriden method) is like writing instance
variables directly.  In other words, you can't reason about the
object's properties and invariants anymore by simply looking at the
object's definition.

-Urs



More information about the Self-interest mailing list