On 6/21/06, Hari Krishna Dara <[EMAIL PROTECTED]> wrote:
Just wanted to add to the below that the problem is not just chaining
functions, but using the return value of the function itself. If the
function returns a dictionary (and probably a list), you can't use it to
access its members, so something like this will also fail:
let t.T()['abc'] = 'xyz'
However, using it in an expression works fine, e.g.,:
return t.T()['abc']
--
Thanks,
Hari
On Wed, 21 Jun 2006 at 3:38pm, Hari Krishna Dara wrote:
>
> I found a problem with chaining function calls through the new
> dictionary functions. Here is some code demonstrate the problem, if you
> execute this code, the last line generates an E488 error, where as the
> previous lines combines (they are equivalent) works fine.
>
> let tt = {}
> function! tt.TT()
> echomsg 'This is TT'
> endfunction
>
> let t = {'tt': tt}
> function t.T()
> return self.tt
> endfunction
>
> let tmptt = t.T()
> call tmptt.TT()
> call t.T().TT()
>
>
From: Richard Emberson <[EMAIL PROTECTED]>
To: [email protected]
Date: May 18, 2006 4:42 PM
Subject: vim patch: fixing resetting dictionary function
Try this without the fix and you get:
ADD
n=9
Error detected while processing /home/emberson/vim/foo.vim:
line 14:
E475: Invalid argument: 1
ADD
n=9
Note that "1" is the index of the function in the dictionary.
Try it with the fix you get:
ADD
n=9
MULTIPLY
n=20
script:
let x = {}
function x.foo(a,b) dict
echo "ADD"
return a:a + a:b
endfunction
let n = x.foo(4,5)
echo "n=" . n
function! x.foo(a,b) dict
echo "MULTIPLY"
return a:a * a:b
endfunction
let n = x.foo(4,5)
echo "n=" . n
*** eval.c 2006-06-15 11:05:16.000000000 -0700
--- eval.c.original 2006-06-15 11:02:59.000000000 -0700
***************
*** 18407,18435 ****
j = 3;
else
j = 0;
- /* The name can be an index into a dictionary. */
- /* There maybe a better way, this demonstrates a fix. */
- while (arg[j] != NUL && VIM_ISDIGIT(arg[j]))
- ++j;
- if (arg[j] != NUL)
- {
- if (*arg == K_SPECIAL)
- j = 3;
- else
- j = 0;
- while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
- : eval_isnamec(arg[j])))
- ++j;
- if (arg[j] != NUL)
- emsg_funcname(_(e_invarg2), arg);
- }
- /*
while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
: eval_isnamec(arg[j])))
++j;
if (arg[j] != NUL)
emsg_funcname(_(e_invarg2), arg);
- */
}
}
--- 18407,18417 ----