home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pop / 169 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.1 KB

  1. From: sfk@otter.hpl.hp.com (Steve Knight)
  2. Date: Tue, 22 Dec 1992 14:13:51 GMT
  3. Subject: Re: POP syntax
  4. Message-ID: <116670037@otter.hpl.hp.com>
  5. Organization: Hewlett-Packard Laboratories, Bristol, UK.
  6. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!hpscit.sc.hp.com!hplextra!otter.hpl.hp.com!otter!sfk
  7. Newsgroups: comp.lang.pop
  8. References: <57553@dime.cs.umass.edu>
  9. Lines: 42
  10.  
  11. Continuing Ian Rogers transliteration from C-syntax to POP-syntax ...
  12.  
  13. Robin Popplestone's original, with correction and standard whitespace and
  14. indentation :-
  15.  
  16.     maplist( x, f ) { 
  17.         null( x ) ? [] : f( hd( x ) ) :: maplist( tl( x ), f )
  18.     }
  19.  
  20. And here's Ian Rogers POP version, modified to use -null- (because that's
  21. an error in Robin's code) _but_ using the dot notation for elegance.
  22.  
  23.     define maplist( x, f ); 
  24.         x.null and [] or x.hd.f :: maplist( x.tl, f ) 
  25.     enddefine;
  26.  
  27. Not surprisingly, when we lay out the code correctly, we find that the
  28. POP code is more concise and visually simpler.  This situation is 
  29. reversed when we add in the obligatory "lvars" declarations, alas.
  30. Here's the kicker ...
  31.  
  32.     define maplist( x, f ); 
  33.         lvars x, f;                                   ;;; pointless.
  34.         x.null and [] or x.hd.f :: maplist( x.tl, f )
  35.     enddefine;
  36.  
  37. These extra declarations are pointless clutter forced upon the reader
  38. by historical changes within POP-11.  Unfortunately, the reader _must_
  39. read these declarations and understand their meaning, since any
  40. change leads to a massive change in semantics.  (In fact, the first two
  41. versions of maplist given here are completely wrong because of the 
  42. omitted declarations.  The arguments default to "vars" and therefore
  43. wrongly mask other top-level declarations of -x- and -f- during the
  44. invocations of the procedure -f-.)
  45.  
  46. To my mind, Ian has produced a nice little demonstration -- by comparison
  47. with another programming language -- why obligatory declarations are 
  48. harmful to POPs syntax.  The obvious solution that has been suggested to
  49. me very frequently (as Pop9x coordinator) is to make the default
  50. declaration "lvars".  And I see this as very sensible.  
  51.  
  52. Steve
  53.