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

  1. From: sfk@otter.hpl.hp.com (Steve Knight)
  2. Date: Fri, 1 Jan 1993 18:22:50 GMT
  3. Subject: More Misfeatures
  4. Message-ID: <116670044@otter.hpl.hp.com>
  5. Organization: Hewlett-Packard Laboratories, Bristol, UK.
  6. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!col.hp.com!news.dtc.hp.com!hpscit.sc.hp.com!hplextra!otter.hpl.hp.com!otter!sfk
  7. Newsgroups: comp.lang.pop
  8. Lines: 98
  9.  
  10. On the subject of misfeatures, Aaron writes:
  11. > However, I suspect that as regards mis-features this issue of
  12. > quotation in list and vectore expressions is minor compared with
  13. > others, including letting commas be optional in variable
  14. > declarations (which should be phased out as soon as possible) 
  15.  
  16. I agree.  This is a completely horrid aspect of POP-11's overly
  17. flexible syntax.  I would add that optional commas should be replaced
  18. by mandatory commas in all other contexts, too.  This includes
  19. formal parameters, dlocal expressions, and so on.
  20.  
  21. > making
  22. > input and output locals default to dynamic rather than lexical and
  23.  
  24. I agree very strongly.  I want to go even further, as I've written
  25. elsewhere, and have any declarations of these variables moved to
  26. the point of introduction.  In other words:
  27.     define f( x, dlocal y ) 
  28. rather than
  29.     define f( x, y ); lvars x; dlocal y;
  30. However, making the default lexical is the main thing.
  31.  
  32. > many other permitted alternative forms for the same thing, including
  33. > the dreadful toleration of "do" in place of "then" in unless
  34. > expressions:
  35. >     unless foo(x) do x else y endunless -> z
  36.  
  37. I've never understood this point.  It has always seemed to me to be
  38. a positive feature of POP-11.  Many conditionals read better with "then"
  39. others with "do".  Since both are reserved words, why not make it 
  40. optional?  
  41.  
  42. My own love-to-hate favourite at the moment is the abomination of
  43. an empty expression used as the target of assignments, especially
  44. in the context of tuples.  e.g.
  45.     EXPR -> ( x, , z )
  46. The above should be a syntax error in my view, not a convenient way
  47. of popping the 1st and 3rd items off the stack.  If you are really a 
  48. purist then I would concede that it might be legal but equivalent
  49. to
  50.     EXPR -> ( x, z )
  51. This must be true since the natural interpretation to assigning to
  52. the empty expression is the null action.  i.e.
  53.      EXPR -> ;
  54. becomes
  55.      EXPR
  56. Of course, in today's POP-11 the latter is actually interpreted
  57. as
  58.      erase( EXPR )
  59.  
  60.  
  61. Why is it wrong?  Basically, it creates a needless exceptional behaviour
  62. in the middle of the language.  (Excluding active variables, for the moment)
  63.  
  64.      ( x, y, z )     pushes 3 things on the stack
  65.      -> ( x, y, z )  pops 3 things off the stack
  66.      ( x, y )        pushes 2
  67.      -> ( x, y )     pops 2
  68.      ( x )           pushes 1
  69.      -> ( x )        pops 1
  70.      ()              pushes 0
  71.      -> ()           pops 1 ?! 
  72.  
  73. And the requirement for a convenient way of erasing an arbitrary element
  74. could just as easily be served through an anonymous variable.  The great
  75. advantage of an anonymous variable is that it could be used in any 
  76. context to good effect.  For example, using '_' as the anonymous
  77. variable:
  78.  
  79.  
  80.      define K( x ); lvars x;
  81.          procedure( _ );      ;;; why give it a name?
  82.              x
  83.          endprocedure
  84.      enddefine;
  85.  
  86.      for k, _ in_property P do .... endfor
  87.   
  88.      -> ( x, _, z )
  89.  
  90. It might even make sense to use it in push-mode as well as pop-mode.  
  91. For example ....
  92.  
  93.      ident _
  94.  
  95. As you can see, the presense of an anonymous variable would be an
  96. elegant device.  The two proposed names for it are _ and undef.
  97. The advantage of "_" as a name is that it is exactly the same
  98. name as used by Prolog and SML which support an extremely similar
  99. idea.  The advantage of "undef" is that it is a reserved word with
  100. approximately the right associations.
  101. The problem with "_" is that it binds to "->", although I regard
  102. this is pretty insignificant.  The problem with "undef" is that
  103. it is visually bulky which I feel inappropriate.
  104.  
  105. But I'd prefer either to the ghastly assignment to empty expressions!
  106.  
  107. Steve
  108.