News for hackers. Stuff that matters.
Re:Evil Coding Incantations by Someone on Monday December 25, 2017 @02:32PM (#16005383)
If your language has “low level” integers that can take on exactly 2^n values, all bit patters are numbers, so there is no need to “check whether there is a number there at all”.

If, in addition, you want implicit conversion from integers to booleans, you have to pick some patterns as meaning ‘false’.

The first is fairly normal in low-level languages. So, the question is why one would want implicit conversion from integer to boolean. The main reasons I can think of are

- because assembly doesn’t have boolean.

- to keep source code shorter.

For C, I think it was a combination of both. Testing for null pointers using if(p) is nicely short. From there, given that there’s little or no difference between pointers and integers at register level, it is a short step to if(i) for integer i.

Re:Evil Coding Incantations by vardump on Monday December 25, 2017 @05:06PM (#16005932)
> because assembly doesn’t have boolean.

What is flags register file for then? Zero flag, carry, overflow, etc? They sure look booleans to me. Sometimes assembler routines pass booleans in carry flag.

Re:Evil Coding Incantations by mjevans on Tuesday December 26, 2017 @12:36AM (#16007295)
They're actually Boolean types created by a bitfield mapping of an integer.
Re:Evil Coding Incantations by a_t48 on Monday December 25, 2017 @10:50PM (#16006968)
Ints. :)