Replies: 3 comments
-
|
Cameleer does not currently support aliasing of exception names (but fails with a very bad error message; I will work on this). From the Gospel perspective, I have the following understanding:
|
Beta Was this translation helpful? Give feedback.
-
|
In order to support exceptions aliasing in Cameleer, since Why3 does not support exceptions aliasing, I am thinking about a very ad-hoc to solve this. Consider ? Meaning, I would have to collect the disjointedness permission and build a disjoint-set to fill a |
Beta Was this translation helpful? Give feedback.
-
|
@mariojppereira, your proposal (which is to make it clear in the code that the handler catches both I think we need to answer at least the following two questions:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Paulo de Vilhena (@DeVilhena-Paulo) and I would like to point out that in OCaml there can be aliasing between exception names, and ask how Gospel (and its tools) face this issue.
The problem stems from two main sources, we believe:
The possibility of declaring
exception E1 = E2. This causes the static namesE1andE2to refer to the same dynamic name.The possibility of writing a functor with two parameters
M1andM2, each of which declares an exceptionE, and of instantiating this functor with twice the same moduleM. This causes the static namesM1.EandM2.Eto refer to the same dynamic name.In summary, the fact that two exceptions
E1andE2have different static names does not imply that these exceptions have distinct dynamic names. In some situations, it is possible to tell that they do have distinct dynamic names; this is typically the case when the definitions of these exceptions are local and visible. Most of the time, however, because of separate compilation and abstraction barriers, it is impossible to tell.Naïvely ignoring this problem can lead to unsound reasoning: if
E1andE2denote the same dynamic name, then an exception handler that appears to catch justE1actually catches bothE1andE2. (@mariojppereira , does Cameleer defend against this danger, and if so, how?)To work around this problem in Gospel, we believe that we may need:
For instance, a function (or functor) whose verification needs
E1andE2to denote distinct dynamic names might publish the hypothesisE1 ≠ E2. (A more lightweight syntax may be needed, in order to avoid publishing a quadratic number of hypotheses. A separating conjunction of uniqueness hypotheses is a possibility.)A module that creates a fresh exception name (by declaring
exception E) might publish the fact that it uniquely owns this name. A functor that takes two parametersM1andM2might require unique ownership tokens for bothM1.EandM2.E, which implies that these static names must denote distinct dynamic names.The details are unclear to us; we believe that this topic might deserve discussion.
Beta Was this translation helpful? Give feedback.
All reactions