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

Re: New snapshot 7.0046

Expand Messages
  • Johnny Blaze
    ... Bram, There is something hinky going on with the locking. I ll paraphrase the script I m working with: let s:dirty = { file : 0, menu : 0 } fun Read()
    Message 1 of 5 , Jan 31, 2005
      On Mon, 31 Jan 2005 23:08:57 +0100, Bram Moolenaar <Bram@...> wrote:
      >
      > I just sent out a new snapshot. Several problems were fixed.
      >
      > New feature: variable locking.
      >
      > :lockvar {name} locks a variable
      > :unlockvar {name} unlocks a variable
      > islocked() checks if a variable or value is locked.
      >

      Bram,

      There is something hinky going on with the locking. I'll paraphrase
      the script I'm working with:

      let s:dirty = { 'file': 0, 'menu': 0 }

      fun Read()
      let s:dirty.menu = 1
      endfun

      fun CheckState()
      if s:dirty.menu
      let s:dirty.menu = 0
      end if
      endfun

      call Read()
      call CheckState()

      At 'call Read()' islocked("s:dirty") == 0 and islocked("s:dirty.menu") == 0
      At 'call CheckState()' islocked("s:dirty") == 0 and
      islocked("s:dirty.menu") == 1
      if I am stepping through the script and before "let s:dirty.menu = 0"
      in CheckState() I execute :unlockvar s:dirty.menu, I get "E742: Cannot
      change value of s:dirty.menu = 0"

      If I source it without unlockvar, I get "E741: Value is locked: s:dirty.menu"

      My questions are, s:dirty or any of its members is never passed as an
      argument. Why would vim lock it? and why isn't unlockvar doing what
      its supposed to do?

      Thanks!

      --

      . o O pyromancer O o .
    • Bram Moolenaar
      ... It s possible that there are still a few places where the lock flag isn t initialized properly. It s hard to find all the spots. ... end if - endif .
      Message 2 of 5 , Feb 1, 2005
        Johnny Blaze wrote:

        > On Mon, 31 Jan 2005 23:08:57 +0100, Bram Moolenaar <Bram@...> wrote:
        > >
        > > I just sent out a new snapshot. Several problems were fixed.
        > >
        > > New feature: variable locking.
        > >
        > > :lockvar {name} locks a variable
        > > :unlockvar {name} unlocks a variable
        > > islocked() checks if a variable or value is locked.
        >
        > Bram,
        >
        > There is something hinky going on with the locking. I'll paraphrase
        > the script I'm working with:

        It's possible that there are still a few places where the lock flag
        isn't initialized properly. It's hard to find all the spots.

        > let s:dirty = { 'file': 0, 'menu': 0 }
        >
        > fun Read()
        > let s:dirty.menu = 1
        > endfun
        >
        > fun CheckState()
        > if s:dirty.menu
        > let s:dirty.menu = 0
        > end if

        "end if" -> "endif".

        > endfun
        >
        > call Read()
        > call CheckState()
        >
        > At 'call Read()' islocked("s:dirty") == 0 and islocked("s:dirty.menu") == 0
        > At 'call CheckState()' islocked("s:dirty") == 0 and
        > islocked("s:dirty.menu") == 1

        Not for me. Must be a missing initialisation. Try this change:

        *** eval.c~ Mon Jan 31 17:56:07 2005
        --- eval.c Tue Feb 1 10:27:42 2005
        ***************
        *** 2211,2216 ****
        --- 2211,2217 ----
        else
        {
        *lp->ll_tv = *rettv;
        + lp->ll_tv->v_lock = 0;
        init_tv(rettv);
        }
        }

        > if I am stepping through the script and before "let s:dirty.menu = 0"
        > in CheckState() I execute :unlockvar s:dirty.menu, I get "E742: Cannot
        > change value of s:dirty.menu = 0"

        That means a flag is set that is used for function arguments. You can't
        reset it with ":unlockvar". Again sounds like missing initialisation.

        --
        A)bort, R)etry, D)o it right this time

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
      • Johnny Blaze
        ... Thanks Bram, It works just fine now. ... so in nomal practice, if a locked variable is found, unlockvar will be able to unlock it? -- . o O pyromancer O o
        Message 3 of 5 , Feb 1, 2005
          On Tue, 01 Feb 2005 10:55:33 +0100, Bram Moolenaar <Bram@...> wrote:
          >
          > Johnny Blaze wrote:
          >
          > > On Mon, 31 Jan 2005 23:08:57 +0100, Bram Moolenaar <Bram@...> wrote:
          > > >
          > > > I just sent out a new snapshot. Several problems were fixed.
          > > >
          > > > New feature: variable locking.
          > > >
          > > > :lockvar {name} locks a variable
          > > > :unlockvar {name} unlocks a variable
          > > > islocked() checks if a variable or value is locked.
          > >
          > > Bram,
          > >
          > > There is something hinky going on with the locking. I'll paraphrase
          > > the script I'm working with:
          >
          > It's possible that there are still a few places where the lock flag
          > isn't initialized properly. It's hard to find all the spots.
          >
          > > let s:dirty = { 'file': 0, 'menu': 0 }
          > >
          > > fun Read()
          > > let s:dirty.menu = 1
          > > endfun
          > >
          > > fun CheckState()
          > > if s:dirty.menu
          > > let s:dirty.menu = 0
          > > endif
          > > endfun
          > >
          > > call Read()
          > > call CheckState()
          > >
          > > At 'call Read()' islocked("s:dirty") == 0 and islocked("s:dirty.menu") == 0
          > > At 'call CheckState()' islocked("s:dirty") == 0 and
          > > islocked("s:dirty.menu") == 1
          >
          > Not for me. Must be a missing initialisation. Try this change:
          >
          > *** eval.c~ Mon Jan 31 17:56:07 2005
          > --- eval.c Tue Feb 1 10:27:42 2005
          > ***************
          > *** 2211,2216 ****
          > --- 2211,2217 ----
          > else
          > {
          > *lp->ll_tv = *rettv;
          > + lp->ll_tv->v_lock = 0;
          > init_tv(rettv);
          > }
          > }
          >

          Thanks Bram, It works just fine now.

          > > if I am stepping through the script and before "let s:dirty.menu = 0"
          > > in CheckState() I execute :unlockvar s:dirty.menu, I get "E742: Cannot
          > > change value of s:dirty.menu = 0"
          >
          > That means a flag is set that is used for function arguments. You can't
          > reset it with ":unlockvar". Again sounds like missing initialisation.

          so in nomal practice, if a locked variable is found, unlockvar will be
          able to unlock it?
          --

          . o O pyromancer O o .
        • Bram Moolenaar
          ... Yes, but :unlockvar can t change anything for a read-only variable, such as a function argument. -- hundred-and-one symptoms of being an internet addict:
          Message 4 of 5 , Feb 1, 2005
            Johnny Blaze wrote:

            > > > if I am stepping through the script and before "let s:dirty.menu = 0"
            > > > in CheckState() I execute :unlockvar s:dirty.menu, I get "E742: Cannot
            > > > change value of s:dirty.menu = 0"
            > >
            > > That means a flag is set that is used for function arguments. You can't
            > > reset it with ":unlockvar". Again sounds like missing initialisation.
            >
            > so in nomal practice, if a locked variable is found, unlockvar will be
            > able to unlock it?

            Yes, but ":unlockvar" can't change anything for a read-only variable,
            such as a function argument.

            --
            hundred-and-one symptoms of being an internet addict:
            14. You start introducing yourself as "Jim at I-I-Net dot net dot au"

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
            \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
          Your message has been successfully submitted and would be delivered to recipients shortly.