3 ms·
Ok some more suggestions: - Pointers aren't arrays. - no implicit conversions at all. - require fields to be initialized before use/end of constructor
by bartwe 4y ago
Ok some more suggestions:
- Pointers aren't arrays.
- no implicit conversions at all.
- require fields to be initialized before use/end of constructor
- compiler-devel 4y agoSome implicit conversions are okay, like type promotion from int to double. Some type coercions are fraught, like char to int or back again. I agree that array decay to pointer could be explicit, and pointers shouldn't cast to arrays.
- nextaccountic 4y agoimplicit int to double is really, really bad! it can silently truncate - double can only store 53 bits integers so for large integers the result will not be an integer! in general, lossy conversions should never, ever be implicit
- compiler-devel 4y agoGreat point, I was thinking of ints as 32 bits. You're absolutely correct for 64 bit ints!
- dataflow 4y agoI would instead say int should be guaranteed to fit in a double. I feel like there's no reason to introduce a pitfall in > 99.999% of use cases just because there might be some obscure architecture where int is 64-bit and its programmers cannot be bothered with the extra keystroke for 'long'.
- favorited 4y agoI'd love to see integer promotion die in a fire, to prevent this: https://twitter.com/stephentyrone/status/1410636445593837569 https://twitter.com/stephentyrone/status/1410636445593837569
- jesse__ 4y ago> require fields to be initialized before use Good idea. That would catch annoying bugs I rarely, but occasionally, have.