Allow multidep enums - #414
Conversation
add full enum info to the abi types
cb9b61e to
29a5700
Compare
|
Are there design documents or something about this way of identifying modules? Have you looked at https://community.simplicity-lang.org/t/nominal-types-and-module-identification-in-simplicityhl/62/3 |
|
Also, in what sense are enums "special"? It seems like we are implementing a half-baked form of nominal typing for enums, and only enums. For example using the |
|
I think @KyrylR can give a better answer to the question "why are enums special." Regarding the module system: it currently supports inline mod, but it doesn't support importing a whole moduleб only individual items out of one (functions, type aliases, and enums). So something like this doesn't currently work: mod A {
pub mod B {
pub fn smth() {}
}
}
use crate::A::B;
use B::smth; // error
fn main() {}But we can get On @stringhandler's main question, about single-file and multi-file programs having an exact equivalent, I think yes, and that's the main reason flattening exists at all (#337, more detailed in linked issue). To show it concretely rather than just assert it: I compiled both of the following programs, and they produce the identical CMR: fn add_32(a: u32, b: u32) -> u32 {
let (_, res): (bool, u32) = jet::add_32(a, b);
res
}
fn main() {
let a: u32 = witness::A;
let b: u32 = witness::B;
let c: u32 = witness::C;
assert!(jet::eq_32(c, add_32(a, b)));
}And: mod X {
pub fn add_32(a: u32, b: u32) -> u32 {
let (_, res): (bool, u32) = jet::add_32(a, b);
res
}
}
use crate::X::add_32;
fn main() {
let a: u32 = witness::A;
let b: u32 = witness::B;
let c: u32 = witness::C;
assert!(jet::eq_32(c, add_32(a, b)));
}Both give CMR |
|
Get back to enums. Regarding their usage in std (u32_conver_test.simf), simplicity-lending, and price-oracle, it would be much more convenient and optimized to use enums instead of custom match branching |
It's not, because it creates behavior that we need to maintain, doesn't make sense to users, and which will be difficult to shoehorn into a properly-designd system. I don't think we should keep grafting ad-hoc extensions onto the existing enum implementation, nor onto the existing module system. We should fix the types and module systems properly. |
|
I have no particular opinion about the architectural/design question here, but I just wanted to mention that the issue that this solves is blocking a new Simplex demo that I made based on I can confirm from testing that this PR does effectively remove that limitation in Simplex, and so, with other minor Simplex changes, it would unblock my demo. I would love to see some solution to this issue land in SimplicityHL so that I could publish that new demo as part of Simplex (it's a lot more sophisticated than the existing We've already been building various examples on the |
|
The PR description, at least, should have some description of the issue it solves. |
Add specific identifier to
EnumInfostruct to support unique type in ABI