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

Reducing helper methods in Standard.Base.Meta #12031

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Jan 9, 2025

Pull Request Description

Let's reduce the amount of code inside of Meta.enso in preparation of #5226.

Important Notes

Another set of provides is related to making Meta.Type, Meta.Atom, etc. constructors private. Turned out the whole type was considered private and for example Meta.Type.find was no longer accessible.

Checklist

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

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

check x y = Meta.is_a x y
Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, is_atom_constructor doesn't seem to have any usages, but for example is_atom is tested:

Usages of is_atom


## 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
Copy link
Member Author

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?

Copy link
Member

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) {
Copy link
Member Author

@JaroslavTulach JaroslavTulach Jan 13, 2025

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any.check_is self t = "got to Any for "+self.to_text+" and "+t.to_text
dispatch a = Type_With_Check.check_is a
Copy link
Member Author

Choose a reason for hiding this comment

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

@JaroslavTulach JaroslavTulach added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Jan 13, 2025
@JaroslavTulach JaroslavTulach changed the title Moving @Builtin_Method definitions outside of Meta Reducing helper methods in Standard.Base.Meta Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants