diff runtime/doc/vim9.txt @ 20115:bd021eb62e73

Update runtime files Commit: https://github.com/vim/vim/commit/2c7f8c574f1f8723d59adca3fec8fb89c41cf8c9 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 20 19:52:53 2020 +0200 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 Apr 2020 20:00:05 +0200
parents c85d4e173cc9
children 56265f711890
line wrap: on
line diff
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -1,4 +1,4 @@
-*vim9.txt*	For Vim version 8.2.  Last change: 2020 Apr 09
+*vim9.txt*	For Vim version 8.2.  Last change: 2020 Apr 19
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -66,6 +66,10 @@ comment can also start with #.  Normally
 numbers, but you can also use `:number` for that. >
 	let count = 0  # number of occurences of Ni!
 
+To improve readability there must be a space between the command and the #
+that starts a comment.  Note that #{ is the start of a dictionary, therefore
+it cannot start a comment.
+
 
 Vim9 functions ~
 
@@ -82,6 +86,29 @@ In the function body:
 	     ...
 
 
+Functions are script-local by default ~
+
+When using `:function` or `:def` to specify a new function at the script level
+in a Vim9 script, the function is local to the script, as if "s:" was
+prefixed.  To define a global function the "g:" prefix must be used.
+
+When using `:function` or `:def` to specify a new function inside a function,
+the function is local to the function.  It is not possible to define a
+script-local function inside a function. To define a global function the "g:"
+prefix must be used.
+
+When referring to a function and no "s:" or "g:" prefix is used, Vim will
+search for the function in this order:
+- Local to the current function scope.
+- Local to the current script file.
+- Imported functions, see `:import`.
+- Global.
+
+Global functions can be defined and deleted at nearly any time.  In Vim9
+script script-local functions are defined once when the script is sourced and
+cannot be deleted.
+
+
 Variable declarations with :let and :const ~
 
 Local variables need to be declared with `:let`.  Local constants need to be
@@ -468,9 +495,12 @@ Then "myvar" will only exist in this fil
 be available as `g:myvar` from any other script and function.
 
 The variables at the file level are very much like the script-local "s:"
-variables in legacy Vim script, but the "s:" is omitted.
+variables in legacy Vim script, but the "s:" is omitted.  And they cannot be
+deleted.
 
-In Vim9 script the global "g:" namespace can still be used as before.
+In Vim9 script the global "g:" namespace can still be used as before.  And the
+"w:", "b:" and "t:" namespaces.  These have in common that variables are not
+declared and they can be deleted.
 
 A side effect of `:vim9script` is that the 'cpoptions' option is set to the
 Vim default value, like with: >