Article View: rec.games.programmer
Article #138Re: TP or C ? (was: Languages to program in and ports and blah and etc...)
From: PauL M SchwartZ
Date: Wed, 22 Jul 1992 20:40
Date: Wed, 22 Jul 1992 20:40
44 lines
2154 bytes
2154 bytes
In article <1992Jul21.025302.22788@hellgate.utah.edu>, galt%peruvian.utah.edu@cs.utah.edu writes...
>The for statement may seem weird at first, but you can do neat things like this:
>
>for(t=root;t!=NULL;t=t->next) puts(t->str);
>
>
>to cycle through a linked list of strings, printing each as it goes.
>
>Pascal would be something like:
>
>t:=root;
>repeat
> begin
> write(t^.str);
> t:=t^.next;
> end
>until t=Nil
>
>
>Sure the C is uglier looking, but an experienced C programmer would easily be
>able to tell what it does. And once you know how for works, you don't have
>to worry about using a "for", a "while", or a "repeat...until". You can just
>use the for statement.
Of course, the experienced TP programer would have written:
t:=root;
while t<>nil do
begin
write(t^.str);
t:=t^.next;
end;
(if root=nil, the repeat loop crashes, someone was sleeping the day they
talked about linked lists in their data structures class)
at least, you could have taken the BEGIN and END out of the repeat loop
(wouldn't have made an operational difference, but I know how you C
programmers like to save keystrokes).
PauL M SchwartZ | Follow men's eyes as they look to the skys
Future site of .sig virus | the shifting shafts of shining
v206gb6c@ubvms.BitNet | weave the fabric of their dreams.
pms@acsu.buffalo.edu | - RUSH -
Technical Details
Message-ID:
<Brt2nt.Ax2@acsu.buffalo.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!gatech!psuvax1!rutgers!ub!acsu.buffalo.edu!ubvmsd.cc.buffalo.edu!v206gb6cReferences:
<1992Jul15.153252.25417@esds.mdc.com> <lzam8cd@lynx.unm.edu> <76207@ut-emx.uucp> <1992Jul20.203317.10143@esds.mdc.com> <1992Jul21.025302.22788@hellgate.utah.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!psuvax1!rutgers!ub!acsu.buffalo.edu!ubvmsd.cc.buffalo.edu!v206gb6c From: v206gb6c@ubvmsd.cc.buffalo.edu (PauL M SchwartZ) Newsgroups: rec.games.programmer Subject: Re: TP or C ? (was: Languages to program in and ports and blah and etc...) Message-ID: <Brt2nt.Ax2@acsu.buffalo.edu> Date: 22 Jul 92 20:40:00 GMT References: <1992Jul15.153252.25417@esds.mdc.com> <lzam8cd@lynx.unm.edu> <76207@ut-emx.uucp> <1992Jul20.203317.10143@esds.mdc.com> <1992Jul21.025302.22788@hellgate.utah.edu> Sender: nntp@acsu.buffalo.edu Followup-To: rec.games.programmer Organization: University at Buffalo Lines: 44 News-Software: VAX/VMS VNEWS 1.41 Nntp-Posting-Host: ubvmsd.cc.buffalo.edu