On 02-May-15, Bram Moolenaar wrote:
>
> Olaf Dabrunz wrote:
>
> > This is an idea to play with.
> >
> > This variant of the extend() patch implements a fourth, optional
> > parameter to extend(). With the parameter the error handling method can
> > be selected: "stop" on error (keep partial changes), "cont"inue after
> > error or "rollback" changes and return on error.
> >
> > Documentation is included, and the existing tests have slightly been
> > updated to test the error handling. But tests are not complete.
> >
> > Even extend(list, list2, where, error_action) works: error_action is
> > ignored, as list extension does not encounter errors (except for "out of
> > memory").
> >
> > Out of memory error handling is unchanged: for dictionaries, the
> > extension always continues, and list extension always stops on the first
> > error.
> >
> > For this reason, "rollback" is really the wrong name for that error
> > handling mode, as it never needs to roll back changes: all error checks
> > are completed before any changes are made.
> >
> > But "rollback" implements all-or-nothing behavior (except when
> > encountering OOM), and it was the best name I could come up with to
> > convey that idea.
> >
> > Please comment.
>
> Well, it's what anyone could ask for. But I suspect it won't be used
> much, while it adds quite a few lines of code.
I think so too.
> I don't recall people actually complaining about extend() not doing the
> right thing. We have only been discussing making it work as documented.
> I think this change adds too much flexibility.
I probably should not have written this patch. It was a toy idea, not a
good one.
Please see my reply to your other mail for a serious suggestion.
FWIW, other ideas I played with and threw away:
- Use exit-on-error mode unless in a :try block, which switches to
all-or-nothing mode. A :try! block would still use exit-on-error
mode. (Implementation exists.)
- Use a new vim variable to select the error mode.
But these approaches would still make the user think about the error
handling too much.
The other mail has a suggestion that IMHO does the right thing™ without
involving the user.
--
Olaf Dabrunz (oda <at> fctrace.org)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.