Hi,
I am starting to convert vim-airline to use vim9 script. vim-airline
makes much use of dictionary functions and I am not sure how to handle
this in vim9 script. Essentially, this comes down to the following
example:
function! Mylen() dict
return len(self.data)
endfunction
def! MyFun(dct: dict<any>): number
let length=dct.len()
return length
enddef
function! DoIt()
let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
call MyFun(mydict)
endfunction
call DoIt()
When sourcing this I get this error message:
Error detected while processing vim9script.vim[19]..function DoIt[2]..MyFun:
line 1:
E725: Calling dict function without Dictionary: Mylen
0
Is that expected or are dictionary functions no longer supported?
For reference, the same as legacy vimscript works just fine:
function! Mylen() dict
return len(self.data)
endfunction
func! MyFun2(dct)
return a:dct.len()
endfunc
function! DoIt()
let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
let length=MyFun2(mydict)
echo length
endfunction
call DoIt()
This works correctly.
Thanks,
Christian
--
Gerade dem, der vielen Ruhm hat, erlaubt man nicht die Anmaßung
irgendeines kleinsten Verdienstes (Nebenrühmchens), das vielleicht
andere haben, sobald er es nicht wirklich verdient. Man hält es für
Geiz und Raubsucht.
-- Jean Paul
--
--
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/20210507213902.GD95831%40256bit.org.