- From: Michael Allen <Michael.R.Allen@Eng.Sun.COM>
- Date: Tue, 21 Jul 1998 17:58:21 -0700 (PDT)
- To: www-dom@w3.org
> > To avoid type checking what kind of NodeVisitor a Node has received, > > you might make NodeVisitor an abstract base class with an Enumerated type > > field which contains an int (or bitfield, maybe) which specifies its type. > > That way, subclasses which the base NodeVisitor doesn't cover could check > > the type of visitors without doing an instanceof test. > > I think it would be better to extend NodeVisitor at the same time as you > specialize Node (which, by the way, I notice that the HTML application > doesn't do -- that's a problem): > > interface HTMLNode: Node { > readonly attribute HTMLNode parentHTMLNode; > ... > > void visit(in HTMLVisitor v) > } Ahhhh, yes! Very nice, by parameterizing the same method name, you let the runtime type checking system take care of calling the right one for you! Brilliant! And HTMLNode can do something vaguely appropriate when it gets a plain old NodeVisitor as well. > > > Throwing my hat in the ring, > > Nice hat. Sometimes the ol' thinking cap pulls through. Michael Allen
Received on Tuesday, 21 July 1998 20:58:02 UTC