vim9 export enhancement

12 views
Skip to first unread message

Ernie Rael

unread,
Mar 22, 2022, 12:39:26 PM3/22/22
to vim...@googlegroups.com
I like having the export with the function/data; good to know I'm
looking at something that escapes into the wild.

But I also like to know what contract the file has simply by looking at
the top of the file.

Allow an optional statement, for example `contract`, with only names and
not definitions. If the contract statement exists then any/all names in
the contract must be exported from the file, otherwise there's an error.
In addition, if something is defined with export then it is an error if
it does not appear in the contract,  For example,

vim9script
contract f1, f2
export def f1
enddef
export def f3
enddef

The above has two errors. f2 is in the contract, but not defined. f3 is
exported, but is not in the contract.

Note the word `export` could be re-used instead of adding a new keyword.

-ernie

(I am unable to file a feature request on github. Cockpit error or ???)

Bram Moolenaar

unread,
Mar 22, 2022, 2:13:44 PM3/22/22
to vim...@googlegroups.com, Ernie Rael
What language does it like this? Why only the names and not the type?
A name is not very useful without knowing what it is.

Generally I don't like this, because you have two places to change when
adding/removing/renaming items. You can just search for "export" to
find out what a script exports.

> (I am unable to file a feature request on github. Cockpit error or ???)

Might be a github hickup. My "git push" failed previously, now it's OK
again.

--
LAUNCELOT leaps into SHOT with a mighty cry and runs the GUARD through and
hacks him to the floor. Blood. Swashbuckling music (perhaps).
LAUNCELOT races through into the castle screaming.
SECOND SENTRY: Hey!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages