Hacker News new | ask | show | jobs
by fingerlocks 119 days ago
Nowhere does it say structs provide “one source of truth”. It says the opposite actually- that classes are to be used when unique instances are required. All classes have a unique ID, which is simply it’s virtual memory address. Structs by contrast get memcpy’d left and right and have no uniqueness.

You can also look at the source code for the language if any it’s confusing. It’s very readable.

1 comments

You're re-stating his exact problem while trying to refute him.
No, I’m not. OP is conflating multiple guidelines for different purposes and attempting to use them all simultaneously.
> OP is ... attempting to use [multiple guidelines] simultaneously.

No, he's literally explaining why the guidelines can't be used simultaneously.

They aren't supposed to be used simultaneously, which is literally what my comment was explaining. Different guidelines to solve different problems.
Have one source of truth is a universal guideline.

Prefer structs over classes is a universal, if weak, guideline.

It's funny how people can be all hung up on composability of things like type systems, and then completely blow off the desire for composability of guidelines.