On Mon, Dec 9, 2013 at 9:43 AM, Kevin Wortman <xxxxxx@gmail.com> wrote:

That's OK, although it makes some intuitive algorithms impossible to
implement. For example a straightforward way of computing the set
difference (A - B) destructively is

for each element x in set A:
  if x is in set B:
    delete x from A

If the "delete x from A" operation invalidates the "for each element x"
cursor then you're out of luck.

Then again, insisting that live cursors stay valid is a heavy
implementation burden that adds a lot of complexity and effectively
prohibits some data structures.

IMO the better part of valor is to try to get away with not having
cursors into mutable data structures. Almost all use cases can already
be handled by the "Mapping and folding" procedures.

I agree with getting rid of cursors, but mapping and
folding doesn't solve the problem - the loop you wrote
above could just as well been written with set-for-each
as with cursors.

We should document whether or not it's an error to
mutate a set while it is being folded over (I would say
it's an error).  The behavior for cursors, if they exist,
follows directly from this.

-- 
Alex