I have implemented the basics of the import and export commands.
Trying it out shows that it works well.  Anyone familiar with JavaScript
(ES6) will immediately see how it works.  For others it's easy to
explain.

As an illustration, I have written help for how to use import with
autoload to make startup fast:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Import in an autoload script ~

For optimal startup speed, loading scripts should be postponed until they are
actually needed.  A recommended mechamism:

1. In the plugin define user commands, functions and/or mappings that refer to
   an autoload script. >
        command -nargs=1 SearchForStuff call searchfor#Stuff(<f-args>)

<   This goes in .../plugin/anyname.vim.  "anyname.vim" can be freely chosen.

2. In the autocommand script do the actual work.  You can import items from
   other files to split up functionality in appropriate pieces. >
        vim9script
        import FilterFunc from "../import/someother.vim"
        def searchfor#Stuff(arg: string)
          let filtered = FilterFunc(arg)
          ...
<   This goes in .../autoload/searchfor.vim.  "searchfor" in the file name
   must be exactly the same as the prefix for the function name, that is how
   Vim finds the file.

3. Other functionality, possibly shared between plugins, contains the exported
   items and any private items. >
        vim9script
        let localVar = 'local'
        export def FilterFunc(arg: string): string
           ...
<   This goes in .../import/someother.vim.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

For the context, see
https://github.com/brammool/vim9/blob/master/runtime/doc/vim9.txt


-- 
If all you have is a hammer, everything looks like a nail.
When your hammer is C++, everything begins to look like a thumb.
                        -- Steve Hoflich, comp.lang.c++

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202001192059.00JKxwHL018512%40masaka.moolenaar.net.

Raspunde prin e-mail lui