Menu

Broken lineage

Developers
a2z
2004-03-10
2004-03-11
  • a2z

    a2z - 2004-03-10

    Putting aside all my objections to TObjectList for now ;-), here are a few suggestions:

    TSourceTokenList derives from TObjectList. Good.
    TSourceToken derives from TParseTreeNode. Fine.

    TParseTreeNode derives from TObject. Objection.

    If you derived TParseTreeNode from TObjectList, then you could have a better lineage; suct that:

    TParseTreeNode = Class(TObjectList)
    TSourceToken = Class(TParseTreeNode)
    TSourceTokenList = Class(TSourceToken)

    Actually, if only you named the property TParseTreeNode.ChildNodes[] something more conventional, such as TParseTreeNode.Items[], you would not need TSourceTokenList at all.
    TSourceToken and TSourceTokenList would be one simple class.

    Any reason not to?

     
    • Anthony Steele

      Anthony Steele - 2004-03-10

      That would compile, maybe even run a bit faster, but fails the semantic test. It is not true that a Source Token is a kind of list. An interior parse tree node *has* child nodes; but a leaf, a source token, doesn't.

       
      • a2z

        a2z - 2004-03-11

        What /semantic/ test? Which hat did that came out of :-)

        TSourceToken is a special case of TSourceTokenList when it does not have any child nodes. Is that not?

        So, instead of thinking TSourceToken as something distinct, think of it in that context and you'll see what I mean.

        IOW, if it will make you feel more comfortable, look at it like this:

        TParseTreeNode = Class(TObjectList)
        TSourceTokenList = Class(TParseTreeNode)
        TSourceToken = Class(TSourceToken)

        and then fold TSourceTokenList and TSourceToken into one single class --and call it TSourceTreeNode if you like.

        BTW, this is the same thing I said in the earlier thread except the wording.

         
        • a2z

          a2z - 2004-03-11

          TParseTreeNode = Class(TObjectList)
          TSourceTokenList = Class(TParseTreeNode)
          TSourceToken = Class(TSourceTokenList)

          TSourceToken + TSourceTokenList --> TSourceTreeNode

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.