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 upTracking issue for `Reflect` stabilization #27749
Comments
aturon
added
T-libs
B-unstable
labels
Aug 12, 2015
This comment has been minimized.
This comment has been minimized.
|
I am in favor of it going away, I've had no use for it (and have heard of none) other than as necessary boilerplate whenever I want to do downcasting. I know of absolutely no types either in std or in the ecosystem which opt out of Reflect (and I can't really think of a good reason to do so). |
This comment has been minimized.
This comment has been minimized.
This is intentional. The point is precisely to prevent downcasting of opaque type parameters. |
This comment has been minimized.
This comment has been minimized.
|
I agree that the outcome of specialization is the key question. |
Ms2ger
referenced this issue
Aug 16, 2015
Open
Tracking: Unstable Rust feature gates used by Servo #5286
This comment has been minimized.
This comment has been minimized.
|
Nominating for 1.6 discussion |
alexcrichton
added
the
I-nominated
label
Nov 4, 2015
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton I do not understand, isn't the situation still :
(And, to my knowledge, specialiation is not settled?) |
This comment has been minimized.
This comment has been minimized.
|
That was part of the discussion I'd like to have :) With nonparametric dropck I wanted to check in on this and see if we could deprecate/remove, but if it still has to do with specialization then I think we'd just keep punting. |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton Yeah, it's tied to specialization. The change to dropck was a conservative one that will make room for specialization but doesn't imply that we give up on parametricity. |
This comment has been minimized.
This comment has been minimized.
|
Alex has been taught the error of his ways, so this issue is not moving into FCP this cycle. |
alexcrichton
removed
the
I-nominated
label
Nov 5, 2015
tinco
referenced this issue
May 23, 2016
Closed
Rustc asks for Reflect, which is unstable, when it could be asking for Any which is stable #33807
nrc
added
I-nominated
T-lang
labels
Aug 18, 2016
This comment has been minimized.
This comment has been minimized.
|
We discussed this in the @rust-lang/lang meeting. We would like to move this issue to final-comment period with the intention to deprecate and remove the Note: This final-comment-period lasts for (roughly) the current release cycle, which began on Aug 18, 2016. |
nikomatsakis
added
final-comment-period
and removed
I-nominated
labels
Aug 22, 2016
This was referenced Aug 22, 2016
This comment has been minimized.
This comment has been minimized.
|
On the general topic of parametricity, there have been numerous comments. In an effort to summarize the conversation, I wanted to link to some of the most salient exchanges:
|
This comment has been minimized.
This comment has been minimized.
|
Reviewing this thread did reveal one interesting thing to me: the opt-in proposal still relied on the |
This comment has been minimized.
This comment has been minimized.
|
Also, @eddyb has pointed out a few times that the current |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Do you mean specialization can "remove" the requirement? Because that's unsound (or rather, it would be for |
This comment has been minimized.
This comment has been minimized.
What I meant is that the specialization RFC does not mention the I am not sure of what relationship you see between |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Ah, sure, I was talking about a |
This comment has been minimized.
This comment has been minimized.
I'm curious what this means in the larger picture, not specific to this tracking issue. |
This comment has been minimized.
This comment has been minimized.
|
@withoutboats In a nutshell, it means that Rust will not attempt to ensure traditional parametricity for type arguments (i.e. that generic code behaves "equivalently" when instantiated with different types). This is already formally the case due to the ability to get the size of a type parameter, but we're opening the door to observable, behavioral differences under different type arguments. That means we will permit language features that let you write a function like: fn print<T>(t: &T) { ... }which e.g. prints its argument using The tradeoff is:
Note that all of the above is specific to type parameters. Lifetime parameters, on the other hand, are intended to remain parametric -- e.g. you can't change the behavior of your function depending on whether a given lifetime is |
This comment has been minimized.
This comment has been minimized.
In my opinion, strict parametricity is not so important, but explicit, algorithmic reflection almost always is a band-aid over a wrong abstraction which results in increasingly unmaintainable spaghetti. Having automatically determined aparametricity during monomorphization (so specialization) is fine, in my opinion, but making explicit downcasting a normal and commonly used part of the language would be a very negative change. The fact that its so hard to do this is one of the language's key selling points to me. That is, I'm comfortable with this: default fn print<T>(t: &T) { ... }
default fn print<T: Debug>(t: &T) { ... }
default fn print<T: Display>(t: &T) { ... }
fn print<T: Debug + Display>(t: &T) { ... }But I'm uncomfortable with something like this: fn print<T>(t: &T) {
if T::implements::<Display>() { ... }
else if T::implements::<Debug>() { ... }
else { ... }
} Partly this is an intuitive judgment, but some obvious advantages of the first:
|
nrc
added a commit
to nrc/rust
that referenced
this issue
Oct 9, 2016
nrc
added a commit
to nrc/rust
that referenced
this issue
Oct 11, 2016
This comment has been minimized.
This comment has been minimized.
naasking
commented
Oct 14, 2016
|
I admit I have no horse in this race since I haven't gotten to use Rust for any projects, but I do follow the theoretical side of Rust. This discussion of introducing typecase puzzles me, particularly because Rust already supports ad-hoc overloading via traits, so why introduce yet another way to overload, and via a mechanism that is more limited to boot, ie. typecase is closed where traits are open? With impl specialization seemingly merged, zero-cost open overloading already seems available, so what's the real use for typecase, aside from reducing a little typing by avoiding trait and impls? |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
You can already use |
This comment has been minimized.
This comment has been minimized.
naasking
commented
Oct 14, 2016
|
@eddyb, if that was a reply to me, then:
|
This comment has been minimized.
This comment has been minimized.
|
Rust supporting dynamic multidispatch and specialization at the language level (2) would cause 1. |
This comment has been minimized.
This comment has been minimized.
naasking
commented
Oct 14, 2016
|
Yes (2) implies (1). An if-chain discriminating on What am I missing? |
This comment has been minimized.
This comment has been minimized.
|
I don't understand, are you arguing against specialization as a whole? |
brson
added a commit
to brson/rust
that referenced
this issue
Oct 19, 2016
This comment has been minimized.
This comment has been minimized.
e-oz
commented
Nov 10, 2016
|
Will it affect rustc-serialize? |
This comment has been minimized.
This comment has been minimized.
|
@e-oz Can you elaborate the question? Reflection in Rust allows some dynamic type checks, but it does not have any structural information like enumeration of struct fields or so, which I imagine could be what you mean? |
This comment has been minimized.
This comment has been minimized.
e-oz
commented
Nov 10, 2016
|
@bluss I didn't know it and thought rustc-serialize does use reflection. Thanks for clarification :) |
This comment has been minimized.
This comment has been minimized.
|
Ah the deprecation here has hit stable, so this issue is resolved! |
alexcrichton
closed this
Nov 10, 2016
bluss
referenced this issue
Nov 11, 2016
Merged
vec: Write the .extend() specialization in cleaner style #37709
eddyb
added a commit
to eddyb/rust
that referenced
this issue
Nov 11, 2016
eddyb
added a commit
to eddyb/rust
that referenced
this issue
Nov 12, 2016
This comment has been minimized.
This comment has been minimized.
|
I'm a bit confused. |
This comment has been minimized.
This comment has been minimized.
|
I'm asking because of issue #39059. |
This comment has been minimized.
This comment has been minimized.
|
@est31 the trait itself was deprecated but not removed. As it was never stable, we can remove it in Rust 1.x. And it was deprecated in 1.14, so maybe we can consider removing it in 1.16. But I think the feature gate stays "active" until then, as you can still mention |
This comment has been minimized.
This comment has been minimized.
|
If we're going to remove |
This comment has been minimized.
This comment has been minimized.
|
@withoutboats I've created a PR to do such a crater run on: #39075 (I don't have any opinion on whether to remove Reflect or not). |
This comment has been minimized.
This comment has been minimized.
|
I started a crater run on @est31's PR. |
This comment has been minimized.
This comment has been minimized.
|
crater report by @brson on the PR above. |
This comment has been minimized.
This comment has been minimized.
|
I too am confused on why this issue is closed. I'm going to open it. =) I think we can remove |
aturon commentedAug 12, 2015
The
Reflecttrait is currently unstable. It was intended to narrow the use of things likeAnyfor runtime introspection, to help retain parametricity properties. However, with impl specialization these properties would go away anyhow, so it's not clear how useful the trait would be.Thus, stabilization should wait at least until specialization is settled.
cc @reem @nikomatsakis @pnkfelix