When defining a function, is it always recommended to use the scope s:
to make it local to the script and avoid overwriting a function with the same name in the global namespace ?
And is it always recommended to use the argument abort
in case the function detects an error ?
function! s:SomeFunction() abort
echo "hello world!"
endfunction
The scope s:
seems a good thing, but it makes the code a little more verbose, because each time I want to call SomeFunction()
from a mapping I have to prefix it with <SID>
:
nnoremap {lhs} :<c-u>call <SID>SomeFunction()<cr>
Or even to store its output inside a variable:
let myvar = <SID>SomeFunction()
Are there some specific cases in which you don't want to use s:
and / or abort
?
If so, for what reasons ?