Friday, March 22, 2013

Re: Calling autoloaded dictionary functions

This is an old post, but I'm glad I ran into it.

I'm fairly sure you're right about this, and that it's a bug in Vim rather than intentional behavior. I think it's a side-effect of the intended behavior that references a variable won't trigger an autoload.

I've been going nuts trying to debug something, and this is the exact behavior I see. I'm not going to dive into the yak shaving hole and check the Vim source tonight, but this warrants some investigation. If it's intentional, I'm not sure why; powerful things could be done with this working.

If I fix it I'll try to remember to update here. This is the only comment on the net about it that I've run across so far.

-Jim

On Thursday, March 17, 2011 4:46:26 PM UTC-4, Ted wrote:
> It looks like calls to dictionary functions of autoload variables do
>
> not trigger the autoload.
>
>
>
> This happens when the `call` command is used, and does not happen when
>
> `echo` or `let` is the command.
>
>
>
> It also does not happen when the call() function is called instead of
>
> making a direct call to the dictionary function.
>
>
>
> EG:
>
>
>
> $ for f in .vim/autoload/foo.vim .vim/plugin/foo.vim tests.sh
>
> tests.out; do
>
> > echo "$f:"; cat "$f" | sed 's/^/ /'; echo --; done
>
> .vim/autoload/foo.vim:
>
> let foo#d = {}
>
> funct! foo#d.f()
>
> return "food!"
>
> endfunct
>
> --
>
> .vim/plugin/foo.vim:
>
> comma! Food echo foo#d.f()
>
>
>
> comma! LetFood let f = foo#d.f()
>
>
>
> comma! CallFood call foo#d.f()
>
>
>
> comma! CallCallFood call call(foo#d.f, [], {})
>
> --
>
> tests.sh:
>
> stripescape() {
>
> sed 's/\x1b\[45;1H//g';
>
> }
>
>
>
> testfood() {
>
> echo "test: $1";
>
> HOME=. vim -T dumb -e -c "$1" -c q | stripescape | sed 's/
>
> ^/ /';
>
> echo;
>
> }
>
>
>
> for command in Food LetFood CallFood CallCallFood; do
>
> testfood "$command";
>
> done;
>
> --
>
> tests.out:
>
> test: Food
>
> food!
>
>
>
> test: LetFood
>
>
>
> test: CallFood
>
> Error detected while processing command line:
>
> E121: Undefined variable: foo#d
>
>
>
> test: CallCallFood
>
>
>
> --
>
>
>
> BTW is there a way to get vim to cease entirely to emit terminal
>
> codes? I managed to stifle them in this case by passing `-T dumb` and
>
> sedding out the remaining codes, but hopefully there is a better way.
>
>
>
> Salutations,
>
> -Ted

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: