-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Change DST syntax to T: Sized?
#490
Conversation
+1. Looks coherent. So with this syntax one could also use these specifications? What about |
@arcto You can already type When we get negative bounds you should be able to type |
I'm weakly in favour of this - I originally liked the I would be wary of having Another worry is that this is churn for not very much benefit. It should be easy to implement, but there will be a lot of fallout. |
Nice!
|
I like that idea in general and I did consider it when making the RFC, but it simply looks a bit weird: in English, ‘?’s come after things, not before. (The same argument could be applied to If enough people like the
I don’t think DST is used too much yet outside the standard library, so I don’t think this will turn out to be a hugely problematic change. We could allow the old syntax with a warning for some time, anyway. |
(assigning myself to shepherd this - we should discuss it pretty soon, I don't think we need to wait for a triage meeting to assign a shepherd) |
Just to throw it out there, |
Is there any reason why we would not name negative bounds with exclamation mark on the end ? ie |
The imaginary (for now) |
How about |
@gifnksm: Using a minus sign to negate an implicit bound goes well with using a plus sign to add a bound, but how would one specify the case of "possibly unsized"? |
@arcto I wrote "
|
I don't see a problem with I do like |
I’m not a huge fan of Regarding |
I like |
Moving to |
All schemes generalise, the current scheme would be |
I support the |
The gain in consistency across the board wins me over. I prefer changing to |
Can't we just get rid of this freaky If I want to define a trait for types that must be
If I want to define a trait for types that may or may not be
The obvious downside to this is that it will require a lot of extra typing to add Even without trait inference, the upside to this is that it would keep the trait system sane and consistent. Is there something wrong with this plan that I'm not seeing? |
Only the last member of a |
@canndrew I would prefer making all traits op in too, but I'm not sure your inference system is a good idea. The precedent in most languages is to just infer types where there is no annotation. I.e. all annotated bindings have exactly the type the user specified. Where you can infer part of the type, one explicitly shows what should be filled in with e.g. an underscore (Agda, Rust), or the "diamond operator" (Java). The only time rust violates this principle is inferring lifetimes, I am not sure even sure that is a good idea. (Consider Also, opinions aside, I am not sure it is possible. Consider that multiple traits with the same method names can be in scope at the same time. Considering these things, I think |
We (the Rust team) discussed this RFC today. We are generally in favour of the changes, we would like to take an adjusted RFC where the question mark comes before The reason for keeping
here,
here, @P1start, if you are willing, could you make these changes to the RFC please? Then ping me and I will merge it. If you don't have time, let me know and I can take care of the changes too. Thanks! |
This adjusts the proposal to propose `T: ?Sized` instead of `T: Sized?`, and changes the syntax for traits to `trait Trait for ?Sized` instead of `trait Trait: Sized?`.
@nick29581 OK, I’ve updated the RFC with those changes. |
Tracking issue: rust-lang/rust#19607 |
Change the syntax for dynamically sized type parameters from
Sized? T
toT: Sized?
, and change the syntax for traits for dynamically sized types totrait Foo: Sized?
. Extend this new syntax to work withwhere
clauses.cc #357
Rendered view