Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upGeneralize over mut and non-mut items #976
Conversation
tommit
added some commits
Mar 14, 2015
This comment has been minimized.
This comment has been minimized.
|
For better readability and to retain more of the proper CamelCase and snake_case looks for traits, structs and functions, we could change them from being the prefix |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@mahkoh I thought about putting |
reem
reviewed
Mar 14, 2015
| where T: opt-Trait | ||
| { | ||
| fn opt-other_foo(&mut self) { | ||
| let t = self.opt-bar(); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
tommit
Mar 14, 2015
Author
@reem Who do you mean it's ambiguous to?
- The parser
- The compiler
- Programmer who is reading quickly and doesn't have syntax highlighting
It shouldn't be ambiguous to the first two, because the opt keyword followed by one or more white space followed by - would always be a compile-time error.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jmesmon
Mar 15, 2015
On the use of - note: allowing - in identifiers is one of the alternatives in #940 (though I can't say many people seem interested).
This comment has been minimized.
This comment has been minimized.
reem
commented
Mar 14, 2015
|
Being generic over mutability is definitely useful, but I think a lot of careful thought is necessary before we settle on any specific incarnation; there are both many conceptual consistency and practical issues that need to be considered. Unfortunately, I'm not convinced this proposal is up to dealing with the magnitude of this challenge. For instance, it doesn't cover abstracting over the "by-value" mode at all, meaning it can't be used to collapse the |
This comment has been minimized.
This comment has been minimized.
|
I agree with @reem in that it needs much more thought. Such extensions tend to have tricky edge cases which aren't apparent from a few simple examples. I also don't see a mention of HKT, which may solve the same problem in a more general way. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Yeah what we want to do is parametrize the capabilities of pointer types. This proposal suffers from the similar expressiveness issues as |
This comment has been minimized.
This comment has been minimized.
|
Another source of inspiration might be this presentation and the many references mentioned in it. In particular I wonder if we couldn't think of our reference types as being a combination of a pointer plus the capability to access it, after a similar fashion as suggested therein:
...or something like that. I suspect this couldn't really work as-is, because our lifetimes aren't quite the same thing as their regions (I believe it's possible for two disjoint pieces of memory to have the same lifetime?), but perhaps the idea could still be useful somehow. (I'm an expert on neither.) (It gets harder if you also wish to consider |
This comment has been minimized.
This comment has been minimized.
|
@glaebhoerl cool slides! Also I'd guess that code that partially assigns + refines a pointer can be generic over various combinations of |
brson
self-assigned this
Mar 19, 2015
This comment has been minimized.
This comment has been minimized.
|
There's no question that there are many types that could usefully generalize over
this struct can be used with |
This comment has been minimized.
This comment has been minimized.
|
I'm also concerned about the unknowns here and think this duality is something we've lived with for a long time and can continue to do so. As @nikomatsakis there are potential other solutions. Let's not be hasty. Thanks for the thought-provoking RFC, but we're not going to pursue this avenue. |
tommit commentedMar 14, 2015
Rendered