-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why load statement must import at least 1 symbol #417
Comments
The point of a load statement is to import a symbol in the environment. So a load with no symbol would be a no-op. If you need to do a side-effect, you could define your own function, e.g. |
could you add a parameter AllowLoadNothing to give "load" the ability to run a module? |
A Starlark load statement must specify both the name of a module to load, and a list of 1 or more symbols to import from it. Anything else is a syntax error. There is no way to say "import all the symbols from a module into this file", because it would make it very hard to tell where a symbol was defined. However, there is an open spec proposal for a way to say "import an entire module to the local name foo", so that you could then access members using the syntax foo.x, but this has not been accepted. Personally I like it but it would be a fair amount of work to implement. Feel free to comment on that issue (and see also #302). |
@adonovan I mean allow the load statement not to import any symbols. like @laurentlb understands. |
What would be the value of a load statement that doesn't load anything? |
Nothing at all. |
I made a packager tool:
https://github.com/vanishs/starc2one
This tool packages the relevant dependent modules through the ”load“ reference
I want to package them into a file by referencing them by "load". like this:
load("mod1")
load("mod2")
load("mod3")
but i got an error: "load statement must import at least 1 symbol"
Why is there such a limit?
The text was updated successfully, but these errors were encountered: