Reply to message «Re: question about string expression evaluation / bug?», sent 22:07:10 23 May 2011, Monday by hsitz:
> :set ignorecase > :echo 'abc' is 'ABC' (output is 1) Missed this. Strange, but `is#' works (guess it is because `#' and `?' are defined as operator suffix for all expr4 operators). I guess it should be added to the help (undocumented=non-existent) as I don't want to dig into my own code and guess where I should write `type(v1)==type(v2) && v1==#v2' and where just `v1==#v2', replacing all is's with is# is simpler. > 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. . . I have 64-bit one. I once thought that problem is strcasecmp in my glibc, but quickly searching vim source revealed that it uses its own mb_strnicmp. Original message: > On May 23, 8:12 am, hsitz <[email protected]> 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 > > ----------------------------------------
signature.asc
Description: This is a digitally signed message part.
