On May 16, 2014 1:58 PM, "Alex Efros" <[email protected]> wrote:
>
> Hi!
>
> On Fri, May 16, 2014 at 12:53:17PM +0400, Nikolay Pavlov wrote:
> > On May 16, 2014 12:29 PM, "Alex Efros" <[email protected]> wrote:
> > > > >     fun s:Foo()
> > > > >     endfun
> > > > >     let g:Foo = function('s:Foo')
> > This change has nothing to do with the change that made
function('s:...')
> > work outside of the plugin which defined this funcref. It was a bug that
> > got fixed.
>
> User reported it on Ubuntu 12.04 LTS with Vim 7.3.429-2ubuntu2.1, I see it
> on 7.3.762 - so, this bug exists in so many vim versions?

It existed since the time when function() was introduced. Until I wrote a
patch that expanded s: when defining funcrefs nobody seemed to be bothered
with the fact that you cannot call s: funcrefs outside of the plugin which
defined them.

>
> > To workaround it on old vims you should use manually replace s: with
> > <SNR>N_ when defining funcrefs. AFAIR :h <SID> shows some ways to get N.
>
> You mean I should add
>
>     function s:SID()
>             return matchstr(expand('<sfile>'), '\zs<SNR>\d\+_\zeSID$')
>     endfunction
>
> into each file of my plugin (it uses sort of sub-plugins in separate
> files, so there a lot of them), and then replace in each file each
>
>     let g:Foo = function('s:Foo')
>
> with
>
>     let g:Foo = function(s:SID().'Foo')
>
> And this is only way to keep compatibility with these vim versions?

I would recommend switching to anonymous functions if you do not like this
variant. There are no other ways I know about.

Anonymous functions:

    let s:F = {}
    function s:F.foo()
    endfunction
    let g:Foo = s:F.foo

. But this has one problem: anonymous functions cannot be called without a
dictionary. So to call g:Foo you will either need to always use 3-argument
form of call() or define g:FooDict with 'foo' key and call using
g:FooDict.foo().

>
> --
>                         WBR, Alex.
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
"vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui