Skip to content
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

import segregation #3

Closed
4 tasks done
andrewrk opened this issue Dec 11, 2015 · 4 comments
Closed
4 tasks done

import segregation #3

andrewrk opened this issue Dec 11, 2015 · 4 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@andrewrk
Copy link
Member

  • In /my/project/path if I import "std.zig" which is in /usr/lib/zig/lib/std.zig, and then "std.zig" wants to import its own dependencies, those should be looking in the /usr/lib/zig/lib/ root, and not searching /my/project/path.
  • If a.zig imports b.zig and then b.zig imports c.zig, a.zig should not see c.zig symbols.
  • Ability to import into a namespace in addition to importing all. `import a = "a.zig";
  • rename use to import ?
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Dec 11, 2015
@andrewrk
Copy link
Member Author

andrewrk commented Jan 4, 2016

use "a.zig";

This would import everything into the global namespace.

use "a.zig" as a;

To use a.zig symbols with this style, use a::symbol.

@thejoshwolfe
Copy link
Contributor

How about this instead for an explicit namespace:

use a = "a.zig";

That looks more like you're creating a symbol and initializing it. The as syntax you proposed is borrowed from python, which also uses that syntax for its with syntax. But for zig, as is used for type casting, so it doesn't seem appropriate in this context.

@andrewrk
Copy link
Member Author

andrewrk commented Jan 4, 2016

I like that. It's more consistent with typedef syntax.

type foo = other;

@andrewrk
Copy link
Member Author

andrewrk commented Jan 4, 2016

use was from when I thought to borrow rust syntax. Given the new syntax proposal, how about renaming use to import?

andrewrk added a commit that referenced this issue Jan 4, 2016
andrewrk added a commit that referenced this issue Jan 4, 2016
@andrewrk andrewrk added this to the debut milestone Jan 18, 2016
gonzus added a commit to gonzus/zig that referenced this issue May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants