Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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-gener...



Another 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.


Not 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.


Yes, 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?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: