You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: RationaleMCP/0034/ReadMe.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ It was concluded in [#2211](https://github.com/modelica/ModelicaSpecification/is
8
8
9
9
The proposal is based on the following principles:
10
10
- A new built-in type, `Ternary`.
11
-
- A new literal constant `unknown` for the third truth value.
11
+
- A new top-level constant `unknown` for the third truth value.
12
12
- Explicit as well as implicit conversion from `Boolean`.
13
13
- No implicit conversion to `Boolean`.
14
14
- No new built-in functions.
@@ -28,10 +28,12 @@ All authors of this MCP or their organizations have signed the "Modelica Contrib
28
28
See [separate document](rationale.md).
29
29
30
30
## Backwards Compatibility
31
-
The introduction of the keyword `unknown` introduces a backwards incompatibility with code making use of that name for identifiers.
31
+
As built-in types are treated similar to keywords, the introduced `Ternary` introduces a backwards incompatibility with code making use of that name for identifiers.
32
+
By introducing `unknown` as a top-level constant rather than a keyword, this will not break code making use of this name for identifiers.
33
+
By deprecating uses of `unknown` that wouldn't work if `unknown` was a keyword, it will be possible to later align the syntaxes of `true`, `false`, and `unknown`.
32
34
33
35
## Tool Implementation
34
-
A prototype has been implemented in a development version of Wolfram SystemModeler. In the prototype, the type is named `__Wolfram_Ternary`, and the third truth value is named `__Wolfram_unknown`.
36
+
A prototype has been implemented in a development version of Wolfram SystemModeler. In the prototype, the type is named `__Wolfram_Ternary`, and the third truth value is named `__Wolfram_unknown`. The prototype currently has `__Wolfram_unknown` as a keyword, but will be updated to have a top-level constant instead.
35
37
36
38
The prototype is complemented with a collection of example models, provided in a separate repository: https://github.com/henrikt-ma/TernaryTest
Copy file name to clipboardExpand all lines: RationaleMCP/0034/rationale.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ For those who don't want to read through #2211 to get the background, the applic
7
7
# Rationale
8
8
The principles on which this MCP is base were listed on the [entry page](ReadMe.md), and are repeated here for convenience:
9
9
- A new built-in type, `Ternary`.
10
-
- A new literal constant `unknown` for the third truth value.
10
+
- A new top-level constant `unknown` for the third truth value.
11
11
- Explicit as well as implicit conversion from `Boolean`.
12
12
- No implicit conversion to `Boolean`.
13
13
- No new built-in functions.
@@ -20,12 +20,17 @@ Although one could imagine ternary logic only being used in annoations to just h
20
20
One could also have imagined just introducing `Ternary` as a new built-in enumeration, but expressing ternary logic in analogy with Boolean logic would then require defining the meaning of Boolean operators such as `and` to have meaning for this particular enumeration. That is probably not how we want enumerations to be used.
21
21
22
22
## New literal constant
23
-
The introduction of the keyword `unknown` to represent the third third truth value makes it very convenient to construct. Alternatives that were considered less attractive include:
23
+
The introduction of the top-level constant `unknown` to represent the third third truth value avoids the backwards incompatibility that would come with making `unknown` a keyword similar to `true` and `false`. Uses that makes it distinguishable from being a keyword are deprecated from start, to pave the way for future alignment with `true` and `false`.
24
+
25
+
Alternatives that were considered less attractive include:
26
+
- Making `unknown` a keyword similar to `true` and `false`.
24
27
- Defining `Ternary()` to construct `unknown`.
25
28
- Defining a `Ternary`-valued operation that can produce `unknown` as a function of only known values, for example `consensus(true, false)`.
26
29
27
30
The alternative approaches both suffer from the problem of not having a symmetric way of refering to _unknown_ in the same way as we refer to `false` and `true`. This lack of symmetry is both a problem for source code as well as in specification text and other places where writing about Modelica.
28
31
32
+
As shadowing the top-level `unknown` is allowed but deprecated, there can be situations where one would like to access the top-level constant while it is shadowed. It was considered to allow something like `Ternary()` to avoid the need to access the top level constant, but the current design instead relies on using the fully qualified `.unknown`. Use of the fully qualified form is deprecated from start, meaning that it should only be used when a model also contains the deprecated exostence of another identifier named `unknown`.
0 commit comments