Quote: "Also why doesn't AppGameKit as [have] a boolean data type .. ?"
In Basic or C++? Since 1999 most C++ compilers already have a bool type with true and false defined. VC++ has BOOL, TRUE and FALSE defined.
This is a bit of a pig's ear, because any non-zero number is interpreted as true, and hence:
if (b==true) is not equivalent to if(b)
Basic follows the C lack of typing, so defining TRUE and FALSE in Basic results in the same danger.
This doesn't happen in Pascal, Modula-2 etc, because true and false have always been defined as enumerated types: type boolean = (false,true) and you cannot simply use a number.
So defining a boolean type in Basic would be ok, if hazardous, but defining it for Pascal or C++ would cause a potential keyword conflict.
Most 32-bit compilers will align data on 4-byte boundaries. Older CPUs are significantly slower fetching non-aligned data. The latest Intel and ARM processors are apparently better at it.
This is why C++ has
#pragma pack and Pascal has the
packed keyword. The unpacked size of a boolean in Delphi is 1 byte, despite the fact that only 1 bit is required to store the values 0 and 1, so:
var b : array[1..32] of boolean; // uses 32 bytes
z : packed array[1..32] of boolean; //uses 4 bytes
As always, the trade-off is memory versus CPU efficiency.
It becomes even more fun using fuzzy logic, where the "truth" of a statement might (for example) be a value between 0 and 100!
EDIT:
It is fairly easy to extend Pascal to provide a C-style if:
function iff(v : integer):boolean; inline;
begin
result := v <> ord(false);
end;
-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL