[DGD] boolean integers: mudos vs dgd

Jared Maddox absinthdraco at gmail.com
Mon Apr 22 01:50:08 CEST 2013


> Date: Sun, 21 Apr 2013 01:07:28 -0700
> From: Raymond Jennings <shentino at gmail.com>
> To: "All about Dworkin's Game Driver" <dgd at dworkin.nl>
> Subject: [DGD] boolean integers: mudos vs dgd
> Message-ID:
> 	<CAGDaZ_rmphQzYe0pJZ45okvYZ_aakErjipfn==NV1YzF6u8ojQ at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> A friend of mine (blain) reports that the expression (5 || 3) returns 5,
> and the expression (3 || 5) returns 3, whereas dgd returns 1 for both of
> them.
>
> First of all, any major reason for the difference?
>
> Secondly, is treating an integer as a boolean value in this way stepping on
> undefined or implementation defined behavior either in LPC or regular C?
>

To go back to the (at least older) C standard, in that situation,
returning 1, 3, 5, 127, or any other positive in-bounds number is
perfectly acceptable. Counting on 3, or 5, or 1, or any other specific
value is dangerous, because it relies upon implementation-defined
behavior. The exact value of the return value is undefined, but the
generalities are defined, thus the exact value is
implementation-defined.



More information about the DGD mailing list