home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / pascal / 5351 < prev    next >
Encoding:
Text File  |  1992-09-12  |  2.5 KB  |  52 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!usc!sol.ctr.columbia.edu!eff!world!art
  3. From: art@world.std.com (Al Thompson)
  4. Subject: Re: TP units question
  5. In-Reply-To: dmurdoch@mast.queensu.ca's message of Fri, 11 Sep 1992 19:50:49 GMT
  6. Message-ID: <ART.92Sep12140732@world.std.com>
  7. Sender: art@world.std.com (Al Thompson)
  8. Organization: The World Public Access UNIX, Brookline, MA
  9. References: <1992Sep4.141203.28370@news.columbia.edu> <ART.92Sep10133100@world.std.com>
  10.     <ART.92Sep11131535@world.std.com>
  11.     <dmurdoch.151.716241049@mast.queensu.ca>
  12. Date: Sat, 12 Sep 1992 19:07:32 GMT
  13. Lines: 37
  14.  
  15. In article <dmurdoch.151.716241049@mast.queensu.ca> dmurdoch@mast.queensu.ca (Duncan Murdoch) writes:
  16.  
  17.    In article <ART.92Sep11131535@world.std.com> art@world.std.com (Al Thompson) writes:
  18.    >   That sounds like a bad flaw in the Extended Standard.  Without the compiler 
  19.    >   checking up on you, how do you know that the parameter list you put in the 
  20.    >   implementation section is really correct?  
  21.    >
  22.    >You miss the point.  You are not supposed to put the parameter list in
  23.    >the implementation section.  Therefore it will be neither correct nor
  24.    >incorrect.  It just doesn't appear.  In TP this is optional.
  25.  
  26.    No, I think you missed the point.  You said (and repeat below) that you *do* 
  27.    put the parameter list in the implementation section, but in a comment.  
  28.    What I'm saying is that you're much better off putting it in as code, so 
  29.    that the compiler can check that you got it right.
  30.  
  31. But how would you get it "wrong"?  Presumably you're using an editor that
  32. allows you to cut and paste.  This should ensure you get it right.
  33. In a sense, this is exactly the way forward declared procedures work in
  34. standard Pascal.
  35.  
  36.    >But in TP its optional.  In TP I never include the parameter list in the
  37.    >implementation section.  What I do is write the procedure and then using
  38.    >my ever helpful emacs copy the procedure heading to the interface
  39.    >section.  After that's done I go back to the implementation and comment
  40.    >out the parameter list.
  41.  
  42.    That sounds like a crazy thing to do.  Why not let the compiler see it 
  43.    twice?  It's free insurance against mistakes.
  44.  
  45. How?  What mistakes?  In the body of the procedure the paramters are just
  46. another bunch of local variables.  If you refer to a variable not
  47. mentioned in the heading and not declared as a local or global you will
  48. get a variable undefined error message.  If the variable is misused, e.g.
  49. treating a var parameter as a value parameter, the compiler won't
  50. complain a bit.
  51.  
  52.