On 22/10/08 16:25, James Vega wrote:
> On Wed, Oct 22, 2008 at 03:54:23PM +0200, Nikolai Weibull wrote:
>> On Wed, Oct 22, 2008 at 15:16, Tony Mechelynck
>> <[EMAIL PROTECTED]>  wrote:
>>
>>> On 22/10/08 13:57, Nikolai Weibull wrote:
>>>> [...] I really dislike this tendency
>>>> computers have to not adhering to the mantra "do as I mean, not as I
>>>> say".[...]
>>> Sorry, but in the programming world I don't follow your "don't do as I
>>> say, do as I mean" mantra. With me it's "do as I say, and if I talk
>>> nonsense (if I'm using invalid syntax), tell me so".
>> You miss the point entirely.  If I say remove(list, 8, -1) I expect it
>> to give me a list of the first 8 elements in list.
>
> This is odd since, as pointed out earlier, Bram modelled the List usage
> after Python.  remove(list, 8, -1) looks like simple slicing, which
> would be done as list[:8] in Python and works just fine in Python if the
> list doesn't actually have 8+ items.
>

It has everything to do with syntax. The documented syntax (at ":help 
remove()") says if {end} is before {idx} it's an error. The definition 
of a List (see ":help expr-[]") says that element [-1] is the last one 
and that the first element is element [0], therefore I expect 
remove(List,8,-1) to return:

- from the ninth to the last element (inclusive) if there are 9 or more. 
The items returned are removed from the original List.
- an exception otherwise.

Anything else (such as, if there are less than 9 elements, doing 
nothing, or returning just the last element, or maybe everything) is 
what I call a bug. Whether it is a program bug or a documentation bug 
remains to be decided.


As documented under ":help expr-[:]", List[:8] works in Vim if the 
indices are in range (otherwise it throws an exception). The result is a 
list with the first 9 items removed, if there are at least that many. 
The original List is unchanged. The remove() function, on the contrary, 
modifies the original List as a side-effect (when it doesn't throw an 
exception). Just like above, if what the program does ("actual 
behaviour") is not what the help says it does ("expected behaviour") 
than it's either a program bug or a documentation bug.


Best regards,
Tony.
-- 
Angels we have heard on High
Tell us to go out and Buy.
                -- Tom Lehrer

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui