I read several threads on here about structs (one about mutable structs) and I keep reading about how a struct should have no identity.
What exactly is a lack of identity in a struct? I am guessing it would be like a number, e.g. 5, not having a context (5 what?). Whereas client would be someone expecting a service, and thus there is an identity. Am I thinking correctly?
I know the technical differences and how structs are thread safe (as long as they can’t be mutated, but I can still write methods to mutate state), they have new copies everytime they are passed into a method, etc…
It means that the only data you have about a struct is the values is stores – there’s no difference between one ‘5’ and another ‘5’. Compare this with a class:
Now
person1andperson2have references to distinct objects, although they both contain the same data.person2andperson3both refer to the same objects. With structs this distinction doesn’t exist.