Timeline for Why don't languages like C have NAND operators?
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 14, 2021 at 14:44 | comment | added | Steve | @gnasher729, indeed. The only sensible implementation of such 3-input gates must be as NOT(a AND b AND c) (or NAND(a,b,c)) - meaning "not all" or "not every" input is true - rather than as (a NAND b) NAND c (or NAND(NAND(a,b),c)) which is how it would be parsed most typically in existing computer languages. Hence, why languages tend not to provide a NAND infix operator, and simply let the programmer compose it from AND and NOT operators when required. | |
| Feb 14, 2021 at 9:59 | comment | added | gnasher729 | Steve, interestingly, in hardware you have nand(x) which is just not x, nand(x,y), nand(x, y, z) etc. The output signal gets weaker with the number of inputs, so at some point it stops working. | |
| Feb 13, 2021 at 11:29 | comment | added | Steve | @davidbak, I seem to remember something similar to this question coming up recently. A main problem with NAND (like NOR) is that it is not associative - that is, you can't handle 3 or more operands on equal terms - so there is no straightforward way to compose the operation into larger expressions. It also has no real English language equivalent. | |
| Feb 13, 2021 at 11:18 | comment | added | gnasher729 | @davidbak Sorry to hear that. | |
| Feb 13, 2021 at 11:17 | comment | added | gnasher729 | Greg, nand is important on the lowest hardware level, where just because of the way physics works either nand with 1, 2 and possibly more inputs is the only logic available, or nor with similar inputs. There is no way to build an AND other than from a NAND with two inputs, used as input to a NAND with one input aka “not”. That’s the level where you need NAND. Any level above that you don’t need it and avoid it. | |
| Feb 13, 2021 at 0:55 | comment | added | Greg Burghardt | I hadn't heard of NAND before this. Or maybe it's been 20 years since my discrete mathematics course in college coupled with the fact I haven't seen this in 20 years of programming. To be honest, it just doesn't read well and it would take me a moment every time I came across this operator to convert it to "not a and b". I have a hard enough time with people inserting 8 unnecessary matching parenthesis in boolean conditions, much less jumping through the mental hoops you need to jump through with the NAND logic. | |
| Feb 13, 2021 at 0:37 | comment | added | davidbak | Gosh, I was with you until you implied that { Normal People ∩ Software Developers } ≠ ∅. (Speaking as a software developer.) Maybe its not actually null, but merely of such low cardinality that you never meet one. | |
| Feb 13, 2021 at 0:29 | history | answered | gnasher729 | CC BY-SA 4.0 |