"Prof. A Olowofoyeku (The African Chief)" wrote:
Peter N Lewis wrote:
... snip ...
BTW, I noticed in string.pas
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".
It is not safe in Standard Pascal, nor even in Turbo (which can be configured for complete evaluation) because the s2^ component may be dereferenced. It is necessary to write it as:
IF s2 <> nil THEN BEGIN IF s2^ <> chr(0) THEN (* whatever *) ELSE (* handle empty string *) END ELSE (* handle nil pointer case *)
with attendant complications. the OR_ELSE was introduced to ensure short circuit evaluation, and allow the simpler sort of expression you are using.