home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7821 < prev    next >
Encoding:
Text File  |  1993-01-03  |  949 b   |  36 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!think.com!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!s.psych.uiuc.edu!amead
  3. From: amead@s.psych.uiuc.edu (Alan Mead)
  4. Subject: Ok, why doesn't THIS cause an error?
  5. Message-ID: <C0AEH3.Hvr@news.cso.uiuc.edu>
  6. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  7. Organization: UIUC Department of Psychology
  8. Date: Sun, 3 Jan 1993 16:43:50 GMT
  9. Lines: 25
  10.  
  11. I'm was a little amazed when I accidentally wrote the below bug.  I
  12. cannot imagine why you are allowed to alter the counter of a for..do
  13. loop.  I suppose it's too hard for the compiler to check?
  14.  
  15. BTW, this was Turbo Pascal.  And I suppose its a reason to give your
  16. variables (no matter how trivial) a real name...
  17.  
  18. -alan mead
  19.  
  20. program bug;
  21. var i,j,k : integer;
  22.  
  23.   function whatever;
  24. {  var i,j,k:integer;}  { this was the missing line }
  25.   begin
  26.     i := 2;
  27.     for k := 1 to i*x do
  28.      ...
  29.   end;
  30.  
  31. begin
  32.   for i := 1 to TheEnd do
  33.     whatever;
  34. end.
  35.  
  36.