]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(doc): Fill in a few details regarding :enums (#14349)
authorAliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com>
Thu, 4 Apr 2024 20:05:33 +0000 (23:05 +0300)
committerGitHub <noreply@github.com>
Thu, 4 Apr 2024 20:05:33 +0000 (22:05 +0200)
- Mention the support of eval() for enumeration values.

- Clarify the extent of immutability for enumeration values.

- Specify the requirements for class methods to meet for
  class variable initialisation and their use in nested
  functions and lambda expressions.

- Remove a duplicate sentence that describes how to access
  parent class methods in derivative classes (see another
  "copy" two paragraphs below).

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/builtin.txt
runtime/doc/vim9class.txt

index 088daa75a35705a242f602513ab17116d72b86f4..6a4c8d981f430f99056de8eb0989c42a18a5e1f1 100644 (file)
@@ -1,4 +1,4 @@
-*builtin.txt*  For Vim version 9.1.  Last change: 2024 Mar 29
+*builtin.txt*  For Vim version 9.1.  Last change: 2024 Apr 03
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -2307,7 +2307,8 @@ eval({string})    Evaluate {string} and return the result.  Especially useful to
                turn the result of |string()| back into the original value.
                This works for Numbers, Floats, Strings, Blobs and composites
                of them.  Also works for |Funcref|s that refer to existing
-               functions.
+               functions.  In |Vim9| script, it can be used to obtain |enum|
+               values from their fully qualified names.
 
                Can also be used as a |method|: >
                        argv->join()->eval()
index 8820d77b54b5a45f1d6eab70c0ea47738c65cfb8..804e02dc17a0e14ec5bf50d2e0984ddf041d15d9 100644 (file)
@@ -1,4 +1,4 @@
-*vim9class.txt*        For Vim version 9.1.  Last change: 2024 Mar 28
+*vim9class.txt*        For Vim version 9.1.  Last change: 2024 Apr 04
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -328,10 +328,27 @@ variables but they have no access to the object variables, they cannot use the
           enddef
        endclass
 
-Inside the class the class method can be called by name directly, outside the
-class the class name must be prefixed: `OtherThing.ClearTotalSize()`.  To use
-a class method from a parent class in a child class, the class name must be
-prefixed.
+Inside the class, the class method can be called by name directly, outside the
+class, the class name must be prefixed: `OtherThing.ClearTotalSize()`.  Also,
+the name prefix must be used for public class methods in the special contexts
+of class variable initializers and of lambda expressions and nested functions:
+>
+    class OtherThing
+       static var name: string = OtherThing.GiveName()
+
+       static def GiveName(): string
+           def DoGiveName(): string
+               return OtherThing.NameAny()
+           enddef
+
+           return DoGiveName()
+       enddef
+
+       static def NameAny(): string
+           return "any"
+       enddef
+    endclass
+<
 
 Just like object methods the access can be made protected by using an
 underscore as the first character in the method name: >
@@ -972,8 +989,8 @@ The following example shows an enum with object variables and methods: >
     echo Planet.Earth.has_rings
 <
                                                *E1421* *E1423* *E1424* *E1425*
-Enums and their values are immutable. They cannot be modified after
-declaration and cannot be utilized as numerical or string types.
+Enums and their values are immutable.  They cannot be utilized as numerical or
+string types.  Enum values can declare mutable instance variables.
 
                                                *enum-name*
 Each enum value object has a "name" instance variable which contains the name