Monday, May 23, 2011

Re: question about string expression evaluation / bug?

On May 23, 8:12 am, hsitz <hes...@gmail.com> wrote:
> > This is a reason why I never use `==', `!=', `>', `>=', `<', `<=' for comparing
> > strings, only `is'/`isnot' (it looks better then `==#' and `!=#') and operators
> > with either `?' or `#' at the end.
>

Zyx -- I didn't even realize 'is'/'isnot' were defined for strings.
However, it seems that they are equivalent to '==' and '!=' and not
the matchcase operators you suggest. From the docs:
"the original |List|. When using "is" without a |List| it is
equivalent to
using "equal", using "isnot" equivalent to using "not equal". Except
that a
different type means the values are different. "4 == '4'" is true, "4
is '4'"
is false."

E.g.,

:set ignorecase
:echo 'abc' is 'ABC' (output is 1)
:echo 'abc' == 'ABC' (output is 1)
:echo 'abc' ==# 'ABC' (output is 0)

Your point about specifying matchcase or ignorecase expressly is a
good one. I will be modifying my code to do that.

Still wondering about the issue with different values for my empty
string comparison, though. Seems like it must be a bug in either
design or implementation of 'ignorecase'. I wonder whether with
'ignorecase' set the expression: 'abc' > '' returns 0 on 64-bit vim
and 1 on 32-bit. . .

-- Herb

> Zyx -- Thanks very much, I think you're onto something.
>
> However on my machine the two expressions you give above both evaluate
> to 1.  What is the explanation for the difference?:
> ------------------------------------------
>  :echo 'DONE' ># ''
>     1
> :echo 'DONE' >? ''
>     1
> ----------------------------------------

--
You received this message from the "vim_use" 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

No comments: