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

calling dict function without dict?

Expand Messages
  • Marc Weber
    Eg why should this fail? let a = {} function! a.foo() dict echo foo endfunction call call(a[ foo ],[]) I m not using self anywhere. The help (E725) even
    Message 1 of 5 , Dec 1, 2008
    • 0 Attachment
      Eg why should this fail?

      let a = {}
      function! a.foo() dict
      echo "foo"
      endfunction

      call call(a['foo'],[])

      I'm not using self anywhere.

      The help (E725) even states:

      It is also possible to add a function without the "dict" attribute as a
      Funcref to a Dictionary, but the "self" variable is not available then.

      Sincerly
      Marc Weber

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Marc Weber
      ... The workaround seems to be easy: Always pass at least {} as self parameter.. Marc --~--~---------~--~----~------------~-------~--~----~ You received this
      Message 2 of 5 , Dec 1, 2008
      • 0 Attachment
        On Tue, Dec 02, 2008 at 12:45:09AM +0100, Marc Weber wrote:
        > Eg why should this fail?

        The workaround seems to be easy: Always pass at least {} as self
        parameter..

        Marc

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Larson, DavidX S
        ... Try this instead: call a.foo() --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_dev maillist. For more
        Message 3 of 5 , Dec 1, 2008
        • 0 Attachment
          > Eg why should this fail?
          >
          > let a = {}
          > function! a.foo() dict
          > echo "foo"
          > endfunction
          >
          > call call(a['foo'],[])

          Try this instead:

          call a.foo()

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Matt Wozniski
          ... Yes, but that s not what you re doing - you re adding a function *with* the dict attribute as a funcref to a dictionary. If you want to call it without a
          Message 4 of 5 , Dec 1, 2008
          • 0 Attachment
            On Mon, Dec 1, 2008 at 6:45 PM, Marc Weber wrote:
            >
            > Eg why should this fail?
            >
            > let a = {}
            > function! a.foo() dict
            > echo "foo"
            > endfunction
            >
            > call call(a['foo'],[])
            >
            > I'm not using self anywhere.
            >
            > The help (E725) even states:
            >
            > It is also possible to add a function without the "dict" attribute as a
            > Funcref to a Dictionary, but the "self" variable is not available then.

            Yes, but that's not what you're doing - you're adding a function
            *with* the dict attribute as a funcref to a dictionary. If you want
            to call it without a self... don't make it a 'dict' function, and you
            won't need to provide a "self" dict.

            ~Matt

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Agathoklis D. Hatzimanikas
            ... or, call call(a[ foo ], [], a) Regards, Ag. --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_dev maillist.
            Message 5 of 5 , Dec 2, 2008
            • 0 Attachment
              On Mon, Dec 01, at 03:54 Larson, DavidX S wrote:
              > > Eg why should this fail?
              > >
              > > let a = {}
              > > function! a.foo() dict
              > > echo "foo"
              > > endfunction
              > >
              > > call call(a['foo'],[])
              >
              > Try this instead:
              >
              > call a.foo()
              >

              or,

              call call(a['foo'], [], a)

              Regards,
              Ag.

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_dev" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            Your message has been successfully submitted and would be delivered to recipients shortly.