-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__OpenModelica_tearingSelect annotation uses undeclared identifiers #11949
Comments
Ping @casella @kabdelhak @phannebohm for input. |
I would recommend |
I agree we shouldn't leave it like it is. On the other hand the modeler is allowed to have a class called |
Yes, that was my concern. But thinking a bit more about it we shouldn't add it to the top-level scope but to the annotation scope, which is checked last and only in annotations. That way there won't be any name conflicts and a userdefined I tried looking up what other vendors are doing but I couldn't find any examples of using enumerations in vendor annotations, only strings and magic numbers instead. |
Absolutely. The point of __OpenModelica annotations is that we are free to define whatever annotations we want, whereas variable attributes must be defined by the Modelica Language Specification; if we write Real x(TearingSelect = tearingSelect.always); this would actually be illegal code and it could be rejected by other Modelica tools. |
That's not really relevant here, the issue is that if we define it as |
I get your point, but as a matter of fact, all tools other than OMC can just skip __OpenModelica annotations entirely, without even the need of actually parsing them further. So why bother. Do I miss something? |
I'm not really concerned about other tools, as long as the annotation uses standard syntax it shouldn't cause any issues. It's more that if we want to add enumeration types that can be instantiated by the compiler (which we do for e.g. The likelyhood that adding a |
I agree that we shouldn't pollute the namespace, but it is also true that there the chance of this being a problem is much lower than the chance that omc segfaults because of some other issue. I would tentatively add it, and possibly remove it or change it if somebody complains. |
- Add `TearingSelect` enumeration type to the annotation environment. - Change `__OpenModelica_tearingSelect` to also accept `TearingSelect` values in addition to the existing identifiers such as `always`. - Give a deprecation warning when using the old identifiers with `__OpenModelica_tearingSelect`. Fixes OpenModelica#11949
- Add `TearingSelect` enumeration type to the annotation environment. - Change `__OpenModelica_tearingSelect` to also accept `TearingSelect` values in addition to the existing identifiers such as `always`. - Give a deprecation warning when using the old identifiers with `__OpenModelica_tearingSelect`. Fixes OpenModelica#11949
- Add `TearingSelect` enumeration type to the annotation environment. - Change `__OpenModelica_tearingSelect` to also accept `TearingSelect` values in addition to the existing identifiers such as `always`. - Give a deprecation warning when using the old identifiers with `__OpenModelica_tearingSelect`. Fixes OpenModelica#11949
- Add `TearingSelect` enumeration type to the annotation environment. - Change `__OpenModelica_tearingSelect` to also accept `TearingSelect` values in addition to the existing identifiers such as `always`. - Give a deprecation warning when using the old identifiers with `__OpenModelica_tearingSelect`. Fixes OpenModelica#11949
- Add `TearingSelect` enumeration type to the annotation environment. - Change `__OpenModelica_tearingSelect` to also accept `TearingSelect` values in addition to the existing identifiers such as `always`. - Give a deprecation warning when using the old identifiers with `__OpenModelica_tearingSelect`. Fixes OpenModelica#11949
- Add `TearingSelect` enumeration type to the annotation environment. - Change `__OpenModelica_tearingSelect` to also accept `TearingSelect` values in addition to the existing identifiers such as `always`. - Give a deprecation warning when using the old identifiers with `__OpenModelica_tearingSelect`. Fixes #11949
The
__OpenModelica_tearingSelect
annotation currently uses simple identifiers as the values, e.g.__OpenModelica_tearingSelect=always
. In the context of Modelica this makes little sense since e.g.always
isn't declared anywhere, and if it where (which probably would be a really bad idea) it wouldn't be a value in itself but a variable with some binding equation.This can be problematic since annotations are expected to follow the normal Modelica rules, and breaking that expectation makes it harder to deal with in the compiler. For example, in #11948 I had to add an exception specifically for
__OpenModelica_tearingSelect
because of this.As I see it there are two alternatives, using strings (
"always"
) or an enumeration (e.g.TearingSelect.always
). I would lean towards strings since that doesn't require adding anything to the top-level scope.We should obviously also keep the current semantics for a while since people use it, but add a deprecation warning for it.
The text was updated successfully, but these errors were encountered: