Marc Weber wrote:
> I'd like to enhance user experience when installing plugins.
> I stumbled uppone one small but important issue:
> funcref('a#foo#Func') barks if the functions hasn't been loaded yet.
> Why is this bad? Because it's no longer lazy.
> Wether the function should be loaded if it doesn't exist yet should be
> done when it is called, not when the reference is created!
>
> Is there any chance to change this?
> I really don't want to add pseudo types such as
> {'funcref': 'funcname'}. But I think I don't have a choice right now.
> How do you feel about this?
>
> I'd like to be able to use function references inconfiguration files
> without those references files beeing loaded when loading the config.
>
> Of course I can use Function('name') instead of fucntion which loads the
> file. But then I don't have to use autoloading at all.
I don't see a problem with accepting a function name for auto-loading as
a funcref. The only problem might be that you get an error for the
function not being defined when it's used, instead of when the funcref
is set.
Try this patch:
*** ../vim-7.2.055/src/eval.c Fri Nov 28 21:26:50 2008
--- src/eval.c Sat Nov 29 12:28:51 2008
***************
*** 10339,10345 ****
s = get_tv_string(&argvars[0]);
if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
EMSG2(_(e_invarg2), s);
! else if (!function_exists(s))
EMSG2(_("E700: Unknown function: %s"), s);
else
{
--- 10339,10346 ----
s = get_tv_string(&argvars[0]);
if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
EMSG2(_(e_invarg2), s);
! /* Don't check an autoload name for existence here. */
! else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s))
EMSG2(_("E700: Unknown function: %s"), s);
else
{
--
FATHER: Did you kill all those guards?
LAUNCELOT: Yes ... I'm very sorry ...
FATHER: They cost fifty pounds each!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// 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.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---