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

Re: minor feature request: let!

Expand Messages
  • Mikolaj Machowski
    ... Definitely not. I was thinking about suggestion of :let! few times before and each time I was throwing it away. For example :let allows to change settings.
    Message 1 of 10 , Jul 2, 2006
    • 0 Attachment
      Dnia niedziela, 2 lipca 2006 12:06, Nikolai Weibull napisał:
      > 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.
      >
      Definitely not. I was thinking about suggestion of :let! few times before
      and each time I was throwing it away. For example :let allows to change
      settings. Silently dropping changing of option value or setting it to
      some absurd setting would be Bad Thing(tm).

      m.
    • Yakov Lerner
      ... I d like to see how current :let is so super-intelligent so that it prevents assignment of what you call absurd setting to the &options. Consider
      Message 2 of 10 , Jul 2, 2006
      • 0 Attachment
        On 7/2/06, Mikolaj Machowski <mikmach@...> wrote:
        > Dnia niedziela, 2 lipca 2006 12:06, Nikolai Weibull napisał:
        > > 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.
        > >
        > Definitely not. I was thinking about suggestion of :let! few times before
        > and each time I was throwing it away. For example :let allows to change
        > settings. Silently dropping changing of option value or setting it to
        > some absurd setting would be Bad Thing(tm).

        I'd like to see how current :let is so super-intelligent
        so that it prevents assignment of what you call "absurd setting"
        to the &options.

        Consider string-to-number assignment rules.
        :let &readonly="abc" " silently allowed
        :let &shiftwidth="xyz" " silently allowed
        :let &statusline=123 " silently allowed
        Just normal silent string-to-nubmer (and number to string,
        whre applicable) conversion well-accepted in interpreted languages.
        Where did you see the "intelligent prevention of absurd values"
        in the existing :let ? If anything, it's boolean and numeric
        nature of some options that forces corresponsing conversion, or
        string nature of the other options.

        It forces :let into silent type conversion, right now.
        This is exactly what prompred Justin and Nikolai to ask for
        analogous silent type conversion between lists and strings.

        Yakov
      • Yakov Lerner
        ... Excuse me, I was wrong in this sentence. Justin and Nikolai didn t advocate silent type conversion between lists and strings. Yakov
        Message 3 of 10 , Jul 2, 2006
        • 0 Attachment
          On 7/2/06, Yakov Lerner <iler.ml@...> wrote:
          > ... Justin and Nikolai to ask for
          > analogous silent type conversion between lists and strings.

          Excuse me, I was wrong in this sentence. Justin and Nikolai didn't
          advocate silent type conversion between lists and strings.

          Yakov
        • Nikolai Weibull
          ... And in any case, setting an option using let is very different from setting a user variable to a value. This is a case of Trying Too Hard . When exactly
          Message 4 of 10 , Jul 2, 2006
          • 0 Attachment
            On 7/2/06, Yakov Lerner <iler.ml@...> wrote:
            > On 7/2/06, Mikolaj Machowski <mikmach@...> wrote:
            > > Dnia niedziela, 2 lipca 2006 12:06, Nikolai Weibull napisał:
            > > > 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.
            > > >
            > > Definitely not. I was thinking about suggestion of :let! few times before
            > > and each time I was throwing it away. For example :let allows to change
            > > settings. Silently dropping changing of option value or setting it to
            > > some absurd setting would be Bad Thing(tm).
            >
            > I'd like to see how current :let is so super-intelligent
            > so that it prevents assignment of what you call "absurd setting"
            > to the &options.
            >
            > Consider string-to-number assignment rules.
            > :let &readonly="abc" " silently allowed
            > :let &shiftwidth="xyz" " silently allowed
            > :let &statusline=123 " silently allowed

            And in any case, setting an option using let is very different from
            setting a user variable to a value.

            This is a case of "Trying Too Hard".

            When exactly does this prevent you from making an error?

            It's only valid for options, and they have very different semantics
            from user variables. So just drop the check and allow people to reuse
            their variables if they like.

            nikolai
          • 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 5 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 6 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 7 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.