-
Notifications
You must be signed in to change notification settings - Fork 6
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
Unary minus unsupported in math expressions #432
Comments
I would propose to add support for negative numeric literals (e.g., Option 1: Only support negative numeric literals without parentheses
Con: This interpretation is not consistent to Ada. The need for removing parentheses is uncommon and thus confusing. Option 2: Change syntax of aggregates with single element2.1: Pro: Similar to Ada. 2.2: Pro: Simple and obvious syntax. |
Option 3: Change syntax of aggregates
Pro: No ambiguities wrt. to parenthesizing |
Option 2.1 is something I always hated about Ada aggregates and I always found it a confusing technicality. I don't think option 1 is favorable either - users will be confused about expressions that look perfectly valid. Option 2.2 is okayish, but the difference between a single-element aggregate and a parenthesized number is still minimal (which again may confuse users). I'm also not a big fan of the trailing comma. Maybe we should switch to backets like in Python lists? Aggregates are not that common in our specs after all and I don't want to be Ada-compatible at any cost. |
I like the idea of using square brackets. That would be my preferred option. 2.2 would be fine too. |
Option 2.1 is clear as long as one is used to the Ada syntax, it might be confusing otherwise. Option 2.2 is something I really dislike as it introduces an error possibility by forgetting a single symbol (especially since the error leads to changing the type of the expression instead of an invalid syntax). Option 3 with square brackets would be okay for me since this is a common syntax for aggregates and also already discussed here. |
Interesting! Then square brackets it is. |
Introducing an expression representation which is incompatible with Ada has some implications. Currently, we just use the same expression classes for representing our specification in Python as for generating Ada code. This will not work anymore, when aggregates have a different syntax. That is why I would decouple both representations by duplicating the existing expression hierarchy into the Ada module. This separation has also the advantage, that it makes clear which expressions need support for additional functionality like simplification, substitution, Z3 proof or typing, and which not (expressions in our specification vs. expressions needed for Ada). |
Use square brackets `[]` instead of parentheses `()` for aggregates. Ref. #432
Use square brackets `[]` instead of parentheses `()` for aggregates. Ref. #432
Use square brackets `[]` instead of parentheses `()` for aggregates. Ref. #432
Use square brackets `[]` instead of parentheses `()` for aggregates. Ref. #432
Expressions with unary minus (aka. negation) are not excepted by our parser:
Why is it needed? Our simplification produces these kind of expressions:
If we want to be able to parse the result, we need to support unary minus. Another option would be to fix the simplification to avoid these changes.
The text was updated successfully, but these errors were encountered: