Peter N Lewis wrote:
At 2:35 PM +0100 29/4/03, Prof. A Olowofoyeku (The African Chief) wrote:
BTW: a CString/pChar is type-compatible with zero-based arrays of char (e.g., var foo : array [0..1023] of char). I think you might have to use {$X+} in your code for this - but I don't remember (I always use it anyway).
So basically, CString is ^Char, but why then can it be accessed as an array?
BP compatibility (which in this case means C compatibility)-: ...
Can any other pointers be accessed as arrays?
Nope (at least not intentionally).
Is this only for $X+?
Yes (if you find another case, report it as a bug).
Call it laziness, but there are many such places. I think the code becomes more readable (and a little easier to write when one doesn't have to consider whether `or' can be safely used or `or_else' must be used) ...
Fair enough, I just get nervous whenever I see if (s <> nil) or (s^ ...). In CW Pascal, they use | and & for short circuit evaluation - anything is better than plain or in my book which no Pascal standard ever defined to short circuit (or even left to right evaluation I think?).
No standard indeed, AFAIK. But BP and GPC define it so if the short circuit option is enabled (which it is in GPC by default, and I think also in BP).
Frank