Benjamin R. Haskell wrote:
> On Sun, 11 Jul 2010, tyru wrote:
>
> > > Bram
> > > This works as intended. Autoload scripts are only loaded when used.
> > > Not when you check if something defined in it exists.
> >
> > This is expected behavior?
> > hmm, but checking this at command-line, exists() returns 1.
> > :echo exists('*mylib#func')
> > and seeing :scriptnames, autoload/mylib.vim has been loaded.
>
> The expected behavior is for it to return 0. But, as tyru is seeing,
> I'm also getting the unexpected return of 1 with the following, simpler setup:
>
> ===> /tmp/just-autoload/vimrc <===
> let &rtp='/tmp/just-autoload,'.&rtp
> fun! TestExists()
> echo '(expected) in TestExists:' exists('*mylib#func')
> endfun
> call TestExists()
> echo '(unexpected) in vimrc:' exists('*mylib#func')
> quit
>
> ===> /tmp/just-autoload/autoload/mylib.vim <===
> fun! mylib#func()
> " function never gets called
> echo "(not printed:) called mylib#func()"
> endfun
>
> $ vim -U NONE -N -u /tmp/just-autoload/vimrc
> (expected) in TestExists: 0
> (unexpected) in vimrc: 1
Yeah, exists() should not load the autoload script.
It's a side effect of translating the function name.
I'll fix that.
--
You were lucky. We lived for three months in a brown paper bag in a
septic tank. We used to have to get up at six o'clock in the morning,
clean the bag, eat a crust of stale bread, go to work down mill for
fourteen hours a day week in-week out. When we got home, our Dad
would thrash us to sleep with his belt!
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
You received this message from the "vim_dev" 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