> > This happens because "script.Item" is compiled without knowing whether
> > it is a function reference or something else.
>
> I forgot: the issue only affected a method call:
>
> # ERROR
> 'base'->script.Item()
>
> # OK
> script.Item('base')
>
> I would have thought that if Vim was able to infer that `script.Item`
> was a function reference in the second case, it would come to the same
> conclusion in the first one.
At the script level the autoload script needs to be loaded anyway, and
then we can figure out the type of "Item" before calling it.
> > We'll have to deal with this at runtime.
>
> The error was already given at runtime. I hope it doesn't mean that
> we lose some type checking at compile time when we use a method call.
> Otherwise, I might be tempted to avoid methods when calling a function
> from an import autoload script.
We do miss type checking at compile time, because the autoload script
has not been loaded. We can't load it without defeating the whole idea
of only loading it when used. Compiling a function does not always mean
it is used.
Perhaps we should make a difference between compiling a function because
'defcompile' is used and when we are actually going to call the
function? Still, compilation does not always mean we actually need to
load the autoload script:
import autoload "script.vim"
var someCondition = false
def MaybeCall()
if someCondition
script.Func()
endif
enddef
MaybeCall()
--
ARTHUR: Bloody peasant!
DENNIS: Oh, what a give away. Did you hear that, did you hear that, eh?
That's what I'm on about -- did you see him repressing me, you saw it
didn't you?
The Quest for the Holy Grail (Monty Python)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ 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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220118132309.463601C044E%40moolenaar.net.