Peter N Lewis peter at stairways.com.au
Wed Apr 30 09:08:10 CEST 2003

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?

Can any other pointers be accessed as arrays?  Is this only for $X+?

>  >     if (s2 = nil) or (s2^ = #0)
>  >
>  >I know GPC defaults to always doing short circuit, but would that be
>  >better written or_else?
>Dunno. I think that expression is one of the safest ways of dealing
>with pChar variables. I don't know what "or_else" means or how it
>differs from "or".

or_else always does short circuit evaluation.

>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 
<http://www.interarchy.com/>  <http://documentation.interarchy.com/>

More information about the Gpc mailing list