[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AST serialization



Etienne M. Gagnon writes:
> > Haven't thought much about this, but you might want to consider
> > implementing Comparable and Cloneable as well, if not already.
> 
> I see some problems here:
> 
> (1) Comparable:  This one requires ordering of compared objects. How do
> you "order" different AST nodes?  If you want to use, let say, the depth
> first ordering, then comparing two nodes might get complicated, and O(N)
> in the worst case, where N is the size of the AST.  Ugh!
> 
> (2) Cloneable:  Because a SableCC AST node cannot have to distinct
> parents, this would mean that you want a "deep" cloning.  This is not
> supported by the Comparable interface, which goal is to declare that
> "shallow copying" is safe.  The alternative is to override clone(), but
> is this really a needed feature?  Might be!?

I think those are valid points.. it's not worth doing unless
there is a 'natural' meaning for it... so nevermind that idea :-)

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com