5 ms·
> there's no meaningful semantic difference Traits can be defined for existing structs without changes to the struct definition, so there are at least practica
by DougBTX 7y ago
> there's no meaningful semantic difference
Traits can be defined for existing structs without changes to the struct definition, so there are at least practical differences.
Examples here: https://blog.theenginerd.com/blog/2015/06/27/traits-on-generics/ https://blog.theenginerd.com/blog/2015/06/27/traits-on-gener...
- LukaD 7y agoAnother practical difference is that you can implement multiple traits for a given struct which require a method with the same name and same/different signature. The compiler always knows which trait implementation the code is calling so the names implementations don't clash.
- ajross 7y agoNot to pick on you two: but a feature that implements the same concept modulo changes to the source code like friend declarations (first example) or naming (second) is the very definition of a merely syntactic difference. Rust represents the same stuff, it just does it in funny ways. That was my point.
- DougBTX 7y agoYes, I avoided the “semantic” question as it seems very slippery, it could easily devolve to “Rust is turing complete so it is just the same as any other language”. Out of interest, do you have any examples that you would consider semantically different, while still being appropriate for day-to-day programming?