-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Use for
to introduce universal quantification
#157
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use for
to introduce universal quantification
#157
Conversation
Interesting proposal. I would prefer adding the keyword That said, I think that the idea of explicit quantification could be useful with e.g. a revised form of RFC PR 105 (Unboxed, abstract return types). In the case of wanting to return some value that conforms to fn my_transform<T, Iter: Iterator<T>, exists RIter: Iterator<T>>(iter: Iter) -> RIter { ... } But if we allow This suggests that instead we should have a different keyword to introduce a type parameter list for the use of higher-rank lifetimes. I don't have a good suggestion for what to use, though. Alternatively, we could just use nothing and continue to allow un-prefixed type parameter lists to appear in type position in a function signature like we do today. |
I suppose an approach that allows the prefix style again is to use forall<T, Iter: Iterator<T>>
exists<RIter: Iterator<T>>
fn my_transform(iter: Iter) -> RIter { ... } But it's not that great either. And allowing a prefix-style Given that, I'm not in favor of this approach. But I thought it was worth documenting. The other problem is this requires |
What I was trying to point out in the Motivation is that these distinct semantic meanings are very similar.
I don't think existential quantification is necessarily the right way to think about this.
Are you opposed to syntactic sugar on principle? Should we remove (I personally think TIOOWTDI is important on the semantic level, but inconsequential on the syntactic one.) |
No, but I don't see |
I think of Anyway, this branch of the discussion belongs in #122. |
I personally don't see the current syntax as problematic. Even if it were, adding more characters and making people sort out another meaning of |
-1. It is widely acknowledged that function signatures (and typaram declarations specifically) are a problem, but this does nothing to solve any of the verbosity that we currently suffer (it makes it worse, in fact). We need a more widespread and cohesive redesign here, rather than having everyone chuck syntax at the wall independently. |
I suspect, but am not sure, that you might be misreading the proposal. The motivation has nothing to do with solving the "problem" of function signatures and typaram declarations, and the RFC isn't proposing any change to them. The motivation is only to (a) make the syntax for higher-rank types a bit more obvious and (b) suggest The only proposed change to the current language is to the syntax of higher-rank closure types. To repeat the example from the RFC: Before:
After:
RFC PR #122 was only brought up as another example where such a keyword would be appropriate if we were to adopt it. (This kind of thing - an example to clarify the proposal or its motivation getting confused for the proposal itself - seems to be a recurrent problem with my RFCs. I guess I need to make this even more explicit in the future.) |
Higher-rank lifetimes seem like an excellent place to add more characters if it makes them more distinctive / makes them easier to read / makes their meaning clearer. They're going to be a new and unfamiliar concept to the vast majority of people, so clear and distinctive is good, and occur infrequently, so verbosity is not a significant issue. |
And because we're supposed to respond to things from the recommended-for-discussion-at-meeting emails in the PR comments instead of to the email, even though I still feel strange doing this:
Once again this is a fundamental misreading of the proposal. I refer you to my previous response to @bstrie. |
@glaebhoerl ah, apologies for misreading the proposal. I got the wrong impression from the title and summary and skimming the comments. I'll have a proper read through (as advice, I would say that the smaller the effect of an RFC the more likely it is to be accepted, so you should write your title and summary to give a clear indication of the scope of the changes. In this case, the reader does not find out that the proposal only applies to closures and not all functions until line 28, by which point I had given up, assuming (presumptuously) it would never be accepted and there was no point in spending more time). |
Thank you for this proposal. Although closures have a lot of knobs to tweak, we are reasonably happy with the current syntax. Closing. |
Just to clarify: You (plural) don't think the proposed change ( |
Unreadable, not improvement |
stream::once -- one element stream
Pretty