-
Notifications
You must be signed in to change notification settings - Fork 321
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
Clearly select single specialization with enum dispatch pattern #6819
Conversation
…ithout negative hasType check
engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java
Outdated
Show resolved
Hide resolved
Something is wrong with JSON conversions... 71ad4e8 seems to fix it. |
engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
ca1b79a
to
f32e2ba
Compare
There was a problem hiding this 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 🤷
Jaroslav Tulach reports a new STANDUP for yesterday (2023-05-24): Progress: - robustness via enum dispatch pattern: #6819
Next Day: Bugfixing
|
* 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)
…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) ...
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 toWithoutType
node. That node can safely assumevalue
doesn't have a type.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Java,