I am translating an "old" C program into (Object) Pascal. I am reconsidering my translation of the following:
for (objlist = list->unbounded; objlist; objlist = objlist->next) {
/* do stuff */
}
At first I translated the loop as follows:
objlist := list.unbounded;
repeat
// do stuff
objlist := objlist.next;
until objlist = nil;
But then I wondered, what happens if "objList" is nil? Should the loop be translated as a while loop (so objList can be tested before entering the loop)?
objlist := list.unbounded;
while (objlist <> nil) do
begin
// do stuff
objlist := objlist.next;
end;
Thanks in advance.
