News for hackers. Stuff that matters.
Re:The Ten Commandments for C Programmers (1987) by adrianN on Saturday May 23, 2020 @12:15PM (#23284127)
I dislike implicit type conversions, but I think every cast needs to be accompanied by an assertion. Just sprinkling casts everywhere does nothing but silence important compiler warnings.
Re:The Ten Commandments for C Programmers (1987) by phkahler on Saturday May 23, 2020 @01:54PM (#23284950)
>> I dislike implicit type conversions...

What do you think of "auto" in C++ ?

Re:The Ten Commandments for C Programmers (1987) by codys on Saturday May 23, 2020 @06:13PM (#23287013)
Not the parent, but `auto` in c++ improves the situation wrt implicit conversions as variables now automatically get the type of the thing assigned to them. IOW: less unintentional implicit conversions.
Re:The Ten Commandments for C Programmers (1987) by bl0b on Saturday May 23, 2020 @02:14PM (#23285058)
'auto' is only available to use when the type of a variable can be automatically deduced from its initializer, meaning the declaration would be redundant. It has nothing to do with type conversions.

edit: now I see what you mean in the context of adding assertions to make type conversions safer, and how there could be some parallels with auto for that

Re:The Ten Commandments for C Programmers (1987) by dllthomas on Saturday May 23, 2020 @03:05PM (#23285500)
It's an example of making something explicit implicit.

Whatever the answer, it won't surface a contradiction; but that doesn't mean it's not an interesting, obliquely related question.

Re:The Ten Commandments for C Programmers (1987) by phkahler on Saturday May 23, 2020 @03:25PM (#23285641)
It's implicit declaration, which seems worse in some ways than implicit conversions. After a conversion you know what type you have even if not the type you started with.