comparison runtime/doc/vim9.txt @ 29121:2a1f9b4a5ac9

Update runtime files. Commit: https://github.com/vim/vim/commit/6ba83ba9ee292f68aa0b218b3eef42db31c0b632 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 12 22:15:57 2022 +0100 Update runtime files.
author Bram Moolenaar <Bram@vim.org>
date Sun, 12 Jun 2022 23:30:04 +0200
parents c58baa6d6dda
children 0fdf36de4018
comparison
equal deleted inserted replaced
29120:df636592681d 29121:2a1f9b4a5ac9
1 *vim9.txt* For Vim version 8.2. Last change: 2022 May 21 1 *vim9.txt* For Vim version 8.2. Last change: 2022 Jun 10
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
1610 and cannot be accessed by the importing script. 1610 and cannot be accessed by the importing script.
1611 1611
1612 This mechanism exists for writing a script that can be sourced (imported) by 1612 This mechanism exists for writing a script that can be sourced (imported) by
1613 other scripts, while making sure these other scripts only have access to what 1613 other scripts, while making sure these other scripts only have access to what
1614 you want them to. This also avoids using the global namespace, which has a 1614 you want them to. This also avoids using the global namespace, which has a
1615 risc of name collisions. For example when you have two plugins with similar 1615 risk of name collisions. For example when you have two plugins with similar
1616 functionality. 1616 functionality.
1617 1617
1618 You can cheat by using the global namespace explicitly. That should be done 1618 You can cheat by using the global namespace explicitly. That should be done
1619 only for things that really are global. 1619 only for things that really are global.
1620 1620
1756 used: > 1756 used: >
1757 noremap <silent> ,a :call <SID>name.Function()<CR> 1757 noremap <silent> ,a :call <SID>name.Function()<CR>
1758 1758
1759 When the mapping is defined "<SID>name." will be replaced with <SNR> and the 1759 When the mapping is defined "<SID>name." will be replaced with <SNR> and the
1760 script ID of the imported script. 1760 script ID of the imported script.
1761 1761 An even simpler solution is using |<ScriptCmd>|: >
1762 noremap ,a <ScriptCmd>name.Function()<CR>
1763 <
1762 *:import-cycle* 1764 *:import-cycle*
1763 The `import` commands are executed when encountered. If script A imports 1765 The `import` commands are executed when encountered. If script A imports
1764 script B, and B (directly or indirectly) imports A, this will be skipped over. 1766 script B, and B (directly or indirectly) imports A, this will be skipped over.
1765 At this point items in A after "import B" will not have been processed and 1767 At this point items in A after "import B" will not have been processed and
1766 defined yet. Therefore cyclic imports can exist and not result in an error 1768 defined yet. Therefore cyclic imports can exist and not result in an error
2200 Vim supports a kind-of object oriented programming by adding methods to a 2202 Vim supports a kind-of object oriented programming by adding methods to a
2201 dictionary. With some care this can be made to work, but it does not look 2203 dictionary. With some care this can be made to work, but it does not look
2202 like real classes. On top of that, it's quite slow, because of the use of 2204 like real classes. On top of that, it's quite slow, because of the use of
2203 dictionaries. 2205 dictionaries.
2204 2206
2205 It would be good to support real classes, and this is planned for a leter 2207 It would be good to support real classes, and this is planned for a later
2206 version. The support is a "minimal common functionality" of class support in 2208 version. The support is a "minimal common functionality" of class support in
2207 most languages. It will work much like Java, which is the most popular 2209 most languages. It will work much like Java, which is the most popular
2208 programming language. 2210 programming language.
2209 2211
2210 2212