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

Better imports #21

Merged
merged 4 commits into from
Dec 18, 2020
Merged

Better imports #21

merged 4 commits into from
Dec 18, 2020

Conversation

p7g
Copy link
Owner

@p7g p7g commented Dec 18, 2020

See 7e46deb

This does not support importing from directories within a directory in CBCVM_PATH, like lib/inner/abc.rbcvm, where lib is in CBCVM_PATH.

Some next steps could be to support that, and in the process change it to be more like Python, i.e. using identifier tokens for imports, and dot-separated paths for module hierarchies.

The core of this change is to have module names tied to file names, much like
Python. As an example, importing "hashmap" looks for a file in a CBCVM_PATH
named "hashmap.rbcvm", and the resulting module is called "hashmap".

This has some implications:
- Since the module name is now the file name, there is no more "module header".
- "module" is no longer a keyword.
- File names must now be valid identifiers (if they are to be imported).
- There is no longer a concept of a "script" which is not module.

While at it, I added some logic to avoid reading a module's file if we've
already imported it once.

Closes #18
Closes #6
@p7g p7g merged commit ca79231 into master Dec 18, 2020
@p7g p7g deleted the better-import branch July 23, 2024 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant