3 ms·
> So how does it work, in the opt-in case, if Cell should be freezable only if T is freezable? impl<T: Freeze> Freeze for Cell<T> { } > I'd rather see the
by chrismorgan 13y ago
> So how does it work, in the opt-in case, if Cell should be freezable only if T is freezable?
impl<T: Freeze> Freeze for Cell<T> { }
> I'd rather see these kinds of traits always be implicit, because that allows for more interaction potential between independent libraries.
Quite the opposite: them being implicit causes trouble with interaction between independent libraries. Because at present, a seemingly innocuous change deep in the internals of one library can prevent its being used in another library—for example, a POD type can have an owned type added to it, and all of a sudden utterly independent code that depended upon its POD behaviour will fail due to move semantics on the linear types.
- stormbrew 13y agoI'm not clear on how it being implicit or explicit changes this issue. Sure, it is a benefit for the library writer that they can be told that their library is breaking a contract that it previously held to, but if they change it anyway the downstream user is still shit outta luck either way. If it's just about making sure library writers don't accidentally fail a changed contract just make it so that they can declare an explicit contract that will cause an error if they don't meet and thus make clear the contracts they intend to continue honoring. This makes the error explicit for exactly the right person in the event of a contract change: the library writer if they break without intending to and the user of the library if they are using the library in a way that they expect to work but were not guaranteed to by the library writer. > impl<T: Freeze> Freeze for Cell<T> { } I see. Is it multiple statements for multiple traits or can theybe combined into one statement? Forgive the newbish question.
- chrismorgan 13y agoIt makes it clear that a contract is being broken, which, if one is following semver, would necessitate a new major version number. As it is, an expert could easily miss the change; making this explicit is a Very Good Thing™. On the Cell Freeze matter: I don't understand your question. Can you clarify what you mean?
- jruderman 13y agoDo you need multiple statements if you want your type to be "Freeze if T is Freeze", "Share if T is Share", etc?
- chrismorgan 13y agoYes, you do. But that's not arduous.
- dbaupp 13y ago(The problems would be dramatically helped by better diagnostics about the kinds (e.g. showing which field of struct is causing non-Pod-ness) and better documentation of them (e.g. the kinds are not listed on documentation pages for types). But that still doesn't completely help with library interaction.)