On 4-apr-06, at 22:48, Frank Heckenbach wrote:
Adriaan van Os wrote:
So we have the choice either to leave the range at False {0} .. True {1}, and forbid other values, and change the test programs,
In my opinion, the only correct option.
Then I doubt whether we need such types at all (unless required for compatibility to Delphi or something).
or to really declare the range according to the bitsize (e.g. False {0} and 255 values of True for an 8 bit type).
The former would seem more Pascalish. OTOH, such types are probably often used for C interfaces, and what will happen if C routines put values > 1 in them?
Use an integer or cardinal type instead (for example in the Win32 API, but that API is a mess anyway, dependent on the call you have to check for <> 0 or = 0 or <> 1 or =1).
I don't know this API. Do you mean there are functions where 0 means False, 1 means True, but 2, 3, ... means False? (Or vice versa?) Ouch!
Some examples (but I have seem more weird cases)
SystemParametersInfo <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ sysinfo/base/systemparametersinfo.asp> If the function succeeds, the return value is a nonzero value. If the function fails, the return value is zero. To get extended error information, call GetLastError.
SHGetPathFromIDList <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ wceshellui5/html/wce50lrfshgetpathfromidlist.asp> TRUE indicates success. FALSE indicates failure.
DeviceCapabilities <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/ prntspol_21bn.asp> If the function succeeds, the return value depends on the setting of the fwCapability parameter. A return value of zero generally indicates that, while the function completed successfully, there was some type of failure, such as a capability that is not supported. For more details, see the descriptions for the fwCapability values. If the function fails, the return value is -1.
Regards,
Adriaan van Os