Re: DOM L2 comments, various

Arnaud Le Hors wrote:
> 
> John Cowan wrote:
> >
> > Au contraire.  I believe that using instanceof for type discrimination
> > (as in, if (x instanceof Element) do_this else if (x instanceof Attr) do_that)
> > is the worst kind of bogus OOP.  My implementation makes zero
> > guarantees about underlying classes, how many or with what crossovers.
> 
> Well, I disagree, but it's ok.

I also disagree, but that's irrelevant because there are other kinds of
"non-bogus" OOP that do type descrimination without instanceof that
would also break.  Namely, I'm thinking of the technique "double
dispatch" most commonly used by the Visitor design pattern.  Of course,
since using the Visitor pattern requires that you write your own
implementation, it's kind of moot.

Speaking of which, can anyone address whether Visitor was considered for
inclusion in the DOM 2 as another Traversal mechanism, and if it was
considered, why it has been omitted?  I posted a more comprehensive
question in August that was never replied to:

http://lists.w3.org/Archives/Public/www-dom/1999JulSep/0033.html

Of course, I suppose I can answer my own question: that loosely typed
languages like ECMASCript can't perform double dispatch.  Any other
reasons for omission?

Tim


> 
> > BTW, I don't see how you can implement all HTML*Element interfaces with
> > one class in Java, since some of the instance methods have incompatible
> > return types, and Java doesn't allow overloading on the return type.
> > I needed IIRC six classes.
> 
> Same here, that's why I said "_Basically_ all the HTML*Element
> interfaces were implemented on the same class." ;-)
> --
> Arnaud

Received on Friday, 8 October 1999 04:02:46 UTC