Jean-Marc Lasgouttes wrote:
"Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:
I do not see why you want to find a suboptimal method which only
interest is to fit some theory of yours.
Abdelrazak> My theory is simple: use what we have access to. Scanning
Abdelrazak> all the enclosing inset in search for an information that
Abdelrazak> you could have at first hand _is_ suboptimal in terms of
Abdelrazak> CPU cycle.
You know, people do weird things with their documents, ad you should
not assume automatically that the only thing you are interested is
just the inset above.
Which was the point of the recursive parent() approach.
Kind of a solution in search for a problem.
Abdelrazak> No, if you really want to scan through all the enclosing
Abdelrazak> insets it is still possible with a recursive call to
Abdelrazak> parent(). It will be less code than the inset scanning and
Abdelrazak> more efficient too.
Are we really here arguing about a loop over at most 5 elements? Any
solution which is always right will fit the bill. Personally, I prefer
the cursor approach, and you have the right to prefer another
approach. But for the code in discussion, it is 100% equivalent.
My point is that is not equivalent. A tree-like approach will inevitably
lead to cleaner and shorter code, I am 100% sure of that. Besides, I
still have difficulty to grasp the cursor slice concept. Make a poll in
the list and you will realise that close to nobody really understand the
cursor and cursor slice related code. For example I still don't know
how to select a text between two Cursors...
The reason is obvious: the Cursor approach hides the internal memory
structure. It is complicated because it does not have a simple mental model.
IMO, the Cursor (the DocIterator really) should only be used to move the
cursor logically within the document and nothing else. And I reckon that
the code in DocIterator.C will be dramatically simplified if we had
access to the parent (because there is only one) and children in an easy
way.
The
only difference is that the recursive parent code is not implemented,
but the code to scan a cursor is already here.
Sure, three lines of code is really difficult to implement ;-)
Abdel.