home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / misc / 3745 < prev    next >
Encoding:
Text File  |  1992-11-17  |  7.4 KB  |  168 lines

  1. Newsgroups: comp.lang.misc
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!wupost!micro-heart-of-gold.mit.edu!news.bbn.com!noc.near.net!news.cs.brandeis.edu!chaos.cs.brandeis.edu!waterman
  3. From: waterman@chaos.cs.brandeis.edu (T.S. Waterman)
  4. Subject: Syntax and expressiveness (Re: Accessing the hardware directly
  5. Message-ID: <waterman.722038647@chaos.cs.brandeis.edu>
  6. Sender: news@news.cs.brandeis.edu (USENET News System)
  7. Reply-To: waterman@cs.brandeis.edu
  8. Organization: CAVEAT Labs, Inc.
  9. References: <721626972@sheol.UUCP> <BxpsHo.MID@mentor.cc.purdue.edu> <mwm.2n3n@contessa.palo-alto.ca.us> <BxrK6x.A04@mentor.cc.purdue.edu>
  10. Date: Tue, 17 Nov 1992 22:17:27 GMT
  11. Lines: 155
  12.  
  13. (I have no idea why I'm joining the fray, but here goes)
  14.  
  15. hrubin@pop.stat.purdue.edu (Herman Rubin) writes:
  16. >mwm@contessa.palo-alto.ca.us (Mike Meyer) writes:
  17.  
  18. >>If you don't like the syntax they provide for accessing these
  19. >>facilities, bitch at *them*. Have you called the people who build the
  20. >>machines you use and asked for a more accessible assembler?
  21.  
  22. >It is not a matter of access, but of SYNTAX.  
  23.  
  24. It would seem Mr. Meyer was referring not to the physical accessibility
  25. of the assembler, but it's ability to provide access to the 
  26. manipulations you might want to perform. This can be viewed as matching
  27. its syntax to your own notation for manipulating the machine.
  28.  
  29.   What you've said you want, Mr. Rubin, is a method of extending
  30. a given language's syntax. Those available do not seem to fit your
  31. needs.  What you should be aware of, however, is that the tools
  32. to construct new language syntax, and to modify existing languages, exist.
  33. In fact, they are well developed and are used extensively for
  34. purposes exactly as you have described needing.
  35.  
  36. >What I have asked for is that the language be fully extensible.  If
  37. >I want to add another type, I do so.  To SOME extent, C has this in
  38. >structs, and C++ does a good job with its classes.  
  39.  
  40. >> [about writing a language specification]
  41.  
  42. >I still do not know what you mean by a spec.  I have stated that one
  43. >thing which is certainly going to be needed is a really versatile
  44. >macro converter.
  45. >...
  46.  
  47. These converters exist, in numerous forms and specializations.
  48. When they get complex and versatile enough, they are usually
  49. referred to as 'compiler generators'.
  50.  
  51. >Looking at what I have written above, the types certainly will not be
  52. >limited to those in the current languages.  Bob Silverman has given 
  53. >some examples of the notation; he would like to write
  54.  
  55. >    c = a ** b
  56.  
  57. >to multiply two integers of a given size to form a double length integer.
  58. >Now in C++ one could insert a function doubmult, and even overload it to
  59. >handle the possibility of different lengths being doubled, and instruct
  60. >the compiler (?) to inline this.  Now with the macro converter, Bob would
  61. >still have to define the function doubmult, but he could also have the
  62. >macro conversion instruction
  63.  
  64. >###     a ** b    {
  65. >    doubmult(a,b);}#
  66.  
  67. >or some other suitable notation, and then he could blithely write a ** b
  68. >in the program wherever he wants to.   Now there are more complicated
  69. >situations.
  70.  
  71. This is already a very comlicated situation!  While consistently comlaining
  72. about the syntax of available language, you do not seem to show an appreciation
  73. of how difficult it is in the general case to reduce a notation to the 
  74. specific operations you understand it to mean.
  75.   For instance, what priority does this new '**' operation take (what is
  76. its associativity)? when you write  a + b ** c, or even a ** b ** c, what
  77. exactly do you mean. You need to specify this in your macro extension
  78. as well. 
  79.   One problem with this is that the numberous possible syntactic
  80. interactions between various operator specifications adds largely
  81. to the complexity of writing a compiler; more exactly, to the
  82. complexity of that compiler's _parser_. Thus, every time you add a new
  83. operator, you add a large number of possible decisions to
  84. the interpretation of an arbitrary program.
  85.  
  86.  
  87. >There is one which even others have cited as "impossible"
  88. >to understand.  I will now endeavor to show that it is not so bad, and
  89. >I will give most of what it is doing, and why.  The syntax is
  90.  
  91. >    c{'z} ={tc} {-}{|}{ta} a{'x} OP{mod} {|}{tb} b{'y} {/\{~}w}
  92. >      1     2    3  4   5     6  7   8    9  10    11   12 13
  93.  
  94. >Since there are so many optional fields, I have numbered them.  Now this
  95. >is what it requires:
  96.  
  97. > [long list of chioice and switching options for the various fields]
  98.  
  99.     This situation is far from the impossible. You have demonstrated
  100. that by giving a decision algorithm stating what should be done in
  101. every case.  The fact that you can do so leads me to think that you
  102. can easily write a macro to convert this notation to the appropriate
  103. set of declarations and statements in assembly, or any other
  104. language suitable for specifying such things as odd and even registers
  105. and half or full vectors (whatever they ore).
  106.  
  107.   C contains, as a set of programs adjuct to the compiler, a
  108. preprocessor, which does lexical substitutions for specific
  109. expressions. It has a very limitted syntax and control structure.
  110. It can be written in less than a page or two of lex/yacc/C.
  111. The most complex thing about it is it's ability to keep track of
  112. the macro names (not very hard, on any scale).
  113.  
  114.   Obviously, this macro language (for it is a language, seperate from C,
  115. even though it is described in the same texts) is not enough for what
  116. you want to do. Since you, with perhaps a very few others, are the
  117. ones in need of a powerful meta syntax, the answer is obvious:
  118.   Write Your Own.
  119.  
  120.   Oh Right! you say, I'm going to go write my own language syntax!
  121. Well why not? You did it four paragraphs above. You do it all the
  122. time, specifying notations particular to the problem at hand.
  123. What you don't seem to realize is that you _can_ specify a language
  124. about as easily as you can specify the decision algorithm you gave
  125. for the notation above.
  126.   This is not a brush-off --- I do this all the time.  I've written
  127. 4 different interpretters and cross-compilers in the last few months,
  128. simply in order to get work done. They're not major projects.
  129. One was in Lisp, two in prolog, and one I wrote using lex, yacc and C.
  130. It's not very difficult.
  131.  
  132.   Get yourself a copy of Aho, Sethi and Ullman "Compilers". I think
  133. it's in 3rd edtion by now.  The process of writing a language
  134. specification and implementing a parser and compiler are well described.
  135. From scratch, I bet you can write a cross-compiler from your notation
  136. to C (or whatever) in about 3 weeks, half time. The second one you write
  137. will take 1/3 that time.  You can even write the converter at the
  138. time you're developing the notation for your current problem.
  139.  
  140.  
  141. In this way, you'll be able to specify the problem in a notation that
  142. reflects its intrinsic structure (as far as that is reflected in the
  143. notation), and only have to write out those horrendous chunks of 
  144. nested pointer chains once, when you write the compiler. 
  145. This should simplify your life by allowing you to think about the
  146. problem at hand, rather than constantly thinking about how
  147. to convert it into a procedure that runs over your hardware.
  148.  
  149.  
  150. >I do not see how any system of references will enable writing
  151.  
  152. >    *fill(*descriptor)
  153.  
  154. >any faster. 
  155.  
  156. How about
  157.     fill(descriptor)  ?
  158.  
  159. Remeber, the dereferencing of the names 'fill' and 'descriptor'
  160. are done only once, at _compile_ time, and don't take up a single
  161. iota of energy at _run_ time.
  162.  
  163. --ts
  164. Natural Language and Generative Semantics,
  165. Brandeis Univ.
  166. Waltham, MA 02254
  167.  
  168.