[gclist] Unreal

Fergus Henderson fjh@cs.mu.OZ.AU
Tue, 20 Jul 1999 14:22:56 +1000


On 17-Jul-1999, Nigel Bree <nbree@kcbbs.gen.nz> wrote:
> But if the compiler can _check_ for this property (and without the ability to
> check the truth of the programmer's assertion, they can get it wrong) then
> the compiler can just as easily _infer_ it.

This is not quite true, for two reasons.  One is that checking can be
local, whereas inference in general needs to be global.  The other is
that checking can be done in a single pass, whereas inference generally
requires a fixpoint calculation.

> The value of the keyword is thus
> either in a) documentation, or b) to deal with limitations of your separate
> compilation model.

(b) could alternatively be phrased as "to avoid limitations of your
global analysis model" ;-).

And there's also (c) error-checking.  As Tim Sweeney wrote,

 | The other thing I like about this "visitor" limitor is that it helps  
 | programmers avoid making stupid memory management mistakes, keeping objects
 | referenced that shouldn't be.

If the designer of a base class interface declares a method argument
with the "visitor" keyword, then they intend that the method not
save away any references to its argument.  If some derived class
has a definition of that method that does try to save a reference to
its argument, then this may cause a bug, or a performance problem,
and so the programmer probably wants to be notified about this.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3        |     -- the last words of T. S. Garp.