On Jan 8, 10:00 pm, "Ian Tegebo" <[EMAIL PROTECTED]> wrote:
> I'm exploring functional programming with vimL and immediately ran into
> seemingly counter-intuitive behavior:
>
> ------------------------------------
> function! Outer()
>         let outer_var = 0
>         function! Inner()
>                 let outer_var += 1
>         endfunction
>         call Inner()
>         echo outer_var
> endfunction
>
> call Outer()
> -------------------------------------
>
> The result, when I run this from 7.1.156, is that 'Inner' reports
> 'outer_var' as
> unknown.  I was expecting '0' but would eventually like to have my 'Inner'
> use 'outer_var' as state via dictionaries or some other mechanism.  It's
> disturbing that 'outer_var' is not available to 'Inner'.
>
> Am I missing something?
>
There are no closures in what you call vimL. Your code is equivalent
to
this :

------------------------------------
function! Outer()
        let outer_var = 0
        call Inner()
        echo outer_var
endfunction

function! Inner()
        let outer_var += 1
endfunction

call Outer()
-------------------------------------

As Tony pointed out, you have 2 different local variables.

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

Raspunde prin e-mail lui