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

Added .pop() to Chan as a complete alternative to .succ() and .zero(). #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ebfull
Copy link

@ebfull ebfull commented Oct 21, 2015

.pop() will automatically bring the type upward from the "recursive" depth indicated by Var<N>, obviating the need for .succ().succ().succ().zero() or similar things.

Closes #25

@ebfull
Copy link
Author

ebfull commented Oct 21, 2015

One thing I have not tested is how far the compiler is willing to resolve this recursively, though I'm sure similar issues pop up anyway with highly recursive protocols.

@@ -370,7 +395,7 @@ pub struct ChanSelect<'c, T> {
}


impl<'c, T> ChanSelect<'c, T> {
impl<'c, T: 'c> ChanSelect<'c, T> {
Copy link
Author

Choose a reason for hiding this comment

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

This fixes a warning that will become a hard error in the next stable release.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks

@laumann
Copy link
Collaborator

laumann commented Oct 29, 2015

I like this - IMO it's mostly an ergonomics thing, but it still adds value. 👍

@Munksgaard
Copy link
Owner

Yeah, I like this too. One thing that might be a concern is if error messages get polluted with Pop types. I can't test it right now, but I'll try to take a look at it tonight.

@laumann
Copy link
Collaborator

laumann commented Nov 2, 2015

I understand this a little better now - pop() substitutes zero() as well, right?

EDIT: This sounds like a really silly question in hindsight...

type Tail = (A, B);
}

impl<A, B: Pop<N>, N> Pop<S<N>> for (A, B) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

How well are trait impls for tuples supported? We did this once and found out that it was a bit of an unstable feature - but that might have been at that time...

Copy link
Author

Choose a reason for hiding this comment

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

Well, it's available in stable. :) Might have been an issue before the major coherence changes earlier this year.

Copy link
Owner

Choose a reason for hiding this comment

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

Perhaps it could be done with associated types like we're using for Send, Recv, etc.?

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.

3 participants