Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove keywords *begin, *end and *then #681

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

Daniel-Cortez
Copy link
Contributor

What this PR does / why we need it:

Removes keywords *begin, *end and *then, as well as alternative syntaxes for if, switch, for, while and do-while statements, as explained in #611.

Which issue(s) this PR fixes:

Fixes #611

What kind of pull this is:

  • A Bug Fix
  • A New Feature
  • Some repository meta (documentation, etc)
  • Other

Additional Documentation:
This PR also includes the changes from #680 (they are needed to prevent a crash in one of the tests), so you'll probably want to review and merge that PR first.

@Daniel-Cortez Daniel-Cortez requested a review from a team as a code owner September 30, 2021 15:30
@YashasSamaga YashasSamaga linked an issue Oct 8, 2021 that may be closed by this pull request
@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had recent activity.

@stale stale bot added the state: stale label Jan 9, 2022
@Y-Less
Copy link
Member

Y-Less commented Mar 8, 2022

Merged locally.

@stale stale bot removed the state: stale label Mar 8, 2022
…o-while`

This includes removal of keywords `*begin`, `*end` and `*then`.
@Daniel-Cortez
Copy link
Contributor Author

Daniel-Cortez commented Mar 8, 2022

While working on this PR, I noticed one interesting detail:

main()
{
    new x = 0;
    do { ++x; } while x < 10; // this would compile, even though
                              // there are no parentheses around 'x < 10'
}

Apparently, the parentheses around the control expressions of do..while loops are optional. But for some reason they're only optional for do-while loops; in all other control flow statements (while, for, if, switch) parentheses are mandatory.
I'm not sure why there's this strange rule for do..while statements, there are no comments about this syntax in the compiler code, and the Language Guide doesn't seem to say anything about this either.

I wonder if this syntax is already used somewhere. Because if not, then removing it would allow to greatly simplify the code in function test() (sc1.c). This PR is about removing excess syntax anyway.

@Daniel-Cortez Daniel-Cortez force-pushed the remove-excess-keywords branch from 08e3086 to 6c565c5 Compare April 9, 2022 08:09
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove *begin, *end and *then
2 participants