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

Type deduction RFC #4

Merged
merged 13 commits into from Oct 20, 2020
Merged

Type deduction RFC #4

merged 13 commits into from Oct 20, 2020

Conversation

LhKipp
Copy link
Contributor

@LhKipp LhKipp commented Sep 12, 2020

No description provided.

@LhKipp LhKipp changed the title WIP Type deduction RFC Type deduction RFC Sep 13, 2020
Copy link
Contributor

@thegedge thegedge left a comment

Choose a reason for hiding this comment

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

Looks good, @LhKipp . I only focused on the content that was present, but I'll think some more about things that may have been missed and come back and add additional comments (if I think of anything missing). I added a few nitpicks, and some more important comments (which I've highlighted with a ⚠️ at the beginning of the comment)

One interesting thing I found with this RFC was that you're basically describing a large surface area of the parser. One thing that we're kind of missing right now is a good description of our parser. It's making me think about whether or not we could somehow maintain such a description 🙂

Since @jonathandturner has been reviewing some of the code you've written, and has a lot more context on this space, I'm going to lean on his thumbs up as the final 👍 to take this to consensus with the team.

text/0004-type-deduction.md Outdated Show resolved Hide resolved
text/0004-type-deduction.md Outdated Show resolved Hide resolved
text/0004-type-deduction.md Outdated Show resolved Hide resolved
text/0004-type-deduction.md Outdated Show resolved Hide resolved
text/0004-type-deduction.md Outdated Show resolved Hide resolved
text/0004-type-deduction.md Outdated Show resolved Hide resolved
text/0004-type-deduction.md Show resolved Hide resolved
text/0004-type-deduction.md Outdated Show resolved Hide resolved
(false, true) -> set_union_excluding_any(existing_deductions, set_intersection(existing_deductions, new_deductions))
(false, false) -> set_intersection(existing_deductions, new_deductions)?
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this would be simpler to reason about if we expanded SyntaxShape::Any into the set of types it can represent, and then did checked_insert like above (just a set intersection) 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good hint :)

Copy link
Member

Choose a reason for hiding this comment

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

I was just wondering that too. A kind of SyntaxShape::OneOf(a, b, c) form.

Copy link
Contributor Author

@LhKipp LhKipp Oct 8, 2020

Choose a reason for hiding this comment

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

I wonder if this would be simpler to reason about if we expanded SyntaxShape::Any into the set of types it can represent, and then did checked_insert like above (just a set intersection) thinking

After thinking this through, I am not sure whether it would simplify the implementation.
Looking closes at the pseudo code, it is obvious that:

        (true, false) -> set_union_excluding_any(new_deductions, set_intersection(existing_deductions, new_deductions))

is the same as:

        (true, false) -> new_deductions

The reason I have written it down like this is, that meta information (where was this deduction be made?) needs to get merged. If SyntaxShape::Any would be expanded into every type, handling the meta data correctly might be a pain in the concrete implementation.

I was just wondering that too. A kind of SyntaxShape::OneOf(a, b, c) form.

OneOf should then probably contain a vector of SyntaxShape variants? From my point of view this is almost the same as a vector of SyntaxShape's. It may make the code a little more declarative, but at the added cost of having a different size for the SyntaxShape enum. I would like to stick with the current pseudo code.

text/0004-type-deduction.md Show resolved Hide resolved
@fdncred
Copy link

fdncred commented Sep 15, 2020

@LhKipp I just want to add a big wow! and thank you! for this RFC. Lots of detail here.

@LhKipp
Copy link
Contributor Author

LhKipp commented Sep 17, 2020

@thegedge Thanks for your feedback. The comments I haven't answered are all valid. I will update the rfc and the implementation hopefully some time soon. I am quite bussy the next 2.5 weeks. Please first expect major progress after 2.5 weeks :).

@thegedge
Copy link
Contributor

Thanks, @LhKipp. No rush. Excited to see this come together, on whatever timeline works best for you 🙂

@LhKipp
Copy link
Contributor Author

LhKipp commented Oct 8, 2020

Thanks everyone. Your comments helped a lot to polish up this rfc.

@sophiajt
Copy link
Member

sophiajt commented Oct 16, 2020

I think this looks good. I'm okay landing it as is. Other Nushell team folks, how do you feel?

@sophiajt
Copy link
Member

Thanks all. And thanks @LhKipp for putting this together.

Accepting this RFC.

@sophiajt sophiajt merged commit 11b93a4 into nushell:main Oct 20, 2020
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.

None yet

4 participants