Skip to content

[RFC] case statement with renamed type values #36

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

@yannickmoy
Copy link
Contributor

Hi @GyorgyRotter can you reformat your PR? It does not display well correctly, which makes it hard to follow. See the link at the top for how it is displayed currently. thx

@GyorgyRotter
Copy link
Author

Hi, please check and read it

@yannickmoy
Copy link
Contributor

I fear that others will consider it confusing that you can use "a | a" in a case statement or expression. It seems that the current workaround that you mentioned of using "a .. x", in the quite special case you refer to where x is a renaming of a (and you don't have more renamings), provides what you need, except for the syntax using | instead of ..

@GyorgyRotter
Copy link
Author

Hi,
I think if the compiler could distinguish between the a and it's renamed type value x we may exclude such cases.
In this case to refer the same type value could be forbidden in this "a | a" form but could be allowed in "a | x" form.
This could make possible to use multiple renames what the current implementation does not make possible by .. when we are writing this "when a .. x | a .. y" (where "y" is an other rename for "a").
Currently if I understand well for the compiler it is totally equivalent to "when a .. a | a .. a" which is forbidden because of "when a | a" was also forbidden.
With this distinction could produce more readable code in the case of e.g. complex state machines when we could look at the name of the states from different perspectives and we would like to express it in our case statement. I think it would be a nice feature.

@yannickmoy
Copy link
Contributor

Hi @GyorgyRotter. I suggest you try to get support for this feature from other Ada developers, so that they weight in this discussion. Otherwise, I fear most people may just push back due to the possibility for undesirable ambiguities that would be possible with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants