3 ms·
> static_assert(sizeof(Quote) == 28, "Quote size wrong"); A good reminder that trying to "let the types do the work" in C++ is an oxymoron. If you're so keen
by laureny 13y ago
> static_assert(sizeof(Quote) == 28, "Quote size wrong");
A good reminder that trying to "let the types do the work" in C++ is an oxymoron.
If you're so keen on algebraic data types, there are languages much better suited to that than C++.
- vinkelhake 13y ago> If you're so keen on algebraic data types, there are languages much better suited to that than C++. Variants of this comment are often seen. For any given feature, there's going to be a language that shines in that particular area. However, choice of language rarely comes down to a specific feature. There's usually a multitude of aspects that needs to be considered - some of them aren't even technical.
- axman6 13y agoThat seems like an orthogonal issue to me. The assert is to ensure that the data type matches some external requirement; a quote is a structure that as 28 bytes long, and if something changes to make a Quote not 28 bytes long, you'll be told. If it weren't there, the algebraic data stuff would still work fine. Edit: I say this as someone whose primary language is Haskell
- pjmlp 13y ago> If you're so keen on algebraic data types, there are languages much better suited to that than C++. Yes, you are quite right. However it only works when one works alone. Usually the choice of a language is driven by what the customer requires as technology, what the team members are capable of using or willing to learn, finally what the boss allows.