Proposal for new operator :-)

Alan Rooks alan at oscvax.UUCP
Sat Sep 28 06:10:39 AEST 1985


It seems, from all of the talk of boolean types, and programming-in-the-
abstract, that C is being used for more and more abstract, quiche-eating,
pascal-ish stuff.
The language was obviously not intended to have a boolean type, otherwise
Ritchie would have included bool as a primitive type.
Anyways, if C must have bools, then i propose a new operator, analogous
to the ++ and -- operators, to be used for a very common *boolean* operation.

The !! operator.

if (!!flag) {

    /* done if flag was false, but now it's true */

} else {

    /* done if flag was true, now it's false */

}

if (flag!!) {

    /* done if flag was true, now it's false */

} else {

    /* done if flag was false, but now it's true */

}


Or to initialize the squares of a chess board:

isblack = TRUE;
for (i = 0; i < 8; i++)
    for (j = 0; j < 8; j++)
	board[i][j].colour = isblack!!;


This makes the "english" interpretation of the code very interesting:

if (machine_is_on_fire!!)
    put_it_out();
else
    machine_is_on_fire!!;
/* now machine_is_on_fire == FALSE */


Shall i submit this to mod.std.c ?????

Alan Rooks             ...!utzoo!oscvax!alan

P.S. Please do not start up the ^^ and ->= discussions again.



More information about the Comp.lang.c mailing list