Kana Natsuno schrieb:
> On Thu, 19 Nov 2009 18:36:03 +0900, Andy Wokula <[email protected]> wrote:
>> " callee.vim:
>> com! -nargs=* -complete=command FrameworkLocal <args>
>>
>> function s:cript_local_function(...)
>>     return string(a:000)
>> endfunction
>>
>> let s:mile = 'XD'
>>
>> --------------------------
>> " caller.vim:
>> FrameworkLocal echo s:cript_local_function(['Vim', 'is', 'forever'])
>>     " ==> ['Vim', 'is', 'forever']
>> FrameworkLocal echo s:mile
>>     " ==> 'XD'
>
> It's not possible to interact with caller's script-local variables easily.
> For example:
>
> caller.vim:
>   let s:callers_variable = '...'
>   FrameworkLocal let s:callee_variable = s:caller_variable  " ???

Within a function, you can pass a local copy of the s:callers_variable:
    func CallerFunc()
        let var = s:callers_variable
        FrameworkLocal let s:callee_variable = var
    endfunc

I agree that your
    :let s['callee_variable'] = s:caller_variable
works better here.

> And user-defined Ex commands (= :FrameworkLocal) are usually for
> interactive use, not for scripts.

Really?  What are your reasons for this statement?

> Defining Ex commands may be annoying for users whenever they try to
> complete the names of Ex commands in Command-line mode.

Not if the name is :ZFrameworkLocal ...

And yes, :FrameworkLocal is mainly for interactive use and debugging and
should not be used in the final version of a framework "architecture".
It gives the caller too much power to manipulate the framework during
session.  But it's very simple and lets you keep most of the normal
command syntax.

-- 
Andy

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to