On Tue, 24 Jun 2003, Andre Poenitz wrote:

> In the full-rebreak-everytime approach there is only one operation
> modifying the row list: its creation. I wonder whether we could get
> something cheaper than the stable iterators. Simple integer offset from
> begin or similar...

How you implement the stable iterator is up to you. An integer offset
might certainly be the simplest way.

> Another (and certainly robust) option would be a 'marker': Put a special
> marker (inset?) at cursor position on begin of rebreak, drop the row cache,
> start rebreaking line by line, re-set the cursor once the marker is hit.

This might also work, although my gut feeling is that this is more work,
and less general: You have a problem with sequencing: Suddenly, two
iterators can not point to the same position.

> I am a bit wary of highly interconnected data structure although I see that
> in case of stable iterators there might be a possibility to encapsulate the
> dependencies nicely... OTOH, stable iterators might indeed be much
> cheaper than I think and more flexible in the long run.

The key is that the dependency is between the list and the iterator only.
There is no new dependency between users of the list or users of the
iterators. Therefore, I think it is nice and flexible.

> Since we are at it: Assume we had stable iterators the way you've proposed.
> How does one copy these things? Wouldn't that mean that the copy has to
> register itself with the list? I.e. we'd need a copy constructor with side
> effects?

Yes, when you copy an iterator, you have to add the copy to the list
of iterators as well. There is nothing wrong with having side effects
like this in a copy constructor.

> If your point is working _enough_ I fully agree. But I don't see a point in
> requiring 'zero tolerance' concerning regressions as long as the list of
> regression is small (like 'only cosmetical issues in rare circumstances'
> etc). Of course, finding consensus on where to draw the line is not
> simple...

My point is exactly working _enough_. That's what I call it keeping
afloat. The metaphor is this: Today, we are stuck in one island. We can
see another, nicer island in the distance. We have a boat to go there, but
this boat is not perfect: It has holes. It is very far to sail to the nice
island, but it is just close enough to be reachable if we go the
optimal way. On the other hand, if we zig-zag, we will either run out of
energy, or the boat will sink. In those case, we will eventually drown.

Now, the problem is that we have to turn the back to the target each
time we row the boat, and we don't know how the current will affect us. We
take a deep breath, turn our back to the island, row the boat, turn again
and hope that we got closer.

So, now it's clear that with many small steps, we will not zig-zag too
much. However, small steps are not fast - we might drown before we reach
the goal. On the other hand, big steps are good, because they can be more
economical: If done correctly, we will reach the island faster. However,
big steps can also make the holes in the boat bigger, so that we will be
drowning faster. Also, with big steps, we might have moved in the wrong
direction, and thus miss the target.

So, you have to sail the boat safely from one island to the next.
If you boat is safe, you have a steady supply of energy, and the current
is mild, you can take many small steps and go there slowly over time.
However, if you have a boat with holes in it, or the current is strong,
you have to go fast, but not faster than you still hit the target.

It's ok to leave some holes in the boat as long as you can still see where
you are going and that you know that you will reach the shore before you
drown. When you are safely on the shore, you have the time to fix the
holes so that you are ready to go to the next island. (Unless you broke
the boat so much that you only reached the shore by swimming.)

Regards,

Asger

Reply via email to