Skip to content
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

Clearly select single specialization with enum dispatch pattern #6819

Merged
merged 7 commits into from
May 24, 2023

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented May 24, 2023

Pull Request Description

Many of our specializations have complicated guards. They accept one alternative, but try to avoid others with negative checks. It is messy and problematic to keep consistency when expanding the guards. This PR proposes enum dispatch pattern instead. The algorithm to select a specialization is encoded in find method - whatever gets selected is the right @Specialization. No need for negative guards.

Since a86fd22 the check of types.hasType is performed and if not, all the other operations are delegated to WithoutType node. That node can safely assume value doesn't have a type.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • All code follows the
    Java,
  • All code has been tested:
    • Unit tests have been written where possible.

@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label May 24, 2023
@JaroslavTulach JaroslavTulach self-assigned this May 24, 2023
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented May 24, 2023

Something is wrong with JSON conversions... 71ad4e8 seems to fix it.

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

That enum dispatch pattern looks so much cleaner than the guards that we have before which kind of grew over time to be a bit messy and it was pretty hard to see if the condition of being disjunctive was even satisfied. The new code is so much easier to understand! 🎉

Just 2 small questions/suggestions above.

@JaroslavTulach JaroslavTulach force-pushed the wip/jtulach/UniqueSpecialization_6682 branch from ca1b79a to f32e2ba Compare May 24, 2023 14:59
Copy link
Contributor

@hubertp hubertp left a comment

Choose a reason for hiding this comment

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

👍 although I assumed that such semantics of matching on the type of the polyglot value were desired and correct. Wasn't aware this has changed 🤷

test/Tests/src/Semantic/Case_Spec.enso Show resolved Hide resolved
@JaroslavTulach JaroslavTulach merged commit 792cbc4 into develop May 24, 2023
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/UniqueSpecialization_6682 branch May 24, 2023 18:42
@enso-bot
Copy link

enso-bot bot commented May 25, 2023

Jaroslav Tulach reports a new STANDUP for yesterday (2023-05-24):

Progress: - robustness via enum dispatch pattern: #6819

Next Day: Bugfixing

Google Docs
| 2nd meeting: May 30, 2023 ⋅ 3:15pm – 4pm, Join with Google Meet 1st meeting: May 24, 2023 ⋅ 3:15pm – 4pm Central European Time - Warsaw Motto Once upon a time there was a bug report: #6553 … and then a discussion started… Overview A discussion has recently been held in our discord channe...

Procrat added a commit that referenced this pull request May 26, 2023
* develop:
  Allow casting a Mixed column into a concrete type (#6777)
  Stop graph editing when in full-screen visualization mode (#6844)
  Handle `show-dashboard` event (#6837)
  Fix some dashboard issues (#6668)
  Fix JWT leak (#6815)
  Fix "set username" screen (#6824)
  Fallback to opened date when ordering projects (#6814)
  Various test improvements to increase coverage and speed things up (#6820)
  do not activate nested dropdowns together (#6830)
  Clearly select single specialization with enum dispatch pattern (#6819)
  Prevent incorrect application of list widget on incompatible expressions (#6771)
Procrat added a commit that referenced this pull request May 30, 2023
…le-6756-6804

* develop: (22 commits)
  Coalesce graph editor view invalidations (#6786)
  Append warnings extracted before tail call execution (#6849)
  Detect and override hooks of the same kind (#6842)
  Dynamic app resampling and better performance measurements. (#6595)
  Show spinner when opening/creating a project, take #2 (#6827)
  Infrastructure for testing inter project imports and exports (#6840)
  Only initialise visualisation chooser if it is used. (#6758)
  Allow casting a Mixed column into a concrete type (#6777)
  Stop graph editing when in full-screen visualization mode (#6844)
  Handle `show-dashboard` event (#6837)
  Fix some dashboard issues (#6668)
  Fix JWT leak (#6815)
  Fix "set username" screen (#6824)
  Fallback to opened date when ordering projects (#6814)
  Various test improvements to increase coverage and speed things up (#6820)
  do not activate nested dropdowns together (#6830)
  Clearly select single specialization with enum dispatch pattern (#6819)
  Prevent incorrect application of list widget on incompatible expressions (#6771)
  Update GraalVM to 22.3.1 JDK17 (#6750)
  Import/export syntax error have more specific messages (#6808)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants