Uh oh!
There was an error while loading. Please reload this page.
Explain why 'elision' - #23558
Conversation
rust-highfive
commented
Mar 20, 2015
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
Gankra
commented
Mar 20, 2015
I'm not clear if there's a rigorous distinction between elision and inference. Both will put different values based on context. Inference fails out if it's ambiguous, elision fails out if what is picked doesn't work? Inference is also more best-effort, while elision is about certain if-then rules? |
steveklabnik
commented
Mar 23, 2015
@gankro to me, elision is a passive thing, while inference is an active thing. |
Kimundi
commented
Mar 27, 2015
Well, technically lifetime elision is a very restricted secondary type inference algorithm that only applies in item signatures, where the primary one is forbidden. That is to say, Rust might be a bit weird in that regard because it has more than one type inference algorithm. (Other languages that claim to infer types have also different algorithms, but I'm not aware of a case where there are multiple ones) It probably makes sense to keep telling them apart as "inference" vs "ellision" as a shorthand, but the fact that both automatically infer some types without needing to write them down should not be glossed over. The best example here is that For the docs, maybe an approach that makes both the distinction and similarity clear would work? "Rust supports powerful local type inference in function bodies, but it's forbidden in item signatures to allow reasoning about the types just based in the item signature alone. However, for ergonomic reasons a very restricted secondary inference algorithm called "lifetime elision" applies in function signatures. It infers only based on the signature components themselves and not based on the body of the function, only infers lifetime paramters, and does this with only three easily memorizable and unambiguous rules. This makes lifetime elision a shorthand for writing an item signature, while not hiding away the actual types involved as the full local inference would if applied to it. |
steveklabnik
commented
Mar 27, 2015
What do you think of that version, @gankro ? |
Gankra
commented
Mar 27, 2015
👍 that's a great explanation, @Kimundi! |
e81a800 to
56c2191Comparesteveklabnik
commented
Mar 30, 2015
There was a problem hiding this comment.
I would say 'in' here, but can see 'on' too.
Gankra
commented
Mar 30, 2015
r=me with nits |
56c2191 to
8f0c952Comparesteveklabnik
commented
Mar 30, 2015
I agree with one nit, but disagree with the other. :) |
steveklabnik
commented
Mar 30, 2015
@bors: r=gankro rollup |
bors
commented
Mar 30, 2015
📌 Commit 8f0c952 has been approved by |
No description provided.