On 7/9/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:

Justin Constantino wrote:

> Currently, if you try to assign a value to a variable with a different
> type, you get:
>
> E706: Variable type mismatch
>
> To make it work, you have to first unlet the variable, which is kind
> of annoying if the expression you are assigning references that
> variable.  For example, to split a string in-place, you have to do:
>
> let foo = "one,two,three"
> let temp = split(foo, ',')
> unlet foo
> let foo = temp
> unlet temp
>
> As a minor improvement, I think it would be nice if you could do:
>
> let foo = "one,two,three"
> let! foo = split(foo, ',')

Suppose someone asks you what the "foo" variable is for, what are you
going answer?

The point is: let the variable name reflect what it contains, don't
re-use the same variable for something else.  That way your code will be
a lot more readable.

 let fooline  = "one,two,three"
 let foowords = split(fooline, ',')


Fair enough, but in most of the cases where this came up, I never
really cared about the 'fooline' variable. It only existed as an
intermediate to 'foowords'.  My choices were either: 1) put everything
in one assignment, which can get long and messy and harder to read, or
2) split it into two assignments by declaring an extra 'foowords' that
I never really care about.  Reusing the variable makes sense to me in
this case, and this seemed like a harmless and logical addition, but I
guess you're the Bram.

Reply via email to