Mercurial > vim
comparison runtime/doc/vim9.txt @ 23360:eb7d8f39363c v8.2.2223
patch 8.2.2223: Vim9: Reloading marks a :def function as deleted
Commit: https://github.com/vim/vim/commit/cdc40c43f1008bda2f173d3a13606236679e8067
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 26 17:43:08 2020 +0100
patch 8.2.2223: Vim9: Reloading marks a :def function as deleted
Problem: Vim9: Reloading marks a :def function as deleted.
Solution: Clear the function contents but keep the index.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Dec 2020 17:45:03 +0100 |
parents | b3142fc0a414 |
children | 517fca70e084 |
comparison
equal
deleted
inserted
replaced
23359:35b42d31593d | 23360:eb7d8f39363c |
---|---|
216 vimscript noclear | 216 vimscript noclear |
217 setlocal completefunc=SomeFunc | 217 setlocal completefunc=SomeFunc |
218 if exists('*SomeFunc') | finish | endif | 218 if exists('*SomeFunc') | finish | endif |
219 def g:SomeFunc() | 219 def g:SomeFunc() |
220 .... | 220 .... |
221 | |
222 There is one gotcha: If a compiled function is replaced and it is called from | |
223 another compiled function that is not replaced, it will try to call the | |
224 function from before it was replaced, which no longer exists. This doesn't | |
225 work: > | |
226 vimscript noclear | |
227 | |
228 def ReplaceMe() | |
229 echo 'function redefined every time' | |
230 enddef | |
231 | |
232 if exists('s:loaded') | finish | endif | |
233 var s:loaded = true | |
234 | |
235 def NotReplaced() | |
236 ReplaceMe() # Error if ReplaceMe() was redefined | |
237 enddef | |
238 | 221 |
239 | 222 |
240 Variable declarations with :var, :final and :const ~ | 223 Variable declarations with :var, :final and :const ~ |
241 *vim9-declaration* *:var* | 224 *vim9-declaration* *:var* |
242 Local variables need to be declared with `:var`. Local constants need to be | 225 Local variables need to be declared with `:var`. Local constants need to be |