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

RFC: Give MethodMatch its own type #36702

Merged
merged 1 commit into from
Jul 20, 2020
Merged

RFC: Give MethodMatch its own type #36702

merged 1 commit into from
Jul 20, 2020

Conversation

Keno
Copy link
Member

@Keno Keno commented Jul 17, 2020

Every time I see any code dealing with the svecs we get back from
the method match code, I think that it shouldn't really be an svec:

  1. It's always the same length
  2. Basically every use of it typeasserts the field type
  3. Every use of it needs the same magic numbers to access the fields.

All put together this should just be a type. This basically does that,
but there's a few things missing, so before I go finish it, I figured,
I'd make sure that there isn't some reason not to do this.

TODO:

  1. (deprecated) getindex/iterate for MethodMatch to avoid breaking packages that use the internal API
  2. Make the bitfield a uint8_t for compatibility with compiler that use a different layout
  3. Double check the gf.c changes. I think I fatfingered one of the mappings.

Doesn't need extensive review in this state, since it isn't done,
just a quick yay/nay on the direction.

@JeffBezanson
Copy link
Sponsor Member

Yes I definitely like this.

src/jltypes.c Outdated
@@ -2383,6 +2384,11 @@ void jl_init_types(void) JL_GC_DISABLED
jl_perm_symsvec(2, "typ", "fields"),
jl_svec2(jl_any_type, jl_array_any_type), 0, 0, 2);

jl_method_match_type = jl_new_datatype(jl_symbol("MethodMatch"), core, jl_any_type, jl_emptysvec,
jl_perm_symsvec(4, "metharg", "methsp", "method", "fully_covers"),
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Can we give these real words? (or at least the same mangling we do now):
signature (or specTypes), env (or sparam_vals), method, <: (or whatever this is)?

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 is what they were called in inlining. I agree we can pick better names. How about just specTypes, sparams, method, fully_covers? I don't like using <: as a field name.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

How about not mixing snake case and camel case? 😬

Copy link
Member Author

Choose a reason for hiding this comment

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

spec_types then, though at some point we should also switch over MethodInstance then.

@Keno Keno force-pushed the kf/methodmatch branch 2 times, most recently from 5dfd35e to 606cd91 Compare July 19, 2020 05:39
@Keno Keno marked this pull request as ready for review July 19, 2020 05:39
@Keno
Copy link
Member Author

Keno commented Jul 19, 2020

Alright, this should be done now.

Every time I see any code dealing with the svecs we get back from
the method match code, I think that it shouldn't really be an svec:
1. It's always the same length
2. Basically every use of it typeasserts the field type
3. Every use of it needs the same magic numbers to access the fields.

All put together this should just be a type. This updates all
the uses accordingly, but adds fallback getindex/iterate defintions
for external users that expect this to be a SimpleVector (in
deprecated.jl - hopefully by 2.0 all external users will upgraded).
@Keno Keno merged commit 2cca0a4 into master Jul 20, 2020
@Keno Keno deleted the kf/methodmatch branch July 20, 2020 19:57
simeonschaub pushed a commit to simeonschaub/julia that referenced this pull request Aug 11, 2020
Every time I see any code dealing with the svecs we get back from
the method match code, I think that it shouldn't really be an svec:
1. It's always the same length
2. Basically every use of it typeasserts the field type
3. Every use of it needs the same magic numbers to access the fields.

All put together this should just be a type. This updates all
the uses accordingly, but adds fallback getindex/iterate defintions
for external users that expect this to be a SimpleVector (in
deprecated.jl - hopefully by 2.0 all external users will upgraded).
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.

4 participants