Skip to content

Commit b7ab0b1

Browse files
committed
Change 'unknown' from keyword to top-level constant
1 parent dd4a298 commit b7ab0b1

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

RationaleMCP/0034/ReadMe.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It was concluded in [#2211](https://github.com/modelica/ModelicaSpecification/is
88

99
The proposal is based on the following principles:
1010
- 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.
1212
- Explicit as well as implicit conversion from `Boolean`.
1313
- No implicit conversion to `Boolean`.
1414
- No new built-in functions.
@@ -28,10 +28,12 @@ All authors of this MCP or their organizations have signed the "Modelica Contrib
2828
See [separate document](rationale.md).
2929

3030
## 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`.
3234

3335
## 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.
3537

3638
The prototype is complemented with a collection of example models, provided in a separate repository: https://github.com/henrikt-ma/TernaryTest
3739

RationaleMCP/0034/rationale.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ For those who don't want to read through #2211 to get the background, the applic
77
# Rationale
88
The principles on which this MCP is base were listed on the [entry page](ReadMe.md), and are repeated here for convenience:
99
- 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.
1111
- Explicit as well as implicit conversion from `Boolean`.
1212
- No implicit conversion to `Boolean`.
1313
- No new built-in functions.
@@ -20,12 +20,17 @@ Although one could imagine ternary logic only being used in annoations to just h
2020
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.
2121

2222
## 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`.
2427
- Defining `Ternary()` to construct `unknown`.
2528
- Defining a `Ternary`-valued operation that can produce `unknown` as a function of only known values, for example `consensus(true, false)`.
2629

2730
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.
2831

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`.
33+
2934
## Conversion from Boolean
3035

3136
### Explicit conversion

0 commit comments

Comments
 (0)