home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / rexx / 787 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  9.0 KB

  1. Path: sparky!uunet!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!aun.uninett.no!ugle.unit.no!ugle!anders
  2. From: anders@lise3.lise.unit.no (Anders Christensen)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: Blanks, REXX, and portability...
  5. Message-ID: <ANDERS.92Aug26105620@lise3.lise.unit.no>
  6. Date: 26 Aug 92 08:56:20 GMT
  7. References: <9208260321.AA05688@SERVER.uwindsor.ca>
  8. Sender: news@ugle.unit.no (NetNews Administrator)
  9. Organization: /home/flipper/anders/.organization
  10. Lines: 192
  11. In-Reply-To: ophof@SERVER.UWINDSOR.CA's message of 26 Aug 92 03:21:29 GMT
  12.  
  13. In article <9208260321.AA05688@SERVER.uwindsor.ca> ophof@SERVER.UWINDSOR.CA (Scott Ophof) writes:
  14.  
  15. > Question:  When are blanks not only the space character?
  16. > Answer:    In any case in Unix.
  17.  
  18. Answer is incorrect .... Correct answer (for any ASCII-based system):
  19.  
  20. In some cases, blanks are tabs and in some cases blanks are spaces, and 
  21. it is sometimes hard to predict it in advance, and it might differ
  22. from machine to machine, and from login-session to login-session. 
  23.  
  24. > In "The REXX Language" (Mike Cowlishaw) and most other REXX
  25. > publications meant for CMS and equivs, the character known as
  26. > "space" and the concept of "blanks" are used interchangeably.
  27.  
  28. TRL always uses the terms 'blank' and 'blanks', I believe?
  29.  
  30. > For CMS-REXX (and analogous implementations), this poses no
  31. > problems.  The space character is the *only* character defined
  32. > as a "blank".
  33. > (Note that I'm *not* talking about non-printable characters,
  34. > and the space char *is* a printable character!)
  35.  
  36. Actually, this is rather a EBCDIC vs ASCII conflict, rather than a
  37. CMS vs the-rest-of-the-world (is there is difference, btw? :-)
  38.  
  39. In ASCII, the following characters are often considered 'whitespace',
  40. listed in decreasing order of 'whitespaceness' (codes in decimal)
  41.  
  42.    ascii 32 - space
  43.    ascii  9 - HT (horizontal tab)
  44.    ascii 10 - LF (line feed) 
  45.    ascii 13 - CR (carriage return) 
  46.    ascii 12 - NP (new page, or FF - formfeed)
  47.    ascii 11 - VT (vertical tab)  
  48.  
  49. There might be even more. And worse, in some modes, I think characters
  50. above 128 are space characters, like hard-space (a space that can not
  51. be divided between lines).  In particular the HT is considered
  52. whitespace, since it conceptually a number of compressed space
  53. characters (customarily 2-8).
  54.  
  55. > Under Unix however, the tab character (and some others) are
  56. > considered "blanks", though it's called "whitespace" there.
  57. > At least some REXX implementations for Unix recognize more than
  58. > the space char as whitespace.  And REXX on the PC recognizes at
  59. > least the space char and the tab char as whitespace/blank...
  60.  
  61. Well ... try this if you are using Unix: 
  62.  
  63.     who | od -a 
  64.  
  65. Now, are all whitespace spaces, or is there any tabs (ht) mixed into
  66. the output? *Many* of the Unix commands use tab and other whitespace
  67. characters in the output. Reason: to save characters. If you are using
  68. a 300 baud modem line, compressing 8 spaces to a tab is a Major
  69. Advancement of Civilization.
  70.  
  71. > My point?
  72. > I would hate to have to port to CMS any REXX program written for
  73. > Unix (or PC); to have a program fail due to something like this
  74. > would not be very easy to debug...
  75.  
  76. I think you would hate even more to port a rexx program from one unix
  77. machine to another unix machine; and have the program fail due to one
  78. of the machines being more intelligent about compressing spaces to
  79. tabs. And it is far more probable that you would do that, than porting
  80. between CMS and Unix! And, this is not just a Unix problem; it is more
  81. or less a ASCII problem. 
  82.  
  83. If the ANSI REXX committee requires that blank have one specific
  84. character code within each character set, then IMHO the committee has
  85. made Rexx harder to move *from* EBCDIC (i.e. IBM mainframes), not
  86. eased the spreading of Rexx to the rest of the computing community.
  87. Most machines use multiple characters as blanks, and Rexx should not
  88. be limited to just those machine which have One Blank character.
  89.  
  90. By the way ... I really can't see the problem?  Unix generates tabs
  91. and spaces as whitespace, the Unix rexx interpreter interprets boths as
  92. blanks, No problem! 
  93.  
  94. You port it to CMS: CMS generates spaces as whitespace, the CMS
  95. interpreter interprets only space as blanks. No problem.
  96.  
  97. You ftp a file from Unix to CMS. You don't use binary mode, since the
  98. ASCII code would be unreadable on a EBCDIC machine anyway. So you use
  99. text mode, and your CMS machine translates the text to EBCDIC,
  100. including translating the tabs to spaces. No problem.
  101.  
  102. You ftp a file from CMS to Unix, by the same reason as above, you use
  103. text mode, all the CMS spaces becomes Unix spaces. No problem. 
  104.  
  105. Your Unix code contains parse patterns like '09'x to match a tab, you
  106. take your program over to CMS. But if you make assumptions about the
  107. glyphs of the characters, you're in trouble anyway. In fact, if your
  108. Unix Rexx interpreter interpreted tab as a whitespace character, you
  109. probably wouldn't have had to parse on the '09'x pattern in the first
  110. place. No problem. 
  111.  
  112. Where is the problem, Scott?
  113.  
  114. (Oops, I seem to have assumed that all Unix machines are ASCII, which
  115. is probably not correct; interpret "CMS" as EBCDIC-based, and Unix as
  116. ASCII-based in the list above, that is more what I meant.)
  117.  
  118. > My suggestion?
  119. > In the interest of increasing the chance of successful porting, to
  120. > request the ANSI-REXX committee to define that the *only* blank/
  121. > whitespace recognized in standard REXX is the SPACE character (ASCII
  122. > hex-20, EBCDIC hex-40).
  123.  
  124. And there is indeed also a very good chance that this suggestion (if
  125. accepted) will make any rexx interpreter for Unix rather useless, or
  126. at best, just redline the astonishing factor (see end of posting for
  127. an example).
  128.  
  129. Instead, perhaps the ANSI REXX committee should look over the shoulder
  130. of the ANSI C committee, and how they solved the problem of
  131. whitespace, and their definition of the isspace() function.
  132.  
  133. If the ANSI REXX committee determines that one particular character in
  134. ASCII and one particular character in EBCDIC is to be considered the
  135. Only True Blank, it might even have consequences for using Rexx with
  136. national characters (locales) (yes, in some systems, blanks may even
  137. depend on the language chosen!).
  138.  
  139. Section one of TRL states that Rexx "... involve the use of two
  140. character sets." One used for the rexx script (source code), and one
  141. used by the interpret under execution (data). If you want to define
  142. that a rexx script may only include certain characters as blanks under
  143. parsing of the source code (except in quotes and comments), that's
  144. fine. However, if you suggests that only certain characters should be
  145. recognized by the interpreter as blanks under execution (as data), then
  146. I fear Real Trouble. 
  147.  
  148. I also want to question whether appointing specific character codes as
  149. the Only True Blank, is in the spirit of TRL. To quote section 1:
  150. "[...] this book uses characters to convey meaning and not to imply a
  151. specific character code [...] At no time is REXX concerned with the
  152. glyph (actual appearance) of a character."
  153.  
  154. The way I read the, a Blank is the common character used as a Blank in
  155. the operating system that you are running. Consequently, if your
  156. operating system has more than one blank character, all these are
  157. interpreted as blanks. However, as a default to pad characters in the
  158. builtin functions, it would be appropriate to require that one single
  159. character is used consistently. But I still think it should be beyond
  160. the definition of Rexx as a language to specify which character that
  161. is in the various character sets.
  162.  
  163. > Your comments?  :-)
  164.  
  165. Please, by all means, standardize what a blank is, but *please*, don't
  166. standardize it in such a way, that it makes it impossible to use the a
  167. true standard Rexx interpreter on some platforms. 
  168.  
  169. My suggestion?  
  170. In the interest of increasing the chance of successful porting of the
  171. Rexx standard itself from EBCDIC to ASCII based systems, to request
  172. that the ANSI-REXX committee explicitly allows the common whitespace
  173. characters of the host operating system to be interpreted as 'blank'
  174. characters, and that the definition of exactly what is blank, is
  175. implementation-dependent and system-dependent.
  176.  
  177. -anders
  178.  
  179. So, the example I promised. The output from the command 'who' on
  180. this machine (ultrix) currently is:
  181.  
  182. > jorgens  ttyp0   Aug 24 10:51   (129.241.27.23:0.)
  183. > anders   ttyp3   Aug 26 09:05   (129.241.36.3:0.0)
  184.  
  185. Suppose the address syntax made it possible to push something on the
  186. stack, then the following Rexx program ought to work:
  187.  
  188.    address unix to queue 'who'
  189.    do queued()
  190.       parse pull user . . . time node 
  191.       say user 'is logged in from' node 'at time' time'!'
  192.       end
  193.  
  194. Simple isn't it? It is just that is only works on some machines, and
  195. even then only sometimes. Why would such a program write out:
  196.  
  197.    jorgens is logged in from  at time 10:51     (129.241.27.23:0.)!
  198.    anders is logged in from  at time 09:05      (129.241.36.3:0.0)!
  199.  
  200. The answer is, there is at tab between the time and the hostname. This
  201. rexx script will work, dependent on the machine type, the terminal
  202. type, the mood of your system operator and a lot of other conditions.
  203. Prohibiting the tab as a space did not *help* the user in this
  204. situation, in fact it will only confuse.
  205.