Re: [fpc-pascal] array [boolean] and typecasting fail

2009-10-23 Thread ik
The use of 'array[boolean]' does not mean that the array is true or false, but rather '0..1'. You indicate a range, not a boolean behavior. 6 and 4 gives 4, and 4 is above the range of 1 (the highest cell of the array you declared). If you would have cast it to boolean, or provide a better usage,

Re: [fpc-pascal] array [boolean] and typecasting fail

2009-10-23 Thread David Emerson
On Fri 23 Oct 2009, ik wrote: The use of 'array[boolean]' does not mean that the array is true or false, but rather '0..1'. You indicate a range, not a boolean behavior. Well, pascal is a typed language, so while I do realize that the information is stored as false=0 and true=1, and that's

Re: [fpc-pascal] array [boolean] and typecasting fail

2009-10-23 Thread Martin
David Emerson wrote: I did cast it to boolean! That's why it smells like a bug var b : boolean; begin b := boolean (6 and 4); writeln (t_or_f [b]); A type cast does not changes the value. A typecast merely allows you to store a value into a field of a different type same for

Re: [fpc-pascal] array [boolean] and typecasting fail

2009-10-23 Thread David Emerson
Thanks, Martin -- I'm doing the if/then, and am being reminded of what typecasting actually does! On Fri 23 Oct 2009, Martin wrote: A type cast does not changes the value. A typecast merely allows you to store a value into a field of a different type

[fpc-pascal] array [boolean] and typecasting fail

2009-10-22 Thread David Emerson
It appears that, in a special case here, the boolean typecast is not being done properly/completely, and thus an array is being indexed out of bounds. If I compile with rangechecking, I get a rangecheck error; without, I get garbage and an EAccessError exception! (trash and crash) uses math;