I am trying to achieve the following :
- Having a set of predefined functions in my script
- Having a map of relation between the functions and their argument
- Calling the functions with their argument dynamically
Here is the code that I have :
function! s:A(a) abort
return 'A'.a:a
endfunction
function! s:B(b) abort
return 'B'.a:b
endfunction
let s:functions_map ={
\ 'A': 'aa',
\ 'B': 'bb'
\ }
function! s:CallMap() abort
for [l:key, l:value] in items(s:functions_map)
let l:Current_function = function(l:key)
echo l:Current_function(l:value)
endfor
endfunction
command! Call call <SID>CallMap()
When I run Call
I get the following message :
E700: Unknown function: A
Do you know where the issue could be coming from ?
Edit :
I replace l:current_function
by l:Current_function
to solve another error that was not directly related to the problem.