71007Re: Funcref and script local functions
- Jul 3, 2006On 7/3/06, Yakov Lerner <iler.ml@...> wrote:
> On 7/3/06, Yakov Lerner <iler.ml@...> wrote:The problem with this is that you can no longer have private object
> > On 6/30/06, Hari Krishna Dara <hari_vim@...> wrote:
> > > ... The Funcref obtained via function('s:T') can't be
> > > called from outside the script ... [unexpectedly]
> > I agree, Hari. I'd expect funcref function('s:T') to be callable
> > outside of the script, too.
> To make myself more clear. I expect g:Xxx() to be callable
> from global scope of from another script in this example:
> " --- scritp x.vim
> function! s:XXX()
> echo "func XXX"
> let g:Xxx=function('s:XXX')
I'd be interested to hear from Bram about what the intent was here.
I think I can see some method in the maddness.
1) let ref = function('s:XXX')
This mains the standard scope rules for the func ref, and so it
stays local even if the variable holding it is global. I can image
situations where this could be useful.
2) let ref = function('<SNR>66_XXX')
This forces the function to be available globally because it is
explicitely defined, and there is little chance of mistakes about
3) function obj.funcref() dict
Again, I think the intent for having the object function in the global
scope is unknown (to me at least). I think it left global because you
don't really need specific scoping for it, as when it is used, it
*should* be used via the object name, which is scoped by the user.
function s:obj.funcref() dict
Hari, can you give an example of why function('s:T') should be
globally scoped? I can't see a need for it, given all the
possibilites for obtaining a ref.
- << Previous post in topic Next post in topic >>