Would something like this be useful for ltac2? https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute
I think that's a very, very useful tool to have but I am not sure how the idea of a rust crate would be mapped to Ltac2. The crucial point is that the defining crate itself doesn't have to add _
cases. If that cannot easily be recreated in Ltac2 I don't see a benefit over making the enum extensible to begin with.
I don't think that the crucial point is about the defining crate, it's just a QoL syntax. It's not critical to have to handle unknown cases even in the scope where you have control over the type, at worst you lose a little bit of safety. The interest is to force the users to have this default check.
I can imagine that this would be useful to write user extensible tactics, e.g. in Princeton VST. In some cases one would have to extend some enum or record data types for such extensions.
But extensible enums already force users to handle the default case, don't they? What's the difference to non_exhaustive
without the QoL feature of skipping the default case in the defining crate/module?
extensible enums can be extended by users too
There are also non-exhaustive structs.
Those are good points. I understand now.
Gaëtan Gilbert said:
extensible enums can be extended by users too
Yes, it is possible with Ltac2 as is. As far as I understand the suggestion, it would make it safer / easier to maintain user extensible tactics.
Last updated: Oct 12 2024 at 12:01 UTC