-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Project
compiler
Describe the feature
Reasoning
The main reasoning is to enable an analogue of the OpenZeppelin library to exist in the SimplicityHL ecosystem.
The idea is that the code will be distributed via crates.io and will allow developers to speed up the development of applications.
Primarily, it will significantly increase code reusability. If a project is heavily focused on security, it will be able to “flatten” the code and use all the functions without external dependencies.
Semantics
- Visibility:
pub fnmakes a function importable from other files;fnis file-private.pub usere-exports imported symbols;useonly brings them into the local scope.pub typeexports a type alias (optional but included for consistency).
- use forms:
use m::name;,use m::name as alias;,use m::{a, b as c};,use m::*;pub use m::{a, b as c};,pub use m::*;(re-export)
- Merging with C3 linearization when resolving
pub use ...::*across a graph of re-exports. First wins according to the MRO; conflicts require explicit aliasing. - Conflicts:
- A local
use *that causes a collision → error unless explicitly aliased. - Re-export collisions are resolved by C3 order; later entries are ignored unless aliased.
- A local
- Path resolution: relative to the importing file’s directory, then search
-Idirectories in CLI order; append.simfif missing. - Running: Only files defining a zero-arg unit
fn mainare runnable. Libraries (nomain) are accepted under--check; attempting to run them results in an error.
Overall, this feature can be delivered in milestones, so we can gradually add support.
Even though the StarkWare team introduced macros, in the long term it is much more beneficial to have official compiler support for imports. It can already be seen that their compiler version is outdated.
Reactions are currently unavailable
Metadata
Metadata
Labels
No labels