News for hackers. Stuff that matters.
Re:Show HN: Easy Forth by danbolt on Friday November 27, 2015 @01:22AM (#10636119)
This is an enjoyable read! I've been coming across mentions of Forth much more often lately, so it feels satisfying being able to get a sense of it.

One thing that caught my attention is that Forth's boolean value for "false" is 0, and for "true" is -1. This makes sense if you look at their binary values, being 00000000 and 11111111, respectively. Does anyone know if there was an underlying design decision for this? Fast hardware checking? Bit masking tricks?

Re:Show HN: Easy Forth by TazeTSchnitzel on Friday November 27, 2015 @06:40AM (#10636863)
If you define it like that, you don't need separate boolean and bitwise AND and OR. 11111111 & 00000000 = 00000000, 11111111 | 00000000 = 11111111, ~11111111 = 00000000 etc.

QBASIC (and possibly other Microsoft BASIC dialects?) did the same thing. There's no &&, || or ! in QBASIC.

If you define "true" as just 00000001 then it works for & and |, but not for ~.

Re:Show HN: Easy Forth by abecedarius on Friday November 27, 2015 @01:55AM (#10636187)
Bit masking tricks (though Leo Brodie objected to calling that kind of code a 'trick'). Kind of amusing history: in FORTH-79 tests returned 1 for true, then FORTH-83 changed it, and also changed NOT to mean bitwise complement because you could use 0= for logical complement. Confusion! In the next standard NOT was left undefined, or rather they changed the name to INVERT.