-
Couldn't load subscription status.
- Fork 208
add multiverse lookup to Type #309
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
base: master
Are you sure you want to change the base?
Conversation
|
|
|
Welcome @ziyue-101! |
|
Hi @ziyue-101. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/assign @thockin @yongruilin |
|
Thanks @ziyue-101! Can you please add tests for this? |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ziyue-101 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@jpbetz |
|
/ok-to-test |
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.
I think this can be simpler still.
41c00a5 to
7c1013b
Compare
|
@ziyue-101: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
| // generation. For example the imported code my have T but not *T, while the generated code needs *T. This | ||
| // can't be part of the main Universe because that is a simple map, with no locking, and we all know what happens | ||
| // when you modify a map while it is being iterated. Storing the multiverse alongside a Type ensures that there's | ||
| // at most one *Type for every type, and maintains the invariant that PointerTo(String) == PointerTo(String). |
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.
Super not since I am leaving other comments. s/String/T in the invariant
|
|
||
| // InitMultiverse inits a multiverse for a Type. | ||
| // It panics if called twice. | ||
| func (t *Type) InitMultiverse(u Universe) { |
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.
Just call it Init -- multiverse is an implementation detail, it doesn't need to leak into the API
| // It panics if called twice. | ||
| func (t *Type) InitMultiverse(u Universe) { | ||
| if t.multiverse != nil { | ||
| panic("Can't initialize a non-empty multiverse on Type") |
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.
"can't re-initialize type %v"...
| multiverse: &multiverse{ | ||
| real: u, | ||
| synthetic: map[string]*Type{ | ||
| "*pkgname.thridstructname": &Type{ |
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.
s/thrid/third
Or just call these T1, T2, T3 :)
| func (p *Parser) walkType(u types.Universe, useName *types.Name, in gotypes.Type) *types.Type { | ||
| var out *types.Type | ||
| defer func() { | ||
| out.InitMultiverse(u) |
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.
I just realized someone needs to call this on all of the builtin types. This means that there can be only 1 Universe because the builtins are global variables, which have a single multiverse pointer each. That makes me sad.
Can you think of any alternative that is not so limited?
Is the cure worse than the sickness? I don't like that PointerTo(T) != PointerTo(T) but if there were two universes active T != T, anyway...
Have to think on this...
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.
Revisiting this - I still don't know what we should do.
Large-scale redesign of gengo apps (e.g. making the Universe the central abstraction, passing it everywhere, so instead of types.String you might use u.String() or u.PointerTo(t)) seems unlikely.
Making a global universe (so there can't be more than one) seems plausible but amounts to gengo v3, and I don't see anyone working on that right now, especially without some other driver.
We could pre-populate a t.Pointer up to some level of depth (e.g. ***T) and thast "should be enough for anyone" but requires more gengo work.
I'm letting this sit for now until it is clearer what we need.
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle stale |
Fixes: #298