Project
compiler
Motivation
The long-term goal is to run Simplicity programs in the browser via Simplex. To support multi-file projects, they would need to be compiled into a single entry point before being passed to Simplex to eliminating filesystem dependencies and establishing a single source of truth for the program.
Our driver can already flatten multiple files into a single Vec<Item> and inject visibility rules into the structure. However, this is not sufficient for correct composition: the flat merge breaks visibility boundaries and alias resolution, producing an invalid program.
Main Idea
Treat each imported file as a separate module by wrapping it in a mod block. this preserves namespaces and proper scoping, allowing items to be accessed safely via qualified paths:
let bar_res: u32 = mod_block::bar_fn();
Proposed Semantics
The module system is modelled after Rust's module system, adapted for Simplicity. The following features are in scope:
- Visibility:
pub mod { /* ... */ }
- Nested modules: Because one namespace can be called from the another.
- Extended
use declarations: Currently use only allows importing specific items (e.g. use math::crypto::sha256). We propose extending it to also support qualified path access inside code (e.g. module_a::bar()) without requiring an explicit use import.
Waiting for comments from @apoelstra, @stringhandler, @KyrylR to discuss the concept of implementation.
Project
compiler
Motivation
The long-term goal is to run Simplicity programs in the browser via Simplex. To support multi-file projects, they would need to be compiled into a single entry point before being passed to Simplex to eliminating filesystem dependencies and establishing a single source of truth for the program.
Our driver can already flatten multiple files into a single
Vec<Item>and inject visibility rules into the structure. However, this is not sufficient for correct composition: the flat merge breaks visibility boundaries and alias resolution, producing an invalid program.Main Idea
Treat each imported file as a separate module by wrapping it in a
modblock. this preserves namespaces and proper scoping, allowing items to be accessed safely via qualified paths:Proposed Semantics
The module system is modelled after Rust's module system, adapted for Simplicity. The following features are in scope:
pub mod { /* ... */ }usedeclarations: Currentlyuseonly allows importing specific items (e.g.use math::crypto::sha256). We propose extending it to also support qualified path access inside code (e.g.module_a::bar()) without requiring an explicituseimport.Waiting for comments from @apoelstra, @stringhandler, @KyrylR to discuss the concept of implementation.