-
Notifications
You must be signed in to change notification settings - Fork 324
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
Reducing helper methods in Standard.Base.Meta
#12031
base: develop
Are you sure you want to change the base?
Conversation
check x y = Meta.is_a x y |
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.
Calling Meta.is_a
doesn't really work with EnsoMultiValue
- another problem to keep in mind for
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.
What do you mean by "doesn't work"? Does it return wrong results, or raise an error?
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.
It extracts the first value from EnsoMultiValue
and dispatches to it, I think.
@@ -491,7 +388,7 @@ type Language | |||
Arguments: | |||
- value: The value to check. | |||
is_atom_constructor : Any -> Boolean | |||
is_atom_constructor value = @Builtin_Method "Meta.is_atom_constructor" | |||
is_atom_constructor value = @Tail_Call Meta_Helpers.is_atom_constructor_builtin value |
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.
This could be rewritten as Meta.meta value . is_a Meta.Atom
, but I guess that's too complicated? Or isn't it?
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.
Does it have any usages?
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.
|
||
## PRIVATE | ||
instrumentor_builtin op args = @Builtin_Method "Meta.instrumentor_builtin" | ||
get_qualified_type_name value = @Tail_Call Meta_Helpers.get_qualified_type_name_builtin value |
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.
This should be (Meta.meta value : Meta.Type) . qualified_name
. There is quite a few usages, but I can rewrite them if we think it is a good idea?
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.
Given there are so many usages I think it may be good to have one common method that encapsulates this common pattern instead of reproducing the 'assert type + get qualified_name' in every place.
Function anyFun = symbol.getScope().lookupMethodDefinition(any, symbol.getName()); | ||
if (anyFun != null) { | ||
function = anyFun; | ||
if (selfTpe.getDefinitionScope().getAssociatedType() != selfTpe) { |
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.
Refines
to give precedence to Meta.is_a
over Any.is_a self
, just like it used to be done when Meta.is_a
was a builtin.
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.
- separated into its own Prefer module methods over
Any
instance ones #12048
Any.check_is self t = "got to Any for "+self.to_text+" and "+t.to_text | ||
dispatch a = Type_With_Check.check_is a |
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.
- this case remains the same as specified by Always call instance methods on Any #7033
Standard.Base.Meta
Pull Request Description
Let's reduce the amount of code inside of
Meta.enso
in preparation of #5226.Important Notes
Meta.is_a
from a builtin into regular method had its issues - solved by Prefer module methods overAny
instance ones #12048Another set of provides is related to making
Meta.Type
,Meta.Atom
, etc. constructors private. Turned out the whole type was considered private and for exampleMeta.Type.find
was no longer accessible.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Java,