-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
On August 18, 2014 5:16:44 PM GMT+03:00, Bram Moolenaar <[email protected]>
wrote:
>
>ZyX wrote:
>
>> On Sunday, August 17, 2014 9:28:25 PM UTC+4, ZyX wrote:
>> > And fourth: behave like map: do its job until lock occurs and fail
>at the first lock.
>> > * The above code was for :unlet, for :let slice assignment there
>should be something similar (except that option 3. will no longer be
>consistent with anything).
>>
>> Full patch for fourth approach (with tests):
>
>Thanks for providing so many alternatives. In my opinion what most
>people expect is that it either works, removes all items, or fails,
>does
>not remove any items.
>
>Running map is different, since it's clear the function is called for
>one item at a time. While removing is expected to do the whole slice
>at
>once.
I would not say so for map(). In most languages it creates a new list, so it is
expected to exhibit "do everything or fail having done nothing" behavior. If it
is to be thought about as a :for cycle replacement then it is expected to
exhibit "do everything what can be done (unless in :try)". There are also
languages where map() returns an iterator in which case (depending on code) it
may be even "do everything what can be done" (though with iterator you normally
may have any behavior you want, but usual uses exhibit same "stop at first
error" as Vim... if "usual use" is foreach cycle: other usual use is creating a
list in which case it is the first variant). In any case I would not expect it
to stop at first error, still having done something: either do not stop or do
not do.
Of course this only applies to pure (without side effects) expressions in map()
second argument.
And Vim constantly exhibits this behavior: does what it can until error occurs,
sometimes even after error occurs. E.g. consider
let var = (system('some-cmd-with-side-effect')
: command will be run, but due to missing parenthesis var will not be assigned
anything. Since VimL is the only language I use that does not have a parsing
stage this behavior is highly unexpected: all other languages will at least not
execute anything here, not to mention the vast majority that will not execute
any code in the same file at all. So fourth variant may be not expected, but it
definitely is consistent, not only with map(). After working with VimL a few
years this will even be expected.
>
>I understand that the second solution is more work to implement, but
>user expectation is more important.
It is rather trivial as well: "more work" is only by comparison. Most of work
(finding a place to fix for :let slice assignment) was done anyway.
>
>Can you make a test for the second solution? The test for the fourth
>solution should already be close.
-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1
iQI1BAEBCgAfBQJT8hh6GBxaeVggPHp5eC52aW1AZ21haWwuY29tPgAKCRCf3UKj
HhHSvjY6EACH47yFwYOcDU/2+DFYajs+DekQgf5DC6RL+wt2PoFHGW73qfYDF2Aa
Ic/T7arGrJvrLneD1zfnZKJQS4w5WlWg2JG8eU6NUvqKfKH5/dtAAnXRRDcQ3oZY
RVkmxEh+MtgLv33xjzgLIO698WpG926SxpjNBWt9OxwDM/g4wZni+dZ8ORFsN8EK
HflXCSP8jDtu5TiWKqb+n4s2aY2p6fWHINpv9jEnHYEZNUDeG6IaDS7AjNI+/KBT
ctwW0hpSt6BUgaZXoegufWeGFFWV3IkEv6jKuDw3kgaYOrwqxeL1iZB+O/aUnbOn
yHYte2FXTBWCSUlpfQZDrOVGHY7XXxzZFA3XNEGlyH/n6m7aJzevIDXVhQ/deXyR
gApuhmL2od0XD2i0x6I2BRhyDT2mglUmB8TbCC6O8AzTbbgwKgCxa/8zKyq3BE2A
e7bQz5DjOtfgvLYEI+UpZaBD1JbK+LzrjHIfpFkRSiMYC+3ZWohss6d+Czw9h3Qv
plQLikpWfYvphoJfBOVBIFwOdjFfY2ryO/8Y/VlxOUwXFNQCoXFoEgwaPXQsfDxq
K2VOi7Rsc5yrF2GUuGpNtdLEwXzUDjmW6ZlSM2d4YJ+t7Ym+K4ihcUooR83eQfDS
FaJ7mRnCaSckNRFx7yqjhc41O+l7iz1bFNxNKw/PF0Q6QuCi7/iA5A==
=bMl9
-----END PGP SIGNATURE-----
--
--
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.