Loading ...
Sorry, an error occurred while loading the content.

Re: minor feature request: let!

Expand Messages
  • Hari Krishna Dara
    ... I recently sent a question to vim list about the same restriction. The restriction doesn t make any sense to me either. -- Thanks, Hari
    Message 1 of 10 , Jul 2, 2006
    • 0 Attachment
      On Sun, 2 Jul 2006 at 12:06pm, Nikolai Weibull wrote:

      > On 7/1/06, justin constantino <goflyapig@...> wrote:
      >
      > > E706: Variable type mismatch
      >
      > > As a minor improvement, I think it would be nice if you could do:
      > >
      > > let foo = "one,two,three"
      > > let! foo = split(foo, ',')
      >
      > I think we should just remove the whole restriction.
      >
      > nikolai
      >

      I recently sent a question to vim list about the same restriction. The
      restriction doesn't make any sense to me either.

      --
      Thanks,
      Hari

      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com
    • Bram Moolenaar
      ... 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
      Message 2 of 10 , Jul 9, 2006
      • 0 Attachment
        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, ',')

        --
        For large projects, Team Leaders use sophisticated project management software
        to keep track of who's doing what. The software collects the lies and guesses
        of the project team and organizes them in to instantly outdated charts that
        are too boring to look at closely. This is called "planning".
        (Scott Adams - The Dilbert principle)

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
      • justin constantino
        ... 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
        Message 3 of 10 , Jul 13, 2006
        • 0 Attachment
          On 7/9/06, Bram Moolenaar <Bram@...> 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.
        Your message has been successfully submitted and would be delivered to recipients shortly.