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

Variadic tuples #2775

Closed

Conversation

fredericvauchelles
Copy link

@fredericvauchelles fredericvauchelles commented Oct 2, 2019

This RFC introduce variadic tuples, and API to handle tuples with an arbitrary arity.

Rendered
Internal's thread

@fredericvauchelles
Copy link
Author

A small update concerning the feedbacks received. First thanks for your feedbacks, I will take them into account, as they are a lot of them I will process them over several days.

Cons-list

As suggested I looked at other RFCs and focused mostly on cons-list proposals (like #2702).

To do so, I wrote some use case with both RFCs (https://gist.github.com/fredpointzero/7b40e93d3e2226ca4aec00fdd1bc3e20).

Note: I used a less gross syntax for the variadic tuple RFC, by using

for (k, map), (Key, Value) in (&k, &self.maps), (K, V) {
    HashMap::<Key, Value>::get(&map, k)
}

// Instead of
for (k, map) <Key, Value> @in (&k, &self.maps) <K, V> {
    HashMap::<Key, Value>::get(&map, k)
}

What I found is:

  1. The RFC I suggested includes cons-list as well. (See Rev implementation) so this is as expressive as cons-list proposals
  2. A lot of implementations can be implemented only with cons-lists (See Hash, Merge, Zip, ...)
  3. Some implementations can't be implemented or are very difficult to implement with only cons-lists (See MegaMap, Split)
  4. This RFC is probably more complex to implement in Rust language than other proposals

So, in my opinion, both cons-list and iterative patterns must be available to use when considering variadic tuples.

I haven't looked at hlist yet, but I will do later.

Clarity of the RFC

The current document is not clear and I will first focus on making it easier to understand. Mostly the guide-level section.

For loop syntax

I am not fan of the syntax as well, and still will try to come up with something better.

A little note here, although the feature is powerfull enough without the variadic tuple iteration, I prefer to make sure that the variadic tuple iteration is possible, at least in future possibilities. In my opinion, this is required to implementent some features easily.

And a quick suggestion here, to have something less gross we can use the syntax suggested above.
Or also, as the issue is about iterating through two kinds of variable (variadic tuple members and variadic tuple type members) we may use two for loops, like:

for (k, map) in (&k, &self.maps)		// variadic tuple
for (Key, Value) in (K, V) {			// variadic tuple type
    HashMap::<Key, Value>::get(&map, k)
}

// Instead of
for (k, map) <Key, Value> @in (&k, &self.maps) <K, V> {
    HashMap::<Key, Value>::get(&map, k)
}

Comment on lines +225 to +227
let (head, tail @ ..): (Head, (..Tail)) = source;
let (head, tail @ ..): (&Head, (..&Tail)) = &source;
let (head, tail @ ..): (&mut Head, (..&mut Tail)) = &mut source;
Copy link
Member

Choose a reason for hiding this comment

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

Is &Tail a reference to the tail or a tuple of references? The former would prevent currently performed struct layout optimizations, see rust-lang/unsafe-code-guidelines#105 for more details. The latter would be costly since could require a lot of intermediate values on the stack.

Choose a reason for hiding this comment

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

It's a tuple of references.

@fredericvauchelles
Copy link
Author

A quick update on this, I need to handle an unfortunate private event, so I pause my work here and resume it in a few weeks

@jonas-schievink jonas-schievink added A-tuples Proposals relating to tuples. T-lang Relevant to the language team, which will review and decide on the RFC. labels Nov 22, 2019
@nico-abram
Copy link

@fredpointzero It's been a few weeks, could you provide any status updates? I'm just a slightly too curious onlooker :P

Thank you for your work so far.

@fredericvauchelles
Copy link
Author

@nico-abram Unfortunately, I don't think I will be able to have enough spare time now to work on this PR, so I do not plan to work on it in the near future.

I'll be glad if someone could continue this PR

@nikomatsakis
Copy link
Contributor

Hello,

We discussed this RFC recently in the lang team's backlog bonanza effort. The idea of variadic generics is one that has come up a number of times. It's a feature we would like to have, but at the same time, one that we feel like will require some significant bandwidth on the lang team's part to do properly and we don't think the time is quite ripe for that. Therefore, we are going to move to close this RFC.

However, we do expect to pick up this topic again at some point, and when we do, it would be great if we have summaries of the various approaches that have been considered to solve it and what their strong/weak points were. To that end, we would like to strongly encourage @fredpointzero or others on this thread to help us in growing the "lang team design notes" section of the web site. The idea would be to prepare a PR rather like rust-lang/lang-team#52 which adds notes and links about variadic generics. If new ideas come up, then follow-up PRs could be added too.

Thanks to @fredpointzero and all the participants in this thread for the RFC.

@rfcbot fcp close

@rfcbot
Copy link
Collaborator

rfcbot commented Oct 19, 2020

Team member @nikomatsakis has proposed to close this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. disposition-close This RFC is in PFCP or FCP with a disposition to close it. labels Oct 19, 2020
@nikomatsakis
Copy link
Contributor

@rfcbot reviewed -- I have checked the names of folks who were in the backlog bonanza meeting where we discussed this, at least to my recollection.

@rfcbot rfcbot added the final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. label Oct 19, 2020
@rfcbot
Copy link
Collaborator

rfcbot commented Oct 19, 2020

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. label Oct 19, 2020
@dlight
Copy link

dlight commented Oct 23, 2020

Why is this a close, and not a postpone like #2666 ?

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this RFC. and removed final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. labels Oct 29, 2020
@rfcbot
Copy link
Collaborator

rfcbot commented Oct 29, 2020

The final comment period, with a disposition to close, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC is now closed.

@rfcbot rfcbot added to-announce closed This FCP has been closed (as opposed to postponed) and removed disposition-close This RFC is in PFCP or FCP with a disposition to close it. labels Oct 29, 2020
@rfcbot rfcbot closed this Oct 29, 2020
@PoignardAzur
Copy link

@nikomatsakis It's not exactly what you asked, but I did a survey of variadic generics here: https://gist.github.com/PoignardAzur/aea33f28e2c58ffe1a93b8f8d3c58667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tuples Proposals relating to tuples. closed This FCP has been closed (as opposed to postponed) finished-final-comment-period The final comment period is finished for this RFC. T-lang Relevant to the language team, which will review and decide on the RFC. to-announce
Projects
None yet
Development

Successfully merging this pull request may close these issues.