Skip to content

Conversation

@1RyanK
Copy link
Contributor

@1RyanK 1RyanK commented Jan 21, 2026

Switched all of the operator usage to enums. It may look like a lot of code but just about everything is converting to enums.

Closes #5325: Switch BinOp.chpl and OperatorMsg.chpl to using enums

@1RyanK 1RyanK changed the title Closes 5325: Switch BinOp.chpl and OperatorMsg.chpl to using enums Closes #5325: Switch BinOp.chpl and OperatorMsg.chpl to using enums Jan 21, 2026
@1RyanK 1RyanK force-pushed the 5325-switch_binop_chpl_and_operatormsg_chpl_to_using_enums branch 2 times, most recently from 7520d65 to 748ed5f Compare January 22, 2026 13:43
@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@a449c14). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #5326   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         4           
  Lines           ?        63           
  Branches        ?         0           
========================================
  Hits            ?        63           
  Misses          ?         0           
  Partials        ?         0           
Flag Coverage Δ
python-coverage 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@1RyanK 1RyanK marked this pull request as ready for review January 22, 2026 15:23
@ajpotts ajpotts requested a review from e-kayrakli January 22, 2026 15:26
@1RyanK 1RyanK force-pushed the 5325-switch_binop_chpl_and_operatormsg_chpl_to_using_enums branch from 748ed5f to b2cb094 Compare January 22, 2026 15:27
Copy link
Contributor

@ajpotts ajpotts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

}
select op {
when "//" { // floordiv
when Operator.FloorDiv { // floordiv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment is not necessary anymore thanks to self-documenting code!

visted = true;
}
when "%" { // modulo " <- quote is workaround for syntax highlighter bug
when Operator.Mod { // modulo " <- quote is workaround for syntax highlighter bug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto. I am almost certain the workaround is no longer necessary as you removed the quote, too.

}
when "**=" { l.a **= r.a; }
when "%=" {
when OpEq.Ee { l.a **= r.a; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the most cryptic name to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was "exponent-equals," I already have "Pe" for "plus-equals," so I didn't want to put it as "pow-equals." I guess I could do "Poe" for "pow-equals" in the same way I have "Moe" for "mod-equals."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I don't think this is a single point that needs changing. See my other comment for naming change suggestions.

enum OpEq {
Invalid,
Pe, Me, Te, De, Fde, Moe, Ee, Oe, Ae, Xe, Sle, Sre
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some notes here:

  • Is the separation of enums well-motivated? From a systems perspective, everything is an operator. Whether it is a compound operator that modifies LHS doesn't seem very relevant to me.
  • If we are separating enums, and using qualified names like Operator.Add, and OpEq.Pe, we can keep the enum values identical. i.e. Operator.Add, and OpEq.Add. Though I don't like this idea.
  • Instead, regardless of whether we use the same or separate enums, I prefer Add and AddE (or Adde). As per Chapel style guidelines, they should be operator.add and operator.addE. (both the enum and the values are ought to be snakeCase). I don't necessarily think we should enforce that here, but just noting. As it stands, one operator is referring to the operation, the other is referring to the operator. This requires more mental energy from the maintainer.
  • If you want to avoid qualifying enums' values (i.e. Operator.Add vs just Add), you can use Operator. Verbosity didn't bother me here at all, but just wanted to make sure that you are aware of that option.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch BinOp.chpl and OperatorMsg.chpl to using enums

4 participants