home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group88a.txt < prev    next >
Internet Message Format  |  1988-10-29  |  333KB

  1. From icon-group-request  Fri Jan  1 02:17:02 1988
  2. From: grand!day@uunet.uu.net  (Dave Yost)
  3. Organization: Grand Software, Inc., 213-650-1089, Los Angeles, CA
  4. Subject: complicated sorting
  5. Sender: icon-group-request@arizona.edu
  6. To: icon-group@arizona.edu
  7. Errors-To: icon-group-request
  8. Status: RO
  9.  
  10. I need to sort a list of records
  11. according to complicated sort criteria,
  12. The standard icon sort() routine is
  13. not making this task easy.  What I
  14. need is something more like the C
  15. library qsort routine that lets me
  16. provide my own comparison routine.
  17.  
  18. Is there any hope of my finding something
  19. like this in icon, or am I missing some
  20. elegant way to do this with the existing
  21. sort() routine?
  22.  
  23.   --dave yost
  24.  
  25. From icon-group-request  Sun Jan  3 13:39:43 1988
  26. From: "Kenneth Walker" <kwalker>
  27. In-Reply-To: <397@grand.UUCP>
  28. To: grand!day@uunet.uu.net, icon-group@arizona.edu
  29. Subject: Re:  complicated sorting
  30. Errors-To: icon-group-request
  31. Status: O
  32.  
  33.     Date: 1 Jan 88 05:33:51 GMT
  34.     From: grand!day@uunet.uu.net  (Dave Yost)
  35.     
  36.     I need to sort a list of records
  37.     according to complicated sort criteria,
  38.     The standard icon sort() routine is
  39.     not making this task easy.  What I
  40.     need is something more like the C
  41.     library qsort routine that lets me
  42.     provide my own comparison routine.
  43.     
  44.     Is there any hope of my finding something
  45.     like this in icon, or am I missing some
  46.     elegant way to do this with the existing
  47.     sort() routine?
  48.     
  49. The comparison routine used by the Icon sort function is built
  50. into the run-time system and cannot be overriden without
  51. modifying Icon.
  52.  
  53. Sometimes a comlicated sort criterion can be handled by constructing
  54. artifical keys for records such that a key sorts the corrosponding
  55. record where it needs to go in the sequence. The records can then
  56. be put in a table using the keys and the table can be sorted to
  57. produce the desired sequence of records. The artifical keys would
  58. typically be strings. If such keys are not easy to produce, your
  59. best bet is probably to write a sort procedure in Icon specific to
  60. your application.
  61.  
  62. From icon-group-request  Mon Jan  4 17:37:23 1988
  63. From: ihnp4!ihuxy!nowlin
  64. Message-Version: 2
  65. >To: /addr=ihnp4!arizona!icon-group
  66. End-Of-Header: 
  67. Email-Version: 2
  68. X-Postmark: jerry.d.nowlin attbl ix1c461 55621 3129790441 ihuxy!nowlin
  69. To: arizona!icon-group
  70. Subject: Re: complicated sort
  71. Ua-Message-Id: <post.nowlin.Mon 04 Jan 1988 09:02 CST>
  72. End-Of-Protocol: 
  73. Content-Length: 2730
  74. Errors-To: icon-group-request
  75. Status: O
  76.  
  77. > I need to sort a list of records according to complicated sort criteria,
  78. > The standard icon sort() routine is not making this task easy.  What I need
  79. > is something more like the C library qsort routine that lets me provide my
  80. > own comparison routine.
  81. > Is there any hope of my finding something like this in icon, or am I
  82. > missing some elegant way to do this with the existing sort() routine?
  83. >   --dave yost
  84.  
  85. I'm not sure this is what you had in mind but the procedure enclosed is
  86. handy for sorting records and can be modified to work with your own
  87. comparison routines fairly easily.  I don't know of any way to use the
  88. builtin sort() for anything other than standard types.
  89.  
  90. This recsort() procedure only sorts on one field of a record but it
  91. wouldn't be too hard to pass it a list of the fields in the record that
  92. should be sorted on instead of a single value.  The way the intermediate
  93. table of records is maintained will make it fairly easy to sort on multiple
  94. keys.  Hope this is helpful.  (Sorry for the lack of comments.)
  95.  
  96. Jerry Nowlin
  97. (...!ihnp4!ihuxy!nowlin)
  98.  
  99. # This example program sorts a UNIX style password file.  The first
  100. # argument to the program should be the field in each password entry to
  101. # sort on.  The program has a limit of the first 20 entries built in but
  102. # it can be removed to test the program on the whole password file.  The
  103. # program uses the recsort() procedure to sort a list of records.
  104.  
  105. record    passwd(name,pass,uid,gid,info,logdir,shell)
  106.  
  107. procedure main(args)
  108.  
  109.     if *args = 0 then stop("I need a numeric field index to sort on")
  110.  
  111.     users := []
  112.  
  113.     in := open("/etc/passwd","r")
  114.  
  115.     every line := !in\20 do line ? {
  116.  
  117.         user := passwd()
  118.         user.name := tab(upto(':')) & move(1)
  119.         user.pass := tab(upto(':')) & move(1)
  120.         user.uid := tab(upto(':')) & move(1)
  121.         user.gid := tab(upto(':')) & move(1)
  122.         user.info := tab(upto(':')) & move(1)
  123.         user.logdir := tab(upto(':')) & move(1)
  124.         user.shell := tab(0)
  125.         put(users,user)
  126.  
  127.     }
  128.  
  129.     close(in)
  130.  
  131.     write("UNSORTED: ",image(users)," ",image(users[1]))
  132.     every user := !users do write(    user.name," : ",
  133.                     user.pass," : ",
  134.                     user.uid," : ",
  135.                     user.gid," : ",
  136.                     user.info," : ",
  137.                     user.logdir," : ",
  138.                     user.shell)
  139.  
  140.     stuff := recsort(users,!args)
  141.  
  142.     write("\nSORTED: ",image(stuff)," ",image(stuff[1]))
  143.     every user := !stuff do write(    user.name," : ",
  144.                     user.pass," : ",
  145.                     user.uid," : ",
  146.                     user.gid," : ",
  147.                     user.info," : ",
  148.                     user.logdir," : ",
  149.                     user.shell)
  150.  
  151. end
  152.  
  153. procedure recsort(recs,index)
  154.  
  155.     tempt := table()
  156.  
  157.     every rec := !recs do
  158.         (/tempt[rec[index]] := [ rec ]) | put(tempt[rec[index]],rec)
  159.  
  160.     templ := sort(tempt,1)
  161.  
  162.     newrecs := []
  163.  
  164.     every pair := !templ do
  165.         every put(newrecs,!pair[2])
  166.  
  167.     return newrecs
  168.  
  169. end
  170.  
  171. From icon-group-request  Tue Jan  5 01:07:52 1988
  172. From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  173. To: icon-group@arizona.edu
  174. Subject: find/upto
  175. Errors-To: icon-group-request
  176. Status: O
  177.  
  178.  
  179. Can someone explain to me why
  180.  
  181.           str := "hello"
  182.           write(str[find("",str):0])
  183.  
  184. writes "hello", while
  185.  
  186.           str := "hello"
  187.           write(str[upto('',str):0])
  188.  
  189. writes nothing?
  190.  
  191.                           -Richard
  192.  
  193. From icon-group-request  Tue Jan  5 14:10:31 1988
  194. From: Brain in Neutral <bin@rhesus.primate.wisc.edu>
  195. To: icon-group@arizona.edu
  196. Subject: Icon document request
  197. Errors-To: icon-group-request
  198. Status: O
  199.  
  200.  
  201. I'd like to order IPD18 "Benchmarking Icon Expressions" and IPD41
  202. "Tabulating Expression Activity in Icon", please.  My address is
  203.  
  204. Paul DuBois
  205. University of Wisconsin-Madison Primate Center
  206. 1220 Capitol Court
  207. Madison, WI 53715-1299
  208.  
  209. (608) 263-3509
  210.  
  211.  
  212. Thank you,
  213. Paul DuBois
  214. dubois@rhesus.primate.wisc.edu    rhesus!dubois
  215. bin@rhesus.primate.wisc.edu    rhesus!bin
  216.  
  217. From icon-group-request  Tue Jan  5 17:25:09 1988
  218. From: "Kenneth Walker" <kwalker>
  219. In-Reply-To: <8801050803.AA14397@sophist.uchicago.edu>
  220. To: goer%sophist@gargoyle.uchicago.edu, icon-group@arizona.edu
  221. Subject: Re:  find/upto
  222. Errors-To: icon-group-request
  223. Status: O
  224.  
  225. >  Date: Tue, 5 Jan 88 02:03:48 CST
  226. >  From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  227. >  
  228. >  Can someone explain to me why
  229. >  
  230. >            str := "hello"
  231. >            write(str[find("",str):0])
  232. >  
  233. >  writes "hello", while
  234. >  
  235. >            str := "hello"
  236. >            write(str[upto('',str):0])
  237. >  
  238. >  writes nothing?
  239. >  
  240. >                            -Richard
  241. >  
  242.  
  243. find("", str) searches str for the substring "". The empty string occurs
  244. as a substring at every point in every string (in particular at the beginning).
  245.  
  246. upto('', str) searches str for characters in the character set (cset) ''.
  247. This set contains no characters for upto to locate, so it fails to locate
  248. any.
  249.  
  250. From icon-group-request  Wed Jan  6 12:37:53 1988
  251. From: grand!day@uunet.UU.NET
  252. Posted-Date: Tue, 05 Jan 88 23:38:53 PST
  253. To: icon-group@arizona.edu
  254. Cc: day@uunet.UU.NET
  255. Subject: open ("command", "wp)
  256. Organization: Grand Software, Inc., makers of "The Grand Editor"
  257. Domain-From: day@grand.COM
  258. Phone: 213-650-1089
  259. Errors-To: icon-group-request
  260. Status: O
  261.  
  262. Consider the following /bin/sh script:
  263.  
  264. echo finished | (sleep 15 ; cat)
  265.  
  266. Compare that with the following icon program:
  267.  
  268. procedure
  269. main (args)
  270.     local output
  271.  
  272.     if not (output := open ("sleep 15 ; cat",  "wp")) then
  273.     stop ("trmsg: can't open a pipe for writing")
  274.     write (output, "finished")
  275.     return
  276. end
  277.  
  278. I believe they should be functionally equivalent.
  279. They're not.  The shell script waits for the cat,
  280. while the icon version exits immediately after
  281. writing to the pipe, without waiting.
  282.  
  283. I think this is an obvious bug.
  284. If you don't agree, I will be happy to explain more fully.
  285.  
  286.  --dave
  287.  
  288. From icon-group-request  Wed Jan  6 12:50:32 1988
  289. From: "Kelvin Nilsen" <kelvin>
  290. In-Reply-To: <8801060738.AA13176@grand.COM>
  291. To: grand!day@uunet.UU.NET, icon-group@arizona.edu
  292. Subject: Re:  open ("command", "wp)
  293. Cc: day@uunet.UU.NET
  294. Errors-To: icon-group-request
  295. Status: O
  296.  
  297. >
  298. >procedure
  299. >main (args)
  300. >    local output
  301. >
  302. >    if not (output := open ("sleep 15 ; cat",  "wp")) then
  303. >    stop ("trmsg: can't open a pipe for writing")
  304. >    write (output, "finished")
  305. >    return
  306. >end
  307. >
  308.  
  309. in the above, add a close(output) before the return.  this works
  310. for me.
  311.  
  312.  
  313.  
  314. From icon-group-request  Wed Jan  6 16:16:26 1988
  315. From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  316. To: icon-group@arizona.edu
  317. Subject: shell script vs. icon pipes
  318. Errors-To: icon-group-request
  319. Status: O
  320.  
  321.  
  322. In response to a posting (which I have - unfortunately - rm'ed), try:
  323.  
  324. procedure main()
  325.     local output, com
  326.     com := "echo \'this is a message\' | (sleep 15; cat)"
  327.     output := open(com,"rp") | stop("Try again :-)")
  328.     write(!output)
  329. end
  330.  
  331. This also works fine.  You could, of course, do com := arg[1] || "| (sleep
  332. 15; cat)".
  333.  
  334. From icon-group-request  Mon Jan 11 11:39:27 1988
  335. From: ihnp4!ihuxy!nowlin
  336. Message-Version: 2
  337. >To: /addr=ihnp4!arizona!icon-group
  338. Email-Version: 2
  339. X-Postmark: jerry.d.nowlin attbl ix1c461 55621 3129790441 ihuxy!nowlin
  340. To: arizona!icon-group
  341. Subject: Re: open ("command", "wp)
  342. Ua-Message-Id: <post.nowlin.Thu 07 Jan 1988 10:01 CST>
  343. Content-Length: 1563
  344. Errors-To: icon-group-request
  345. Status: O
  346.  
  347. > Consider the following /bin/sh script:
  348. > echo finished | (sleep 15 ; cat)
  349. > Compare that with the following icon program:
  350. > procedure
  351. > main (args)
  352. >     local output
  353. >     if not (output := open ("sleep 15 ; cat",  "wp")) then
  354. >     stop ("trmsg: can't open a pipe for writing")
  355. >     write (output, "finished")
  356. >     return
  357. > end
  358. > I believe they should be functionally equivalent.
  359. > They're not.  The shell script waits for the cat,
  360. > while the icon version exits immediately after
  361. > writing to the pipe, without waiting.
  362. > I think this is an obvious bug.
  363. > If you don't agree, I will be happy to explain more fully.
  364. >  --dave
  365.  
  366. I don't see why this is an Icon bug.  The real culprit is the program.  If
  367. you'll add a close(output) to your program then the program will wait for
  368. the process attached to the pipe to complete and you'll see the behavior
  369. you expected.
  370.  
  371.     procedure
  372.     main (args)
  373.         local output
  374.  
  375.         if not (output := open ("sleep 15 ; cat","wp")) then
  376.             stop ("trmsg: can't open a pipe for writing")
  377.         write (output, "finished")
  378.  
  379.         close(output)  #  IMPORTANT LINE
  380.  
  381.         return
  382.     end
  383.  
  384. If you open the pipe, write to it, and then terminate your Icon program
  385. without waiting for the pipe to complete (sort of pull the rug out from
  386. under it) the output to the pipe stays in the input buffer of the spawned
  387. commands and when the sleep completes the cat will pick it up.  Learn to
  388. program symmetrically so that files or pipes that are opened are also
  389. closed and you will run into far fewer problems.
  390.  
  391. Jerry Nowlin
  392. (...!ihnp4!ihuxy!nowlin)
  393.  
  394. From icon-group-request  Mon Jan 11 11:39:31 1988
  395. From: grand!day@uunet.UU.NET
  396. Posted-Date: Fri, 08 Jan 88 17:33:06 PST
  397. To: "Kenneth Walker" <kwalker@arizona.edu>
  398. Cc: icon-group@arizona.edu, day@uunet.UU.NET
  399. Subject: Re: complicated sorting
  400. In-Reply-To: Your message of Sun, 03 Jan 88 13:38:47 MST.
  401.              <8801032038.AA13538@megaron.arizona.edu> 
  402. Organization: Grand Software, Inc., makers of "The Grand Editor"
  403. Domain-From: day@grand.COM
  404. Phone: 213-650-1089
  405. Errors-To: icon-group-request
  406. Status: O
  407.  
  408.     Date: Sun, 3 Jan 88 13:38:47 MST
  409.     From: "Kenneth Walker" <arizona.edu!kwalker@uunet.UUCP>
  410.     In-Reply-To: <397@grand.UUCP>
  411.     To: day@grand.UUCP, icon-group@arizona.edu
  412.     Subject: Re:  complicated sorting
  413.  
  414.     The comparison routine used by the Icon sort function is built
  415.     into the run-time system and cannot be overriden without
  416.     modifying Icon.
  417.  
  418. Right.
  419.  
  420.     Sometimes a comlicated sort criterion can be handled by constructing
  421.     artifical keys for records such that a key sorts the corrosponding
  422.     record where it needs to go in the sequence. The records can then
  423.     be put in a table using the keys and the table can be sorted to
  424.     produce the desired sequence of records. The artifical keys would
  425.     typically be strings.
  426.  
  427. This is exactly what I am doing, and it's cumbersome.
  428.  
  429.     If such keys are not easy to produce, your best bet is probably
  430.     to write a sort procedure in Icon specific to your application.
  431.  
  432. I believe the best solution is a more powerful sort function
  433. to which the user supplies the comparison procedure, like qsort
  434. in the C library.
  435.  
  436. The problem I am solving in icon (thank God and you people I'm
  437. not trying to do it in C!) is the preparation of a book index.
  438. The index is a list of entries consisting of a list of subentries
  439. consisting of a list of page numbers.
  440.  
  441. A built-in function a la the C library qsort, would help.
  442. It might look like this:
  443.  
  444. sortx(a, p)
  445.  
  446.     Sortlist is a stable sort which sorts list a and
  447.     produces a new, sorted list.  Procedure p is called each
  448.     time sortx needs to compare two list entries.  It takes
  449.     two arguments and returns -1, 0, or 1 when the first
  450.     argument is less than, equal to, or greater than the
  451.     second argument, respectively.  If p is omitted, the
  452.     standard icon sort order is used.
  453.  
  454. Since I wrote my first message on this subject, I now see
  455. that even this proposed sortx doesn't really cut it for my
  456. present problem.  It turns out to be the trivial case of what
  457. I really need:
  458.  
  459. sortlist(a, p, depth)
  460.  
  461.     Sortlist is a stable sort which sorts list a and
  462.     produces a new, sorted tree of lists of the specified
  463.     depth.  In the simplest case, when the depth argument is
  464.     1 or not specified, sortlist returns a simple sorted
  465.     list.  If depth is 2, then a list of lists is returned,
  466.     and so on for greater values of depth.
  467.  
  468.     Procedure p is called each time sortlist needs to
  469.     compare two list entries.  If p is not specified, the
  470.     standard icon sort order is used.
  471.  
  472.     When depth is not specified or is 1, procedure p must be
  473.     in this form:
  474.  
  475.     procedure p(x1, x2)
  476.        return relation_result
  477.     end
  478.  
  479.     where relation_result return value is -1, 0, or 1 when
  480.     x1 is less than, equal to, or greater than x2,
  481.     respectively.
  482.  
  483.     When depth is specified and is > 1, procedure p must be
  484.     in this form:
  485.  
  486.     record sortcompare(relation, depth)
  487.  
  488.     procedure p(x1, x2)
  489.        return sortcompare(relation_result, depth_result)
  490.     end
  491.  
  492.     The relation_result return value is -1, 0, or 1 when x1
  493.     is less than, equal to, or greater than x2, respectively.
  494.  
  495.     The depth_result return value specifies how deep p had
  496.     to go in making the comparison before deciding on the
  497.     value for the relation field.  For efficiency, it is
  498.     advisable to write procedure p so that it never bothers
  499.     to compare to a depth greater than needed by its caller.
  500.  
  501.     For example, the list [ "aa", "ba", "bb", "c" ] sorted to
  502.     a depth of 2 with the aid of a suitable comparison routine
  503.     could yield: [ [ "aa" ], [ "ba", "bb" ], [ "c" ] ]
  504.  
  505. Such a function would be perfect for my application, and I
  506. bet it would be a useful and powerful tool for other sorting
  507. problems.
  508.  
  509. I don't have an algorithm to implement this.
  510. I wish I did.  Any takers?
  511.  
  512. To be sure what I'm getting at is clear, here's an example:
  513.  
  514. procedure
  515. cmp(x1, x2)
  516.     if x2[1] ~== x1[1] then return sortcompare(x2[1] - x2[1], 1)
  517.     if x2[2] ~== x1[2] then return sortcompare(x2[2] - x2[2], 2)
  518.     return sortcompare(x2[3] - x2[3], 3)
  519. end
  520.  
  521. Input:  ["aaa", "baa", "bba", "caa", "cab" ]
  522.  
  523. Call:   sortlist(Input, p, 1)
  524. Output: [ "aaa", "baa", "bba", "caa", "cab" ]
  525.  
  526. Call:   sortlist(Input, cmp, 2)
  527. Output: [
  528.       [ "aaa" ],
  529.       [ "baa", "bba" ],
  530.       [ "caa", "cab" ]
  531.     ]
  532.  
  533. Call:   sortlist(Input, cmp, 3)
  534. Output: [
  535.       [
  536.         [ "aaa" ]
  537.       ],
  538.       [
  539.         [ "baa" ],
  540.         [ "bba" ]
  541.       ],
  542.       [
  543.         [ "caa", "cab" ]
  544.       ]
  545.     ]
  546.  
  547. Call:   sortlist(Input, cmp, 4)
  548. Output: [
  549.       [
  550.         [
  551.           [ "aaa" ]
  552.         ]
  553.       ],
  554.       [
  555.         [
  556.           [ "baa" ]
  557.         ],
  558.         [
  559.           [ "bba" ]
  560.         ]
  561.       ],
  562.       [
  563.         [
  564.           [ "caa" ],
  565.           [ "cab" ]
  566.         ]
  567.       ]
  568.     ]
  569.  
  570. etc.
  571.  
  572.  --dave yost
  573.  
  574. From icon-group-request  Tue Jan 12 07:51:30 1988
  575. From: grand!day@uunet.uu.net  (Dave Yost)
  576. Organization: Grand Software, Inc., Los Angels, CA 213-650-1089
  577. Subject: Re: open ("command", "wp)
  578. References: <8801091948.AA28813@megaron.arizona.edu>
  579. Sender: icon-group-request@arizona.edu
  580. To: icon-group@arizona.edu
  581. Errors-To: icon-group-request
  582. Status: O
  583.  
  584. Thanks.  I'm relieved to know that if I explicitly do the close,
  585. as I agree I should have, it works properly.  Still, the book
  586. does say that open files are closed automatically upon program
  587. termination, so my program should have acted as if I had done
  588. the close.  I have already mentioned this to the Icon Group.
  589.  
  590.  --dave yost
  591.  
  592. From icon-group-request  Tue Jan 12 12:35:40 1988
  593. From: "Kenneth Walker" <kwalker>
  594. To: icon-group
  595. Subject: Re:  complicated sorting
  596. Errors-To: icon-group-request
  597. Status: O
  598.  
  599.     From: grand!day@uunet.UU.NET
  600.     Date: Fri, 08 Jan 88 17:33:06 PST
  601.  
  602.         ...
  603.     
  604.     I believe the best solution is a more powerful sort function
  605.     to which the user supplies the comparison procedure, like qsort
  606.     in the C library.
  607.  
  608. This suggestion sounds to me like something worth putting on the list
  609. of possible future enhancements to Icon. There is an actual list.
  610. Inclusion in the list doesn't insure a feature will every get put in
  611. the language, but it does mean that it will get consideration when (and if)
  612. the next round of enhancements are implemented.
  613.     
  614.     Since I wrote my first message on this subject, I now see
  615.     that even this proposed sortx doesn't really cut it for my
  616.     present problem.  It turns out to be the trivial case of what
  617.     I really need:
  618.     
  619.         [details omitted - essentially a routine to sort on multiple
  620.          keys producing a tree structure]
  621.  
  622. I can beleive that such a routine is usefull occationally, but its need
  623. doesn't seem to me to be wide spread enough to burden the language
  624. with such a complex feature.
  625.  
  626. When I need to sort on multiple keys, I sometimes use multi-level tables.
  627. Perhaps a modification of the following routine could be used for your
  628. purposes.
  629.  
  630. #
  631. # Sort records on 3 keys. The result is a list of lists of lists (that is,
  632. #  a 3 level tree - one level for each key). The intermediate data structure
  633. #  is a table of tables of tables; each level of tables is keyed on the
  634. #  corrosponding record key.
  635. #
  636. record info(key1, key2, key3)
  637.  
  638. procedure main()
  639.    local s, w_sp
  640.    local rec
  641.    local tbl, x
  642.    local lst
  643.  
  644.    #
  645.    # 1st level table
  646.    #
  647.    tbl := table()
  648.  
  649.    #
  650.    # read records and store in intermediate table structure
  651.    #
  652.    while s := read() do {
  653.       s ? rec := info(tab(many(&lcase)),
  654.                       tab(upto(&lcase)) & tab(many(&lcase)),
  655.                       tab(upto(&lcase)) & tab(many(&lcase)))
  656.       #
  657.       # put the record in the correct table, making sure the required 2nd
  658.       # and 3rd level tables exist
  659.       #
  660.       /tbl[rec.key1] := table()
  661.       x := tbl[rec.key1]
  662.       /x[rec.key2] := table()
  663.       x := x[rec.key2]
  664.       x[rec.key3] := rec
  665.       }
  666.  
  667.    #
  668.    # convert each level of table into a sorted list
  669.    #
  670.    lst := sort_tbl(tbl)
  671.  
  672.    do_whatever(lst)
  673. end
  674.  
  675. procedure sort_tbl(tbl)
  676.    local l1, l2
  677.  
  678.    l1 := sort(tbl, 3)
  679.  
  680.    #
  681.    # remove keys from list, sorting entries if they are tables
  682.    #
  683.    l2 := list()
  684.    get(l1)
  685.    if type(l1[1]) == "table" then
  686.       while put(l2, sort_tbl(get(l1))) do
  687.          get(l1)
  688.    else
  689.       while put(l2, get(l1)) do
  690.          get(l1)
  691.    return l2
  692. end
  693.  
  694. From icon-group-request  Wed Jan 13 13:40:58 1988
  695. From: ihnp4!ihuxy!nowlin
  696. Message-Version: 2
  697. >To: /addr=ihlpe!orf, /addr=ihnp4!arizona!icon-group
  698. End-Of-Header: 
  699. Email-Version: 2
  700. X-Postmark: jerry.d.nowlin attbl ix1c461 55621 3129790441 ihuxy!nowlin
  701. To: arizona!icon-group
  702. Cc: ihlpe!orf
  703. Subject: Re: complicated sorts
  704. Ua-Message-Id: <post.nowlin.Tue 12 Jan 1988 07:04 CST>
  705. End-Of-Protocol: 
  706. Content-Length: 4176
  707. Errors-To: icon-group-request
  708. Status: O
  709.  
  710. Group,
  711.  
  712.     I sent an example sorting procedure out a couple days ago in
  713. response to a message about sorting routines.  I mentioned in the
  714. accompanying note that the procedure could be extended to sort on multiple
  715. keys with just a little modification.  I then decided to go ahead and make
  716. it sort on multiple keys on my own.  The modified routine follows.  I also
  717. commented the procedure this time so it would be easier to follow.
  718.  
  719. There is one final modification I'd like to see and I'd like some help from
  720. you Icon gurus out there.  How could I pass a list of sorting keys that
  721. consist of strings corresponding to the labels used to reference the fields
  722. in a record instead of numeric indexes for the record that is being sorted
  723. to the recsort() procedure?  If you didn't follow that question here is an
  724. example of what I mean.  Given the program that follows, If I want to sort
  725. the password file by the uid field I have to invoke the program with "3" as
  726. the sorting key.  I'd like to be able to invoke it with "uid" as the
  727. sorting key.
  728.  
  729. Any suggestions are welcome.  The real trick is to do this in a record
  730. definition independent way.  This means that recsort() can't know ahead of
  731. time about the definition of the record type it's sorting.  I don't think
  732. it can be done given the current Icon.  Please prove me wrong.
  733.  
  734. Jerry Nowlin
  735. (...!ihnp4!ihuxy!nowlin)
  736.  
  737. # This example program is to illustrate the recsort() procedure.  It sorts
  738. # a UNIX style password file.  The arguments to the program should be the
  739. # fields in each password entry to sort on in order of precedence.  The
  740. # program has a built-in limit of the first 20 entries in the password file
  741. # but it can be removed to test the program on the whole password file.
  742. # Notice that the UID and GID fields are now forced to be numeric.  Sorts
  743. # on these fields will work accordingly.
  744.  
  745. record passwd(name,pass,uid,gid,info,logdir,shell)
  746.  
  747. procedure main(args)
  748.  
  749.     if *args = 0 then stop("I need a numeric record index to sort on")
  750.  
  751.     users := []
  752.  
  753.     in := open("/etc/passwd","r")
  754.  
  755.     every line := !in\20 do line ? {
  756.  
  757.         user := passwd()
  758.         user.name := tab(upto(':')) & move(1)
  759.         user.pass := tab(upto(':')) & move(1)
  760.         user.uid := numeric(tab(upto(':'))) & move(1)
  761.         user.gid := numeric(tab(upto(':'))) & move(1)
  762.         user.info := tab(upto(':')) & move(1)
  763.         user.logdir := tab(upto(':')) & move(1)
  764.         user.shell := tab(0)
  765.         put(users,user)
  766.  
  767.     }
  768.  
  769.     close(in)
  770.  
  771.     write("UNSORTED: ",image(users)," ",image(users[1]))
  772.     every user := !users do write(    user.name,":",
  773.                     user.pass,":",
  774.                     user.uid,":",
  775.                     user.gid,":",
  776.                     user.info,":",
  777.                     user.logdir,":",
  778.                     user.shell)
  779.  
  780.     stuff := recsort(users,args)
  781.  
  782.     write("\nSORTED: ",image(stuff)," ",image(stuff[1]))
  783.     every user := !stuff do write(    user.name,":",
  784.                     user.pass,":",
  785.                     user.uid,":",
  786.                     user.gid,":",
  787.                     user.info,":",
  788.                     user.logdir,":",
  789.                     user.shell)
  790. end
  791.  
  792. # Sort a list of records by the fields given in keys.  These fields must
  793. # be numeric indexes to one or more of the fields in the record type being
  794. # sorted.  A sorted list of records is returned.
  795.  
  796. procedure recsort(recs,keys)
  797.  
  798.     # Initialize a temporary table.
  799.     tempt := table()
  800.  
  801.     # Get a sorting key.
  802.     key := get(keys)
  803.  
  804.     # Take every record in the recs list and add it to the table.
  805.     every rec := !recs do
  806.  
  807.         # Each index to the table is a different sorting key.  To
  808.         # avoid losing records which have identical sorting keys
  809.         # each value in the table must be a list of the records
  810.         # that are indexed by a given sorting key.
  811.         (/tempt[rec[key]] := [ rec ]) | put(tempt[rec[key]],rec)
  812.  
  813.     # Sort the table by the indexes (sorting keys).
  814.     templ := sort(tempt,1)
  815.  
  816.     # Initialize a new records list.
  817.     newrecs := []
  818.  
  819.     # Take apart the pairs of lists generated by the sort.
  820.     every pair := !templ do {
  821.  
  822.         # If there is more than one record in this value list and
  823.         # there are additional keys to sort on recursively sort this
  824.         # value list with the remaining keys.
  825.         if *pair[2] > 1 & *keys > 0 then
  826.             pair[2] := recsort(pair[2],copy(keys))
  827.  
  828.         # Add each record from the value list to the temporary list.
  829.         every put(newrecs,!pair[2])
  830.     }
  831.  
  832.     # Return the new sorted list of records.
  833.     return newrecs
  834. end
  835.  
  836. From icon-group-request  Wed Jan 13 17:05:34 1988
  837. From: "David Gudeman" <gudeman>
  838. To: ihnp4!ihuxy!nowlin, icon-group
  839. In-Reply-To: <8801132040.AA07880@megaron.arizona.edu>
  840. Subject: complicated sorts
  841. Errors-To: icon-group-request
  842. Status: O
  843.  
  844.    From: ihnp4!ihuxy!nowlin
  845.  
  846.    ...How could I pass a list of sorting keys that consist of strings
  847.    corresponding to the labels used to reference the fields in a
  848.    record instead of numeric indexes for the record that is being
  849.    sorted to the recsort() procedure?  If you didn't follow that
  850.    question here is an example of what I mean.  Given the program that
  851.    follows, If I want to sort the password file by the uid field I
  852.    have to invoke the program with "3" as the sorting key.  I'd like
  853.    to be able to invoke it with "uid" as the sorting key.
  854.  
  855. You can't reference records by string name anyway, so getting a string
  856. corresponding to a field name wouldn't do you any good.  You probably
  857. should be using tables if you want to do this.  Table references are a
  858. little uglier than record references, e.g.: foo["name"] vs. foo.name,
  859. but tables are a lot more flexible.
  860.  
  861. From icon-group-request  Sun Jan 24 00:46:07 1988
  862. From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  863. To: icon-group@arizona.edu
  864. Subject: help
  865. Errors-To: icon-group-request
  866. Status: O
  867.  
  868.  
  869. Since first coming to know about Icon last year, I've gone from a complete
  870. programming neophyte to an intermediate user.  In fact, I cut my teeth on
  871. Icon - the reverse of what most people do.  Only after getting to the last
  872. chapters of Griswold & Griswold did I open up a book on C.  Imagine my horror
  873. when I found out that all my variables would have to be declared, along with
  874. their sizes and types.  No more garbage-collection and run-time typing!  No
  875. more goal-oriented iterations!  No more coroutines, at least as I knew them
  876. from Icon.
  877.  
  878. Things seemed quite a mess at first.  But after a while I discovered some im-
  879. portant advantages to using C.  This brings me to my real purpose in writing.
  880. As it turns out, nearly all of these advantages stem from features that would
  881. be equally nice in Icon.  Although it's clearly not going to have any impact
  882. on version 7, I'd still like to mention what some of these advantages are, and
  883. see if anyone else agrees with me.
  884.  
  885.   1)  First and foremost is the ability to pass variables by reference rather
  886.       than by value.  When I got to Pascal, this became even more natural than
  887.       in C.  In Icon, it is impossible, unless one makes the variable in ques-
  888.       tion global.  A typical situation in which this engenders problems is
  889.       when a procedure gathers information that can be applied to more than
  890.       one variable.  Often, for instance, I have to parse header lines in des-
  891.       criptively marked-up text.  The information thus obtained is then used
  892.       to set up several tables and lists.  Why should I have to do the proce-
  893.       dure over again for each structure?  Why, on the other hand, should I
  894.       have to introduce a superabundance of global variables?  It would be much
  895.       faster and more elegant to allow passing of pointers in addition to val-
  896.       ues.
  897.  
  898.   2)  Addendum to the previous:  If I can't have pointers, I'd like dynamic
  899.       variables.  Ideally, I'd like to see them based on the current &level
  900.       of the current activation branch (what would this do to coexpressions?).
  901.  
  902.   3)  Another nice point to C is the existence of standard pattern-matching
  903.       routines.  Many compilers even provide regular expression pattern-
  904.       matching routines.  It has been more than once that I have wanted to
  905.       do
  906.  
  907.                    str ? egrep(s) #where egrep(str) works like find, except
  908.                                   #that it accepts egrep-style regexp's
  909.  
  910.       in Icon.
  911.      
  912.   4)  Finally, it would be wonderful to have a compiler.  I keep wanting to
  913.       send off Icon programs to friends who do not know the language, and who
  914.       do not have the slightest interest in setting up an interpreter on their
  915.       system (frequently they don't know ANY programming language, so this is
  916.       no slight to Icon).  This seems a lot to ask, I know.  I'd just like to
  917.       register my feelings.  Anyone else out there feel the need?  We would
  918.       presumably get a little extra speed out of a compiler, too, so it could
  919.       be useful in the later stages of preparing programs (after most of the
  920.       bugs have been zapped).
  921.  
  922.  
  923.      Anyone else out there have views pro/con?  I fully expect to get jumped on
  924. by the more experienced programmers.  I probably deserve it.
  925.  
  926.                                                                    -Richard
  927.  
  928. From icon-group-request  Sun Jan 24 13:07:12 1988
  929. From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  930. To: icon-group@arizona.edu
  931. Subject: silly me
  932. Errors-To: icon-group-request
  933. Status: O
  934.  
  935.  
  936. As usual, I end up looking silly in my last posting.  Yes, I do in fact know
  937. that structures are passed by pointers, and are not de-referenced.  I still
  938. have the problem of not being able to do this with other types of variables.
  939. It would seem convenient to have the ability to pass pointers as a generally
  940. available device in Icon.
  941.  
  942. Please don't hit me!
  943.  
  944.                                                                  -Richard
  945.  
  946. From icon-group-request  Sun Jan 24 13:48:29 1988
  947. From: "Kenneth Walker" <kwalker>
  948. In-Reply-To: <8801240741.AA05380@sophist.uchicago.edu>
  949. To: goer%sophist@gargoyle.uchicago.edu, icon-group@arizona.edu
  950. Subject: Re:  help
  951. Errors-To: icon-group-request
  952. Status: O
  953.  
  954. This is a response to Richard Goerwitz's suggestions for new features
  955. for Icon.
  956.  
  957. Usual preface:
  958.  
  959. There are several reasons for not including a new feature in Icon.
  960. Implementing and maintaining new features place an additional burden
  961. on limited resources. The language is already rather large - small
  962. languages are easier to master. Some features may be very useful for
  963. a few problems, but don't have wide spread applicability. Some features
  964. don't fit into the philosophy of Icon.
  965.  
  966.     Date: Sun, 24 Jan 88 01:41:13 CST
  967.     From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  968.     
  969.         ...
  970.  
  971.       1)  First and foremost is the ability to pass variables by reference
  972.           rather than by value.  ...
  973.  
  974. This suggestion comes up occasionally. I think most people agree that it
  975. would sometimes be nice to have. However, it doesn't look like it will
  976. be added to the language.
  977.     
  978.       2)  Addendum to the previous:  If I can't have pointers, I'd like
  979.           dynamic variables.  ...
  980.  
  981. There has been some discussion on dynamic variables. It has been motivated
  982. in part by the fact that &subject and &pos act like dynamic variables
  983. with respect to string scanning operations; one approach to language
  984. design is to try to generalize existing features. There has been no
  985. consensus on what such a feature should look like. Making all variables
  986. dynamic is not a good idea (note that most Lisp implementations now
  987. use static scope, atleast for the default scope).
  988.     
  989.       3)  Another nice point to C is the existence of standard
  990.           pattern-matching routines.  Many compilers even provide
  991.           regular expression pattern-matching routines.  It has been
  992.           more than once that I have wanted to do
  993.     
  994.                 str ? egrep(s) #where egrep(str) works like find, except
  995.                                #that it accepts egrep-style regexp's
  996.     
  997.           in Icon.
  998.  
  999. Icon matching expressions are more powerful than regular expressions. If
  1000. s is a string constant, then you can easily do this with the current
  1001. facilities (though the code won't be as short). If you need to construct
  1002. the regular expression at run time or if it is supplied as a parameter
  1003. to the program, then it is not as easy to do it with the current facilities.
  1004.  
  1005. You get into philosophical questions here. If you want to be able to
  1006. construct regular expressions at run-time, wouldn't it be better to have
  1007. something along the lines of SNOBOL4's pattern data type?
  1008.  
  1009. In my own opinion, an egrep function (maybe with a different name) sounds
  1010. reasonable. However, I am not interested enough to implement it. We
  1011. do accept new built-in functions implemented by members of the user
  1012. community. There is no guarentee that such a function will get incorporated
  1013. in future releases, but having a working version increases the chances.
  1014.  
  1015.       4)  Finally, it would be wonderful to have a compiler. ...
  1016.  
  1017. Some interesting work has been done (by Janalee O'Bagy) on
  1018. optimizations which are possible in an Icon compiler. The work has
  1019. been done using prototype compilers written mostly in Icon (what else?).
  1020. However, converting from a prototype which is acceptable for research
  1021. to a production quality compiler is a significant undertaking.
  1022.  
  1023. From icon-group-request  Mon Jan 25 15:49:19 1988
  1024. From: naucse!sbw (Steve Wampler)
  1025. To: arizona!icon-group
  1026. Subject: IconTest Problem One Winner!
  1027. Errors-To: icon-group-request
  1028. Status: O
  1029.  
  1030.  
  1031. Paul Abrahams submitted the nicest entry (the problem was to
  1032. use Icon to compute A^B, for potentially large B - with specific
  1033. I/O restrictions.  His solution follows.
  1034.  
  1035. ---cut here---
  1036.  
  1037. # Procedure to compute A^B
  1038. # Written by Paul Abrahams    November 10, 1987
  1039.  
  1040. procedure main()
  1041.     local a, b, bbits, prod
  1042.     every line := !&input do {
  1043.         (a := integer(line[1:6]), b:= integer(line[6:11]),
  1044.             a > 0, b > 0 ) |
  1045.             {write("Invalid input line ", image(line)); next}
  1046.         write("A = ", right(a, 5, "0"), "\nB = ", right(b, 5, "0"), "\n")
  1047.         bbits := binrep(b)
  1048.         if prod := power(a,bbits) then
  1049.             print_it(prod)
  1050.         else
  1051.             write("Too many digits in the result!\n\n")
  1052.         }
  1053. end
  1054.  
  1055. procedure binrep(n)
  1056. # Compute the binary representation of n (as a string)
  1057.     local retval
  1058.     retval := ""
  1059.     while n > 0 do {
  1060.         retval := n % 2 || retval
  1061.         n /:= 2
  1062.         }
  1063.     return retval
  1064. end
  1065.  
  1066. procedure power(a, bbits)
  1067. # Compute a to the power bbits, where bbits is a bit string.
  1068. # The result is a list of coefficients for the polynomial a(i)*k^i,
  1069. # least significant values first, with k=10000 and zero trailing coefficient
  1070. # deleted.
  1071.     local b, m1, retval
  1072.     m1 := (if a >= 10000 then [a % 10000, a / 10000] else [a])
  1073.     retval := [1]
  1074.     every b := !bbits do {
  1075.         (retval := product(retval, retval)) | fail
  1076.         if b == "1" then
  1077.             (retval := product(retval, m1)) | fail
  1078.         }
  1079.     return retval
  1080. end
  1081.  
  1082. procedure product(a,b)
  1083. # Compute a*b as a polynomial in the same form as for power.
  1084. # a and b are also polynomials in this form.
  1085.     local i, j, k, retval, x
  1086.     if *a + *b > 5001 then
  1087.         fail
  1088.     retval := list(*a + *hv)
  1089.     every i := 1 to *a do
  1090.         every j := 1 to *b do {
  1091.             k := i + j - 1
  1092.             retval[k] +:= a[i] * b[j]
  1093.             while (x := retval[k]) >= 10000 do {
  1094.                 retval[k + 1] +:= x / 10000
  1095.                 retval[k] %:= 10000
  1096.                 k +:= 1
  1097.             }   }
  1098.     every i := *retval to 1 by -1 do
  1099.         if retval[i] > 0 then
  1100.             break
  1101.     return retval[1+:i]
  1102. end
  1103.  
  1104. procedure print_it(n)
  1105.     local ds, i, j, k
  1106.     ds := ""
  1107.     every k := *n to 1 by -1 do
  1108.         ds ||:= right(n[k], 4, "0")
  1109.     ds ?:= (tab(many("0")), tab(0))
  1110.     ds := repl("0", 4 - (*ds - 1) % 5) || ds
  1111.  
  1112.     every i := 1 to *ds by 50 do {
  1113.         k := *ds > i + 45 | *ds
  1114.         every j := i to k by 5 do
  1115.             writes(ds[j+:5], " ")
  1116.         write()
  1117.         }
  1118.     writes("\n\n")
  1119. end
  1120.  
  1121.  
  1122. From icon-group-request  Tue Jan 26 04:58:46 1988
  1123. From: NETWORK@FRSAC11.BITNET
  1124. Subject: ATARI ICON.
  1125. To: icon-group@arizona.edu
  1126. X-Delivery-Notice:  SMTP MAIL FROM does not correspond to sender.
  1127. Errors-To: icon-group-request
  1128. Status: O
  1129.  
  1130. I have a version of ICON 6.5 for Atari ST, with the following
  1131. change (from the previous version) :
  1132.      
  1133. . Co-expression are OK.
  1134. . Arithmetic overflow is handled.
  1135. . system() work. (depends on your shell....)
  1136.   (Most shell are not able to support system("ls")...try
  1137.   command.tos, it may work...)
  1138.   The shell is found by the SHELL environment variable.
  1139. . Faster. (Should be better than any PC or AT at that...)
  1140. . Usable from a shell or from the desktop.
  1141.   (An environment (ICON or PATH) variable can locate the ITRAN, ILINK &
  1142.   ICONX programs, or if not from a shell, a new switch in ICONT will
  1143.   tell where they are.)
  1144. . Handle environment variable for ICONX settings (Like the UNIX
  1145.    (version) (getenv() works.)
  1146. . Handle stderr redirection, just like the MSDOS version.
  1147.      
  1148. If you want to have it or test it, just drop me a mail.
  1149. (I will send it arc'ed and uue'coded, in several mail.)
  1150.      
  1151. regards,
  1152.      
  1153. Jean-Pierre H. Dumas
  1154.      
  1155. network@frsac11 (bitnet)
  1156. network%frsac11.bitnet@mitvma.mit.edu (arpanet)
  1157. dumas@sumex-aim.stanford.edu (arpanet)
  1158.  
  1159. From icon-group-request  Tue Jan 26 13:33:32 1988
  1160. From: naucse!sbw (Steve Wampler)
  1161. To: arizona!icon-group
  1162. Subject: Solution to IconTest Problem One was corrupted...
  1163. Errors-To: icon-group-request
  1164. Status: O
  1165.  
  1166.  
  1167. The solution I posted to problem one of the IconTest was a
  1168. version that had been corrupted in transmission to me.  My
  1169. apologies, particularly to Paul, for sending that version out.
  1170. The uncorruption is:
  1171.  
  1172.     In the procedure product(a,b), change the line
  1173.  
  1174.        retval := list(*a + *hv)
  1175.  
  1176.     to
  1177.  
  1178.        retval := list(*a + *b, 0)
  1179.  
  1180. again, my apologies!
  1181.  
  1182.     -Steve Wampler
  1183.  
  1184. From icon-group-request  Wed Jan 27 15:51:46 1988
  1185. From: ihnp4!ihlpe!orf
  1186. Message-Version: 2
  1187. >To: /addr=ihnp4!arizona!icon-group
  1188. End-Of-Header: 
  1189. Email-Version: 2
  1190. X-Postmark: ihlpe!orf
  1191. To: arizona!icon-group
  1192. Subject: Re: ATARI ICON.
  1193. Ua-Message-Id: <post.orf.Tue 26 Jan 1988 14:12 CST>
  1194. End-Of-Protocol: 
  1195. Content-Length: 834
  1196. Errors-To: icon-group-request
  1197. Status: O
  1198.  
  1199.  >      
  1200.  > If you want to have it or test it, just drop me a mail.
  1201.  > (I will send it arc'ed and uue'coded, in several mail.)
  1202.  >      
  1203.  > regards,
  1204.  >      
  1205.  > Jean-Pierre H. Dumas
  1206.  >      
  1207.  > network@frsac11 (bitnet)
  1208.  > network%frsac11.bitnet@mitvma.mit.edu (arpanet)
  1209.  > dumas@sumex-aim.stanford.edu (arpanet)
  1210.  > 
  1211.  
  1212. Sounds Great!!  I don't know how to reach you, so I had to send this via
  1213. the Icon group.  Jerry Nowlin just downloaded the version on the Arizona
  1214. Icon bulletin board -- and the documentation says 6.0.  We assume this is
  1215. not yours... (You may want to provide AZ the system, and then we can use the 
  1216. bulletin board to download.)
  1217.  
  1218. Questions:
  1219.  
  1220. a) Will the source be sent to U. of A/Ralph?
  1221. b) if not, can we get it?
  1222. c) Does your 6.5 run on a 520?
  1223.  
  1224. We appreciate the work!!
  1225.  
  1226. Rick Fonorow
  1227. ...ihlp4!ihlpe!orf
  1228. (312) 979-7173
  1229.  
  1230.  
  1231. From icon-group-request  Fri Jan 29 09:35:43 1988
  1232. From: naucse!sbw (Steve Wampler)
  1233. To: arizona!icon-group
  1234. Subject: IconTest Problem Two
  1235. Errors-To: icon-group-request
  1236. Status: O
  1237.  
  1238.  
  1239. Ok, I confess.  This isn't one of the problems from the
  1240. 1987 ACM Mountain Regional Programming Contest, but a
  1241. student came to me with this yesterday and it has so
  1242. many nifty little solutions in Icon that I couldn't resist.
  1243.  
  1244.   The Tea-Time Tennis Troop enjoys meeting once a year for a tennis
  1245.   gala.  Since this is a social (as opposed to a sporting) event,
  1246.   they would like to schedule matches so that each player plays
  1247.   with as many other players as possible.  Consequently they have a
  1248.   hard and fast rule that no one is allowed to play more than a
  1249.   single match with anyone he has seen before.  (The TTTT always
  1250.   plays doubles - four players to a court.)
  1251.  
  1252.   Write a program that takes as arguments the number of available
  1253.   tennis courts and the number of players.  The output should be
  1254.   the players on each court in each round of tennis for as many
  1255.   rounds as possible until there is no way to avoid violating their
  1256.   rule on duplications.  All the courts are played on simultane-
  1257.   ously, so each player can play only one match per round.  You may
  1258.   assume that there are less than 1000 members in the TTTT, and
  1259.   that you are to keep all the courts filled each round.  For-
  1260.   tunately, all the players have names from 1 to the number of
  1261.   players.
  1262.  
  1263. From icon-group-request  Fri Jan 29 22:30:37 1988
  1264. From: ihnp4!ihlpf!nevin1
  1265. To: arizona!icon-group
  1266. Subject: Please add me to your email mailing list
  1267. Errors-To: icon-group-request
  1268. Status: O
  1269.  
  1270. Please add me to the icon-group email mailing list.  If you could, please
  1271. send confirmation that this has happened.
  1272.  
  1273. Thanks,
  1274.  _ __            NEVIN J. LIBER    ..!ihnp4!ihlpf!nevin1    (312) 510-6194
  1275. ' )  )                The secret compartment of my ring I fill
  1276.  /  / _ , __o  ____        with an Underdog super-energy pill.
  1277. /  (_</_\/ <__/ / <_    These are solely MY opinions, not AT&T's, blah blah blah
  1278.  
  1279.  
  1280. From icon-group-request  Sun Jan 31 10:10:10 1988
  1281. From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  1282. To: icon-group@arizona.edu
  1283. Subject: pointers, structures, confusion
  1284. Errors-To: icon-group-request
  1285. Status: O
  1286.  
  1287. Can someone out there explain to my why the following program outputs
  1288. Status: R
  1289.  
  1290. "hello"
  1291. "hello"
  1292. "hello"
  1293. "hello"
  1294. "hello"
  1295. "hello"
  1296.  
  1297. and not just "hello" plus a bunch of blank lines?
  1298.  
  1299.  
  1300. procedure main()
  1301.  
  1302.   List := list(4,[""])
  1303.   List[1] := AlterList(copy(List[1]))
  1304.   WriteList(List)
  1305.  
  1306. end
  1307.  
  1308.  
  1309. procedure AlterList(l)
  1310.  
  1311.   l[1] := "hello"
  1312.   return l
  1313.  
  1314. end
  1315.  
  1316.  
  1317. procedure WriteList(List)
  1318.  
  1319.   local i
  1320.   every i := 1 to *List
  1321.   do write(List[i][1])
  1322.   return 0
  1323.  
  1324. end
  1325.  
  1326.  
  1327.  
  1328.  
  1329. I realize that if I pass a copy of List[1] to AlterList, it will function as
  1330. expected.  But I'm not sure why.
  1331.  
  1332.                                                                    -Richard
  1333.  
  1334.  
  1335. From icon-group-request  Sun Jan 31 10:10:40 1988
  1336. From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  1337. To: estlist%sophist@gargoyle.uchicago.edu, icon-group@arizona.edu
  1338. Subject: pointers, structures, confusion
  1339. Errors-To: icon-group-request
  1340. Status: O
  1341.  
  1342.  
  1343. Can someone out there explain to my why the following program outputs
  1344.  
  1345. "hello"
  1346. "hello"
  1347. "hello"
  1348. "hello"
  1349. "hello"
  1350. "hello"
  1351.  
  1352. and not just "hello" plus a bunch of blank lines?
  1353.  
  1354.  
  1355. procedure main()
  1356.  
  1357.   List := list(4,[""])
  1358.   List[1] := AlterList(copy(List[1]))
  1359.   WriteList(List)
  1360.  
  1361. end
  1362.  
  1363.  
  1364. procedure AlterList(l)
  1365.  
  1366.   l[1] := "hello"
  1367.   return l
  1368.  
  1369. end
  1370.  
  1371.  
  1372. procedure WriteList(List)
  1373.  
  1374.   local i
  1375.   every i := 1 to *List
  1376.   do write(List[i][1])
  1377.   return 0
  1378.  
  1379. end
  1380.  
  1381.  
  1382.  
  1383.  
  1384. I realize that if I pass a copy of List[1] to AlterList, it will function as
  1385. expected.  But I'm not sure why.
  1386.  
  1387.                                                                    -Richard
  1388.  
  1389. From icon-group-request  Sun Jan 31 10:38:33 1988
  1390. From: "Kenneth Walker" <kwalker>
  1391. In-Reply-To: <8801311629.AA18373@sophist.uchicago.edu>
  1392. To: goer%sophist@gargoyle.uchicago.edu, icon-group@arizona.edu
  1393. Subject: Re:  pointers, structures, confusion
  1394. Errors-To: icon-group-request
  1395. Status: O
  1396.  
  1397.     Date: Sun, 31 Jan 88 10:29:35 CST
  1398.     From: goer%sophist@gargoyle.uchicago.edu (Richard Goerwitz)
  1399.     
  1400.     Can someone out there explain to my why ...
  1401.  
  1402. (I assume you ment to post the version of the program that did _not_ pass
  1403. a copy of List[1] to AlterList)
  1404.  
  1405. The effect that you are seeing is an interaction of 2 features of Icon:
  1406.  
  1407.    - the pointer semantics of lists
  1408.    - the fact that arguments are evaluated only once
  1409.  
  1410. The expression list(4,[""]) does _not_ create a list of 4 lists of
  1411. strings. It creates a list with 4 entries each of which references
  1412. the _same_ list contining the string "". To see why this happens, 
  1413. consider the evaluation of the expression in detail:
  1414.  
  1415.    1) the constant 4 is evaluated
  1416.    2) "" is evaluated
  1417.    3) [] is excuted resulting in a new list containting one element, the
  1418.       string ""
  1419.    4) list() is called with 4 and a reference to the list created in the
  1420.       last step. It creates an new list with 4 elements each containing
  1421.       the reference.
  1422.  
  1423. If you change the contents of the list created in step 3, you will
  1424. see the change no matter which of the 4 references you use to access
  1425. the list.
  1426.  
  1427. From icon-group-request  Tue Feb  2 04:39:59 1988
  1428. Received: by bocklin.arizona.edu; Tue, 2 Feb 88 04:40:04 MST
  1429. Received: from megaron.arizona.edu by bocklin.arizona.edu; Tue, 2 Feb 88 04:39:59 MST
  1430. Message-Id: <8802021139.AA02428@megaron.arizona.edu>
  1431. Received: from [128.228.1.2] by megaron.arizona.edu; Tue, 2 Feb 88 04:39:43 MST
  1432. Received: from FRSAC11.BITNET by CUNYVM.CUNY.EDU ; Tue, 02 Feb 88 06:38:45 EST
  1433. Date: Tue, 02 Feb 88 12:38:52 GMT
  1434. To: icon-group@arizona.edu
  1435. From: NETWORK%FRSAC11.BITNET@CUNYVM.CUNY.EDU
  1436. Comment: CROSSNET mail via SMTP@INTERBIT
  1437. Subject: Icon 6.5 for Atari ST
  1438. Errors-To: icon-group-request
  1439.  
  1440. If you are not into Atari ST, or the Icon programming language,
  1441. just go to the next message of your favorite mailer.
  1442.  
  1443.                      +++++++++++++++++++++++++++
  1444.  
  1445. ICON 6.5 (Implementation revision (e)) for the ATARI ST
  1446. has been sent to some people.
  1447.  
  1448. As the files are quite large, and I do not wish to abuse the local
  1449. mailer, I will ask any further request to be redirected to the nearest
  1450. person that already have it.
  1451.  
  1452. Here is the list where the binaries have been sent:
  1453.  
  1454. Vitas P.                rochester!ritcv!vxp6840 (uucp)
  1455. Denise ?                rochester!ritcv!dsh3059 (uucp)
  1456. Mark Storin             ihnp4!uwmcsd1!lakesys!mark (uucp)
  1457. Marty Wiedmeyer         ihnp4!uwmcsd1!lakesys!martin (uucp)
  1458. Rich ?                  ihnp4!uwmcsd1!lakesys!rich (uucp)
  1459. Plinio Barbeito         acm@valhalla.cs.ucla.edu (edu)
  1460. Bertrand Decouty        decouty@frcicg71 (earn)
  1461. Klaus Hahn              hahn_k@dmrhrz11 (earn)
  1462. Greg Onufer             ucbvax!ucdavis!uop.edu!root (uucp)
  1463. Andres F. Moreno        moreno@umn-cs.cs.umn.edu (edu)
  1464. Bob Bright              bright@dalac (bitnet)
  1465. Matthias Moritz         u608017@hnykun11 (earn)
  1466. Ruud van der Plaats     vdplaats@hnykun53 (earn)
  1467. Gordon Joly             gcj%@uk.ac.qmc.maths (uk)
  1468. Rick Fonorow            ihnp4!ihlpe!orf (uucp)
  1469. Wilfried Bloemberg      fonetiek@hnykun52 (earn)
  1470. Jerry Nowlin            ihnp4!ihuxy!nowlin (uucp)
  1471.  
  1472. The sources will not be distributed by me, They have been sent to
  1473. the Icon project at U. of Arizona, and to the 2 original implementors.
  1474.  
  1475. Some of you asked for some documentation on ICON or on this peculiar
  1476. version: I can send upon request the article on Icon version 6 from
  1477. U. of Arizona, and the various files that come with the former
  1478. implementation.
  1479.  
  1480. The reference book for the language beeing the book:
  1481. Griswold, Ralph E. and Madge T. Griswold. The Icon Programming
  1482. Language, Prentice-Hall, Inc., Englewood Cliffs, New Jersey.
  1483. 1983.
  1484.  
  1485. Send all inquiries to icon-project@arizona.edu
  1486.  
  1487.                     ++++++++++++++++++++++++
  1488.  
  1489. Notes on this (e) implementation:
  1490.  
  1491. -It is done using MCC Lattice 3.04 C compiler, with sources coming
  1492. from U. of Az (Rick Fonorow & Jerry Nowlin, made it for the 3.03 C).
  1493. I added the support for various missing stuff, the arithmetic overflow
  1494. and Co-expression assembly code was furnished to me by Ralph Griswold.
  1495. Ralph did answer to all questions that allowed me to bring this code up.
  1496.  
  1497. -All binaries are called .TTP in order to be called from the desktop,
  1498. without using a shell if you dont like it, or if you are short in memory.
  1499. I used/developped the thing on a 1040ST Monochrome, with a 400K
  1500. ram-disk. I think iconx.ttp will work on 520ST, with TOS in ROM.
  1501. Iconx.ttp takes 200K for the heap, and 10K for the stack, plus data
  1502. and text segment.
  1503.  
  1504. -If you want to use icont: it will attempt to find itran/ilink/iconx
  1505. by looking at the ICON environment variable, that should be set to
  1506. the disk/directory where these can be found, then it will try for the
  1507. PATH variable, then for the root directory of all currently mounted
  1508. disk drives, in alphabetical order.
  1509. If you are invoking icont.ttp from the desktop, you can tell where are
  1510. the other binaries by the "-p disk:\dir" option.
  1511. All options to icont can be in upper or lower case.
  1512.  
  1513. -If you want to use a very large Icon program, you may have to
  1514. increase some memory area, in this case, you will have to tell the
  1515. startup code of Iconx, with the % option, before all other arguments
  1516. on the command line. {iconx> is currently equivalent to <iconx %200000>,
  1517. you may have to try %300000 or more. The number after % is the total
  1518. heap size, in byte.)
  1519.  
  1520. -If you want to use the system() call, find a shell that can do what
  1521. you want... I have'nt yet...
  1522. Iconx will look into the SHELL environment variable, it should be set
  1523. to the complete filename of the shell you want to invoke.
  1524. I have tried PCOMMAND, ASH, MSH, COMMAND.TOS, and the lowly last one
  1525. gave me best results... (most shells are not able to understand
  1526. arguments passed to them, if this is an internal command, they
  1527. always try to "fork" it...)
  1528. (In fact it does not need to be a shell, just any program can be
  1529. "forked", args passed, and the exit code will be returned back.)
  1530. (I am still looking for the sources of a good shell that I can hack
  1531. and make useful on the ST, whatever be your keyboard religion.)
  1532.  
  1533. I would appreciate any hints of bugs, to be reported, altough
  1534. it may take time to fix... may be version 7...
  1535.  
  1536. Regards,
  1537.  
  1538. Jean-Pierre H. Dumas
  1539.  
  1540. network@frsac11 (bitnet)
  1541. network%frsac11.bitnet@mitvma.mit.edu (arpanet)
  1542. dumas@sumex-aim.stanford.edu (arpanet)
  1543.  
  1544. From icon-group-request  Wed Feb 10 02:27:40 1988
  1545. Received: by bocklin.arizona.edu; Wed, 10 Feb 88 02:27:44 MST
  1546. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 10 Feb 88 02:27:40 MST
  1547. Received: from SUN.COM by megaron.arizona.edu; Wed, 10 Feb 88 02:27:31 MST
  1548. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-3.2)
  1549.     id AA09831; Wed, 10 Feb 88 01:26:41 PST
  1550. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  1551.     id AA01498; Wed, 10 Feb 88 01:26:50 PST
  1552. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  1553.     id AA23975; Wed, 10 Feb 88 01:19:03 PST
  1554. Received: from Nuksun.Europe.Sun.COM (inuksun) by UK.Sun.COM (3.2/SMI-3.2)
  1555.     id AA01478; Wed, 10 Feb 88 09:26:26 GMT
  1556. Received: from stevie.nuksun.uucp by Nuksun.Europe.Sun.COM (1.1/SMI-3.2)
  1557.     id AA02791; Wed, 10 Feb 88 09:25:55 GMT
  1558. Received: by stevie.nuksun.uucp (3.2/SMI-3.2)
  1559.     id AA18977; Wed, 10 Feb 88 09:25:49 GMT
  1560. Date: Wed, 10 Feb 88 09:25:49 GMT
  1561. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - TSE)
  1562. Message-Id: <8802100925.AA18977@stevie.nuksun.uucp>
  1563. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  1564. Subject: E-mail handling software - testers wanted
  1565. Errors-To: icon-group-request
  1566.  
  1567. I have a number of programs to do various things with e-mail,
  1568. which I would like to put out in the field for testing.  Since
  1569. they are written in Icon, this is the logical group to approach.
  1570. The following programs are available:
  1571.  
  1572. classify:    reorganises mail folders and can produce tables
  1573.         of contents for them.
  1574.  
  1575. getmail:    retrieves selected (by number, so a table of contents
  1576.         is useful) mail items from a folder.
  1577.  
  1578. mailtrim:    tidies up a mail folder by throwing away redundant
  1579.         headers.
  1580.  
  1581. mp:        Has proved especially popular with Sun customers,
  1582.         prints e-mail messages and/or folders on a PostScript
  1583.         printer with relatively clean-looking headings.
  1584.  
  1585. These programs have seen quite a lot of use collectively.  They all
  1586. rely on a "mailio" library also in Icon, which could do with a tidier
  1587. rewrite.
  1588.  
  1589. If anyone is prepared to take these programs and feed back suggestions
  1590. for improvement could they please reply.  I will distribute the programs
  1591. to those interested in about a week.
  1592.  
  1593. Yours fraternally
  1594. Steve Holden
  1595.  
  1596. From icon-group-request  Wed Feb 10 08:36:28 1988
  1597. Received: by bocklin.arizona.edu; Wed, 10 Feb 88 08:36:31 MST
  1598. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 10 Feb 88 08:36:28 MST
  1599. Received: from SUN.COM by megaron.arizona.edu; Wed, 10 Feb 88 08:36:22 MST
  1600. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-3.2)
  1601.     id AA14325; Wed, 10 Feb 88 07:35:34 PST
  1602. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  1603.     id AA08779; Wed, 10 Feb 88 07:35:43 PST
  1604. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  1605.     id AA26719; Wed, 10 Feb 88 07:27:50 PST
  1606. Received: from snail.sun.com (snail-swanbb) by UK.Sun.COM (3.2/SMI-3.2)
  1607.     id AA04825; Wed, 10 Feb 88 15:34:52 GMT
  1608. Received: from Sun.COM (arpa-dev) by snail.sun.com (4.0/SMI-3.2)
  1609.     id AA26709; Wed, 10 Feb 88 07:27:12 PST
  1610. Received: from megaron.arizona.edu by Sun.COM (4.0/SMI-3.2)
  1611.     id AA14304; Wed, 10 Feb 88 07:34:27 PST
  1612. Received: by megaron.arizona.edu; Wed, 10 Feb 88 08:34:56 MST
  1613. Date: Wed, 10 Feb 88 06:01:27 mst
  1614. From: sunuk!sun!arizona.edu!naucse!sbw@Sun.COM (Steve Wampler)
  1615. Message-Id: <8802101301.AA00900@naucse>
  1616. To: sunuk!nuksun!stevie!steveh%arizona@Sun.COM,
  1617.         sun!arizona.edu!icon-group%sunuk@Sun.COM
  1618. Subject: Re:  E-mail handling software - testers wanted
  1619. Errors-To: icon-group-request
  1620.  
  1621. I would like to try out your Email processors.  May I?
  1622.  
  1623. Steve Wampler
  1624.  
  1625. From icon-group-request  Wed Feb 10 14:22:38 1988
  1626. Received: by bocklin.arizona.edu; Wed, 10 Feb 88 14:22:42 MST
  1627. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 10 Feb 88 14:22:38 MST
  1628. Received: from jvax.ccit.arizona.edu by megaron.arizona.edu; Wed, 10 Feb 88 14:22:36 MST
  1629. Received: from BITNET-GATEWAY by jvax.ccit.arizona.edu; Wed, 10 Feb 88 13:35 MST
  1630. Received: from RL.IB by UKACRL.BITNET (Mailer X1.25) with BSMTP id 3332; Wed,
  1631.  10 Feb 88 19:22:18 GMT
  1632. Date: Wed, 10 Feb 88 18:52:07 GMT
  1633. From: Sebastian Rahtz <spqr@CM.SOTON.AC.UK>
  1634. Subject: icon e-mail programs
  1635. To: icon-group <icon-group%edu.arizona@UK.AC.RL>
  1636. Via:        UK.AC.RL.EARN; Wed, 10 Feb 88 19:22:17 GMT
  1637. Via:        UK.AC.NCL; 10 FEB 88 19:22:13 GMT
  1638. Message-Id: <6842.8802101922.cheviot@uk.ac.newcastle>
  1639. Errors-To: icon-group-request
  1640.  
  1641. i would love to acquire Steve Holden's programs, but the mail
  1642. route is unclear - can anyone send a clearer address for him?
  1643.      
  1644. sebastian rahtz, computer science, southampton, uk
  1645. spqr@uk.ac.soton.cm
  1646.  
  1647. From icon-group-request  Wed Feb 10 18:59:46 1988
  1648. Received: by bocklin.arizona.edu; Wed, 10 Feb 88 18:59:49 MST
  1649. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 10 Feb 88 18:59:46 MST
  1650. Received: from SUN.COM by megaron.arizona.edu; Wed, 10 Feb 88 18:59:39 MST
  1651. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-3.2)
  1652.     id AA26731; Wed, 10 Feb 88 17:58:52 PST
  1653. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  1654.     id AA22560; Wed, 10 Feb 88 17:59:01 PST
  1655. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  1656.     id AA13290; Wed, 10 Feb 88 17:50:25 PST
  1657. Received: from snail.sun.com (snail-swanbb) by UK.Sun.COM (3.2/SMI-3.2)
  1658.     id AA04436; Thu, 11 Feb 88 01:56:23 GMT
  1659. Received: from sun.Sun.COM (sun-bb) by snail.sun.com (4.0/SMI-3.2)
  1660.     id AA13255; Wed, 10 Feb 88 17:47:32 PST
  1661. Received: from cbosgd.UUCP by sun.Sun.COM (4.0/SMI-4.0)
  1662.     id AA22514; Wed, 10 Feb 88 17:55:15 PST
  1663. Received: by cbosgd.MIS.OH.ATT.COM (smail2.1)
  1664.     id AA16747; 10 Feb 88 18:34:00 EST (Wed)
  1665. Received: by n8emr.UUCP (smail2.5)
  1666.     id AA04604; 10 Feb 88 18:20:30 EST (Wed)
  1667. Received: by uncle.UUCP (smail3.0)
  1668.     id AA05629; 10 Feb 88 18:13:10 EST (Wed)
  1669. To: ihnp4!arizona!sunuk!nuksun!stevie!steveh@Sun.COM,
  1670.         sun!arizona.edu!icon-group%sunuk@Sun.COM
  1671. Subject: Re:  E-mail handling software - testers wanted
  1672. Message-Id: <8802101813.AA05625@uncle.UUCP>
  1673. Date: 10 Feb 88 18:13:05 EST (Wed)
  1674. From: sunuk!sun!uncle!jbm@Sun.COM (John B. Milton)
  1675. Errors-To: icon-group-request
  1676.  
  1677. I volunteer
  1678. --
  1679. John Bly Milton IV, jbm@uncle.UUCP, {ihnp4|cbosgd}!n8emr!uncle!jbm
  1680. home: (614) 294-4823, work: (614) 459-7641, FLAME via email :)
  1681.  
  1682. From icon-group-request  Fri Feb 12 11:16:04 1988
  1683. Received: by bocklin.arizona.edu; Fri, 12 Feb 88 11:16:07 MST
  1684. Received: from megaron.arizona.edu by bocklin.arizona.edu; Fri, 12 Feb 88 11:16:04 MST
  1685. Received: from SUN.COM by megaron.arizona.edu; Fri, 12 Feb 88 11:15:56 MST
  1686. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-3.2)
  1687.     id AA17076; Fri, 12 Feb 88 10:14:51 PST
  1688. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  1689.     id AA09395; Fri, 12 Feb 88 10:14:58 PST
  1690. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  1691.     id AA16524; Fri, 12 Feb 88 10:05:37 PST
  1692. Received: from Nuksun.Europe.Sun.COM (inuksun) by UK.Sun.COM (3.2/SMI-3.2)
  1693.     id AA24088; Fri, 12 Feb 88 18:12:57 GMT
  1694. Received: from stevie.nuksun.uucp by Nuksun.Europe.Sun.COM (1.1/SMI-3.2)
  1695.     id AA11741; Fri, 12 Feb 88 18:12:26 GMT
  1696. Received: by stevie.nuksun.uucp (3.2/SMI-3.2)
  1697.     id AA04997; Fri, 12 Feb 88 18:12:22 GMT
  1698. Date: Fri, 12 Feb 88 18:12:22 GMT
  1699. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - TSE)
  1700. Message-Id: <8802121812.AA04997@stevie.nuksun.uucp>
  1701. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  1702. Subject: Re: Mail handling software
  1703. Errors-To: icon-group-request
  1704.  
  1705. Those who requested this package should have received it by now.
  1706. Iff you asked for it and never got a reply, (some of my replies
  1707. bounced) please contact me to try and work out a route or, worst
  1708. case, arrange for delivery on punched cards :-) or more suitable
  1709. media.
  1710.  
  1711. Regards
  1712. Steve Holden
  1713. Sun Microsystems UK Ltd.        +44 61 477 3100
  1714.                     {many nodes}!sun!sholden
  1715.                     sholden@sun.com
  1716.  
  1717. From icon-group-request  Mon Feb 15 13:51:35 1988
  1718. Received: by bocklin.arizona.edu; Mon, 15 Feb 88 13:51:37 MST
  1719. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 15 Feb 88 13:51:35 MST
  1720. Received: from SUN.COM by megaron.arizona.edu; Mon, 15 Feb 88 13:51:25 MST
  1721. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-3.2)
  1722.     id AA08487; Mon, 15 Feb 88 12:50:32 PST
  1723. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  1724.     id AA15727; Mon, 15 Feb 88 12:50:53 PST
  1725. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  1726.     id AA20369; Mon, 15 Feb 88 12:42:43 PST
  1727. Received: from snail.sun.com (snail-swanbb) by UK.Sun.COM (3.2/SMI-3.2)
  1728.     id AA18477; Mon, 15 Feb 88 20:50:22 GMT
  1729. Received: from Sun.COM (arpa-dev) by snail.sun.com (4.0/SMI-3.2)
  1730.     id AA20361; Mon, 15 Feb 88 12:42:32 PST
  1731. Received: from askone.s1.gov by Sun.COM (4.0/SMI-3.2)
  1732.     id AA08484; Mon, 15 Feb 88 12:50:03 PST
  1733. Received: by askone.s1.gov id AA25051; Mon, 15 Feb 88 12:49:26 PST
  1734.     id AA25051; Mon, 15 Feb 88 12:49:26 PST
  1735. Date: Mon, 15 Feb 88 12:49:26 PST
  1736. From: sunuk!sun!mordor.s1.gov!berry%askone.s1.gov@Sun.COM
  1737. Message-Id: <8802152049.AA25051@askone.s1.gov>
  1738. To: nuksun!stevie!steveh%sunuk@Sun.COM
  1739. Cc: sun!arizona.edu!icon-group%sunuk@Sun.COM
  1740. In-Reply-To: Steve Holden - TSE's message of Wed, 10 Feb 88 09:25:49 GMT <8802100925.AA18977@stevie.nuksun.uucp>
  1741. Subject: E-mail handling software - testers wanted
  1742. Errors-To: icon-group-request
  1743.  
  1744. I'm interested....  sorry it's so late but I've been gone to Usenix.
  1745.   --berry
  1746.  
  1747. From icon-group-request  Tue Feb 16 17:20:44 1988
  1748. Received: by bocklin.arizona.edu; Tue, 16 Feb 88 17:20:47 MST
  1749. Received: from megaron.arizona.edu by bocklin.arizona.edu; Tue, 16 Feb 88 17:20:44 MST
  1750. Received: from sphinx.uchicago.edu by megaron.arizona.edu; Tue, 16 Feb 88 17:19:35 MST
  1751. Received: from sophist.uchicago.edu by sphinx.uchicago.edu (5.52/2.0Sx)
  1752.     id AA17049; Tue, 16 Feb 88 18:19:15 CST
  1753. Return-Path: <goer@sophist.uchicago.edu>
  1754. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  1755.     id AA00347; Tue, 16 Feb 88 18:15:41 CST
  1756. Date: Tue, 16 Feb 88 18:15:41 CST
  1757. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  1758. Message-Id: <8802170015.AA00347@sophist.uchicago.edu>
  1759. To: icon-group@arizona.edu
  1760. Errors-To: icon-group-request
  1761.  
  1762. Subject: p(a,b,c[]) and &null
  1763.  
  1764. I was recently going over old icon-group mail, and noted the following:
  1765.  
  1766.      If we call a procedure defined as having arguments (a,b,c[]) with
  1767.      p(a), what will be passed to the procedure is (.a,&null,[]).
  1768.  
  1769. Why?  It would seem more natural to think that the same thing that happens to
  1770. b should happen to c, even though the notation there makes it clear that if
  1771. any values get passed, in addition to a and b, they are formed into a list.
  1772. To put it more lucidly:  I would expect that if we pass on a value for a only,
  1773. that b and c would turn up being null.  The notation p(a,b,c[]) simply means
  1774. to me that anything after b get put into a list (if there is in fact anything
  1775. to put there).  The fact that [] gets passed even in cases where nothing beyond
  1776. a and b is present seems strange to me.
  1777.  
  1778. Obviously I am missing something.
  1779.  
  1780. Could some kind soul(s) explain to me the motivation behind passing [] even
  1781. in cases where no value is present?
  1782.  
  1783.                                                   -Richard L. Goerwitz
  1784.                                                   goer@sophist.uchicago.edu
  1785.                                                   !ihnp4!gargoyle!sophist!goer
  1786.  
  1787. From icon-group-request  Tue Feb 16 22:13:17 1988
  1788. Received: by bocklin.arizona.edu; Tue, 16 Feb 88 22:13:20 MST
  1789. Received: from megaron.arizona.edu by bocklin.arizona.edu; Tue, 16 Feb 88 22:13:17 MST
  1790. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu; Tue, 16 Feb 88 22:13:08 MST
  1791. Received: by ucbvax.Berkeley.EDU (5.58/1.26)
  1792.     id AA10342; Tue, 16 Feb 88 20:45:19 PST
  1793. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  1794.     for icon-group@arizona.edu (icon-group@arizona.edu)
  1795.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  1796. Date: 17 Feb 88 03:08:12 GMT
  1797. From: marque!martin@csd1.milw.wisc.edu  (Martin Wiedmeyer)
  1798. Organization: Marquette University, Milwaukee, WI
  1799. Subject: Re: Mail handling software
  1800. Message-Id: <39@marque.mu.edu>
  1801. References: <8802121812.AA04997@stevie.nuksun.uucp>
  1802. Sender: icon-group-request@arizona.edu
  1803. To: icon-group@arizona.edu
  1804. Errors-To: icon-group-request
  1805.  
  1806. I tried to send e-mail & my message got bounced back as 'host unknown'.
  1807. Please send me your Icon e-mail messaging files.
  1808.  
  1809. Thanks,
  1810.  
  1811. Marty
  1812.  
  1813. From icon-group-request  Wed Feb 17 10:57:42 1988
  1814. Received: by bocklin.arizona.edu; Wed, 17 Feb 88 10:57:45 MST
  1815. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 17 Feb 88 10:57:42 MST
  1816. Date: Wed, 17 Feb 88 10:57:39 MST
  1817. From: "Ralph Griswold" <ralph>
  1818. Message-Id: <8802171757.AA02952@megaron.arizona.edu>
  1819. Received: by megaron.arizona.edu; Wed, 17 Feb 88 10:57:39 MST
  1820. To: icon-group
  1821. Subject: Version 7 of Icon for UNIX and VAX/VMS
  1822. Errors-To: icon-group-request
  1823.  
  1824. Version 7 of Icon is now available for UNIX and VAX/VMS systems.
  1825.  
  1826. Version 7 has a number of new features, including
  1827.  
  1828.     1. Functions for bit operations on integers, inserting and
  1829.        deleting tabs in text, accessing operating-system
  1830.        information, etc., etc.
  1831.  
  1832.     2. Error trace back, showing the sequence of procedure calls
  1833.        leading to the error, followed by an image of the offending
  1834.        expression.
  1835.  
  1836.     3. Procedures with a variable number of arguments.
  1837.  
  1838.     4. Corrected handling of co-expression activation, allowing use
  1839.        of co-expressions in a coroutine fashion, and also co-expression
  1840.        tracing.
  1841.  
  1842.     5. Corrected handling of string scanning so that the values of
  1843.        &subject and &pos are properly restored whenever scanning is
  1844.        exited (no matter how).
  1845.  
  1846.     6. And lots of other "goodies".
  1847.  
  1848. Version 7 is distributed on magnetic tape. It costs $25, which includes
  1849. documentation and shipping in the United States and Canada. There is a $10
  1850. additional charge for shipping to other countries.
  1851.  
  1852. The UNIX and VMS systems are independent; if you need Version 7 of Icon
  1853. for both systems, order both. For UNIX, specify tar or cpio format and 1600 or
  1854. 6250 bpi. For VMS, specify 1600 or 6250 bpi.
  1855.  
  1856. Checks should accompany orders and be made payable to the University
  1857. of Arizona.  Checks must be written on a bank with a branch in the
  1858. United States.
  1859.  
  1860. Send orders to:
  1861.  
  1862.     Icon Project
  1863.     Department of Computer Science
  1864.     The University of Arizona
  1865.     Tucson, AZ   85721
  1866.  
  1867. Work is underway on Version 7 of Icon for other systems. These implementations
  1868. will be announced as they become available.
  1869.  
  1870. If you have questions, send electronic mail to icon-project@arizona
  1871. (*not* icon-group@arizona).
  1872.  
  1873. From icon-group-request  Wed Feb 17 11:04:21 1988
  1874. Received: by bocklin.arizona.edu; Wed, 17 Feb 88 11:04:24 MST
  1875. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 17 Feb 88 11:04:21 MST
  1876. Date: Wed, 17 Feb 88 11:04:20 MST
  1877. From: "Ralph Griswold" <ralph>
  1878. Message-Id: <8802171804.AA03682@megaron.arizona.edu>
  1879. Received: by megaron.arizona.edu; Wed, 17 Feb 88 11:04:20 MST
  1880. To: icon-group
  1881. Subject: Version 7 Icon for VMS
  1882. Errors-To: icon-group-request
  1883.  
  1884. I forgot to mention Version 7 of Icon requires VMS 4.6 or higher.
  1885.  
  1886. From icon-group-request  Wed Feb 17 13:31:03 1988
  1887. Received: by bocklin.arizona.edu; Wed, 17 Feb 88 13:31:07 MST
  1888. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 17 Feb 88 13:31:03 MST
  1889. Date: Wed, 17 Feb 88 13:31:01 MST
  1890. From: "Kenneth Walker" <kwalker>
  1891. Message-Id: <8802172031.AA11080@megaron.arizona.edu>
  1892. Received: by megaron.arizona.edu; Wed, 17 Feb 88 13:31:01 MST
  1893. In-Reply-To: <8802170015.AA00347@sophist.uchicago.edu>
  1894. To: icon-group
  1895. Subject: variable args
  1896. Errors-To: icon-group-request
  1897.  
  1898.     Date: Tue, 16 Feb 88 18:15:41 CST
  1899.     From: Richard Goerwitz <goer@sophist.uchicago.edu>
  1900.     
  1901.     I was recently going over old icon-group mail, and noted the following:
  1902.     
  1903.          If we call a procedure defined as having arguments (a,b,c[]) with
  1904.          p(a), what will be passed to the procedure is (.a,&null,[]).
  1905.     
  1906.     Why?   <text deleted>
  1907.     I would expect that if we pass on a value for a only,
  1908.     that b and c would turn up being null.   <text deleted>
  1909.     The fact that [] gets passed even in cases where nothing beyond
  1910.     a and b is present seems strange to me.
  1911.     
  1912. (NOTE, this feature is only available in Version 7 of Icon, which has not
  1913. yet been released for all systems)
  1914.  
  1915. It is indead possible either to argue that c should be null or to argue that
  1916. it should be the empty list. The philosophical argument for the empty list
  1917. is that c is defined to be a list and that the null value is not a list.
  1918. There is however a practical argument which deals with how c is likely to
  1919. be used. c contains the optional arguments to the procedure. If there are
  1920. no optional arguments in the call and c contains the empty list, then
  1921. code which tries to access the non-existant elements of c will simply
  1922. fail. In most situations the result is exactly what you want - the code
  1923. is simply not executed. If c were the null value, an attempt to do an
  1924. element access will result in a run-time error; thus you will need a
  1925. special test for null to handle this case.
  1926.  
  1927. From icon-group-request  Thu Feb 18 02:46:05 1988
  1928. Received: by bocklin.arizona.edu; Thu, 18 Feb 88 02:46:12 MST
  1929. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 18 Feb 88 02:46:05 MST
  1930. Received: from SUN.COM by megaron.arizona.edu; Thu, 18 Feb 88 02:45:34 MST
  1931. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-4.0)
  1932.     id AA19478; Thu, 18 Feb 88 01:44:41 PST
  1933. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  1934.     id AA27678; Thu, 18 Feb 88 01:44:49 PST
  1935. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  1936.     id AA21030; Thu, 18 Feb 88 01:35:32 PST
  1937. Received: from Nuksun.Europe.Sun.COM (inuksun) by UK.Sun.COM (3.2/SMI-3.2)
  1938.     id AA14507; Thu, 18 Feb 88 09:43:19 GMT
  1939. Received: from stevie.nuksun.uucp by Nuksun.Europe.Sun.COM (1.1/SMI-3.2)
  1940.     id AA08569; Thu, 18 Feb 88 09:42:41 GMT
  1941. Received: by stevie.nuksun.uucp (3.2/SMI-3.2)
  1942.     id AA06649; Thu, 18 Feb 88 09:42:35 GMT
  1943. Date: Thu, 18 Feb 88 09:42:35 GMT
  1944. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - TSE)
  1945. Message-Id: <8802180942.AA06649@stevie.nuksun.uucp>
  1946. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  1947. Subject: Mail handling software
  1948. Errors-To: icon-group-request
  1949.  
  1950. If you aren't interested in this stuff, please delete this mail and
  1951. accept my apologies for tying up bandwidth.  I've had a number of
  1952. requests for this software to which, due to mail addressing problems,
  1953. I have been unable to reply.
  1954.  
  1955. In general I am quite willing to try and communicate with people about
  1956. this stuff, but to make sure everyone gets it I am posting it to the
  1957. group.  What follows is a copy of the original mail which went out in
  1958. response to requests I got up to last Friday.  I have also done a couple
  1959. of individual mailing since.
  1960.  
  1961. Steve Holden
  1962. {many nodes}!sun!sunuk!nuksun!stevie!steveh
  1963. {many nodes}!sun!sholden
  1964. sholden@sun.com
  1965. ---------------------------------------------------------------------------
  1966. Well, here they are: each program is preceded by a line containing its
  1967. name between asterisks.  Icon hackers should be able to sort that out,
  1968. but I'd appreciate it if someone would enlighten me as to a reliable
  1969. way to produce shell archives.
  1970.  
  1971. I was unable to reply to some of the people who mailed me - there are
  1972. best-guess addresses for them.  I'll post icon-group to let them know
  1973. it's gone out, and they can try to get it from the lucky people who
  1974. *do* receive it.
  1975.  
  1976. No makefile, no help, no README, just software.  I'd really like to
  1977. bundle this into a public domain package.  Any ideas for improvement,
  1978. please mail me.
  1979.  
  1980. Steve
  1981. ********************* classify.1l *********************
  1982. .TH CLASSIFY 1 "19 Oct 1987" "Sun UK North"
  1983. .SH NAME
  1984. classify \- re-order or index a mail folder by subject alphabetically
  1985. .SH SYNOPSIS
  1986. .B classify
  1987. \fB\-i\fP
  1988. ]
  1989. .SH DESCRIPTION
  1990. .I Classify
  1991. filters its input, which is assumed to be a mail folder,
  1992. and produces an output which consists of the same messages
  1993. sorted by subject.
  1994. .sp
  1995. The output resulting from re-ordering
  1996. can be processed as a folder
  1997. by the mail system in the usual ways.
  1998. .sp
  1999. An option is available to produce an index for the folder instead
  2000. of a new folder.  The index is always in alphabetical order.
  2001. If the file is re-organised first then the items in the index
  2002. should be in ascending number sequence.
  2003. .SH OPTIONS
  2004. The possible options are:
  2005. .TP
  2006. \fB\-i\fP
  2007. Instead of producing a mail folder as output, produce a
  2008. readable index.
  2009. Index lines look something like this:
  2010. .nf
  2011.  
  2012. \fBSubject-line  . . . . . . . . . . . . .  12; 13, 14, 15\fP
  2013.  
  2014. .fi
  2015. where the number(s) before the semi-colon represent messages with the
  2016. given subject line, and the number(s) after it represent messages which
  2017. refer to the given subject line.
  2018. .SH EXAMPLES
  2019. .LP
  2020. To organise a mail folder alphabetically by subject-line:
  2021. .nf
  2022.  
  2023.     \fBclassify < mailfile > /tmp/rhubarb
  2024.     mv /tmp/rhubarb mailfile\fP
  2025.  
  2026. .fi
  2027. .LP
  2028. To print a table of contents for a mail file two-up on a laserwriter:
  2029. .nf
  2030.  
  2031.     \fBclassify -i < mailfile | enscript -q -2r -f Courier7
  2032.  
  2033. .fi
  2034. .SH "SEE ALSO"
  2035. \fBgetmail(1), mailtrim(1), mp(1)\fP
  2036. .SH BUGS
  2037. Header lines which are repeated in a message (such as \fBReceived\fP)
  2038. will have all but the last occurrences silently removed.
  2039. Subjects which generate index lines too long for the output line will
  2040. produce erratic output.  There is no control over output line width.
  2041. ********************* classify.icn *********************
  2042. #
  2043. #    classify.icn:    read a mail file and produce a subject-sorted
  2044. #            list of mail items and replies, or an index to
  2045. #            the mail file.
  2046. #
  2047. #    @(#)classify.icn    1.4    10/20/87
  2048. #
  2049. #    Bugs:        Sort is case-sensitive.
  2050. #            Craps out on overlength index lines.
  2051. #            (Possibly elsewhere) subjects are not always
  2052. #                well-trimmed.
  2053. #            Does not label untitled mail correctly :-(
  2054. #
  2055. link mailio        # mail i/o library
  2056.  
  2057. procedure main(arg)
  2058.  
  2059.  
  2060. while arg[1][1] == "-" do
  2061.     case (o :=pop(arg))[2] of {
  2062.     "i":    indexrun := ""
  2063.     default:stop("Unrecognised classify option: ",o)
  2064.     }
  2065.  
  2066. if *arg = 0 then arg := [ "-" ]
  2067. if *arg > 1 then stop("Bug: can only handle one file at a time. Sorry.")
  2068.  
  2069. ttls := table([])
  2070. refs := table([])
  2071.  
  2072. msg := []
  2073. while filename := pop(arg) do {
  2074.     if filename == "-"
  2075.     then ifn := &input
  2076.     else ifn := open(filename,"r") | stop("Cannot open file ",filename)
  2077.     while put(msg,readmail(ifn))
  2078. }
  2079. #DB7 write(*msg," items in mail file")
  2080.  
  2081. every m := 1 to *msg do {
  2082.     trim( \(msg[m].header["Subject"]) | "** Untitled Mail" ) ?
  2083.         if (="Re:" & tab(upto(~':\t ')))
  2084.         then refs[ms := tab(0)] |||:= [m]
  2085.         else ttls[ms := tab(0)] |||:= [m]
  2086. #DB7    write(ms,":: ",m)
  2087. }
  2088. #DB7 write("Ttls: ",*ttls,", Refs: ",*refs)
  2089.  
  2090. tlst := sort(ttls)
  2091. rlst := sort(refs)
  2092.  
  2093. #DB9 write("Tlist: ",*tlst,"  Rlist: ",*rlst)
  2094. #DB9 write("Title list")
  2095. #DB9 every x := !tlst do {
  2096. #DB9     writes(x[1],":")
  2097. #DB9     every(writes(!x[2],":"))
  2098. #DB9     write()
  2099. #DB9 }
  2100. #DB9 write("Reference list")
  2101. #DB9 every x := !rlst do {
  2102. #DB9     writes(x[1],":")
  2103. #DB9     every(writes(!x[2],":"))
  2104. #DB9     write()
  2105. #DB9 }
  2106. #DB9 write("\n")
  2107.  
  2108. while (*tlst > 0) | (*rlst > 0) do {        # for each subject...
  2109. #    write("## ",*tlst,"+",*rlst)
  2110.     if (rlst[1][1] << tlst[1][1]) | (*tlst = 0)
  2111.     then {                    # orphaned reference
  2112.         subject := rlst[1][1]
  2113.         refs := pop(rlst)[2]
  2114.         ttls := []
  2115.     } else {                # message
  2116.         subject := tlst[1][1]
  2117.         ttls := pop(tlst)[2]
  2118.         if subject == rlst[1][1]    # handle references, if any
  2119.         then refs := pop(rlst)[2]
  2120.         else refs := []
  2121.     }
  2122.     if \indexrun then {
  2123. #        write("Subject: ",subject, " -- ", *ttls,"+", *refs)
  2124.         present(subject,ttls,refs)
  2125.     } else
  2126.     every writemail(msg[!ttls | !refs])
  2127. }
  2128.  
  2129. end
  2130.  
  2131. procedure present(s, t, r, owid)
  2132.  
  2133. local    ts        # temp string for message numbers
  2134.     
  2135. /owid := 72
  2136. ts := ""
  2137. if *t > 0 then {
  2138.     every i := 1 to *t-1 do ts ||:= t[i] || ", "
  2139.     ts ||:= t[-1]
  2140. } else ts := "- "
  2141. if *r > 0 then {
  2142.     ts ||:= "; "
  2143.     every i := 1 to *r-1 do ts ||:= r[i] || ", "
  2144.     ts ||:= r[-1]
  2145. }
  2146. s ||:= repl(" ",3-(*s % 3))
  2147. write(s,": ",right(ts,owid-*s-2,".. "))
  2148. return
  2149. end
  2150. ********************* getmail.1l *********************
  2151. .TH GETMAIL 1 "15 Oct 1987" "Sun UK North"
  2152. .SH NAME
  2153. getmail \- select messages from a mail folder by number
  2154. .SH SYNOPSIS
  2155. .B getmail
  2156. i[-j] ...
  2157. .SH DESCRIPTION
  2158. .I Getmail
  2159. filters its input, which is assumed to be a mail folder,
  2160. and produces an output which consists of those messages which
  2161. are selected by number from the command line.
  2162. .sp
  2163. The resulting output can be processed as a folder
  2164. by the mail system in the usual ways.
  2165. .sp
  2166. The arguments are of the form:
  2167. .TP
  2168. \fB\i\fP
  2169. Include the \fIi\fPth message.
  2170. .TP
  2171. \fB\i-j\fP
  2172. Include the \fIi\fPth message up to the \fIj\fPth one.
  2173. .\".TP
  2174. .\".B \-n
  2175. .\"No message bodies will be output, only the header lines.
  2176. .SH EXAMPLES
  2177. .LP
  2178. To store the first ten messages from a folder at the end of
  2179. another folder:
  2180. .nf
  2181.  
  2182.     \fBgetmail 1-10 < folder1 >> folder2\fP
  2183.  
  2184. .fi
  2185. .LP 
  2186. To print messages 3,4,5,6 and 12 from a mail folder:
  2187. .nf
  2188.  
  2189.     \fBgetmail 3-6 12 < mailfile | mpt\fP
  2190.  
  2191. .fi
  2192.  
  2193. .SH "SEE ALSO"
  2194. \fBmailtrim(1), mp(1), classify(1)
  2195. .SH BUGS
  2196. Header lines which are repeated in a message (such as \fBReceived\fP)
  2197. will have all but the last occurrences silently removed.
  2198. ********************* getmail.icn *********************
  2199. #
  2200. #    getmail.icn:    a program for handling mail
  2201. #            in the UNIX environment.
  2202. #
  2203. #    @(#)getmail.icn    1.4    10/9/87
  2204. #
  2205. #    Usage:        getmail n[-m] ... < mailfile
  2206. #
  2207. #    1.3 changes:
  2208. #
  2209. #    Accept arguments of the form n or n-m
  2210. #
  2211. #    1.4 changes:
  2212. #
  2213. #    Stop reading mail file when highest requested item has been
  2214. #    processed.  Comment if there are fewer messages than expected.
  2215. #
  2216. link mailio            # mail i/o package
  2217.  
  2218. record range(lower,upper)
  2219.  
  2220. procedure main(argv)
  2221.  
  2222. arglst := []
  2223. uplimit := 0
  2224. while (a:=pop(argv)) do
  2225.     a ? {
  2226.         put(arglst,r := range(
  2227.             l := tab(many('01234567789')),
  2228.             (pos(0) & l) |
  2229.                 (="-" & tab(many('01234567789')))
  2230.         )) | Usage()
  2231.         uplimit <:= r.upper
  2232.     }
  2233.  
  2234. item_no := 0
  2235.  
  2236. #DB7    while r := pop(arglst) do write(r.lower,"-",r.upper)
  2237. #DB7    ("Debugged")
  2238.  
  2239. while (msg := readmail() & item_no < uplimit) do {
  2240.  
  2241.     item_no +:= 1
  2242.     every i := 1 to *arglst do {
  2243.         a := arglst[i]
  2244.         if a.lower <= item_no & a.upper >= item_no
  2245.         then {
  2246.             writemail(msg)
  2247.             break
  2248.         }
  2249.     }
  2250. }
  2251. if item_no < uplimit then stop("Only ",item_no," messages this file")
  2252. end
  2253.  
  2254. procedure Usage()
  2255.  
  2256. stop("Usage: getmail n[-m] ...")
  2257.  
  2258. end
  2259. ********************* mailio.3l *********************
  2260. .TH MAILIO 3 "15 Oct 1987" "Sun UK North" "ICON LIBRARY FUNCTIONS"
  2261. .SH NAME
  2262. mailio \- handle mail folders in Icon programs
  2263. .SH SYNOPSIS
  2264. .nf
  2265. \fB
  2266. link mailio
  2267.  
  2268. record message(from,header,body)
  2269.  
  2270. procedure readmail(f)
  2271. procedure writemail(msg,f)
  2272. \fP
  2273. .fi
  2274. .SH DESCRIPTION
  2275. .I Readmail
  2276. reads the file given as an argument (or standard input by default)
  2277. and returns a
  2278. .B message
  2279. record.
  2280. .sp
  2281. The
  2282. .B from
  2283. field is the first line of the message.
  2284. The
  2285. .B header
  2286. field is a table where the entry values are the header keywords
  2287. (such as
  2288. .I Date
  2289. and
  2290. \fISubject\fP), and the assigned values are the
  2291. remainder of the header line with leading spaces trimmed.
  2292. The
  2293. .B body
  2294. field is a list of the lines of the message.
  2295. Note that readmail maintains an internal one-line buffer,
  2296. so you should not try and mix calls of readmail with other
  2297. input from the same file.
  2298. .sp
  2299. .I Writemail
  2300. takes a
  2301. .B message
  2302. record and writes it to the specified file (or standard output by
  2303. default).
  2304. .SH EXAMPLES
  2305. .LP
  2306. To copy every message from standard input to standard output:
  2307. .nf
  2308. \fB
  2309.     while writemail(readmail())
  2310. \fP    
  2311. .fi
  2312. .LP 
  2313. To write just the first lines and Subject headers (if present)
  2314. from a mail folder:
  2315. .nf
  2316. \fB
  2317.     while msg := readmail do {
  2318.         write(msg.from)
  2319.         write(\\msg.header["Subject"])
  2320.         write
  2321.     }
  2322. \fP
  2323. .fi
  2324.  
  2325. .SH "SEE ALSO"
  2326. \fBgetmail(1), mailtrim(1), mp(1), classify(1)\fP
  2327. .SH BUGS
  2328. Header lines which are repeated in a message (such as \fBReceived\fP)
  2329. will have all but the last occurrences silently removed.
  2330. It is hoped this restriction will be removed, at the expense of
  2331. a change in the format of the
  2332. .B message
  2333. record, at a later date.
  2334. ********************* mailio.icn *********************
  2335. #
  2336. #    mailio.icn:    a skeletal package for reading and
  2337. #            writing mail in the UNIX environment.
  2338. #
  2339. #    @(#)mailio.icn    1.3    11/13/87    SMUKL
  2340. #
  2341. #    To test :    Using a main loop of while writemail(readmail())
  2342. #            should be the same as the input file.
  2343. #            (BUG: repeated header fields will be omitted
  2344. #            in the current version, and probably forever).
  2345. #
  2346. #    Note:        Name changed to mailio from mailskel at delta 1.5
  2347. #
  2348.  
  2349. record    message(from,header,body)
  2350.  
  2351. global    the_next_line
  2352.  
  2353.  
  2354. procedure writemail(msg,f)
  2355.  
  2356. local    t, t1, i
  2357.  
  2358. /f := &output
  2359. write(f,msg.from)
  2360. t := sort(msg.header)
  2361. i := 0
  2362. while (t1 := t[i +:= 1]) do
  2363.     write(f,t1[1],": ",t1[2])
  2364. every write(f,!msg.body)
  2365. return
  2366.  
  2367. end
  2368.  
  2369. procedure readmail(f)
  2370.  
  2371. local    line, fromline, headings, body
  2372. static    hch
  2373. initial    hch := &ucase ++ &lcase ++ '-'
  2374.  
  2375. /f := &input
  2376. headings := table()
  2377. if match("From ",fromline := read_header_line(f)) then {
  2378.     while line := read_header_line(f) do {
  2379.         line ?
  2380.         (headings[tab(many(hch))] := (tab(many(': \t')) & tab(0)))
  2381.     }
  2382.  
  2383.     body := []
  2384.     while (line := read_body_line(f)) do {
  2385.         put(body,line)
  2386.     }
  2387.     return message(fromline,headings,body)
  2388. }
  2389.  
  2390. end
  2391.  
  2392. #########################################################################
  2393. #                                    #
  2394. #    Private routines to this package.                #
  2395. #                                    #
  2396. #########################################################################
  2397.  
  2398. procedure read_header_line(f)
  2399.  
  2400. local the_line
  2401.  
  2402. initial the_next_line := read(f) | exit(0)
  2403.  
  2404. if (the_line := the_next_line) == "" then fail
  2405. else while (any(' \t',the_next_line := (read(f) | fail) \ 1 )) do {
  2406.     the_line ||:= "\n" || the_next_line
  2407. }
  2408. return the_line
  2409.  
  2410. end
  2411.  
  2412. procedure read_body_line(f)
  2413.  
  2414. local tmp
  2415.  
  2416. if match("From ",the_next_line) then fail
  2417. tmp := read(f) | "From "
  2418. tmp :=: the_next_line
  2419. return tmp
  2420.  
  2421. end
  2422. ********************* mailtrim.1l *********************
  2423. .TH MAILTRIM 1 "15 Oct 1987" "Sun UK North"
  2424. .SH NAME
  2425. mailtrim \- remove unwanted headers from a mail folder
  2426. .SH SYNOPSIS
  2427. .B mailtrim
  2428. \fB\-n\fP
  2429. ] [
  2430. \fB\-i\fP keyword ...
  2431. ]
  2432. .SH DESCRIPTION
  2433. .I Mailtrim
  2434. filters its input, which is assumed to be a mail folder,
  2435. and produces an output which consists of the same messages with
  2436. only selected header fields from the input.
  2437. .sp
  2438. The first line of messages is never removed, as this is used by the
  2439. mail system to identify the start of a message.
  2440. Requested header lines which do not occur in a message being processed
  2441. will not appear in the output.
  2442. .sp
  2443. The resulting output can be processed as a folder
  2444. by the mail system in the usual ways.
  2445. .sp
  2446. The possible options are:
  2447. .TP
  2448. \fB\-i\fP keyword ...
  2449. Include only the message headers beginning with the given keywords.
  2450. If this option is omitted mailtrim will remove all but the \fBTo\fP, \fBFrom\fP,
  2451. \fBCc\fP, \fBDate\fP and \fBSubject\fP header lines, which will be
  2452. presented in that order.
  2453. .TP
  2454. .B \-n
  2455. No message bodies will be output, only the header lines.
  2456. .SH EXAMPLES
  2457. .LP
  2458. To get a listing of the subject lines of a mail folder:
  2459. .nf
  2460.  
  2461.     \fBmailtrim -n -i Subject < mailfile > subjects\fP
  2462.  
  2463. .fi
  2464. The output file will look something like this:
  2465. .nf
  2466. \fB
  2467. >From sunuk!sun!texsun!sun!rice.edu!Sun-Spots-Request Tue Sep 15 08:14:17 1987
  2468. Subject:  Sun-Spots Digest, v5n42
  2469.  
  2470. >From sunuk!sun!texsun!sun!rice.edu!Sun-Spots-Request Fri Sep 18 05:39:57 1987
  2471. Subject:  Sun-Spots Digest, v5n43
  2472.  
  2473. >From sunuk!sun!sunrise!sunnyc!exchange!mitch Fri Sep 18 05:23:20 1987
  2474.  
  2475. >From sunuk!sun!sunaus!yo Tue Sep 15 08:17:53 1987
  2476. Subject: 16 bit parallel interface card
  2477.  
  2478. >From sunuk!sun!sunuk!sungy!sunmuc!gaby Wed Sep 16 08:32:43 1987
  2479. Subject: 26 " monitor sought
  2480. \fP
  2481. .fi
  2482. .LP
  2483. To tidy up a mail folder:
  2484. .nf
  2485.  
  2486.     \fBmailtrim < mailfile > /tmp/rhubarb
  2487.     mv /tmp/rhubarb mailfile\fP
  2488.  
  2489. .fi
  2490. .SH "SEE ALSO"
  2491. \fBgetmail(1), mp(1), classify(1)
  2492. .SH BUGS
  2493. Header lines which are repeated in a message (such as \fBReceived\fP)
  2494. will have all but the last occurrences silently removed.
  2495. ********************* mailtrim.icn *********************
  2496. #
  2497. #    mailtrim.icn:    a filter to trim mail files into smaller
  2498. #            ones by deleting non-required headers.
  2499. #
  2500. #    @(#)mailtrim.icn    1.5    10/20/87
  2501. #
  2502. #    Usage:        mailtrim  [-n] [-i keyword ...]
  2503. #
  2504. link mailio            # mail i/o library
  2505.  
  2506. procedure main(arg)
  2507.  
  2508. local    msg,            # store for mail message
  2509.     klist,            # list of keywords to print headers
  2510.     a            # argument being processed
  2511. #
  2512. #    Note: although not mentioned in documentation, the
  2513. #        order of output fields is their order in klist
  2514. #
  2515. klist := ["To","From","Cc","Date","Subject"]    # establish defaults
  2516. while arg[1][1] == "-" do {
  2517.     
  2518.     case (a := pop(arg)[2:0]) of {
  2519.     "i":    {
  2520.         klist := []            # clear defaults
  2521.         while (a:= pop(arg)) do        # build list
  2522.             klist |||:= [a]
  2523.         }
  2524.     "n":    nflag := ""
  2525.     default: stop("Unrecognised argument: -",a)
  2526.     }
  2527.     
  2528. }
  2529. while msg := readmail() do {        # for each message in the folder
  2530. write(msg.from)                # always include the first line
  2531. every hwrite(msg.header, !klist)    # include requested headers
  2532. if /nflag                # body required?
  2533. then every write(!msg.body)        # yes: write lines out    (body[1]
  2534. else write()                # no : terminate header    (always blank!
  2535. }
  2536.  
  2537. end
  2538.  
  2539. procedure hwrite(tbl,key)
  2540.  
  2541. write(key,": ",\tbl[key])
  2542.  
  2543. end
  2544.  
  2545. procedure Usage()
  2546.     stop("Usage: mailtrim [-n] [-i keyword ...]")
  2547. end
  2548. ********************* mp.pro.ps *********************
  2549. %!PS-Adobe-1.0
  2550. %%Creator: steve holden
  2551. %%Title: @(#)mp.pro.ps    1.1    2/18/87
  2552. %%CreationDate: see above
  2553. %%DocumentFonts: Times-Bold Times-Roman Courier
  2554. %%Pages: (atend)
  2555. %%EndComments
  2556. %
  2557.  
  2558. save /nuksunmailsave exch def
  2559. /font1d /Times-Bold findfont 10 scalefont def
  2560.  
  2561. /font2d /Times-Roman findfont 10 scalefont def
  2562.  
  2563. /font3d /Courier findfont 9 scalefont def
  2564.  
  2565. /fontHd /Helvetica-BoldOblique findfont 15 scalefont def
  2566.  
  2567. /fontH2 /Helvetica-BoldOblique findfont 10 scalefont def
  2568.  
  2569. /fontNd /Times-Bold findfont 12 scalefont def
  2570.  
  2571. /Bold {font1d setfont} def
  2572. /Roman {font2d setfont} def
  2573. /Courier {font3d setfont} def
  2574. /fontH {fontHd setfont} def
  2575. /fontD {fontH2 setfont} def
  2576. /fontN {fontNd setfont} def
  2577.  
  2578. Courier
  2579.  
  2580. /endpage
  2581. {
  2582.     gsave
  2583.     fontH
  2584.     newpath
  2585.     90 756 moveto
  2586.     100 736 10 180 270 arc
  2587.     536 736 10 270 0 arc
  2588.     536 756 10 0 90 arc
  2589.     100 756 10 90 180 arc
  2590.     closepath 0.75 setgray fill
  2591.     newpath
  2592.     318 746 15 0 360 arc
  2593.     gsave 1 setgray fill grestore
  2594.     closepath
  2595.     0 setgray stroke
  2596.     100 740 moveto
  2597.     (Mail for ) show
  2598.     loginname (\(null\)) eq {(printing)} {loginname} ifelse show
  2599.     fontD
  2600.     timenow stringwidth pop neg 536 add 740 moveto timenow show
  2601.     fontN
  2602.     dup stringwidth pop 2 div neg 318 add 740 moveto show
  2603.     fontH
  2604.     newpath
  2605.     90 60 moveto
  2606.     100 40 10 180 270 arc
  2607.     536 40 10 270 0 arc
  2608.     536 60 10 0 90 arc
  2609.     100 60 10 90 180 arc
  2610.     closepath 0.75 setgray fill
  2611.     0 setgray
  2612.     100 44 moveto hostname show
  2613.     grestore
  2614.     showpage        % display it
  2615.     newpage        % reset parameters for next
  2616. } def
  2617.  
  2618. /newpage
  2619. { /lct 0 def
  2620.   /ypos 700 def
  2621.   100 ypos moveto
  2622. } def
  2623.  
  2624. /showline { show /ypos ypos 10 sub def 100 ypos moveto } def
  2625.  
  2626. newpage            % establish first page parameters
  2627. ********************* mpt.c *********************
  2628. /*
  2629.     mpt.c:    mail trigger program    @(#)mpt.c    1.1    2/18/87
  2630.  
  2631.         Add 'set EDITOR=/usr/local/bin/mpt' (or local
  2632.     equivalent: see Makefile) to .mailrc
  2633.  
  2634.         Use the command 'e 15' to print message 15.
  2635.     (Note: you can only 'e' one message at a time).
  2636.  
  2637.         This program is necessary because EDITOR cannot be
  2638.     a shellscript.  It receives a temporary filename as
  2639.     a single argument.  It gets the user's login name,
  2640.     abd then calls /usr/local/bin/mp which can be
  2641.     customised.
  2642. */
  2643. #include <stdio.h>
  2644.  
  2645. extern int errno;
  2646.  
  2647. main(argc, argv)
  2648.  char *argv[];
  2649.  int argc;
  2650. {
  2651.     char *login, *getlogin();
  2652.         if(argc == 2) {
  2653.         login = getlogin();
  2654.                 execlp("mp",
  2655.             "mp", "-s", "-u", login, argv[1], 0);
  2656.     } else {
  2657.         fprintf(stderr,"Usage: mpt filename (from mail)\n");
  2658.         exit(1);
  2659.     }
  2660.     fprintf(stderr,"mp not found\n");
  2661.         exit(1);        /* executed only if execlp fails */
  2662. }
  2663.  
  2664.  
  2665. From icon-group-request  Thu Feb 18 04:46:45 1988
  2666. Received: by bocklin.arizona.edu; Thu, 18 Feb 88 04:46:49 MST
  2667. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 18 Feb 88 04:46:45 MST
  2668. Received: from SUN.COM by megaron.arizona.edu; Thu, 18 Feb 88 04:46:28 MST
  2669. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-4.0)
  2670.     id AA20978; Thu, 18 Feb 88 03:45:28 PST
  2671. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  2672.     id AA29986; Thu, 18 Feb 88 03:45:41 PST
  2673. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  2674.     id AA21979; Thu, 18 Feb 88 03:36:17 PST
  2675. Received: from Nuksun.Europe.Sun.COM (inuksun) by UK.Sun.COM (3.2/SMI-3.2)
  2676.     id AA16131; Thu, 18 Feb 88 11:43:44 GMT
  2677. Received: from stevie.nuksun.uucp by Nuksun.Europe.Sun.COM (1.1/SMI-3.2)
  2678.     id AA09567; Thu, 18 Feb 88 11:43:11 GMT
  2679. Received: by stevie.nuksun.uucp (3.2/SMI-3.2)
  2680.     id AA07326; Thu, 18 Feb 88 11:43:05 GMT
  2681. Date: Thu, 18 Feb 88 11:43:05 GMT
  2682. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - TSE)
  2683. Message-Id: <8802181143.AA07326@stevie.nuksun.uucp>
  2684. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  2685. Subject: Re:  Mail handling software
  2686. Errors-To: icon-group-request
  2687.  
  2688. Ahem.  Due to an oversight I omitted to include the program which
  2689. started all this off.  This is "mp", which formats mail for printing
  2690. on a PostScript printer.  The distributed program "mpt" exists to
  2691. set default values when mp is called from /usr/ucb/mail.
  2692.  
  2693. The program source and manual page follow.
  2694.  
  2695. Steve
  2696. ********************* mp.icn *********************
  2697. #
  2698. #    mp.icn:    Take a mail file and format each item for laserwriter.
  2699. #
  2700. #    @(#)mp.icn    1.2    10/8/87    SMUKL
  2701. #
  2702. #    1.2 changes:
  2703. #
  2704. #    Give useline() an argument to make it easier to cope with
  2705. #    sections of text longer than one line.
  2706. #
  2707. #    Handle body lines of "form feed" correctly.
  2708. #
  2709. #    Ensure all local variables declared.
  2710. #
  2711. link mailio            # mail i/o library
  2712.  
  2713. global    pn,            # page number within message
  2714.     item,            # message number in mailstream
  2715.     linect,            # line count on current page
  2716.     op,            # output file
  2717.     sflag,            # non-null for single-item numbering
  2718.     nflag,            # non-null for output to stdout
  2719.     shno            # sheet number for PostScript page counts
  2720.  
  2721.  
  2722. procedure main(arg)
  2723.  
  2724. local    msg,            # stores mail item
  2725.     o,            # temporary fpr option strings
  2726.     hostname,        # string for bottom left corner
  2727.     username,        # string after "mail for" at top right
  2728.     infl,            # input file
  2729.     f,            # input file name
  2730.     pf            # prologue file
  2731.  
  2732.  
  2733. while arg[1][1] == "-" do            # handle each option
  2734. case (o := pop(arg))[2] of {
  2735.    "h"    : hostname := pop(arg) | stop("-h needs hostname as next argument")
  2736.    "u"    : username := pop(arg) | stop("-u needs username as next argument")
  2737.    "s"    : sflag := ""
  2738.    "n"    : nflag := ""
  2739. default    : stop("Unknown option ",o)
  2740. }
  2741.  
  2742. linect := shno := item := 0
  2743. /username := "printing"                # default value
  2744. /hostname := &host                # default value
  2745.  
  2746. if *arg > 0                    # input (use file if given)
  2747. then infl := open(f := pop(arg)) | stop("Cannot open file ",f)
  2748. else infl := &input
  2749.  
  2750. pf := open("/private/local/lib/mp.pro.ps") | stop("Prologue file not found")
  2751. if /nflag
  2752. then op := open("lpr","pw") | stop("Can't pipe output to lpr")
  2753. else op := &output
  2754.  
  2755. every write(op,!pf)
  2756. defwrite("hostname",hostname)
  2757. defwrite("loginname",username)
  2758. defwrite("timenow",&dateline)
  2759. write(op,"%%EndProlog")
  2760.  
  2761. while msg := readmail(infl) do {
  2762.     item +:= 1
  2763.     pn := 0
  2764.     startpage()
  2765.     Boldshow(msg.from)
  2766.     every Mixedshow(msg.header,
  2767.             !["From","To","Cc","Date","Subject"])
  2768.     write(op,"Courier")
  2769.     every Textshow(!msg.body)
  2770.     endpage()
  2771. }
  2772.  
  2773. write(op,"%%Trailer")
  2774. write(op,"%%Pages: ",shno)
  2775.  
  2776. end
  2777.  
  2778. procedure Boldshow(s)
  2779. useline(1)
  2780. write(op,"Bold (",expand(s),") showline")
  2781. end
  2782.  
  2783. procedure Mixedshow(t,k)
  2784. local    l    # bits of the line
  2785. if \t[k] then {
  2786.     write(op,"Bold (", k, ": ) show Roman")
  2787.     t[k] ? {
  2788.         while l := tab(many(~'\n')) do {
  2789.             useline(1)
  2790.             write(op,"(", expand(l), ") showline")
  2791.             move(1) | break
  2792.         }
  2793.     }
  2794. }
  2795. end
  2796.  
  2797. procedure Textshow(s)
  2798. if s == "\f" then
  2799.     useline(60)
  2800. else {
  2801.     useline(1)
  2802.     write(op,"(",expand(s),") showline")
  2803. }
  2804. end
  2805.  
  2806. procedure expand(s)
  2807. local    l            # bits between escapes
  2808. l := ""
  2809. s ? while l ||:= (tab(many(~'\\()\t')) | "") do {
  2810.     if pos(0) then break
  2811.     else case move(1) of {
  2812.         "\\":    l ||:= "\\\\"
  2813.         "(" :    l ||:= "\\("
  2814.         ")" :    l ||:= "\\)"
  2815.         "\t":    l ||:= repl(" ",8-(*l % 8))
  2816.     }
  2817. }
  2818. return l
  2819. end
  2820.  
  2821. procedure useline(n)
  2822. if (linect +:= n) > 60
  2823. then {
  2824.     endpage()
  2825.     startpage()
  2826. }
  2827. end
  2828.  
  2829.  
  2830. procedure startpage()
  2831. write(op,"%%Page: ? ",shno +:= 1)
  2832. end
  2833.  
  2834.  
  2835. procedure endpage(n)
  2836. local p
  2837. linect := 0
  2838. p := (/sflag & (item || "." || (pn +:= 1))) | shno
  2839. write(op,"(",p,") endpage")
  2840. end
  2841.  
  2842. procedure defwrite(name,def)
  2843. write(op,"/",name," (",def,") def")
  2844. end
  2845. ********************* mp.1l *********************
  2846. .TH MP 1 "18 February 1987"
  2847. .\"@(#)mp.1    1.1    2/18/87
  2848. .SH NAME
  2849. mp \- mail printer
  2850. .SH SYNOPSIS
  2851. \fBmp\fP 
  2852. [ \fB-u\fP \fIusername\fP ]
  2853. [ \fB-h\fP \fIhostname\fP ]
  2854. [ \fB-n\fP ]
  2855. [ \fB-s\fP ]
  2856. [ file ]
  2857. .SH DESCRIPTION
  2858. .IX  mp "" "\fLmp\fP \(em mail printing program"
  2859. .IX  mail "mp command" "" "\fLmp\fP \(em mail printing"
  2860. .IX "mail printing" "mp command" "" "\fLmp\fP \(em mail printing"
  2861. \fIMp\fP prints mail on a laserwriter.
  2862. The format adopted has shaded stripes containing banner information
  2863. at the top and bottom of every page.
  2864. It normally pipes its output straight into
  2865. \fIlpr\fP, causing direct printing of mail.
  2866. The output is page-reversed to leave the first sheet on the top
  2867. of the output stacker.
  2868. .SH OPTIONS
  2869. .TP
  2870. \fB-u\fP \fIusername\fP
  2871. The top left banner reads "Mail for \fIusername\fP", but the default
  2872. value of \fIusername\fP is "printing".
  2873. This option can be used to substitute, for example, your real name
  2874. for your username.
  2875. .TP
  2876. \fB-h\fP \fIhostname\fP
  2877. The hostname is printed left-justified in the bottom banner stripe.
  2878. You may customise it with this option.
  2879. .TP
  2880. \fB-n\fP
  2881. Do not pipe output to
  2882. \fIlpr\fP, but produce PostScript on standard output.
  2883. .TP
  2884. \fB-s\fP
  2885. Normally \fImp\fP assumes that its input contains a number of messages,
  2886. and numbers the output pages as \fIn.m\fP, where \fIn\fP is the message
  2887. number and \fIm\fP is the page number within the message.
  2888. This option is used when processing a single message, to cause simple
  2889. sequence-numbering of the output pages.
  2890. .SH FILES
  2891. .TP
  2892. /usr/local/mp.pro.ps
  2893. PostScript prologue to define required vocabulary for mail printing.
  2894. Editing this file will alow you to introduce some stylistic variation
  2895. in the printing of mail.
  2896. .TP
  2897. /usr/local/bin/iconx*
  2898. \fIMp\fP is written in Icon.  These files are the run-time package
  2899. for the Icon language.
  2900. Other mail-handling programs will also be written in Icon, so this
  2901. is an investment for the future.
  2902. .SH "SEE ALSO"
  2903. mail(1)
  2904. .SH BUGS
  2905. Needs to be installed at a fixed place in the filestore.
  2906. Does not process more than one file.
  2907. Does not handle overlength lines, truncating them silently.
  2908. Default username has an unhelpful value.
  2909.  
  2910.  
  2911. From icon-group-request  Thu Feb 18 12:15:48 1988
  2912. Received: by bocklin.arizona.edu; Thu, 18 Feb 88 12:15:53 MST
  2913. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 18 Feb 88 12:15:48 MST
  2914. Received: from SUN.COM by megaron.arizona.edu; Thu, 18 Feb 88 12:15:36 MST
  2915. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-4.0)
  2916.     id AA29053; Thu, 18 Feb 88 11:14:41 PST
  2917. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  2918.     id AA08074; Thu, 18 Feb 88 11:14:59 PST
  2919. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  2920.     id AA00832; Thu, 18 Feb 88 11:06:33 PST
  2921. Received: from snail.sun.com (snail-swanbb) by UK.Sun.COM (3.2/SMI-3.2)
  2922.     id AA21714; Thu, 18 Feb 88 19:14:24 GMT
  2923. Received: from Sun.COM (sun-arpa) by snail.sun.com (4.0/SMI-3.2)
  2924.     id AA00824; Thu, 18 Feb 88 11:06:23 PST
  2925. Received: from jhereg.s1.gov by Sun.COM (4.0/SMI-4.0)
  2926.     id AA29003; Thu, 18 Feb 88 11:13:49 PST
  2927. Received: by jhereg.s1.gov id AA05632; Thu, 18 Feb 88 10:30:37 PST
  2928.     id AA05632; Thu, 18 Feb 88 10:30:37 PST
  2929. Date: Thu, 18 Feb 88 10:30:37 PST
  2930. From: sunuk!sun!mordor.s1.gov!berry%jhereg.s1.gov@Sun.COM
  2931. Message-Id: <8802181830.AA05632@jhereg.s1.gov>
  2932. To: nuksun!stevie!steveh%sunuk@Sun.COM
  2933. Cc: sun!arizona.edu!icon-group%sunuk@Sun.COM
  2934. In-Reply-To: Steve Holden - TSE's message of Thu, 18 Feb 88 09:42:35 GMT <8802180942.AA06649@stevie.nuksun.uucp>
  2935. Subject: Mail handling software
  2936. Errors-To: icon-group-request
  2937.  
  2938. #! /bin/sh
  2939. # bundle:  group files into distribution package
  2940. # See Kernighan & Pike;  the Unix Programming Environment; pg 98
  2941. #
  2942. echo '# To unbundle, feed me to sh'
  2943. for i
  2944. do
  2945.     echo "echo $i 1>&2"
  2946.     echo "cat >$i <<'End of $1'"
  2947.     cat $i
  2948.     echo "End of $i"
  2949. done
  2950.  
  2951. From icon-group-request  Thu Feb 18 13:32:45 1988
  2952. Received: by bocklin.arizona.edu; Thu, 18 Feb 88 13:32:49 MST
  2953. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 18 Feb 88 13:32:45 MST
  2954. Received: from XEROX.COM by megaron.arizona.edu; Thu, 18 Feb 88 13:32:37 MST
  2955. Received: from Semillon.ms by ArpaGateway.ms ; 18 FEB 88 11:45:19 PST
  2956. Date: Thu, 18 Feb 88 11:45:06 PST
  2957. From: weiser.pa@Xerox.COM
  2958. To: icon-group@arizona.edu
  2959. Message-Id: <880218-112730-7432@Xerox>
  2960. Errors-To: icon-group-request
  2961.  
  2962. The little bundler just posted is not a good one: it will not survive many types
  2963. of mailers out there, which treat lines beginning with .'s as special.  There
  2964. are many version of the program 'makescript' floating around, which do a better
  2965. job, and also check that sizes are the same after unbundling, etc.  You can get
  2966. one by anonymous to parcvax.xerox.com, directory pub, file makescript.c.
  2967.  
  2968. -mark
  2969.  
  2970.  
  2971. From icon-group-request  Thu Feb 18 16:19:06 1988
  2972. Received: by bocklin.arizona.edu; Thu, 18 Feb 88 16:19:09 MST
  2973. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 18 Feb 88 16:19:06 MST
  2974. Date: Thu, 18 Feb 88 16:19:04 MST
  2975. From: "Bill Mitchell" <whm>
  2976. Message-Id: <8802182319.AA22670@megaron.arizona.edu>
  2977. Received: by megaron.arizona.edu; Thu, 18 Feb 88 16:19:04 MST
  2978. To: icon-group
  2979. Subject: Re:  variable args
  2980. Errors-To: icon-group-request
  2981.  
  2982. As a similarity to the handling of x[] arguments, note that if a program is
  2983. invoked with no arguments, main is called with [] instead of &null.  As I
  2984. recall, this was changed to avoid having to special case the zero argument
  2985. situation.
  2986.  
  2987. From icon-group-request  Sat Feb 20 08:55:34 1988
  2988. Received: by bocklin.arizona.edu; Sat, 20 Feb 88 08:55:36 MST
  2989. Received: from megaron.arizona.edu by bocklin.arizona.edu; Sat, 20 Feb 88 08:55:34 MST
  2990. Date: Sat, 20 Feb 88 08:55:32 MST
  2991. From: "Ralph Griswold" <ralph>
  2992. Message-Id: <8802201555.AA19898@megaron.arizona.edu>
  2993. Received: by megaron.arizona.edu; Sat, 20 Feb 88 08:55:32 MST
  2994. To: icon-group
  2995. Subject: Version 7 Icon available via FTP
  2996. Errors-To: icon-group-request
  2997.  
  2998.  
  2999. The UNIX and VMS Version 7 Icon systems are now available via anonymous
  3000. FTP from arizona.edu.  There also is a printable form of the report that
  3001. describes the features of Version 7 of Icon.
  3002.  
  3003. Do a cd to icon and get README, which is a summary of files available and
  3004. their sizes.  Note that the UNIX and VMS systems are *large*; you may or may
  3005. not find that FTP is practical.
  3006.  
  3007. From icon-group-request  Tue Feb 23 19:21:19 1988
  3008. Received: by bocklin.arizona.edu; Tue, 23 Feb 88 19:21:25 MST
  3009. Received: from megaron.arizona.edu by bocklin.arizona.edu; Tue, 23 Feb 88 19:21:19 MST
  3010. Received: from [128.135.12.98] by megaron.arizona.edu; Tue, 23 Feb 88 19:18:16 MST
  3011. Received:  by sphinx.uchicago.edu (5.54/2.0Sx)
  3012.     id AA23234; Tue, 23 Feb 88 20:18:16 CST
  3013. Return-Path: <goer@sophist.uchicago.edu>
  3014. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  3015.     id AA14338; Tue, 23 Feb 88 20:13:09 CST
  3016. Date: Tue, 23 Feb 88 20:13:09 CST
  3017. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  3018. Message-Id: <8802240213.AA14338@sophist.uchicago.edu>
  3019. To: icon-group@arizona.edu
  3020. Subject: cross posting
  3021. Errors-To: icon-group-request
  3022.  
  3023.  
  3024. A recent discussion of Icon on the HUMANIST - a network devoted to computing
  3025. in various aspects of the Humanities - has turned up some interesting comments,
  3026. both pro and con.  Most have been pro.  I thought it might be useful to cross
  3027. post to this group a representative letter:
  3028.  
  3029. Date:       23 February 1988, 19:06:00 EST
  3030. Sender:     HUMANIST Discussion <HUMANIST%UTORONTO.BITNET@UCHIMVS1.UCHICAGO.EDU>
  3031. Subject:    ICON and commercial support (49 lines)
  3032.  
  3033. >From dow@husc6.BITNET (Dominik Wujastyk)
  3034.  
  3035. I don't agree at all with Mark Olsen's claim that Icon is fettered by
  3036. its public domain status.  Of course it would be nice if a company took
  3037. it up and added goodies.  But I probably couldn't afford them anyway.
  3038.  
  3039. But look for a moment at TeX.  This is a public domain product that has
  3040. more support than any commerical product I can think of.  Have you ever
  3041. tried, for example, to get help from IBM?  Or Lotus?  Or Microsoft?
  3042. Sometimes one strikes lucky, and will get a helpful person.  But TeX
  3043. has a huge and thriving community of users, including many very talented
  3044. programmers, who provide a steady stream of excellent add-on programs and
  3045. macros.  In the first place there is TeXhax, which is a digest of
  3046. questions, answers and macros produced by Malcolm Brown, which appears
  3047. sometimes as often as thrice weekly!  Then there is TeXmag, another on line
  3048. magazine with news and more macros.  There is the USENET news area
  3049. comp.text which is full of TeXiana, and there is TUGboat, a tri-annual journal
  3050. of the highest quality, which is again full of help and interest.  The
  3051. staff of the TeX Users Group are also on hand with help and advice.  As I
  3052. say, I have not met support like this *anywhere* else, and the commercial
  3053. software I have used over the years, especially from the big companies, has
  3054. been abysmally supported.
  3055.  
  3056. It would be interesting to try and analyse just why it is that TeX has
  3057. attracted the support that it has.  In the first place it is a superb
  3058. program: so is Icon.  It is portable across systems and OSs: so is Icon.
  3059. It is supported by the User group, which in turn received a lot of support
  3060. from the American Mathematical Society, which uses TeX for most (perhaps
  3061. all by now) of its journals.  Ah! A difference. Icon does not lend itself
  3062. in any obvious way for large scale use in a semi commercial environment.
  3063. And I think the main reason is that it cannot produce compiled executables.
  3064. As someone else said recently here in Humanist, I think this is one of its
  3065. main drawbacks.
  3066.  
  3067. I make it my general policy to prefer the PD software to the commercial as
  3068. far as possible, and there are few areas where this has not led me to have
  3069. better programs and better support for them.
  3070.  
  3071. Dominik Wujastyk
  3072.  
  3073.  
  3074. Other comments on Icon centered on its power, ease of programming, availabil-
  3075. ity, and its modern, procedural orientation.  Cons included the apparent lack
  3076. of a facility for random disc access, and the absence of a good debugger.  In
  3077. response to this latter point, it was noted that version 7 has much improved
  3078. debugging facilities, and that Icon is so easy to program in (esp. with gar-
  3079. bage collection) that errors harder to make than with C, Pascal, etc.
  3080.  
  3081. People disagreed on whether Icon would make a good first programming language.
  3082. The initial poster argued "yes"; subsequent posters tended to disagree - all
  3083. except one, who was a SNO/SPITBOL programmer (does he really count).
  3084.  
  3085. Overall, the main concern was really the absence of the supposed advantages
  3086. of commercial support - things like a debugger and a built-in editor.  As the
  3087. letter quoted above indicates, not everyone saw these things as major concerns.
  3088. The only universal item on everyone's wish list was a compiler.
  3089.  
  3090. So much for what the Humanists are saying -
  3091.  
  3092.                                                   -Richard L. Goerwitz
  3093.                                                   goer@sophist.uchicago.edu
  3094.                                                   !ihnp4!gargoyle!sophist!goer
  3095. Q.
  3096.  
  3097. From icon-group-request  Fri Feb 26 11:19:32 1988
  3098. Received: by bocklin.arizona.edu; Fri, 26 Feb 88 11:19:35 MST
  3099. Received: from megaron.arizona.edu by bocklin.arizona.edu; Fri, 26 Feb 88 11:19:32 MST
  3100. Received: from SUN.COM by megaron.arizona.edu; Fri, 26 Feb 88 11:19:23 MST
  3101. Received: from sun.Sun.COM ([129.144.1.3]) by Sun.COM (4.0/SMI-4.0)
  3102.     id AA22565; Fri, 26 Feb 88 10:18:20 PST
  3103. Received: from snail.sun.com by sun.Sun.COM (4.0/SMI-4.0)
  3104.     id AA10167; Fri, 26 Feb 88 10:18:53 PST
  3105. Received: from UK.Sun.COM (sunuk) by snail.sun.com (4.0/SMI-3.2)
  3106.     id AA01148; Fri, 26 Feb 88 10:19:32 PST
  3107. Received: from Nuksun.Europe.Sun.COM (inuksun) by UK.Sun.COM (3.2/SMI-3.2)
  3108.     id AA09733; Fri, 26 Feb 88 16:05:40 GMT
  3109. Received: from stevie.nuksun.uucp by Nuksun.Europe.Sun.COM (1.1/SMI-3.2)
  3110.     id AA20901; Fri, 26 Feb 88 16:05:07 GMT
  3111. Received: by stevie.nuksun.uucp (3.2/SMI-3.2)
  3112.     id AA24796; Fri, 26 Feb 88 16:05:03 GMT
  3113. Date: Fri, 26 Feb 88 16:05:03 GMT
  3114. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - TSE)
  3115. Message-Id: <8802261605.AA24796@stevie.nuksun.uucp>
  3116. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  3117. Subject: SunSpots
  3118. Errors-To: icon-group-request
  3119.  
  3120. It has been suggested that the group might be interested in the
  3121. SunSpots mailings from Rice.  If people mail me to express their
  3122. interest I will contact the moderator to see if this would be
  3123. acceptable.  Or perhaps someone else would like to undertake
  3124. the task?
  3125.  
  3126. Steve
  3127.  
  3128. From icon-group-request  Fri Feb 26 20:34:04 1988
  3129. Received: by bocklin.arizona.edu; Fri, 26 Feb 88 20:34:08 MST
  3130. Received: from megaron.arizona.edu by bocklin.arizona.edu; Fri, 26 Feb 88 20:34:04 MST
  3131. Date: Fri, 26 Feb 88 20:34:01 MST
  3132. From: "Gregg Townsend" <gmt>
  3133. Message-Id: <8802270334.AA01812@megaron.arizona.edu>
  3134. Received: by megaron.arizona.edu; Fri, 26 Feb 88 20:34:01 MST
  3135. To: icon-group
  3136. Subject: signatures
  3137. Errors-To: icon-group-request
  3138.  
  3139. I'd like to urge everyone to include a short signature when sending a message
  3140. to the icon-group mailing list.  It's hard in some systems to figure out who
  3141. sent a message when it's been passed through three (minimum) mailers.
  3142.  
  3143. Things are further complicated because we do some header rewriting before
  3144. forwarding messages to the list.  This is to spare the original sender all
  3145. the messages that bounce back due to unreachable list members.
  3146.  
  3147.      Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  3148.      +1 602 621 4325       gmt@Arizona.EDU      {allegra|noao|ihnp4}!arizona!gmt
  3149.  
  3150. From icon-group-request  Fri Feb 26 21:18:33 1988
  3151. Received: by bocklin.arizona.edu; Fri, 26 Feb 88 21:18:37 MST
  3152. Received: from megaron.arizona.edu by bocklin.arizona.edu; Fri, 26 Feb 88 21:18:33 MST
  3153. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu; Fri, 26 Feb 88 21:18:25 MST
  3154. Received: by ucbvax.Berkeley.EDU (5.58/1.26)
  3155.     id AA06565; Fri, 26 Feb 88 16:58:07 PST
  3156. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  3157.     for icon-group@arizona.edu (icon-group@arizona.edu)
  3158.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  3159. Date: 24 Feb 88 15:06:08 GMT
  3160. From: mcvax!ukc!stc!datlog!torch!paul@uunet.uu.net  (Paul Andrews)
  3161. Organization: TORCH Computers Ltd., Cambridge, United Kingdom
  3162. Subject: Map of Europe
  3163. Message-Id: <60@torch.UUCP>
  3164. Sender: icon-group-request@arizona.edu
  3165. To: icon-group@arizona.edu
  3166. Errors-To: icon-group-request
  3167.  
  3168.  
  3169. Looks to me like the map of Europe posted recently was automatically generated
  3170. (in 1986!) from a site list. Anybody know anything about that?
  3171.  
  3172. - Paul
  3173.  
  3174. From icon-group-request  Fri Feb 26 21:19:05 1988
  3175. Received: by bocklin.arizona.edu; Fri, 26 Feb 88 21:19:08 MST
  3176. Received: from megaron.arizona.edu by bocklin.arizona.edu; Fri, 26 Feb 88 21:19:05 MST
  3177. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu; Fri, 26 Feb 88 21:18:56 MST
  3178. Received: by ucbvax.Berkeley.EDU (5.58/1.26)
  3179.     id AA06587; Fri, 26 Feb 88 16:58:56 PST
  3180. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  3181.     for icon-group@arizona.edu (icon-group@arizona.edu)
  3182.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  3183. Date: 24 Feb 88 15:10:37 GMT
  3184. From: mcvax!ukc!stc!datlog!torch!paul@uunet.uu.net  (Paul Andrews)
  3185. Organization: TORCH Computers Ltd., Cambridge, United Kingdom
  3186. Subject: Icon?
  3187. Message-Id: <61@torch.UUCP>
  3188. Sender: icon-group-request@arizona.edu
  3189. To: icon-group@arizona.edu
  3190. Errors-To: icon-group-request
  3191.  
  3192. Would someone like to give me some background on this language. I've never
  3193. heard of it before but it sounds interesting.
  3194.  
  3195. - Paul
  3196.  
  3197. From icon-group-request  Sun Feb 28 21:34:20 1988
  3198. Received: by bocklin.arizona.edu; Sun, 28 Feb 88 21:34:22 MST
  3199. Received: from megaron.arizona.edu by bocklin.arizona.edu; Sun, 28 Feb 88 21:34:20 MST
  3200. Received: from [128.135.12.98] by megaron.arizona.edu; Sun, 28 Feb 88 21:33:02 MST
  3201. Received:  by sphinx.uchicago.edu (5.54/2.0Sx)
  3202.     id AA24237; Sun, 28 Feb 88 22:34:21 CST
  3203. Return-Path: <goer@sophist.uchicago.edu>
  3204. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  3205.     id AA07576; Sun, 28 Feb 88 22:28:58 CST
  3206. Date: Sun, 28 Feb 88 22:28:58 CST
  3207. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  3208. Message-Id: <8802290428.AA07576@sophist.uchicago.edu>
  3209. To: icon-group@arizona.edu
  3210. Subject: A better way?
  3211. Errors-To: icon-group-request
  3212.  
  3213.  
  3214. I was looking at a sorry procedure in a much bigger program that I am writing.
  3215. I kept thinking, "There's gotta be a better way."  Trouble is that everything
  3216. else I tried was - if more elegant - less efficient.
  3217.  
  3218. Here it is.  Can anyone offhand offer me some ideas as to how I might clean
  3219. it up a bit?
  3220.  
  3221. procedure Bal(c1,c2,c3,s)
  3222.  
  3223.   # A bit like bal, but accounts for backslashed characters.
  3224.   local l1, l2
  3225.   l1 := []
  3226.   l2 := []
  3227.   s ? {
  3228.     repeat {
  3229.       &pos >= *s + 1 & fail
  3230.       if &subject[&pos] == "\\"
  3231.       then move(2) & next
  3232.       else {
  3233.         if push(l1,any(c2,move(1))) | push(l2,any(c3,move(1)))
  3234.         then next
  3235.         if (*l1 = *l2) & any(c1,move(1))
  3236.         then (suspend &pos - 1) & next
  3237.         move(1)
  3238.         }
  3239.       }
  3240.     }
  3241.   
  3242. end
  3243.  
  3244.  
  3245.                                                   -Richard L. Goerwitz
  3246.                                                   goer@sophist.uchicago.edu
  3247.                                                   !ihnp4!gargoyle!sophist!goer
  3248.  
  3249. From icon-group-request  Mon Feb 29 11:23:34 1988
  3250. Received: by bocklin.arizona.edu; Mon, 29 Feb 88 11:23:38 MST
  3251. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 29 Feb 88 11:23:34 MST
  3252. Date: Mon, 29 Feb 88 11:23:32 MST
  3253. From: "Kenneth Walker" <kwalker>
  3254. Message-Id: <8802291823.AA17235@megaron.arizona.edu>
  3255. Received: by megaron.arizona.edu; Mon, 29 Feb 88 11:23:32 MST
  3256. To: icon-group
  3257. Subject: Re:  A better way?
  3258. Errors-To: icon-group-request
  3259.  
  3260. I have what I feel is a cleaner solution to Richard Goerwitz's problem.
  3261. I am not sure exactly what he wants to do with back slashes, but I believe
  3262. my version does what his does.
  3263.  
  3264.  
  3265. procedure Bal(c1,c2,c3,s)
  3266.  
  3267.   # A bit like bal, but accounts for backslashed characters.
  3268.   local cnt1, cnt2
  3269.   cnt1 := 0
  3270.   cnt2 := 0
  3271.   s ? {
  3272.     until pos(0) do {
  3273.       if not ="\\" then {
  3274.         if tab(any(c2)) then 
  3275.            cnt1 +:= 1
  3276.         else if tab(any(c3)) then
  3277.            cnt2 +:= 1
  3278.         else  {
  3279.            if (cnt1 = cnt2) & any(c1) then 
  3280.               suspend .&pos
  3281.            move(1)
  3282.            }
  3283.         }
  3284.       }
  3285.     }
  3286.   fail
  3287.   
  3288. end
  3289.  
  3290. Note that suspending from within string scanning is fine in Version 7
  3291. of Icon, but is not recomended in earlier versions. If Bal() is itself
  3292. called from within string scanning and an earlier version of Icon is
  3293. used, there will be problems with &subject and &pos. [this has been
  3294. an unpaid advertisement for V7 - keep posted for announcements of
  3295. release for your favorite system]
  3296.  
  3297. Does anyone else have a still better solution?
  3298.  
  3299. From icon-group-request  Mon Feb 29 18:25:39 1988
  3300. Received: by bocklin.arizona.edu; Mon, 29 Feb 88 18:25:42 MST
  3301. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 29 Feb 88 18:25:39 MST
  3302. From: ihnp4!ihuxy!nowlin
  3303. Message-Id: <8803010125.AA14607@megaron.arizona.edu>
  3304. Received: by megaron.arizona.edu; Mon, 29 Feb 88 18:25:37 MST
  3305. Received: by ihnp4.ATT.COM id AA15689; 29 Feb 88 08:05:46 CST (Mon)
  3306. Message-Version: 2
  3307. >To: /addr=ihnp4!arizona!icon-group
  3308. Date: Mon 29 Feb 1988 08:05 CST
  3309. End-Of-Header: 
  3310. Email-Version: 2
  3311. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  3312. To: arizona!icon-group
  3313. Subject: Re: A better way?
  3314. Ua-Message-Id: <post.nowlin.Mon 29 Feb 1988 08:01 CST>
  3315. End-Of-Protocol: 
  3316. Content-Length: 209
  3317. Errors-To: icon-group-request
  3318.  
  3319. Whoops.  I forgot to add the backslashes to the upto cset.  Change the cset
  3320. definition line to this:
  3321.  
  3322.   cc := c2 ++ c3 ++ '\\'     # combine the brackets into one cset
  3323.  
  3324. Jerry Nowlin
  3325. (...!ihnp4!ihuxy!nowlin)
  3326.  
  3327.  
  3328. From icon-group-request  Mon Feb 29 18:25:36 1988
  3329. Received: by bocklin.arizona.edu; Mon, 29 Feb 88 18:25:39 MST
  3330. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 29 Feb 88 18:25:36 MST
  3331. From: ihnp4!ihuxy!nowlin
  3332. Message-Id: <8803010125.AA14602@megaron.arizona.edu>
  3333. Received: by megaron.arizona.edu; Mon, 29 Feb 88 18:25:34 MST
  3334. Received: by ihnp4.ATT.COM id AA15360; 29 Feb 88 08:00:41 CST (Mon)
  3335. Message-Version: 2
  3336. >To: /addr=ihuxy!nowlin, /addr=ihnp4!arizona!icon-group
  3337. Date: Mon 29 Feb 1988 08:00 CST
  3338. End-Of-Header: 
  3339. Email-Version: 2
  3340. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  3341. To: arizona!icon-group
  3342. Cc: ihuxy!nowlin
  3343. Subject: Re: A better way?
  3344. Ua-Message-Id: <post.nowlin.Mon 29 Feb 1988 07:14 CST>
  3345. End-Of-Protocol: 
  3346. Content-Length: 2392
  3347. Errors-To: icon-group-request
  3348.  
  3349. > From: Richard Goerwitz <ihnp4!arizona!goer@sophist.uchicago.edu>
  3350. > To: icon-group
  3351. > Subject: A better way?
  3352. > I was looking at a sorry procedure in a much bigger program that I am
  3353. > writing.  I kept thinking, "There's gotta be a better way."  Trouble is
  3354. > that everything else I tried was - if more elegant - less efficient.
  3355. > Here it is.  Can anyone offhand offer me some ideas as to how I might
  3356. > clean it up a bit?
  3357. > procedure Bal(c1,c2,c3,s)
  3358. >   # A bit like bal, but accounts for backslashed characters.
  3359. >   local l1, l2
  3360. >   l1 := []
  3361. >   l2 := []
  3362. >   s ? {
  3363. >     repeat {
  3364. >       &pos >= *s + 1 & fail
  3365. >       if &subject[&pos] == "\\"
  3366. >       then move(2) & next
  3367. >       else {
  3368. >         if push(l1,any(c2,move(1))) | push(l2,any(c3,move(1)))
  3369. >         then next
  3370. >         if (*l1 = *l2) & any(c1,move(1))
  3371. >         then (suspend &pos - 1) & next
  3372. >         move(1)
  3373. >         }
  3374. >       }
  3375. >     }
  3376. >   
  3377. > end
  3378. > -Richard L. Goerwitz
  3379. > goer@sophist.uchicago.edu
  3380. > !ihnp4!gargoyle!sophist!goer
  3381.  
  3382. One suggestion.  It's a good idea to send procedures you have questions
  3383. about inside the context of a main procedure and some type of example
  3384. input and output.  That way people who don't have your mindset can try
  3385. things with the procedure and have more confidence they've figured out
  3386. what's expected.
  3387.  
  3388. I see a couple of obvious things that I modified.  I'm concerned that the
  3389. upto() I added doesn't distinguish characters in c1, but the move(1) it
  3390. replaced at the end of the else doesn't check for c1 either.  Is this a bug
  3391. in the existing procedure or did I fail to grasp the meaning of the whole
  3392. thing?  Here is a modified version.  Let me know how it works.
  3393.  
  3394. procedure Bal(c1,c2,c3,s)
  3395.  
  3396.   # A bit like bal, but accounts for backslashed characters.
  3397.   local l1, l2, cc
  3398.   l1 := []
  3399.   l2 := []
  3400.   cc := c2 ++ c3             # combine the brackets into one cset
  3401.   s ? {
  3402.     while not pos(0) do {    # use the pos() built-in function
  3403.       if ="\\" then          # use string scanning instead of subscripting
  3404.         move(1)              # you don't need a next with the else
  3405.       else {
  3406.         if push(l1,any(c2,move(1))) | push(l2,any(c3,move(1)))
  3407.         then next
  3408.         if (*l1 = *l2) & any(c1,move(1))
  3409.         then (suspend &pos - 1) & next
  3410.         tab(upto(cc)) | fail # avoid a bunch of moves with an upto
  3411.         }
  3412.       }
  3413.     }
  3414.  
  3415. end
  3416.  
  3417. Jerry Nowlin
  3418. (...!ihnp4!ihuxy!nowlin)
  3419.  
  3420. From icon-group-request  Mon Feb 29 18:31:37 1988
  3421. Received: by bocklin.arizona.edu; Mon, 29 Feb 88 18:31:40 MST
  3422. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 29 Feb 88 18:31:37 MST
  3423. Date: Mon, 29 Feb 88 18:31:35 MST
  3424. From: "David Gudeman" <gudeman>
  3425. Message-Id: <8803010131.AA15206@megaron.arizona.edu>
  3426. Received: by megaron.arizona.edu; Mon, 29 Feb 88 18:31:35 MST
  3427. To: icon-group
  3428. In-Reply-To: <8802291823.AA17235@megaron.arizona.edu>
  3429. Subject:  A better way?
  3430. Errors-To: icon-group-request
  3431.  
  3432. Ken's solution doesn't skip past the next character when it finds a
  3433. backslash, and I assume that Richard wants it to.  Here is a
  3434. stripped-down version of a solution I've used before.  Note that the
  3435. escape character '\\' should really be a parameter, rather than being
  3436. built in.  Also, the csets should all have reasonable defaults.
  3437. Adding these features back into the procedure is left as an excercise
  3438. for the reader...
  3439.  
  3440. # like bal, but uses \ as an escape character.
  3441. procedure Bal(c, l_brackets, r_brackets, s)
  3442.     local chars # cset of characters with special meaning
  3443.     local count    # incremented for each left-bracket and decremented for
  3444.         #   each right-bracket
  3445.  
  3446.     chars := c ++ l_brackets ++ r_brackets ++ '\\'
  3447.     count := 0
  3448.  
  3449.     s ? while tab(upto(chars)) do {
  3450.         if any(c) & count = 0 then suspend .&pos
  3451.         else if any(l_brackets) then count +:= 1
  3452.         else if any(r_brackets) then count -:= 1
  3453.         else if match("\\") then move(1)
  3454.         move(1)
  3455.         }
  3456. end
  3457.  
  3458. From icon-group-sender  Wed Mar  2 08:55:06 1988
  3459. Received: by bocklin.arizona.edu; Wed, 2 Mar 88 08:55:11 MST
  3460. Date: 25 Feb 88 13:31:57 GMT
  3461. From: mcvax!ukc!stc!datlog!torch!paul@uunet.uu.net  (Paul Andrews)
  3462. Organization: TORCH Computers Ltd., Cambridge, United Kingdom
  3463. Subject: Re: Map of Europe
  3464. Message-Id: <62@torch.UUCP>
  3465. References: <60@torch.UUCP>
  3466. Sender: icon-group-request@arizona.edu
  3467. To: icon-group@arizona.edu
  3468. Errors-To: icon-group-errors
  3469.  
  3470. In article <60@torch.UUCP> paul@torch.UUCP (Paul Andrews) writes:
  3471. >
  3472. >Looks to me like the map of Europe posted recently was automatically generated
  3473.  
  3474.  
  3475. Looks to me like I posted this to the wrong place! Sorry.
  3476.  
  3477. - Paul
  3478.  
  3479. From icon-group-sender  Fri Mar  4 07:15:24 1988
  3480. Received: by bocklin.arizona.edu; Fri, 4 Mar 88 07:15:29 MST
  3481. Message-Id: <8803041415.AA06825@megaron.arizona.edu>
  3482. Date: Fri, 04 Mar 88 13:46:31 GMT
  3483. To: icon-group@arizona.edu
  3484. From: NETWORK%FRSAC11.BITNET@CUNYVM.CUNY.EDU
  3485. Comment: CROSSNET mail via SMTP@INTERBIT
  3486. Subject: Atari 6.5 memory problems.
  3487. Errors-To: icon-group-errors
  3488.  
  3489. About Icon 6.5 for the Atari ST:
  3490.  
  3491. The release (e) as distributed, was a little tight in heap memory
  3492. available, aborting for some programs with a message complaining
  3493. about not enough space. (e.g. #309 or #310)
  3494.  
  3495. The MCC library for the C compiler is weird about memory management.
  3496. To overcome this, at execution time, you can change the heap size by:
  3497. iconx %300000 program-name
  3498. Where %300000 is an example of the heap memory size you request.
  3499.  
  3500. By default this request is 200000, enough to run all the Icon test suite
  3501. programs, but not enough for some other.
  3502. On a 1040ST, without shell, you can try up to aroud %700000.
  3503. This MCC "feature" *cant* be used from Icont, with the -x option.
  3504. (The % arg is not passed to iconx, but used by icont, that does not
  3505. need it.)
  3506.  
  3507. A modified version (f) with a default of 260000 is released,
  3508. and sent to:
  3509.  
  3510. userczak@ualtamts (bitnet)
  3511. listserv@canada01 (the useful prog-a16 server, on bitnet)
  3512. hahn_k@dmrhrz11 (earn, europe)
  3513. ihnp4!uwmcsd1!lakesys6martin (uucp-us)
  3514. ihnp4!ihlpe!orf (uucp-us)
  3515. ukc!uk!ac!qmc!maths!gcj (uucp-europe)
  3516.  
  3517. Please do all request from your closest site.
  3518. (I am myself in France, and cant handle large amount of orders.)
  3519.  
  3520. Regards,
  3521.  
  3522. Jean-Pierre H. Dumas
  3523.  
  3524. network@frsac11 (bitnet)
  3525. network%frsac11.bitnet@mitvma.mit.edu (arpanet)
  3526. dumas@sumex-aim.stanford.edu (arpanet)
  3527.  
  3528. From icon-group-sender  Fri Mar  4 07:15:44 1988
  3529. Received: by bocklin.arizona.edu; Fri, 4 Mar 88 07:15:48 MST
  3530. Message-Id: <8803041415.AA06888@megaron.arizona.edu>
  3531. Date: Fri, 04 Mar 88 13:59:38 GMT
  3532. To: icon-group@arizona.edu
  3533. From: NETWORK%FRSAC11.BITNET@CUNYVM.CUNY.EDU
  3534. Comment: CROSSNET mail via SMTP@INTERBIT
  3535. Subject: Atari Icon 6.5 Memory problems.
  3536. Errors-To: icon-group-errors
  3537.  
  3538. About Icon 6.5 for the Atari ST:
  3539.  
  3540. The release (e) as distributed, was a little tight in heap memory
  3541. available, aborting for some programs with a message complaining
  3542. about not enough space. (e.g. #309 or #310)
  3543.  
  3544. The MCC library for the C compiler is weird about memory management.
  3545. To overcome this, at execution time, you can change the heap size by:
  3546. iconx %300000 program-name
  3547. Where %300000 is an example of the heap memory size you request.
  3548.  
  3549. By default this request is 200000, enough to run all the Icon test suite
  3550. programs, but not enough for some other.
  3551. On a 1040ST, without shell, you can try up to aroud %700000.
  3552. This MCC "feature" *cant* be used from Icont, with the -x option.
  3553. (The % arg is not passed to iconx, but used by icont, that does not
  3554. need it.)
  3555.  
  3556. A modified version (f) with a default of 260000 is released,
  3557. and sent to:
  3558.  
  3559. userczak@ualtamts (bitnet)
  3560. listserv@canada01 (the useful prog-a16 server, on bitnet)
  3561. hahn_k@dmrhrz11 (earn, europe)
  3562. ihnp4!uwmcsd1!lakesys6martin (uucp-us)
  3563. ihnp4!ihlpe!orf (uucp-us)
  3564. ukc!uk!ac!qmc!maths!gcj (uucp-europe)
  3565.  
  3566. Please do all request from your closest site.
  3567. (I am myself in France, and cant handle large amount of orders.)
  3568.  
  3569. Regards,
  3570.  
  3571. Jean-Pierre H. Dumas
  3572.  
  3573. network@frsac11 (bitnet)
  3574. network%frsac11.bitnet@mitvma.mit.edu (arpanet)
  3575. dumas@sumex-aim.stanford.edu (arpanet)
  3576.  
  3577. From icon-group-sender  Tue Mar  8 06:45:42 1988
  3578. Received: by bocklin.arizona.edu; Tue, 8 Mar 88 06:45:45 MST
  3579. Date: Tue, 8 Mar 88 13:43:41 GMT
  3580. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - TSE)
  3581. Message-Id: <8803081343.AA12237@stevie.nuksun.uucp>
  3582. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  3583. Subject: Matching a list of criteria
  3584. Errors-To: icon-group-errors
  3585.  
  3586. I'm probably not thinking straight, but I'd appreciate it if anyone
  3587. could help me.  I'm trying to write a program to scan mail and select
  3588. those message which match certain criteria.  For example, it should be
  3589. possible to issue the command
  3590.  
  3591.     mailget < mailfile From: ...sun!selling > /tmp/out
  3592.  
  3593. to extract into /tmp/out those messages which came from any UUCP address
  3594. which ends in "sun!selling".  However I now wish to extend the selection
  3595. features.
  3596.  
  3597. I started out just by allowing a single criterion (as in the example above).
  3598. The updated version builds a _list_ of criteria, and I want to modify the
  3599. selection routine [selected() in the listing below] so it only returns true
  3600. if all criteria match.
  3601.  
  3602. Anyone think of a smart way to do it?  Sorry about the length of the program
  3603. - I never did learn to stop writing comments like the "C" hackers :-)
  3604.  
  3605. Naturally, other suggestions for improvement will also be welcomed.
  3606.  
  3607. Thanks in advance
  3608.  
  3609. Steve Holden
  3610. sholden@sun.com
  3611. sholden@{sun,sunuk}.uucp
  3612. "On the whole, I'd rather be in Philadelphia"  --  W.C. Fields
  3613.  
  3614.  
  3615. #
  3616. #    mailget.icn:    Gets selected items of mail by header keyword.
  3617. #
  3618. #       %W%     %G%
  3619. #
  3620. link    mailio            # mail i/o package
  3621.  
  3622. record    criterion(key,condition)
  3623.  
  3624. procedure main(argv)
  3625.  
  3626. local    msg, c
  3627.  
  3628. c := []                # nullify criterion list
  3629. #
  3630. #    Scan argument list.  Expected arguments are in pairs:
  3631. #    the first specifies a header keyword such as "From:",
  3632. #    and should be terminated with a colon.  The second
  3633. #    specifies a matching criterion.  This is a literal
  3634. #    string which may be preceded or followed by "..." to
  3635. #    indicate that an arbitrary string may precede or follow
  3636. #    the specified literal.
  3637. #
  3638. while argv[1][-1] == ":" do {
  3639.     keyval := pop(argv)[1:-1]    # everything but the colon
  3640.     value := pop(argv) | stop(keyval,": no value argument")
  3641.     put(c,criterion(keyval,patternfor(keyval,value)))
  3642. }
  3643.  
  3644. while (msg := readmail()) do {
  3645.     if selected(msg,c)
  3646.     then writemail(msg)
  3647. }
  3648.  
  3649. end
  3650.  
  3651. procedure selected(m,c)
  3652. #
  3653. #    The message, m, is tested against the criteria, c,
  3654. #    which is a list of conditions which must all be
  3655. #    true for the mail to be written.  Each condition
  3656. #    is represented by a record.  The first field is the
  3657. #    entry value in the header table, the second field
  3658. #    is an expression which must match against the
  3659. #    corresponding header table assigned value.
  3660. #
  3661. #    Test version just tests the first criterion in the list
  3662. #
  3663. local pattern
  3664.  
  3665. pattern := ^c[1].condition
  3666. if \m.header[c[1].key] ? @pattern
  3667. then return
  3668. end
  3669.  
  3670. procedure patternfor(k,v)
  3671. #
  3672. #    Returns a value to be used in matching the given
  3673. #    header table entry against the value string v.
  3674. #
  3675. #    Test version just returns a co-expression with an
  3676. #    infinite sequence of "Match the string literally".
  3677. #
  3678. if v[1:4] == "..." then {        # if start can be anything
  3679.     v[1:4] := ""                # remove flag
  3680.     if v[-3:0] == "..." then {        # if end can be anything
  3681.         v[-3:0] := ""                # remove flag
  3682.         return create |(arbpat() || =v)        # and just match
  3683.     } else {                # if definite end required
  3684.         return create |(arbpat() || =v ||
  3685.                 endpat())        # force end of word
  3686.     }
  3687. } else {                # if definite start required
  3688.     if v[-3:0] == "..." then {        # if end can be anything
  3689.         v[-3:0] := ""                # remove flag
  3690.         return create |=v            # and just match
  3691.     } else {
  3692.         return create |(=v || endpat())    # else match whole word
  3693.     }
  3694. }
  3695. end
  3696.  
  3697. procedure arbpat()
  3698. every suspend &subject[.&pos:&pos <- &pos to *&subject]
  3699. end
  3700.  
  3701. procedure endpat()
  3702. suspend (any(' \t\n') | pos(0))
  3703. end
  3704.  
  3705. From icon-group-sender  Tue Mar  8 12:39:41 1988
  3706. Received: by bocklin.arizona.edu; Tue, 8 Mar 88 12:39:44 MST
  3707. Date: Tue, 8 Mar 88 12:39:39 MST
  3708. From: "Ralph Griswold" <ralph>
  3709. Message-Id: <8803081939.AA15583@megaron.arizona.edu>
  3710. To: icon-group
  3711. Subject: Version 7 Icon for MS-DOS
  3712. Errors-To: icon-group-errors
  3713.  
  3714. Version 7 Icon for MS-DOS (large-memory model) is now available.
  3715. It should run on any computer with MS-DOS 2.0 or higher and 512KB
  3716. of RAM.
  3717.  
  3718. Executable binaries come on two 2S/DD 5.25" diskettes.  The price is
  3719. $20, including printed documentation and shipping.  Add $5 for overseas
  3720. airmail.
  3721.  
  3722. Source code comes on two 2S/DD 5.25" diskettes also.  The price is
  3723. $25, also including printed documentation and shipping.  Add $5 for
  3724. overseas airmail ($10 for both binaries and source code).
  3725.  
  3726. Make checks payable to The University of Arizona and address requests
  3727. to
  3728.  
  3729.     The Icon Project
  3730.     Department of Computer Science
  3731.     Gould-Simpson Building
  3732.     The University of Arizona
  3733.     Tucson, AZ   85721
  3734.     USA
  3735.  
  3736. Both source and binaries also are available via FTP and our BBS as
  3737. described earlier.
  3738.  
  3739. Please address any questions to me, not icon-group.
  3740.  
  3741.  
  3742. Ralph Griswold / Dept. of Computer Science / Univ of Arizona / Tucson, AZ 85721
  3743.   +1 602 621 6609   ralph@Arizona.EDU     {allegra|noao|ihnp4}!arizona!ralph
  3744.  
  3745.  
  3746. From icon-group-sender  Tue Mar  8 17:24:39 1988
  3747. Received: by bocklin.arizona.edu; Tue, 8 Mar 88 17:24:42 MST
  3748. Date: Tue, 8 Mar 88 11:34:36 MST
  3749. From: "Kenneth Walker" <sunuk!sun!arizona.edu!kwalker@Sun.COM>
  3750. Message-Id: <8803081834.AA12810@megaron.arizona.edu>
  3751. In-Reply-To: <8803081343.AA12237@stevie.nuksun.uucp>
  3752. To: nuksun!stevie!steveh%sunuk@Sun.COM,
  3753.         sun!arizona.edu!icon-group%sunuk@Sun.COM
  3754. Subject: Re:  Matching a list of criteria
  3755. Errors-To: icon-group-errors
  3756.  
  3757. >Date: Tue, 8 Mar 88 13:43:41 GMT
  3758. >From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - TSE)
  3759. >
  3760. >   [text deleted]
  3761. >I'm trying to write a program to scan mail and select
  3762. >those message which match certain criteria.
  3763. >   [example deleted]
  3764. >I started out just by allowing a single criterion (as in the example above).
  3765. >The updated version builds a _list_ of criteria, and I want to modify the
  3766. >selection routine [selected() in the listing below] so it only returns true
  3767. >if all criteria match.
  3768. >
  3769. >Anyone think of a smart way to do it? 
  3770. >   [code for existing program deleted]
  3771.  
  3772. How about a recursive procedure to process the list:
  3773.  
  3774. procedure selected_by_all(str, lst)
  3775.    if *lst = 0 then
  3776.       return    # we got through all of the selection criteria
  3777.    else
  3778.       if selected(str, get(lst)) then
  3779.          return selected_by_all(str, lst)  # see if the rest succeed
  3780.       else
  3781.          fail
  3782. end
  3783.  
  3784. I just wrote this off the top of my head, so you should think through it
  3785. to see if it is the sort of thing you want to do (and you should check
  3786. my Icon). This type of list processing is quite common in Prolog and Lisp
  3787. (they may not be as nice as Icon, but they encourage you to think in
  3788. different ways, which is always good).
  3789.  
  3790. You could make selected() a polymorphic procedure, which incorporates
  3791. the code for both your selected and my selected_by_all(), basing the
  3792. choice of code on whether the second argument is a list or not. Keeping
  3793. them separate might be clearer, though.
  3794.  
  3795. Can someone come up with an iterative solution?
  3796.  
  3797.      Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  3798.      +1 602 621 2858  kwalker@Arizona.EDU   {allegra|noao|ihnp4}!arizona!kwalker
  3799.  
  3800. From icon-group-sender  Wed Mar  9 04:08:44 1988
  3801. Received: by bocklin.arizona.edu; Wed, 9 Mar 88 04:08:50 MST
  3802. From: ihnp4!ihuxy!nowlin
  3803. Message-Id: <8803091108.AA26850@megaron.arizona.edu>
  3804. Message-Version: 2
  3805. >To: /addr=ihnp4!arizona!icon-group
  3806. Date: Tue 08 Mar 1988 20:09 CST
  3807. End-Of-Header: 
  3808. Email-Version: 2
  3809. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  3810. To: arizona!icon-group
  3811. Subject: Re: Matching a list of criteria
  3812. Ua-Message-Id: <post.nowlin.Tue 08 Mar 1988 20:09 CST>
  3813. End-Of-Protocol: 
  3814. Content-Length: 1765
  3815. Errors-To: icon-group-errors
  3816.  
  3817. > From: "Kenneth Walker" <ihnp4!arizona!sunuk!sun!arizona.edu!kwalker@Sun.COM>
  3818. > >Date: Tue, 8 Mar 88 13:43:41 GMT
  3819. > >From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - TSE)
  3820. > >
  3821. > >   [text deleted]
  3822. > >I'm trying to write a program to scan mail and select
  3823. > >those message which match certain criteria.
  3824. > >   [example deleted]
  3825. > >I started out just by allowing a single criterion (as in the example above).
  3826. > >The updated version builds a _list_ of criteria, and I want to modify the
  3827. > >selection routine [selected() in the listing below] so it only returns true
  3828. > >if all criteria match.
  3829. > >
  3830. > >Anyone think of a smart way to do it? 
  3831. > >   [code for existing program deleted]
  3832. > How about a recursive procedure to process the list:
  3833. > procedure selected_by_all(str, lst)
  3834. >    if *lst = 0 then
  3835. >       return    # we got through all of the selection criteria
  3836. >    else
  3837. >       if selected(str, get(lst)) then
  3838. >          return selected_by_all(str, lst)  # see if the rest succeed
  3839. >       else
  3840. >          fail
  3841. > end
  3842. >
  3843. > .
  3844. > .
  3845. > .
  3846. > Can someone come up with an iterative solution?
  3847. >  Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  3848. >  +1 602 621 2858  kwalker@Arizona.EDU   {allegra|noao|ihnp4}!arizona!kwalker
  3849.  
  3850. If you go back to the original code that was posted, the iterative solution
  3851. is fairly straightforward:
  3852.  
  3853.     procedure selected(m,c)
  3854.  
  3855.         local pattern
  3856.  
  3857.         every l := !c do {
  3858.             pattern := ^l.condition
  3859.             if not (\m.header[l.key] ? @pattern)
  3860.             then fail
  3861.         }
  3862.  
  3863.         return
  3864.     end
  3865.  
  3866. This is probably faster and takes less resources than the recursive
  3867. solution.  Sorry, I know Icon programmers aren't supposed to worry about
  3868. things like that.  When you run it on a PC you soon learn though.
  3869.  
  3870. Jerry Nowlin
  3871. (...!ihnp4!ihuxy!nowlin)
  3872.  
  3873. From icon-group-sender  Wed Mar  9 11:09:15 1988
  3874. Received: by bocklin.arizona.edu; Wed, 9 Mar 88 11:09:18 MST
  3875. Date: Tue, 8 Mar 88 18:01:37 pst
  3876. From: mcnamee@iris.ucdavis.edu (Carole McNamee)
  3877. Message-Id: <8803090201.AA16699@iris>
  3878. To: icon-group@arizona.edu
  3879. Subject: ICON library routines?
  3880. Errors-To: icon-group-errors
  3881.  
  3882.  
  3883.     I'm not sure if this is where this request should be directed.  If not
  3884. perhaps you could tell me where to direct it.  
  3885.     I would like to know if there are any available icon library routines
  3886. which will do universal writes, copies and equals.  Thank you for looking
  3887. into this.
  3888.  
  3889. C. M. McNamee
  3890.  
  3891.  
  3892. From icon-group-sender  Thu Mar 10 11:06:18 1988
  3893. Received: by bocklin.arizona.edu; Thu, 10 Mar 88 11:06:21 MST
  3894. Date: Thu, 10 Mar 88 11:06:12 MST
  3895. From: "Gregg Townsend" <gmt>
  3896. Message-Id: <8803101806.AA17771@megaron.arizona.edu>
  3897. To: icon-group
  3898. Subject: tables, mappings, and unified field theory
  3899. Errors-To: icon-group-errors
  3900.  
  3901. I think we should consider a generalized many-to-many datatype.  For
  3902. discussion I'll call it a "map", ignoring collisions with current Icon
  3903. usage for the moment.
  3904.  
  3905. I like Kelvin's idea of making the lookup function be a generator.
  3906.  
  3907. A table would be a special case of a map with a one-to-one mapping.
  3908. A set would be a special case with a many-to-one mapping.
  3909.  
  3910. A map would have all the facilities that sets and tables now have,
  3911. and more.  Inversion of a map would be legal;  inversion of a table
  3912. would produce a map, possibly no longer in table (one-to-one) form.
  3913. Union of two tables would produce a map, again only possibly in table
  3914. form.
  3915.  
  3916. Obviously more work would be needed to hash out the details, and from
  3917. a practical matter the separate datatypes of sets and tables might need
  3918. to remain in Icon.
  3919.  
  3920. From icon-group-sender  Thu Mar 10 15:42:50 1988
  3921. Received: by bocklin.arizona.edu; Thu, 10 Mar 88 15:42:54 MST
  3922. Date: Thu, 10 Mar 88 14:05:19 mst
  3923. From: naucse!sbw (Steve Wampler)
  3924. Message-Id: <8803102105.AA01429@naucse>
  3925. To: arizona!icon-group
  3926. Subject: IconTest Problem Two Results
  3927. Errors-To: icon-group-errors
  3928.  
  3929.  
  3930. First, a couple of apologies, one for being so long in providing
  3931. results, and the other for the fact that the wording on the problem
  3932. did not include a key phrase that makes the problem much simpler.
  3933.  
  3934. (The problem was to write a scheduler for maximizing diversity among
  3935. partners in a doubles tennis tournament.)  The key phrase was that
  3936. the tennis group did not play unless *all* players get to play in
  3937. each round (i.e. number_of_players = 4*number_of_courts).  Omitting
  3938. this phrase means that any optimal solution must backtrack through
  3939. previously scheduled rounds.  My thanks to Gregg Townsend for pointing
  3940. this out.
  3941.  
  3942. The best non-Icon Project solution was by Paul Abrahams, and is reproduced
  3943. below.  It produces optimal scheduling for cases where the above
  3944. criteria is met, and does fairly well at the more general case.
  3945. It was also the fastest (in Icon there's a 'fastest'?) for small
  3946. numbers of players and courts.  Following Paul's solution is one
  3947. submitted anonymously from within Icon Project.  It is also optimal
  3948. for the simple case, and slightly better than Paul's at handling
  3949. the more general case, but still does not always find the optimal
  3950. solutions for the general case.  It is also slower for small input
  3951. values.
  3952.  
  3953. New users to Icon might look at the use of sets in both solutions
  3954. (which is why tennis was the chosen game).
  3955.  
  3956. ----  Winning Solution by Paul Abrahams -----
  3957. ----  (modified slightly to conform to pre-V7 versions of Icon) ----
  3958. # Program to assign players to tennis courts
  3959. # Written by Paul Abrahams     February 1988
  3960.  
  3961. # The assignment strategy backs up over courts and over players, but not over
  3962. # rounds of play.
  3963.  
  3964. global courts, players
  3965. global seen                         # list of sets, one per player
  3966.                     # seen[p] is players seen by p, including
  3967.                     # p himself
  3968.  
  3969. procedure main(args)
  3970.     local round                     # round of play
  3971.     local p
  3972.  
  3973.     courts := args[1]
  3974.     players := args[2]
  3975.     (integer(players) & 1 <= players < 1000 & integer(courts) &
  3976.     1 <= courts) | {write("Invalid input!"); stop()}
  3977.     if players < courts * 4 then
  3978.     {write("Not enough players to fill the courts!"); stop()}
  3979.     round := 0
  3980.     seen := list(players)
  3981.     every seen[p := 1 to players] := set([p])
  3982.     while print(assignment(), round +:= 1)
  3983. end
  3984.  
  3985. procedure assignment()
  3986. # "assignment" returns a list of foursomes for the courts.
  3987. # Each foursome is an ordered list of four players.
  3988. # Available players are kept in a list (not a set), so that after each
  3989. # round of play, the players who were in that round are considered after
  3990. # those who were not in that round.
  3991.     static avail                    # players available for assignment
  3992.     local assigns                   # list of court assignments
  3993.     local foursome                  # set of players on current court
  3994.     local assigned                  # set of players assigned in this round
  3995.     local a, p
  3996.     local list1                     # list of sets of four players
  3997.     initial {
  3998.     avail := []
  3999.     every put(avail, 1 to players)
  4000.     }
  4001.  
  4002.     assigns := []
  4003.     assigned := set([])
  4004.     (list1 := fill_courts(avail, courts)) | fail
  4005.     every a := !list1 do {
  4006.     put(assigns, sort(a))
  4007.     assigned ++:= a
  4008.     }
  4009.     avail := remset(avail, assigned) ||| sort(assigned)
  4010.     return assigns
  4011. end
  4012.  
  4013. procedure fill_courts(avail, n)
  4014. # Attempt to fill n courts with the players in the avail list.
  4015. # The returned value is a list of sets.  Each set consists of the four
  4016. # players on a court.
  4017.     local foursome, seen1, rest
  4018.  
  4019.     if n = 0 then
  4020.     return []
  4021.     seen1 := copy(seen)
  4022.     every foursome := get_players(avail, 4) do {
  4023.     every seen[!foursome] ++:= foursome
  4024.                     # p has seen all players in the foursome
  4025.     if rest := fill_courts(remset(avail, foursome), n - 1) then
  4026.         return push(rest, foursome)
  4027.     seen := seen1               # undo changes to "seen"
  4028.     }
  4029.     fail
  4030. end
  4031.  
  4032. procedure get_players(avail, n)
  4033. # Choose n players from the avail list who haven't previously seen each other
  4034.     local avail1                    # set of remaining available players
  4035.     local p
  4036.     if n = 0 then
  4037.     return set([])
  4038.     n -:= 1
  4039.     every p := !avail do {
  4040.     if *(avail1 := remset(avail, seen[p])) < n then
  4041.         next
  4042.     suspend get_players(avail1, n) ++ set([p])
  4043.     }
  4044.     fail
  4045. end
  4046.  
  4047. procedure remset(l, s)
  4048. # remset(l, s) removes the set s from the list l
  4049.     local e, retval
  4050.     retval := []
  4051.     every e := !l do
  4052.     if not member(s, e) then
  4053.         put(retval, e)
  4054.     return retval
  4055. end
  4056.  
  4057. procedure print(asst, r)
  4058. # Print the court assignments in up to three columns.
  4059.     local rows                      # number of rows in display
  4060.     local c, i, j
  4061.     rows := 3 >= courts | (5 >= courts, courts / 2) | (courts + 2) / 3
  4062.     write(center(" Round " || r || " ", 78, "-"))
  4063.     every i := 1 to rows do {
  4064.     every j := 0 to 2 do {
  4065.         c := i + j * rows
  4066.         if c > courts then
  4067.         break
  4068.         writes(left("Court " || c || ":", 9))
  4069.         every writes(right(!asst[c], 4))
  4070.         writes(j < 2 & "|")
  4071.         }
  4072.     write()
  4073.     }
  4074.     write()
  4075.     return
  4076. end
  4077.  
  4078. ---- Alternate Solution (anonymous) -----
  4079.  
  4080. ## Scheduling tennis players with no person re-encountering another
  4081. #
  4082. procedure main(args)
  4083.    local ncourts, nplayers
  4084.    local allplayers, previous, avail, partners
  4085.    local p1, p2, p3
  4086.  
  4087.    ncourts  := integer(args[1]) | 8
  4088.    nplayers := integer(args[2]) | 32
  4089.  
  4090.    every insert(allplayers:= set([]), 1 to nplayers)
  4091.    every put(previous := list(), set([1 to nplayers]))
  4092.  
  4093.    every write("\nRound ",seq(),":") do {
  4094.  
  4095.       avail := copy(allplayers)    # everyone's available at day start
  4096.  
  4097.       every writes("\tCourt ",1 to ncourts," has ") do {
  4098.  
  4099.          if partners := set([
  4100.               p1 := !avail,
  4101.               p2 := !(avail -- previous[p1]),
  4102.               p3 := !(avail -- (previous[p1]++previous[p2])),
  4103.               !(avail -- (previous[p1]++previous[p2]++previous[p3]))
  4104.               ])
  4105.            then {
  4106.               every writes(right(!partners,4))
  4107.               write()
  4108.               every previous[!partners] ++:= partners
  4109.               avail --:= partners
  4110.               }
  4111.            else
  4112.               stop(" no way to schedule!")
  4113.  
  4114.         }
  4115.  
  4116.       }
  4117.  
  4118. end
  4119.  
  4120. From icon-group-sender  Thu Mar 10 17:47:51 1988
  4121. Received: by bocklin.arizona.edu; Thu, 10 Mar 88 17:47:54 MST
  4122. Date: Thu, 10 Mar 88 17:47:47 MST
  4123. From: "Gregg Townsend" <gmt>
  4124. Message-Id: <8803110047.AA17998@megaron.arizona.edu>
  4125. To: icon-group
  4126. Subject: Tennis Scheduling Problem
  4127. Errors-To: icon-group-errors
  4128.  
  4129. The two contest solutions just posted do not produce optimal solutions.
  4130. For 20 players on five courts, each program quits after just one round.
  4131. Working by hand I can fill five full rounds (below), and almost a sixth
  4132. round.  (It's easily shown that six rounds is an upper bound, and I
  4133. conjecture that six full rounds are indeed possible.)
  4134.  
  4135. round 1:   1  2  3  4    5  6  7  8    9 10 11 12   13 14 15 16   17 18 19 20 
  4136.  
  4137. round 2:   1  6 11 16    5 10 15 20    9 14 19  4   13 18  3  8   17  2  7 12 
  4138.  
  4139. round 3:   4  7 10 13    8 11 14 17   12 15 18  1   16 19  2  5   20  3  6  9 
  4140.  
  4141. round 4:   2  8  9 15    6 12 13 19   10 16  3 17   14 20  1  7   18  4  5 11 
  4142.  
  4143. round 5:  13  2 11 20   17  6 15  4    1 10 19  8    5 14  3 12    9 18  7 16 
  4144.  
  4145. round 6:   1  5  9 13    2  6 10 14    3  7 11 15    4  8 12 16 
  4146.  
  4147.      Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  4148.      +1 602 621 4325       gmt@Arizona.EDU      {allegra|noao|ihnp4}!arizona!gmt
  4149.  
  4150. From icon-group-sender  Fri Mar 11 02:06:32 1988
  4151. Received: by bocklin.arizona.edu; Fri, 11 Mar 88 02:06:35 MST
  4152. Date: Thu, 10 Mar 88 23:10:04 EST
  4153. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  4154. To: icon-group@arizona.edu
  4155. Message-Id: <38347@Wayne-MTS>
  4156. Subject: The Tennis Problem reconsidered
  4157. Errors-To: icon-group-errors
  4158.  
  4159. I'm not at all surprised that neither my solution nor the other (anonymous)
  4160. one to the tennis problem doesn't do well on certain particular cases.  An
  4161. exhaustive solution must back up not only within a round but also over the
  4162. rounds themselves (so that if it fails to produce an expected number of
  4163. rounds, it rearranges earlier rounds).  Clearly the search grows beyond any
  4164. reasonable bound, even for relatively small n.
  4165.  
  4166. The other method of solution that I played with (unsuccessfully) is to try to
  4167. find some pattern to the successful solutions and generate them explicitly.  I
  4168. never found a way to do that.  Nor, apparently, did anyone else (though it
  4169. might be a little easier given the constraint that was missing).  In fact,
  4170. with that constraint there is no reason to give the number of players in the
  4171. input, since it is implied by the number of courts.
  4172.  
  4173. Paul Abrahams
  4174.  
  4175. From icon-group-sender  Fri Mar 11 06:33:51 1988
  4176. Received: by bocklin.arizona.edu; Fri, 11 Mar 88 06:33:53 MST
  4177. Date: Fri, 11 Mar 88 05:54:04 mst
  4178. From: naucse!sbw (Steve Wampler)
  4179. Message-Id: <8803111254.AA03751@naucse>
  4180. To: arizona!gmt, arizona!icon-group
  4181. Subject: Re:  Tennis Scheduling Problem
  4182. Errors-To: icon-group-errors
  4183.  
  4184. sigh.  i should have had you check them out.  i'll post a correction.
  4185.  
  4186. thanks.
  4187.  
  4188. From icon-group-sender  Fri Mar 11 12:12:42 1988
  4189. Received: by bocklin.arizona.edu; Fri, 11 Mar 88 12:12:45 MST
  4190. From: ihnp4!ihuxy!nowlin
  4191. Message-Id: <8803111912.AA03606@megaron.arizona.edu>
  4192. Message-Version: 2
  4193. >To: /addr=ihnp4!arizona!icon-group
  4194. Date: Fri 11 Mar 1988 07:05 CST
  4195. End-Of-Header: 
  4196. Email-Version: 2
  4197. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  4198. To: arizona!icon-group
  4199. Subject: Re: unified field theory
  4200. Ua-Message-Id: <post.nowlin.Fri 11 Mar 1988 06:45 CST>
  4201. End-Of-Protocol: 
  4202. Content-Length: 1482
  4203. Errors-To: icon-group-errors
  4204.  
  4205. > From: "Gregg Townsend" <ihnp4!arizona!gmt>
  4206. > I think we should consider a generalized many-to-many datatype.  For
  4207. > discussion I'll call it a "map", ignoring collisions with current Icon
  4208. > usage for the moment.
  4209. > I like Kelvin's idea of making the lookup function be a generator.
  4210. > A table would be a special case of a map with a one-to-one mapping.
  4211. > A set would be a special case with a many-to-one mapping.
  4212. > A map would have all the facilities that sets and tables now have,
  4213. > and more.  Inversion of a map would be legal;  inversion of a table
  4214. > would produce a map, possibly no longer in table (one-to-one) form.
  4215. > Union of two tables would produce a map, again only possibly in table
  4216. > form.
  4217. > Obviously more work would be needed to hash out the details, and from
  4218. > a practical matter the separate datatypes of sets and tables might need
  4219. > to remain in Icon.
  4220.  
  4221. First of all, the explanation above wasn't clear enough for me to figure
  4222. out what you really mean by "many-to-many datatype."  I hate to sound
  4223. ignorant but what would you use something like this for?  Maybe some
  4224. examples of algorithms that this new type would make easier to implement
  4225. would help to explain it.  I can't think of any functionality this type
  4226. would give me (remember I don't quite grasp what you were talking about)
  4227. that I don't already have with the data types and the incredible amount of
  4228. flexibility that already exists in Icon?  Elucidate.
  4229.  
  4230. Jerry Nowlin
  4231. (...!ihnp4!ihuxy!nowlin)
  4232.  
  4233. From icon-group-sender  Sun Mar 13 23:45:40 1988
  4234. Received: by bocklin.arizona.edu; Sun, 13 Mar 88 23:45:43 MST
  4235. Date: 5 Mar 88 16:22:17 GMT
  4236. From: lakesys!martin@csd1.milw.wisc.edu  (Martin Wiedmeyer)
  4237. Organization: Lake Systems - Milwaukee, WI
  4238. Subject: Re: Atari 6.5 memory problems.
  4239. Message-Id: <487@lakesys.UUCP>
  4240. References: <8803041415.AA06825@megaron.arizona.edu>
  4241. Sender: icon-group-request@arizona.edu
  4242. To: icon-group@arizona.edu
  4243. Errors-To: icon-group-errors
  4244.  
  4245. In article <8803041415.AA06825@megaron.arizona.edu> NETWORK@FRSAC11.BITNET writes:
  4246. >About Icon 6.5 for the Atari ST:
  4247. >
  4248. [info deleted]
  4249. >A modified version (f) with a default of 260000 is released,
  4250. >and sent to:
  4251. >
  4252. [addresses deleted]
  4253. >ihnp4!uwmcsd1!lakesys6martin (uucp-us)
  4254. There is a typo in my path, it is
  4255.  
  4256. ihnp4!uwmcsd1!lakesys!martin (uucp-us)
  4257.  
  4258. >Please do all request from your closest site.
  4259. >(I am myself in France, and cant handle large amount of orders.)
  4260.  
  4261. Thank you Jean-Pierre, for the ST implementation of Icon!
  4262.  
  4263. Marty Wiedmeyer
  4264. -- 
  4265. |    Marty Wiedmeyer                                           |
  4266. |       Lake Systems, Milwaukee, WI                                        |
  4267. |       UUCP: {ihnp4,uwvax}!uwmcsd1!lakesys!martin                         |
  4268. |    Disclaimer: I take the heat for my own (mis)statements.....        | 
  4269.  
  4270. From icon-group-sender  Wed Mar 16 22:14:06 1988
  4271. Received: by bocklin.arizona.edu; Wed, 16 Mar 88 22:14:09 MST
  4272. Date: 15 Mar 88 23:10:43 GMT
  4273. From: amsterdam!dupuy@columbia.edu  (Alexander Dupuy)
  4274. Organization: Columbia University Computer Science Dept.
  4275. Subject: Re: tables, mappings, and unified field theory
  4276. Message-Id: <5417@columbia.edu>
  4277. References: <8803101806.AA17771@megaron.arizona.edu>
  4278. Sender: icon-group-request@arizona.edu
  4279. To: icon-group@arizona.edu
  4280. Errors-To: icon-group-errors
  4281.  
  4282. For an idea of how another language used mappings, you might want to look at
  4283. SETL, a language used extensively within Courant (NYU), although it was not
  4284. widely used elsewhere.
  4285.  
  4286. In SETL, mappings were sets of two element tuples, and the lookup function
  4287. would return the set of matching second elements.  Given a mapping such as
  4288.  
  4289.     map := { [ 1, 2 ], [ 1, 3 ], [ 2, 3 ] };
  4290.  
  4291. ( '{}' are set braces, '[]' are tuple (vector) braces)
  4292.  
  4293. the expression "map[1]" would return "{ 2, 3 }" and map[2] would return "{ 3 }"
  4294. (or perhaps "3"? - SETL was a fairly typeless language, and the distinction was
  4295. minor).
  4296.  
  4297. SETL also had generators (of a different sort than Icon) which could be used to
  4298. generate sets or tuples.  For example, "x := { d | 3 .elt map[d] }" (read as
  4299. "x gets set of d such that 3 is an element of map[d]") would return all the
  4300. domain elements which mapped to 3.  It was even possible to write a one-line
  4301. bubblesort expression which would return a sorted tuple (I can't remember it
  4302. offhand; it was 7 years ago that I used SETL).
  4303.  
  4304. Mappings were used extensively in SETL - it didn't have any pointer type, so
  4305. most complex data structures ended up as mappings of one sort or another.
  4306.  
  4307. @alex
  4308.  
  4309. inet: dupuy@columbia.edu
  4310. uucp: ...!rutgers!columbia!dupuy
  4311.  
  4312. From icon-group-sender  Sun Mar 20 13:11:35 1988
  4313. Received: by bocklin.arizona.edu; Sun, 20 Mar 88 13:11:38 MST
  4314. Date: Sun, 20 Mar 88 13:11:33 MST
  4315. From: "Gregg Townsend" <gmt>
  4316. Message-Id: <8803202011.AA14369@megaron.arizona.edu>
  4317. In-Reply-To: <8803111912.AA03606@megaron.arizona.edu>
  4318. To: icon-group
  4319. Subject: Re: unified field theory
  4320. Errors-To: icon-group-errors
  4321.  
  4322.     From Jerry Nowlin (ihnp4!ihuxy!nowlin Fri Mar 11 12:12:58 1988)
  4323.  
  4324.     [re my comments about a "many-to-many" datatype]
  4325.     
  4326.     First of all, the explanation above wasn't clear enough for me to figure
  4327.     out what you really mean by "many-to-many datatype."  I hate to sound
  4328.     ignorant but what would you use something like this for?  Maybe some
  4329.     examples of algorithms that this new type would make easier to implement
  4330.     would help to explain it.  I can't think of any functionality this type
  4331.     would give me (remember I don't quite grasp what you were talking about)
  4332.     that I don't already have with the data types and the incredible amount of
  4333.     flexibility that already exists in Icon?  Elucidate.
  4334.  
  4335. I'll be the first to admit that I don't have a precise idea of what this
  4336. would be or exactly how it would be used;  it's a research idea (and not
  4337. original with me).  I'm envisioning a general datatype that would encompass
  4338. tables, sets, and more.  From the brief description posted by dupuy@columbia,
  4339. it does sound a lot like SETL mappings.
  4340.  
  4341. Let me try to construct an example.  Suppose you need a database of names
  4342. and phone numbers.  The obvious thing in Icon is a table;  index it by
  4343. name and you get back a telephone number.
  4344.  
  4345. What if somebody has two telephones?  Well, you could make every table
  4346. entry a list to handle cases like this, but my idea is that an Icon
  4347. mapping would provide this automatically, and if you said
  4348.     every write (phones["Fred"])
  4349. you'd get both of them.
  4350.  
  4351. Another thing you can't do with tables is invert them;  that is, create
  4352. a table of names indexed by phone numbers.  Mappings would be invertible.
  4353.  
  4354. Inversions would be useful anyway, but shouldn't be needed to look
  4355. something up.  Given the mapping above it should be easy to generate
  4356. the people who share a given phone number, though an obvious notation
  4357. doesn't come readily to my mind.
  4358.  
  4359. Perhaps this helps explain what I had in mind.  Let's hear some other ideas!
  4360.  
  4361.      Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  4362.      +1 602 621 4325      gmt@Arizona.EDU       110 57 16 W / 32 13 45 N / +758m
  4363.  
  4364. From icon-group-sender  Thu Mar 24 01:49:21 1988
  4365. Received: by bocklin.arizona.edu; Thu, 24 Mar 88 01:49:25 MST
  4366. To: icon-group@arizona.edu
  4367. Subject: string scanning
  4368. Reply-To: rich%sendai.UUCP@umix.cc.umich.edu
  4369. Message-Id: <8803232224.AA02958@sendai.UUCP>
  4370. Date: 23 Mar 88 22:24:07 EST (Wed)
  4371. From: rich%sendai.UUCP@umix.cc.umich.edu (K. Richard Magill)
  4372. Errors-To: icon-group-errors
  4373.  
  4374. Can someone send me a four line?  I want to read four (well, N) fields
  4375. from a line separated by spaces into variables a, b, c, d.
  4376.  
  4377. Actually, I think I understand how to do it but suspect a bug in the
  4378. 3b1 implementation.  If your working four line doesn't work here I
  4379. know to go chasing source.
  4380.  
  4381. From icon-group-sender  Thu Mar 24 07:51:55 1988
  4382. Received: by bocklin.arizona.edu; Thu, 24 Mar 88 07:51:57 MST
  4383. From: ihnp4!ihuxy!nowlin
  4384. Message-Id: <8803241451.AA06102@megaron.arizona.edu>
  4385. Message-Version: 2
  4386. >To: /addr=ihnp4!arizona!icon-group
  4387. Date: Thu 24 Mar 1988 05:34 CST
  4388. End-Of-Header: 
  4389. Email-Version: 2
  4390. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  4391. To: arizona!icon-group
  4392. Subject: Re: string scanning
  4393. Ua-Message-Id: <post.nowlin.Thu 24 Mar 1988 05:25 CST>
  4394. End-Of-Protocol: 
  4395. Content-Length: 1119
  4396. Errors-To: icon-group-errors
  4397.  
  4398. > From: ihnp4!arizona!rich%sendai.UUCP@umix.cc.umich.edu (K. Richard Magill)
  4399. > Can someone send me a four line?  I want to read four (well, N) fields
  4400. > from a line separated by spaces into variables a, b, c, d.
  4401. > Actually, I think I understand how to do it but suspect a bug in the
  4402. > 3b1 implementation.  If your working four line doesn't work here I
  4403. > know to go chasing source.
  4404.  
  4405. Try this program.  It reads from standard in and parses each line of input
  4406. into a list of words.  For the sake of illustration you can run it with
  4407. trace turned on.  This program works fine on the machines I have access to
  4408. and should work on your 3B1.
  4409.  
  4410. procedure main()
  4411.  
  4412.     while line := read() do {
  4413.         words := parse(line)
  4414.         every writes(!words," ")
  4415.         write()
  4416.     }
  4417.  
  4418. end
  4419.  
  4420. procedure parse(t)
  4421.  
  4422.     static    WS
  4423.     initial    WS := ' \t'
  4424.  
  4425.     w := []
  4426.  
  4427.     trim(t,WS) ? until pos(0) do {
  4428.         tab(many(WS))
  4429.         put(w,tab(upto(WS) | 0))
  4430.     }
  4431.  
  4432.     return w
  4433.  
  4434. end
  4435.  
  4436. If you'd used some kind of return address I could decipher I'd have replied
  4437. to you directly.  I only have access to usenet.  Sorry for having to use
  4438. the group address.
  4439.  
  4440. Jerry Nowlin
  4441. (...!ihnp4!ihuxy!nowlin)
  4442.  
  4443. From icon-group-sender  Thu Mar 24 07:51:59 1988
  4444. Received: by bocklin.arizona.edu; Thu, 24 Mar 88 07:52:02 MST
  4445. From: ihnp4!ihuxy!nowlin
  4446. Message-Id: <8803241451.AA06113@megaron.arizona.edu>
  4447. Message-Version: 2
  4448. >To: /addr=ihnp4!arizona!icon-group
  4449. Date: Thu 24 Mar 1988 05:34 CST
  4450. End-Of-Header: 
  4451. Email-Version: 2
  4452. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  4453. To: arizona!icon-group
  4454. Subject: Re: string scanning
  4455. Ua-Message-Id: <post.nowlin.Thu 24 Mar 1988 05:25 CST>
  4456. End-Of-Protocol: 
  4457. Content-Length: 1119
  4458. Errors-To: icon-group-errors
  4459.  
  4460. > From: ihnp4!arizona!rich%sendai.UUCP@umix.cc.umich.edu (K. Richard Magill)
  4461. > Can someone send me a four line?  I want to read four (well, N) fields
  4462. > from a line separated by spaces into variables a, b, c, d.
  4463. > Actually, I think I understand how to do it but suspect a bug in the
  4464. > 3b1 implementation.  If your working four line doesn't work here I
  4465. > know to go chasing source.
  4466.  
  4467. Try this program.  It reads from standard in and parses each line of input
  4468. into a list of words.  For the sake of illustration you can run it with
  4469. trace turned on.  This program works fine on the machines I have access to
  4470. and should work on your 3B1.
  4471.  
  4472. procedure main()
  4473.  
  4474.     while line := read() do {
  4475.         words := parse(line)
  4476.         every writes(!words," ")
  4477.         write()
  4478.     }
  4479.  
  4480. end
  4481.  
  4482. procedure parse(t)
  4483.  
  4484.     static    WS
  4485.     initial    WS := ' \t'
  4486.  
  4487.     w := []
  4488.  
  4489.     trim(t,WS) ? until pos(0) do {
  4490.         tab(many(WS))
  4491.         put(w,tab(upto(WS) | 0))
  4492.     }
  4493.  
  4494.     return w
  4495.  
  4496. end
  4497.  
  4498. If you'd used some kind of return address I could decipher I'd have replied
  4499. to you directly.  I only have access to usenet.  Sorry for having to use
  4500. the group address.
  4501.  
  4502. Jerry Nowlin
  4503. (...!ihnp4!ihuxy!nowlin)
  4504.  
  4505. From icon-group-sender  Thu Mar 24 09:33:59 1988
  4506. Received: by bocklin.arizona.edu; Thu, 24 Mar 88 09:34:03 MST
  4507. Date: Thu, 24 Mar 88 09:28:17 mst
  4508. From: naucse!sbw (Steve Wampler)
  4509. Message-Id: <8803241628.AA28100@naucse>
  4510. To: arizona!icon-group
  4511. Subject: Re: string scanning
  4512. Errors-To: icon-group-errors
  4513.  
  4514.  
  4515. >From: arizona!ihnp4!ihuxy!nowlin
  4516. >> From: ihnp4!arizona!rich%sendai.UUCP@umix.cc.umich.edu (K. Richard Magill)
  4517. >> 
  4518. >> Can someone send me a four line?  I want to read four (well, N) fields
  4519. >> from a line separated by spaces into variables a, b, c, d.
  4520. >> 
  4521. >> Actually, I think I understand how to do it but suspect a bug in the
  4522. >> 3b1 implementation.  If your working four line doesn't work here I
  4523. >> know to go chasing source.
  4524.  
  4525. >Try this program.  It reads from standard in and parses each line of input
  4526. >
  4527. >procedure main()
  4528. >
  4529. >    while line := read() do {
  4530. >        words := parse(line)
  4531. >        every writes(!words," ")
  4532. >        write()
  4533. >    }
  4534. >
  4535. >end
  4536. >
  4537. >procedure parse(t)
  4538. >
  4539. >    static    WS
  4540. >    initial    WS := ' \t'
  4541. >
  4542. >    w := []
  4543. >
  4544. >    trim(t,WS) ? until pos(0) do {
  4545. >        tab(many(WS))
  4546. >        put(w,tab(upto(WS) | 0))
  4547. >    }
  4548. >
  4549. >    return w
  4550. >
  4551. >end
  4552.  
  4553. Here's another approach, though it may not work under all versions
  4554. of Icon.  I suspect that it does, though (the 'dangerous' part is
  4555. the suspend/fail out a a string scanning).  I think v7 handles this
  4556. properly.
  4557.  
  4558.     .
  4559.     .
  4560.     nextfld := create genflds(line,separators)
  4561.     every a|b|c|d := @nextfld
  4562.     .
  4563.     .
  4564.     procedure genflds(s,sep)
  4565.        s ? repeat {
  4566.                   suspend tab(upto(sep)|0)\1
  4567.               move(1) | fail
  4568.                   }
  4569.         end
  4570.  
  4571. I also think the code in genflds() can be cleaned up, I did this in
  4572. a hurry.
  4573.  
  4574. From icon-group-sender  Thu Mar 24 09:55:46 1988
  4575. Received: by bocklin.arizona.edu; Thu, 24 Mar 88 09:55:49 MST
  4576. Date: Thu, 24 Mar 88 09:55:44 MST
  4577. From: "Kenneth Walker" <kwalker>
  4578. Message-Id: <8803241655.AA12476@megaron.arizona.edu>
  4579. In-Reply-To: <8803241628.AA28100@naucse>
  4580. To: icon-group
  4581. Subject: Re: string scanning
  4582. Errors-To: icon-group-errors
  4583.  
  4584. > Date: Thu, 24 Mar 88 09:28:17 mst
  4585. > From: naucse!sbw (Steve Wampler)
  4586. > Here's another approach, though it may not work under all versions
  4587. > of Icon.  I suspect that it does, though (the 'dangerous' part is
  4588. > the suspend/fail out a a string scanning).  I think v7 handles this
  4589. > properly.
  4590.  
  4591. Yes, v7 does indeed "correctly" handle suspend/fail (and return, break, and
  4592. next) out of string scanning. You can "get away with it" in earlier versions
  4593. if you don't used nested scanning, but it is considered a 'dangerous'
  4594. practice.
  4595.  
  4596. From icon-group-sender  Thu Mar 24 11:35:29 1988
  4597. Received: by bocklin.arizona.edu; Thu, 24 Mar 88 11:35:32 MST
  4598. Date: Thu, 24 Mar 88 10:48:52 mst
  4599. From: naucse!sbw (Steve Wampler)
  4600. Message-Id: <8803241748.AA28592@naucse>
  4601. To: arizona!icon-group
  4602. Subject: Re: string scanning
  4603. Errors-To: icon-group-errors
  4604.  
  4605.  
  4606. oops, on returning from class, I see that the problem assumed fields
  4607. separated by 1 or more spaces (separators).  The version of genflds()
  4608. I mailed out assumes two adjacent separators separate an empty field.
  4609.  
  4610. Change the line:
  4611.  
  4612.         move(1) | fail
  4613.  
  4614. into
  4615.  
  4616.         tab(many(sep)) | fail
  4617.  
  4618. From icon-group-sender  Thu Mar 24 13:47:01 1988
  4619. Received: by bocklin.arizona.edu; Thu, 24 Mar 88 13:47:05 MST
  4620. Date: Wed, 23 Mar 88 20:30:14 EST
  4621. From: tower@wheaties.ai.mit.edu (Leonard H. Tower Jr.)
  4622. Message-Id: <8803240130.AA01161@soleus.ai.mit.edu>
  4623. To: info-gnu-emacs-non-usenet@prep.ai.mit.edu
  4624. Cc: Icon-Group@arizona.edu,
  4625.         mailrus!umix!oxtrap!sendai!rich@tut.cis.ohio-state.edu
  4626. Subject: [rich@sendai.uucp: icon mode]
  4627. Reply-To: mailrus!umix!oxtrap!sendai!rich@tut.cis.ohio-state.edu
  4628. Errors-To: icon-group-errors
  4629.  
  4630. Path: mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!mailrus!umix!oxtrap!sendai!rich
  4631. From: rich@sendai.uucp (K. Richard Magill)
  4632. Newsgroups: comp.emacs
  4633. Subject: icon mode
  4634. Date: 22 Mar 88 11:42:59 GMT
  4635. Reply-To: rich@sendai.uucp
  4636. Organization: Digital Works Ltd, Ann Arbor
  4637. Apparently-To: emacs-netnews-distribution@prep.ai.mit.edu
  4638.  
  4639. Anyone have an icon mode like for griswold's icon? (the programming
  4640. language)?
  4641.  
  4642.  
  4643. From icon-group-sender  Thu Mar 24 20:30:06 1988
  4644. Received: by bocklin.arizona.edu; Thu, 24 Mar 88 20:30:13 MST
  4645. Return-Path: <goer@sophist.uchicago.edu>
  4646. Date: Thu, 24 Mar 88 20:51:47 CST
  4647. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  4648. Message-Id: <8803250251.AA00828@sophist.uchicago.edu>
  4649. To: icon-group@arizona.edu
  4650. Subject: coexpressions - help!
  4651. Errors-To: icon-group-errors
  4652.  
  4653.  
  4654. I can't tell why the following program works (i.e. outputs "678"):
  4655.  
  4656. procedure main()
  4657.   C := create GetVal() 
  4658.   every a|b|c := @C
  4659.   write(a,b,c)
  4660. end
  4661.  
  4662. procedure GetVal()
  4663.   every suspend "6"|"7"|"8"
  4664. end
  4665.  
  4666. Why doesn't this work like:
  4667.  
  4668. procedure main()
  4669.   every a|b|c := "6"|"7"|"8"
  4670.   write(a,b,c)
  4671. end
  4672.  
  4673. I.e. why doesn't it output "888" (seeing as each variable eventually gets
  4674. assigned the value "8")?  In the second program, it seems clear that each
  4675. resumption merely assigns successive strings to the same variable.  In
  4676. the first, resumption of @C apparently fails to produce another result.  I
  4677. would have thought that this would have reactiveated C.  Apparently, though,
  4678. the result sequence of @C has a length of one.  Correct?  How come?
  4679.  
  4680. It seems that I am missing something very important about coexpressions and
  4681. coexpression activations, and how they are treated when resumed.  If some kind
  4682. soul could straighten me out, I would be most grateful.
  4683.  
  4684.                                                   -Richard L. Goerwitz
  4685.                                                   goer@sophist.uchicago.edu
  4686.                                                   !ihnp4!gargoyle!sophist!goer
  4687.  
  4688. From icon-group-sender  Fri Mar 25 02:15:16 1988
  4689. Received: by bocklin.arizona.edu; Fri, 25 Mar 88 02:15:19 MST
  4690. Date: Thu, 24 Mar 88 23:35:42 EST
  4691. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  4692. To: icon-group@arizona.edu
  4693. Message-Id: <42248@Wayne-MTS>
  4694. Subject: Splitting a line into tokens
  4695. Errors-To: icon-group-errors
  4696.  
  4697. Here's another version of the line splitter. - Paul Abrahams
  4698.  
  4699. ********************************
  4700.  
  4701. procedure main()
  4702.      while line := read() do {
  4703.              every writes((trim(line) ? parse()), " | ")
  4704.              write()
  4705.      }
  4706. end
  4707.  
  4708. procedure parse()
  4709.     suspend tab(upto(' ')|0) \ 1 | (tab(many(' ')), parse())
  4710. end
  4711.  
  4712. From icon-group-sender  Fri Mar 25 03:21:55 1988
  4713. Received: by bocklin.arizona.edu; Fri, 25 Mar 88 03:21:58 MST
  4714. Date: Fri, 25 Mar 88 10:19:31 GMT
  4715. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - Sun UK TSE)
  4716. Message-Id: <8803251019.AA23622@stevie.nuksun.uucp>
  4717. To: sunuk!sun!sophist.uchicago.edu!goer@Sun.COM
  4718. Subject: Re:  coexpressions - help!
  4719. Cc: sunuk!sun!arizona.edu!icon-group@Sun.COM
  4720. Errors-To: icon-group-errors
  4721.  
  4722. *)I can't tell why the following program works (i.e. outputs "678"):
  4723. *)
  4724. *)procedure main()
  4725. *)  C := create GetVal() 
  4726. *)  every a|b|c := @C
  4727. *)  write(a,b,c)
  4728. *)end
  4729.  
  4730. The "every" above has only three alternates: choose a, b or c to assign to.
  4731. The co-expression generates on of its three alternates each time it is
  4732. activated.  Put more variables and you'd only get assignments to three of
  4733. them (ie "every a|b|c|d := @C" would not assign to d as the coexpression
  4734. would run out of results at that stage).
  4735.  
  4736. *)Why doesn't this work like:
  4737. *)
  4738. *)procedure main()
  4739. *)  every a|b|c := "6"|"7"|"8"
  4740. *)  write(a,b,c)
  4741. *)end
  4742.  
  4743. This "every" has nine alternations (perm every one of {a,b,c} with every
  4744. one of {"6","7","8"}).  Since the expression backtracking activated by the
  4745. every varies the last alternation most rapidly, the last assignment to
  4746. each variable is of the value "8".
  4747.  
  4748. Interesting question.
  4749.  
  4750. Steve
  4751.  
  4752. From icon-group-sender  Fri Mar 25 11:41:31 1988
  4753. Received: by bocklin.arizona.edu; Fri, 25 Mar 88 11:41:34 MST
  4754. Date: 25 Mar 88  14:09:46 gmt
  4755. From: R.J.Hare@EDINBURGH.AC.UK
  4756. To: icon-group@arizona.edu
  4757. Via:        UK.AC.RL.EARN; Fri, 25 Mar 88 14:09:15 GMT
  4758. Via:        UK.AC.ED.EMAS-C; 25 MAR 88 14:09:07 GMT
  4759. Message-Id: <25 Mar 88  14:09:46 gmt  340174@EMAS-C>
  4760. Errors-To: icon-group-errors
  4761.  
  4762. This is my first query to this board - I hope it's the right forum for this
  4763. sort of question.
  4764.      
  4765. Consider the code fragment:
  4766.      
  4767. d:=read(file)
  4768. case d of E-1 : ...
  4769.             0 : ...L
  4770.      
  4771. fairly non-controversial I think, but it doesn't work on my VAX because (as I
  4772. found out after battering my way through the Icon book) the implicit type
  4773. conversion called for here (d(string) -> d(integer)) fails unpredictably. The
  4774. solution is obvious:
  4775.      
  4776. d:=integer(read(file))
  4777. case d of E-1 : ...
  4778.             0 : ...L
  4779.      
  4780. which works fine.
  4781.      
  4782. What I want to know is *why* the implicit type conversion fails in this
  4783. instance.
  4784.      
  4785. Any suggestions gratefully received.
  4786.      
  4787. Roger Hare
  4788. (R.J.HARE@UK.AC.EDINBURGH)
  4789.  
  4790. From icon-group-sender  Fri Mar 25 12:08:58 1988
  4791. Received: by bocklin.arizona.edu; Fri, 25 Mar 88 12:09:02 MST
  4792. Return-Path: <goer@sophist.uchicago.edu>
  4793. Date: Fri, 25 Mar 88 13:04:04 CST
  4794. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  4795. Message-Id: <8803251904.AA00543@sophist.uchicago.edu>
  4796. To: R.J.Hare@EDINBURGH.AC.UK
  4797. Subject: two types of comparisons
  4798. Cc: icon-group@arizona.edu
  4799. Errors-To: icon-group-errors
  4800.  
  4801.  
  4802. In response to the type conversion query, please note that there are
  4803. two types of comparison operations in Icon:  Ones which compare values,
  4804. and ones which don't.  The ones that don't will convert their arguments
  4805. to the appropriate type before comparing.  So "10" == 10 will succeed.
  4806. So will "10" = 10, I believe.  "10" === 10 won't, however, seeing as the
  4807. operation === compares values, and does not convert its arguments to the
  4808. appropriate type.  Case expressions work like ===.  I don't know why,
  4809. myself, since I rarely have to test variables to see what type they
  4810. are.  I rarely use ===.  Although Icon does a lot of implicit type con-
  4811. versions, it's often good to use explicit type-conversion functions like
  4812. integer() and string() so that your understanding of what is going on is
  4813. obvious.
  4814.  
  4815.                                                   -Richard L. Goerwitz
  4816.                                                   goer@sophist.uchicago.edu
  4817.                                                   !ihnp4!gargoyle!sophist!goer
  4818.  
  4819. P.S. Nice to see a Humanist here.
  4820.  
  4821. From icon-group-sender  Fri Mar 25 13:15:10 1988
  4822. Received: by bocklin.arizona.edu; Fri, 25 Mar 88 13:15:15 MST
  4823. Date: Fri, 25 Mar 88 13:13:10 MST
  4824. From: "Ralph Griswold" <ralph>
  4825. Message-Id: <8803252013.AA17684@megaron.arizona.edu>
  4826. To: R.J.Hare@EDINBURGH.AC.UK
  4827. Subject: type conversion
  4828. Cc: icon-group
  4829. In-Reply-To: <25 Mar 88  14:09:46 gmt  340174@EMAS-C>
  4830. Errors-To: icon-group-errors
  4831.  
  4832. Icon only does type conversion when the operation calls for it.  There
  4833. is nothing about a case expression that says the selection should be
  4834. on any particular type, so there isn't.  Subscripting tables is
  4835. similar.
  4836.  
  4837. While you may not have gotten what you expected in your example,
  4838. the lack of type conversion actually provides more generality --
  4839. e.g. you can select on *any* type (even a list, e.g.).  Since
  4840. implicit type conversion that fails is an error, any ad hoc
  4841. decision to convert to a particular type would be restrictive.
  4842.  
  4843. Icon tries to give you the maximum amount of flexibility in
  4844. such situations.
  4845.  
  4846. From icon-group-sender  Fri Mar 25 14:18:07 1988
  4847. Received: by bocklin.arizona.edu; Fri, 25 Mar 88 14:18:10 MST
  4848. Date: Fri, 25 Mar 88 15:05:58 EST
  4849. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  4850. To: icon-group@arizona.edu
  4851. Message-Id: <42455@Wayne-MTS>
  4852. Subject: Sorting in Icon, again
  4853. Errors-To: icon-group-errors
  4854.  
  4855. A while ago there was a flurry of messages about sorting in Icon.  The gist of
  4856. them was that it would be nice if the "<" relation could be specified by the
  4857. user, thus making more general sorts possible.  The people who would have to
  4858. do the work reacted, quite understandably, with less than unbridled
  4859. enthusiasm.
  4860.  
  4861. I have a more modest proposal.
  4862.  
  4863. Currently, according to Scripture, p. 67, all records are treated as one type
  4864. during sorting, and the "<" relation for two records is left unspecified.
  4865. By defining the "<" relation on records, I think we could achieve most of what
  4866. the sorters would like, while at the same time adding no new syntax to Icon.
  4867. The effect of making such a definition would simply be to specify what is now
  4868. left unspecified.
  4869.  
  4870. Three definitions of "<" seem reasonable:
  4871.  
  4872. (1) Major sort on record type, minor sort on fields in the order in which they
  4873. appear in the record definition.
  4874.  
  4875. (2) Major sort on fields in order of appearance, minor sort on record type.
  4876.  
  4877. (3) Sort on fields (lexicographic), record types not considered.
  4878.  
  4879. For (1) and (2), there are two further possibilities: arbitrary sort on
  4880. record type, or sort by name of record type.
  4881.  
  4882. Of these possibilities the weakest (and probably easiest to implement) is
  4883. (3).  Even this definition would solve a lot of the problems that people have
  4884. had with more general sorting.  The most desirable probably would be (1),
  4885. with records sorted by record type.  I consider the sort order of record types
  4886. less important than providing lexicographic sorting on fields.
  4887.  
  4888. Would this be hard to implement?
  4889.  
  4890. Paul Abrahams
  4891.  
  4892. From icon-group-sender  Fri Mar 25 22:42:24 1988
  4893. Received: by bocklin.arizona.edu; Fri, 25 Mar 88 22:42:29 MST
  4894. Return-Path: <goer@sophist.uchicago.edu>
  4895. Date: Fri, 25 Mar 88 23:37:30 CST
  4896. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  4897. Message-Id: <8803260537.AA01330@sophist.uchicago.edu>
  4898. To: icon-group@arizona.edu
  4899. Subject: better way?
  4900. Errors-To: icon-group-errors
  4901.  
  4902.  
  4903. Here's a program that I wrote to convert every sequence of "35," "75," or
  4904. "95" to a lowercase "m" (yes, this actually was a real-world problem).  It
  4905. seemed a bit clunky to me.  If someone out there is so inclined, would he
  4906. or she please offer me some ideas as to how this might better be done:
  4907.  
  4908. procedure main()
  4909.   s2 := ""
  4910.   every s := !&input do {
  4911.     s ? {
  4912.       while s2 ||:= tab(WhichFirst(["35","75","95"]))
  4913.       do s2 ||:= "m" & move(2)
  4914.       s2 ||:= tab(0)
  4915.       }
  4916.     write(s2)
  4917.     }
  4918. end
  4919.  
  4920. procedure WhichFirst(l)
  4921.   t := (u := *&subject + 1)
  4922.   every t := t > upto(!l)
  4923.   return (u ~= t) | fail
  4924. end
  4925.  
  4926.                                                   -Richard L. Goerwitz
  4927.                                                   goer@sophist.uchicago.edu
  4928.                                                   !ihnp4!gargoyle!sophist!goer
  4929.  
  4930. From icon-group-sender  Sat Mar 26 07:09:59 1988
  4931. Received: by bocklin.arizona.edu; Sat, 26 Mar 88 07:10:03 MST
  4932. Date: 25 Mar 88 08:52:50 GMT
  4933. From: rochester!ken@bbn.com  (Ken Yap)
  4934. Organization: U of Rochester, CS Dept, Rochester, NY
  4935. Subject: sets from ranges
  4936. Message-Id: <8041@sol.ARPA>
  4937. Sender: icon-group-request@arizona.edu
  4938. To: icon-group@arizona.edu
  4939. Errors-To: icon-group-errors
  4940.  
  4941. Pardon a novice question. A colleague of mine posed a problem.  Given
  4942. the syntax x{aa-zz}, generate the sequence xaa, xab, ..., xba, ...
  4943. xzz.
  4944.  
  4945. I can handle the multiple counters by invoking a generator for each
  4946. level. But when I came to generating the sequence a, b, ..., z, I
  4947. couldn't think of anything better than this.  (This is just a test
  4948. program to try the idea.)
  4949.  
  4950. procedure main()
  4951.     st := "a"
  4952.     en := "z"
  4953.     al := &ascii
  4954.     ran := al[upto(st,al):upto(en,al)]
  4955.     every write(!ran)
  4956. end
  4957.  
  4958. This looks inelegant.
  4959.  
  4960. It would have been nice if i to j by k took non-integers. Am I missing
  4961. a really simple and obvious way?
  4962.  
  4963.     Ken
  4964.  
  4965. From icon-group-sender  Sat Mar 26 07:25:36 1988
  4966. Received: by bocklin.arizona.edu; Sat, 26 Mar 88 07:25:40 MST
  4967. Date: Sat, 26 Mar 88 07:25:34 MST
  4968. From: "Ralph Griswold" <ralph>
  4969. Message-Id: <8803261425.AA23978@megaron.arizona.edu>
  4970. To: rochester!ken@bbn.com
  4971. Subject: Re:  sets from ranges
  4972. Cc: icon-group
  4973. Errors-To: icon-group-errors
  4974.  
  4975. -----------------------------------------
  4976.    Pardon a novice question. A colleague of mine posed a problem.  Given
  4977.    the syntax x{aa-zz}, generate the sequence xaa, xab, ..., xba, ...
  4978.    xzz.
  4979.    
  4980.    I can handle the multiple counters by invoking a generator for each
  4981.    level. But when I came to generating the sequence a, b, ..., z, I
  4982.    couldn't think of anything better than this.  (This is just a test
  4983.    program to try the idea.)
  4984.    
  4985.    procedure main()
  4986.        st := "a"
  4987.        en := "z"
  4988.        al := &ascii
  4989.        ran := al[upto(st,al):upto(en,al)]
  4990.        every write(!ran)
  4991.    end
  4992.    
  4993.    This looks inelegant.
  4994.    
  4995.    It would have been nice if i to j by k took non-integers. Am I missing
  4996.    a really simple and obvious way?
  4997. -------------------------------------------------
  4998.    
  4999. Version 7 of Icon has a function ord(s) that produces the integer
  5000. corresponding to the representation of the one-character string s.
  5001.  
  5002. So you can say
  5003.  
  5004.     every write(&ascii[ord(st) + 1 to ord(en) + 1])
  5005.  
  5006. You might want to use &cset instead of &ascii for generality.
  5007.  
  5008.      Ralph Griswold / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  5009.      +1 602 621 6609   ralph@Arizona.EDU     {allegra|noao|ihnp4}!arizona!ralph
  5010.  
  5011.  
  5012. From icon-group-sender  Sat Mar 26 13:32:08 1988
  5013. Received: by bocklin.arizona.edu; Sat, 26 Mar 88 13:32:11 MST
  5014. Date: Sat, 26 Mar 88 13:32:06 MST
  5015. From: "Janalee O'Bagy" <janalee>
  5016. Message-Id: <8803262032.AA04273@megaron.arizona.edu>
  5017. In-Reply-To: <8041@sol.ARPA>
  5018. To: icon-group@arizona.edu, rochester!ken@bbn.com
  5019. Subject: Re:  sets from ranges
  5020. Errors-To: icon-group-errors
  5021.  
  5022.     From icon-group-sender Sat Mar 26 07:10:30 1988
  5023.     From: rochester!ken@bbn.com  (Ken Yap)
  5024.     
  5025.     procedure main()
  5026.         st := "a"
  5027.         en := "z"
  5028.         al := &ascii
  5029.         ran := al[upto(st,al):upto(en,al)]
  5030.         every write(!ran)
  5031.     end
  5032.  
  5033.  
  5034.  
  5035. I would also use the element generation operator '!' to
  5036. generate the strings from a to z, but this is a case where
  5037. it is easier to specify the alphabet string with a constant, 
  5038. rather than to construct it, like this:
  5039.  
  5040.         ran := "abcdefghijklmnopqrstuvwxyz"
  5041.         every write(!ran)
  5042.  
  5043. From icon-group-sender  Sat Mar 26 16:28:46 1988
  5044. Received: by bocklin.arizona.edu; Sat, 26 Mar 88 16:28:52 MST
  5045. From: ihnp4!ihuxy!nowlin
  5046. Message-Id: <8803262328.AA09626@megaron.arizona.edu>
  5047. Message-Version: 2
  5048. >To: /addr=ihnp4!arizona!icon-group
  5049. Date: Sat 26 Mar 1988 17:11 CST
  5050. End-Of-Header: 
  5051. Email-Version: 2
  5052. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  5053. To: arizona!icon-group
  5054. Subject: Re: better way
  5055. Ua-Message-Id: <post.nowlin.Sat 26 Mar 1988 17:01 CST>
  5056. End-Of-Protocol: 
  5057. Content-Length: 1040
  5058. Errors-To: icon-group-errors
  5059.  
  5060. > Here's a program that I wrote to convert every sequence of "35," "75," or
  5061. > "95" to a lowercase "m" (yes, this actually was a real-world problem).  It
  5062. > seemed a bit clunky to me.  If someone out there is so inclined, would he
  5063. > or she please offer me some ideas as to how this might better be done:
  5064.  
  5065. I think your line to initialize s2 was in the wrong place.  I moved it
  5066. inside the input loop.  The easiest way to improve this program was to use
  5067. alternation to take advantage of goal directed evaluation in the while
  5068. loop.  Then you can use a plain old find() function to find your sequences
  5069. instead of having to write your own procedure.  Try this version.  I left
  5070. your while line in as a comment but left out your WhichFirst() procedure.
  5071.  
  5072. procedure main()
  5073.   every s := !&input do {
  5074.     s2 := ""
  5075.     s ? {
  5076.       # while s2 ||:= tab(WhichFirst(["35","75","95"]))
  5077.       while s2 ||:= tab(find("35" | "75" | "95"))
  5078.       do s2 ||:= "m" & move(2)
  5079.       s2 ||:= tab(0)
  5080.       }
  5081.     write(s2)
  5082.     }
  5083. end
  5084.  
  5085. Jerry Nowlin
  5086. (...!ihnp4!ihuxy!nowlin)
  5087.  
  5088. From icon-group-sender  Sat Mar 26 20:16:41 1988
  5089. Received: by bocklin.arizona.edu; Sat, 26 Mar 88 20:16:46 MST
  5090. Date: Sat, 26 Mar 88 20:16:39 MST
  5091. From: "Kenneth Walker" <kwalker>
  5092. Message-Id: <8803270316.AA18338@megaron.arizona.edu>
  5093. To: icon-group
  5094. Subject: Re:  better way
  5095. Errors-To: icon-group-errors
  5096.  
  5097. Jerry,
  5098.  
  5099. I'm afraid your solution doesn't always find the first of the
  5100. numbers in the string. Try: 7535
  5101.  
  5102. How is this for a solution
  5103.  
  5104. procedure main()
  5105.   every s := !&input do {
  5106.     s2 := ""
  5107.     s ? {
  5108.       while s2 ||:= tab(upto('379')) do
  5109.         if =("35" | "75" | "95") then
  5110.            s2 ||:= "m"
  5111.         else
  5112.            s2 ||:= move(1)
  5113.       s2 ||:= tab(0)
  5114.       }
  5115.     write(s2)
  5116.     }
  5117. end
  5118.  
  5119. From icon-group-sender  Sat Mar 26 20:21:49 1988
  5120. Received: by bocklin.arizona.edu; Sat, 26 Mar 88 20:21:52 MST
  5121. From: ihnp4!ihlpe!orf
  5122. Message-Id: <8803270321.AA18718@megaron.arizona.edu>
  5123. Message-Version: 2
  5124. >To: /addr=ihnp4!arizona!icon-group
  5125. Date: Sat 26 Mar 1988 20:37 CST
  5126. End-Of-Header: 
  5127. Email-Version: 2
  5128. X-Postmark: ihlpe!orf
  5129. To: arizona!icon-group
  5130. Subject: Re: Better Way?
  5131. Ua-Message-Id: <post.orf.Sat 26 Mar 1988 20:36 CST>
  5132. End-Of-Protocol: 
  5133. Content-Length: 1087
  5134. Errors-To: icon-group-errors
  5135.  
  5136.  >Here's a program that I wrote to convert every sequence of "35," "75," or
  5137.  >"95" to a lowercase "m" (yes, this actually was a real-world problem).  It
  5138.  >seemed a bit clunky to me.  If someone out there is so inclined, would he
  5139.  >or she please offer me some ideas as to how this might better be done:
  5140.  >
  5141. Richard,
  5142.  
  5143. Here is one way.  It is a "SNOBOL-like" solution in that it simply changes
  5144. the line over and over until there are no more changes to make.  If nothing
  5145. else, it is simple..
  5146.  
  5147.  
  5148. procedure main()
  5149.     every s := !&input do 
  5150.     {
  5151.      while  s ?:= 1(tab(find("35"|"75"|"95",s)) , move(2)) || "m" || tab(0)
  5152.      write(s)
  5153.      }
  5154. end
  5155.  
  5156. As an aside, here is another version with the strings you are looking for
  5157. in a list called pat -- if there are no command line arguments it uses
  5158. your default strings. If there are, it will use the argv list instead:
  5159.        
  5160. procedure main(argv)
  5161.     pat := if *argv = 0 then ["35",75","95"] else argv
  5162.     every s := !&input do 
  5163.     {
  5164.      while  s ?:= 1(tab(find(!pat,s)) , move(2)) || "m" || tab(0)
  5165.      write(s)
  5166.      }
  5167. end
  5168.  
  5169.        
  5170.  
  5171. Rick Fonorow
  5172. ihnp4!ihlpe!orf
  5173.  
  5174. From icon-group-sender  Sat Mar 26 21:34:55 1988
  5175. Received: by bocklin.arizona.edu; Sat, 26 Mar 88 21:34:58 MST
  5176. Date: Sat, 26 Mar 88 21:34:51 MST
  5177. From: "Kenneth Walker" <kwalker>
  5178. Message-Id: <8803270434.AA20893@megaron.arizona.edu>
  5179. To: "Re: -s from icon-group ranges", sets
  5180. Errors-To: icon-group-errors
  5181.  
  5182. Instead of computing the string for the subrange by
  5183.  
  5184.      al := &ascii
  5185.      ran := al[upto(st,al):upto(en,al)]
  5186.  
  5187. You can use string scanning
  5188.  
  5189.     &ascii ? {
  5190.        tab(find(st))
  5191.        ran := tab(find(en) + 1)
  5192.        }
  5193.  
  5194. I am not sure if it is more elegant, but it is probably a little easier
  5195. to read. If you are interested in efficiency, you will note that your
  5196. solution converts al from a cset to a string in three places. It also
  5197. converts st and en from strings to csets. Actually the most efficient
  5198. solution is probably a modification of Ralph's V7 solution (I haven't
  5199. run timing tests, so I won't vouch for the relative speeds - it is
  5200. easy to guess wrong when trying to decide the fastest way to do something
  5201. in Icon). It uses ord's dual function, char.
  5202.  
  5203.     every write(char(ord(st) to ord(en)))
  5204.  
  5205. Of course, for many Icon programs minor differences in efficiency
  5206. are not important.
  5207.  
  5208. From icon-group-sender  Sun Mar 27 10:11:28 1988
  5209. Received: by bocklin.arizona.edu; Sun, 27 Mar 88 10:11:31 MST
  5210. Date: Sun, 27 Mar 88 10:11:26 MST
  5211. From: "Kenneth Walker" <kwalker>
  5212. Message-Id: <8803271711.AA15329@megaron.arizona.edu>
  5213. In-Reply-To: <42455@Wayne-MTS>
  5214. To: icon-group
  5215. Subject: Re:  Sorting in Icon, again
  5216. Errors-To: icon-group-errors
  5217.  
  5218. > Date: Fri, 25 Mar 88 15:05:58 EST
  5219. > From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5220.  
  5221. ...
  5222.  
  5223. > Three definitions of "<" seem reasonable:
  5224. >  
  5225. > (1) Major sort on record type, minor sort on fields in the order in which they
  5226. > appear in the record definition.
  5227. >  
  5228. > (2) Major sort on fields in order of appearance, minor sort on record type.
  5229. >  
  5230. > (3) Sort on fields (lexicographic), record types not considered.
  5231. >  
  5232. > For (1) and (2), there are two further possibilities: arbitrary sort on
  5233. > record type, or sort by name of record type.
  5234.  
  5235. ...
  5236.  
  5237. > Would this be hard to implement?
  5238.  
  5239. It does not look hard to do with a recursive comparison routine.
  5240. However, some questions arise. Suppose, for simplicity, that we
  5241. have only integers and records with 1 field. The following routine
  5242. will compare these values (using (3)).
  5243.  
  5244. procedure compare(x, y)
  5245.    if integer(x) then
  5246.       if integer(y) then {
  5247.          if      x < y then return "less"
  5248.          else if x = y then return  "equal"
  5249.                        else return  "greater"
  5250.          }
  5251.       else
  5252.          return "less"       # integers are less than records
  5253.    else   # x is a record
  5254.       if integer(y) then
  5255.          return "greater"    # records are greater than integers
  5256.       else
  5257.     return compare(x[1], y[1])
  5258. end
  5259.  
  5260. Now try running the program:
  5261.  
  5262. record r(a)
  5263.  
  5264. procedure main()
  5265.    local x, y
  5266.  
  5267.    x := r()
  5268.    x.a := x
  5269.    y := r()
  5270.    y.a := y
  5271.    write(compare(x, y))
  5272. end
  5273.  
  5274. Is this reasonable behavior?
  5275.  
  5276. From icon-group-sender  Mon Mar 28 12:13:08 1988
  5277. Received: by bocklin.arizona.edu; Mon, 28 Mar 88 12:13:12 MST
  5278. From: ihnp4!ihuxy!nowlin
  5279. Message-Id: <8803281913.AA14043@megaron.arizona.edu>
  5280. Message-Version: 2
  5281. >To: /addr=ihnp4!arizona!icon-group
  5282. Date: Mon 28 Mar 1988 09:28 CST
  5283. End-Of-Header: 
  5284. Email-Version: 2
  5285. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  5286. To: arizona!icon-group
  5287. Subject: Re: better way (again)
  5288. Ua-Message-Id: <post.nowlin.Mon 28 Mar 1988 09:13 CST>
  5289. End-Of-Protocol: 
  5290. Content-Length: 1054
  5291. Errors-To: icon-group-errors
  5292.  
  5293. It's so hard to leave this alone.  I screwed up with my first attempt by
  5294. not testing thoroughly.  Rick's solution comes closest to being general but
  5295. it still assumes that the list of patterns is always two characters long.
  5296. Here's a solution that works for arbitrary length patterns (that can be
  5297. listed in a different order than they appear in the text...argh!).
  5298.  
  5299. procedure main(args)
  5300.   if *args = 0 then args := ["35","75","95"]
  5301.   every s := !&input do {
  5302.     while s ?:= 1(tab(find(p := !args)) , =p) || "m" || tab(0)
  5303.     write(s)
  5304.   }
  5305. end
  5306.  
  5307. The originator of this problem also asked for a solution that would only
  5308. get the first occurrence of any of the patterns on a given line.  This will
  5309. do it.
  5310.  
  5311. procedure main(args)
  5312.   if *args = 0 then args := ["35","75","95"]
  5313.   every s := !&input do {
  5314.     s1 := s
  5315.     c1 := *s
  5316.     p1 := &null
  5317.     while s ?:= 1(tab(c := find(p := !args)) , =p) || "m" || tab(0) do
  5318.       if c < c1 then c1 := c & p1 := p
  5319.     s1 ?:= 1(tab(find(\p1)) , =p1) || "m" || tab(0)
  5320.     write(s1)
  5321.   }
  5322. end
  5323.  
  5324. Jerry Nowlin
  5325. (...!ihnp4!ihuxy!nowlin)
  5326.  
  5327. From icon-group-sender  Mon Mar 28 13:42:46 1988
  5328. Received: by bocklin.arizona.edu; Mon, 28 Mar 88 13:42:50 MST
  5329. Date: Mon, 28 Mar 88 12:15:02 EST
  5330. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5331. To: icon-group@arizona.edu
  5332. Message-Id: <42915@Wayne-MTS>
  5333. Subject: Sorting records in Icon
  5334. Errors-To: icon-group-errors
  5335.  
  5336. Apparently there was some misunderstanding of my comment about sorting, based
  5337. on the (unsigned) reply that I received.  The problem I was addressing was not
  5338. how to do record sorting in Icon as it stands, but how to change Icon itself
  5339. (by defining a case that is presently undefined) in order to make record
  5340. sorting useful.
  5341.  
  5342. Paul Abrahams
  5343.  
  5344. From icon-group-sender  Mon Mar 28 14:35:45 1988
  5345. Received: by bocklin.arizona.edu; Mon, 28 Mar 88 14:35:49 MST
  5346. Date: Mon, 28 Mar 88 14:35:42 MST
  5347. From: "Kenneth Walker" <kwalker>
  5348. Message-Id: <8803282135.AA22435@megaron.arizona.edu>
  5349. In-Reply-To: <42915@Wayne-MTS>
  5350. To: icon-group
  5351. Subject: Re:  Sorting records in Icon
  5352. Errors-To: icon-group-errors
  5353.  
  5354. > Date: Mon, 28 Mar 88 12:15:02 EST
  5355. > From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5356. > Apparently there was some misunderstanding of my comment about sorting, based
  5357. > on the (unsigned) reply that I received.  The problem I was addressing was not
  5358. > how to do record sorting in Icon as it stands, but how to change Icon itself
  5359. > (by defining a case that is presently undefined) in order to make record
  5360. > sorting useful.
  5361.  
  5362. I was addressing the question of how to define such a sort and was using
  5363. Icon as a convenient language in which to express the comparison algorithm.
  5364. I'm sorry I didn't make that clear - I just automatically prototype
  5365. in Icon. The actual implementation would be done in C as part of the
  5366. Icon run-time system and needs to be more general then the prototype
  5367. I presented. In either Icon or C the question still remains of how much
  5368. work is needed in dealing with the possiblitly of loops created using
  5369. record references.
  5370.  
  5371. By the way, in Version 7 record sorting has been defined to be
  5372. chronological. That is they are sorted into the order in which they
  5373. were created. However, I don't see that has much effect on the
  5374. discussion.
  5375.  
  5376.   Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  5377.   +1 602 621 2858  kwalker@Arizona.EDU   {allegra|noao|ihnp4}!arizona!kwalker
  5378.  
  5379. (I remembered to include a signaure this time :-)
  5380.  
  5381.  
  5382. From icon-group-sender  Tue Mar 29 12:04:16 1988
  5383. Received: by bocklin.arizona.edu; Tue, 29 Mar 88 12:04:19 MST
  5384. Return-Path: <goer@sophist.uchicago.edu>
  5385. Date: Tue, 29 Mar 88 12:55:41 CST
  5386. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  5387. Message-Id: <8803291855.AA03851@sophist.uchicago.edu>
  5388. To: icon-group@arizona.edu
  5389. Subject: Which is first?
  5390. Errors-To: icon-group-errors
  5391.  
  5392. >procedure main()
  5393. >  s2 := ""
  5394. >  every s := !&input do {
  5395. >    s ? {
  5396. >      while s2 ||:= tab(WhichFirst(["35","75","95"]))
  5397. >      do s2 ||:= "m" & move(2)
  5398. >      s2 ||:= tab(0)
  5399. >      }
  5400. >    write(s2)
  5401. >    }
  5402. >end
  5403. >
  5404. >procedure WhichFirst(l)
  5405. >  t := (u := *&subject + 1)
  5406. >  every t := t > upto(!l)
  5407. >  return (u ~= t) | fail
  5408. >end
  5409.  
  5410. With all due respect, I think I like WhichFirst(l) best so far, since it
  5411. could be used to find "35" or "75" or "95," whichever comes first, as well
  5412. as find every one on the line (hence its name).
  5413.  
  5414. Expression of joy:  Isn't it great how Icon lets one say "every t := t >
  5415. upto(!l)"?!  The elegance of this language is amazing except in how it
  5416. shows my inelegance as a programmer....
  5417.  
  5418.                                                            Richard Goerwitz
  5419.                                                   goer@sophist.uchicago.edu
  5420.                                             ...!ihnp4!gargoyle!sophist!goer
  5421.  
  5422. From icon-group-sender  Tue Mar 29 21:41:01 1988
  5423. Received: by bocklin.arizona.edu; Tue, 29 Mar 88 21:41:07 MST
  5424. From: ihnp4!ihuxy!nowlin
  5425. Message-Id: <8803300440.AA17071@megaron.arizona.edu>
  5426. Message-Version: 2
  5427. >To: /addr=ihnp4!arizona!icon-group
  5428. Date: Tue 29 Mar 1988 14:40 CST
  5429. End-Of-Header: 
  5430. Email-Version: 2
  5431. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  5432. To: arizona!icon-group
  5433. Subject: Why Co-expressions?
  5434. Ua-Message-Id: <post.nowlin.Tue 29 Mar 1988 14:38 CST>
  5435. End-Of-Protocol: 
  5436. Content-Length: 959
  5437. Errors-To: icon-group-errors
  5438.  
  5439. I've noticed there are two major classes of solutions to the problems
  5440. posted here; those that use co-expressions and those that don't.  I favor
  5441. solutions that avoid co-expressions and some others seem to favor solutions
  5442. that make use of them.  I guess I've led a relatively sheltered Icon life. 
  5443. Until I recently got V7 on my MS-DOS machine, I haven't had ready access to
  5444. co-expressions. I've learned to get by without them in the past so I don't
  5445. automatically think of them when programming in Icon.
  5446.  
  5447. Some examples that have gone by in this group appear to use co-expressions
  5448. to simply generate the results of an already generative procedure.  I can
  5449. understand the use of co-expressions for parallel and "floating"
  5450. generation.  Other than that I wonder why you would use them?  This is a
  5451. legitimate question.  I want to understand how co-expression will make my
  5452. programming easier now that I have more access to them.
  5453.  
  5454. Jerry Nowlin
  5455. (...!ihnp4!ihuxy!nowlin)
  5456.  
  5457. From icon-group-sender  Wed Mar 30 02:55:10 1988
  5458. Received: by bocklin.arizona.edu; Wed, 30 Mar 88 02:55:18 MST
  5459. Date: 28 Mar 88 22:55:58 GMT
  5460. From: ihnp4!ihlpf!nevin1@ucbvax.Berkeley.EDU  (00704a-Liber)
  5461. Organization: AT&T Bell Laboratories - Naperville, Illinois
  5462. Subject: Re: sets from ranges
  5463. Message-Id: <4171@ihlpf.ATT.COM>
  5464. References: <8041@sol.ARPA>
  5465. Sender: icon-group-request@arizona.edu
  5466. To: icon-group@arizona.edu
  5467. Errors-To: icon-group-errors
  5468.  
  5469. In article <8041@sol.ARPA> ken@cs.rochester.edu (Ken Yap) writes:
  5470. .Pardon a novice question. A colleague of mine posed a problem.  Given
  5471. .the syntax x{aa-zz}, generate the sequence xaa, xab, ..., xba, ...
  5472. .xzz.
  5473.  
  5474. From icon-group-sender  Wed Mar 30 04:53:03 1988
  5475. Received: by bocklin.arizona.edu; Wed, 30 Mar 88 04:53:07 MST
  5476. Return-Path: <goer@sophist.uchicago.edu>
  5477. Date: Wed, 30 Mar 88 05:19:29 CST
  5478. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  5479. Message-Id: <8803301119.AA04972@sophist.uchicago.edu>
  5480. To: icon-group@arizona.edu
  5481. Subject: Why coexpressions?
  5482. Errors-To: icon-group-errors
  5483.  
  5484. Jerry Nowlin, in a recent posting, stated that he wanted to understand coex-
  5485. pressions better.  Me, too.
  5486.  
  5487. I've used them to pop off results from a sequence one at a time in various
  5488. places.  However, because v6 didn't let me do coroutine programming, I have
  5489. never really become accustomed to using coexpressions this way.  I don't
  5490. have a feel for it.
  5491.  
  5492. Could someone maybe offer some short, practical examples?
  5493.  
  5494.                                                   -Richard L. Goerwitz
  5495.                                                   goer@sophist.uchicago.edu
  5496.                                                   !ihnp4!gargoyle!sophist!goer
  5497.  
  5498. From icon-group-sender  Thu Mar 31 06:48:37 1988
  5499. Received: by bocklin.arizona.edu; Thu, 31 Mar 88 06:48:40 MST
  5500. Date: Thu, 31 Mar 88 06:48:35 MST
  5501. From: "Ralph Griswold" <ralph>
  5502. Message-Id: <8803311348.AA10888@megaron.arizona.edu>
  5503. To: icon-group
  5504. Subject: co-expressions
  5505. Errors-To: icon-group-errors
  5506.  
  5507. The following mail is from Steve Wampler a NAU. It was intended for
  5508. icon-group, but wound up elsewhere by accident.  I am just sending it
  5509. along.
  5510. ===================================================================
  5511. Jerry Nowlin recently asked about the uses of co-expressions.  I
  5512. thought I might throw my $0.02 in on this.
  5513.  
  5514.    Goal-directed evaluation is a very generalized, very powerful
  5515.    control regime.  However, as with most such beasts, sometimes
  5516.    it needs 'taming' (you can see why I didn't contribute to
  5517.    recent discussions in the Icon newsletter on terminology!) -
  5518.    that is, often the effects of GDE are not quite what is needed.
  5519.  
  5520.    Several examples:
  5521.  
  5522.     (1) The natural LIFO order to resuming generators isn't
  5523.         at all natural for all problems.  The question on
  5524.         assigning successive results from a result sequence
  5525.         to separate scalar variables that was recently posed
  5526.         to this group is such a case.  Even though there
  5527.         are clear and succinct expressions for generating both
  5528.         the variables:
  5529.                  (a | b | c | d)
  5530.             and the values (say the following, for discussion):
  5531.                  (1 to 4)
  5532.             The normal operation of GDE prevents their combination
  5533.             in the 'natural':
  5534.                  every (a|b|c|d) := (1 to 4)
  5535.  
  5536.         (2) The coupling of a generator (which produces results)
  5537.         to its lexical point of invocation similarly
  5538.             restricts the effective use of generators.  A (very)
  5539.             rough analogy can be made with the concept of an Algol
  5540.         (or C) block - it can be conceptualized as a procedure
  5541.         whose invocation is fixed to the point of definition -
  5542.             a useful tool, but severely restricted in its generality.
  5543.         Generators provide a extremely nice way to describe a
  5544.         result sequence.  Fixing access to the results in that
  5545.         sequence to a single lexical sight forces some
  5546.             uses of generators to be obscured.  For example, one
  5547.             often sees results from a generator being placed into
  5548.             a list - just so the results can be accessed at other
  5549.             places in the program.
  5550.     
  5551.    Co-expressions solve both these problems (and others) by allowing
  5552.    programmers to manage result sequences as data objects in the
  5553.    language - the generator becomes (as it really is) simply a
  5554.    representation of the result sequence.  The co-expression activation
  5555.    allows the programmer control over the production of the results
  5556.    in that sequence.
  5557.  
  5558.    By controling the generator (1 to 4) in the first
  5559.    example, one can use the 'natural' generators above to perform the
  5560.    task:
  5561.  
  5562.     next_result := create (1 to 4)
  5563.         every (a|b|c|d) := @next_result
  5564.  
  5565.    (for the symmetry fanatics, does the following work?
  5566.  
  5567.     next_variable := create (a|b|c|d)
  5568.         next_result   := create (1 to 4)
  5569.         while @next_variable := @next_result
  5570.  
  5571.     Why not?)
  5572.  
  5573.    In general, anytime you find yourself either unable to use a generative
  5574.    expression when a natural one exists, or saving the results from a
  5575.    generative expression into a list - you probably should think
  5576.    'co-expression'.
  5577.  
  5578.    I could go on here, and talk about designing your own control regimes
  5579.    by using co-expressions, but this is way too long already.
  5580.  
  5581. Richard Goerwitz asked for 'short, practical' examples of co-expressions
  5582. used as coroutines.  I wish I could help - but I think 'short, practical
  5583. coroutines' just might be an oxymoron.  Most small examples of coroutines
  5584. are contrived examples that usually can be just as clearly coded in
  5585. some other fashion - this is similar to using factorial to illustrate
  5586. recursive code.  I have a simple prime number seive that uses coroutines.
  5587. I think it appeared in an early newsletter.  You might compare that to
  5588. the considerably more efficient seive that uses Icon sets which appeared
  5589. in a later newsletter.  If you want to see it, I'll be happy to mail it
  5590. to you (the coroutine version, alas) - if I can find it again.  I also
  5591. had (note the past tense) a partial solution to my second Icon programming
  5592. contest problem that used co-expressions as coroutines for managing
  5593. the rounds - but the complexity of the parallelism involved exceeded the
  5594. complexity of my brain paths.
  5595.  
  5596. From icon-group-sender  Thu Mar 31 12:27:00 1988
  5597. Received: by bocklin.arizona.edu; Thu, 31 Mar 88 12:27:07 MST
  5598. Date: Thu, 31 Mar 88 12:54:38 EST
  5599. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5600. To: icon-group@arizona.edu
  5601. Message-Id: <44149@Wayne-MTS>
  5602. Subject: Co-expressions: their uses and non-uses
  5603. Errors-To: icon-group-errors
  5604.  
  5605. I have found co-expressions used in one direction, not as coroutines, to be
  5606. extraordinarily useful -- indeed essential -- in a lot of the work I've been
  5607. doing in Icon.  A typical pattern is:
  5608.  
  5609. gen := create "generator"
  5610. while (v := @gen) { "do something complicated with v" }
  5611.  
  5612. If the code that works on v isn't compact enough to fit into an expression,
  5613. ordinary goal-directed evaluation does not suffice.
  5614.  
  5615. However, I have yet to find any uses for the more general form of
  5616. co-expressions, in which values are passed in both directions.  In fact, most
  5617. of the classic applications of coroutines really use them as generalized
  5618. pipes.  Steve (Wampler), have you ever encountered any situations, even in
  5619. complicated programs, where co-expressions that receive values as well as
  5620. transmit them are useful in the sense of significantly simplifying the
  5621. program?  From your description of the prime sieve with coroutines, I gather
  5622. that coroutines don't produce a more satisfying program.
  5623.  
  5624. Paul Abrahams
  5625.  
  5626. From icon-group-sender  Thu Mar 31 14:16:49 1988
  5627. Received: by bocklin.arizona.edu; Thu, 31 Mar 88 14:16:52 MST
  5628. Date: Thu, 31 Mar 88 14:16:47 MST
  5629. From: "Kenneth Walker" <kwalker>
  5630. Message-Id: <8803312116.AA06405@megaron.arizona.edu>
  5631. In-Reply-To: <44149@Wayne-MTS>
  5632. To: icon-group
  5633. Subject: Re:  Co-expressions: their uses and non-uses
  5634. Errors-To: icon-group-errors
  5635.  
  5636. > From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5637. > To: icon-group@arizona.edu
  5638. > I have found co-expressions used in one direction, not as coroutines, to be
  5639. > extraordinarily useful -- indeed essential -- in a lot of the work I've been
  5640. > doing in Icon.  A typical pattern is:
  5641. >  
  5642. > gen := create "generator"
  5643. > while (v := @gen) { "do something complicated with v" }
  5644. >  
  5645. > If the code that works on v isn't compact enough to fit into an expression,
  5646. > ordinary goal-directed evaluation does not suffice.
  5647.  
  5648. It is not clear from this why you cannot do something like
  5649.  
  5650.   every v := ``generator'' do {
  5651.      ``something complicated with v''
  5652.      }
  5653.  
  5654. could you elaborate?
  5655.  
  5656. From icon-group-sender  Thu Mar 31 15:35:15 1988
  5657. Received: by bocklin.arizona.edu; Thu, 31 Mar 88 15:35:24 MST
  5658. Date: Thu, 31 Mar 88 14:41:48 mst
  5659. From: naucse!sbw (Steve Wampler)
  5660. Message-Id: <8803312141.AA03146@naucse>
  5661. To: arizona!icon-group
  5662. Subject: Re:  Co-expressions: their uses and non-uses
  5663. Errors-To: icon-group-errors
  5664.  
  5665. > From: arizona!Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5666. > However, I have yet to find any uses for the more general form of
  5667. > co-expressions, in which values are passed in both directions.  In fact, most
  5668. > of the classic applications of coroutines really use them as generalized
  5669. > pipes.  Steve (Wampler), have you ever encountered any situations, even in
  5670. > complicated programs, where co-expressions that receive values as well as
  5671. > transmit them are useful in the sense of significantly simplifying the
  5672. > program?  From your description of the prime sieve with coroutines, I gather
  5673. > that coroutines don't produce a more satisfying program.
  5674.  
  5675. My own (very naive) opinion is that coroutines are to recursion as
  5676. recursion is to interation.  At the 'simple' end of recursion, you
  5677. are no clearer than iteration, at the 'simple' end of coroutining[sic],
  5678. you are no clearer than recursion.  However, at the complex end of
  5679. recursion, you are a lot clearer than iteration.  I suspect that
  5680. at the complex end of coroutines, you are a lot clearer than recursion.
  5681. However, my own work (undergraduate teaching) doesn't get into that realm.
  5682.  
  5683. As to the prime sieve, I personally think the coroutine version is very
  5684. clear, but so is a similar recursive version.  The set version (which
  5685. I'm recalling from memory) takes some getting used to, but distills the
  5686. problem down to pretty basic components.
  5687.  
  5688. One problem in using past versions of co-expressions as pipes is
  5689. the fact that the initial call ignores the value in the 'pipe'.
  5690. I don't know if v7 Icon handles that differently.  Thus the seive
  5691. program passes values down the pipe via global variable.
  5692.  
  5693. Before we get too far off, let me state that the more 'conventional'
  5694. uses of co-expressions are very nice - they work simply and can
  5695. often produce much clearer code.
  5696.  
  5697. For the record, here is my co-expression version of the prime-number
  5698. seive (posted semi-reluctantly - people should really look at the
  5699. set version).
  5700.  
  5701. ----
  5702. ## prime number sieve (using co-expressions)
  5703. #    builds an increasingly long 'cascade' of coroutines acting
  5704. #    as filters between the source of numbers and the sink for primes.
  5705.  
  5706. global num, cascade, source, nextfilter
  5707.  
  5708. procedure main()
  5709.  
  5710.    source := create {                   # start the cascade on possible primes
  5711.                 every num := seq(2) do
  5712.                    @@(nextfilter := create !cascade)
  5713.                 }
  5714.    cascade := []
  5715.    put(cascade, create sink())         # the first number (2) is assumed to
  5716.                                         #   be a prime.
  5717.    @source
  5718.  
  5719. end
  5720.  
  5721. procedure sink()                        # have a prime, display it and
  5722. local prime                             #   add a new filter to the cascade
  5723.  
  5724.    repeat {
  5725.       write(prime := num)
  5726.       put(cascade, create filter(prime))    # this keeps us looking at
  5727.       cascade[-2] :=: cascade[-1]        #   small divisors first.
  5728.       @source
  5729.       }
  5730.  
  5731. end
  5732.  
  5733. procedure filter(prime)                 # test to see if num is a multiple
  5734.                                         #   of prime
  5735.    repeat {
  5736.      if num % prime = 0 then @source
  5737.      else @@nextfilter
  5738.      }
  5739.  
  5740. end
  5741.  
  5742. From icon-group-sender  Mon Apr  4 17:24:43 1988
  5743. Received: by bocklin.arizona.edu; Mon, 4 Apr 88 17:24:45 MST
  5744. Return-Path: <goer@sophist.uchicago.edu>
  5745. Date: Mon, 4 Apr 88 19:19:36 CDT
  5746. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  5747. Message-Id: <8804050019.AA03836@sophist.uchicago.edu>
  5748. To: icon-group@arizona.edu
  5749. Subject: Icon prgms. in other languages
  5750. Errors-To: icon-group-errors
  5751.  
  5752.  
  5753. Occasionally I'm faced, for one reason or another, with the task of re-coding
  5754. Icon programs in another language.  Usually I try to use C, but it's often
  5755. very time-consuming and messy compared to the original Icon.  Perhaps this is
  5756. due in part because I don't feel really comfortable programming in C.  More
  5757. than this, though, it seems to be due to the drastically different geniuses
  5758. of the languages.  I wonder:  Would there be a better choice of languages to
  5759. use when faced with the need for re-coding?  Prolog?  Lisp?  Others?  Of
  5760. course, my first choice for what I am doing (natural language processing of
  5761. various sorts) is Icon, and I like to use it if at all possible.  Sometimes,
  5762. however, the people I'm working with don't know it, or don't have it instal-
  5763. led, or for some other reason can't work with Icon.  It's cases like this
  5764. I'm concerned about.  Does anyone have any ideas as to what might serve as
  5765. a good middle-ground?
  5766.  
  5767.                                                   -Richard L. Goerwitz
  5768.                                                   goer@sophist.uchicago.edu
  5769.                                                   !ihnp4!gargoyle!sophist!goer
  5770.  
  5771. From icon-group-sender  Tue Apr  5 12:21:04 1988
  5772. Received: by bocklin.arizona.edu; Tue, 5 Apr 88 12:21:07 MST
  5773. Date: Tue,  5 Apr 88 14:19:33 CDT
  5774. From: D.S.Cargo MN67-2D13 593-2822 <DSCARGO@CIM-VAX.HONEYWELL.COM>
  5775. Subject: Possible bug in getch() in MS-DOS version 7
  5776. To: icon-group@arizona.edu
  5777. X-Vms-Mail-To: EXOS%"icon-group@megaron.arizona.edu"
  5778. Message-Id: <880405141933.0000052A081@CIM-VAX.HONEYWELL.COM>
  5779. Errors-To: icon-group-errors
  5780.  
  5781. ## yesno -- a program to allow manual filtering of lines through a pipe
  5782. # Try testing with "iconx yesno <yesno.icn >junk" to observe behavior.
  5783. # Use a ^C when it finally gets around to getting terminal input.
  5784. # I sure hope somebody can tell me whats going on here.
  5785. # It looks like a bug to me.  If it isn't, then the applicable documents
  5786. # need to be updated.  Code that has been commented out are fossils of
  5787. # attempts to find alternate implementations that would work as intended.
  5788. # David S. Cargo -- DSCARGO@CIM-VAX.HONEYWELL.COM
  5789.  
  5790. procedure main (a)
  5791.   local answer, conin, conout, line
  5792. # conin := open ("CON", "r")
  5793.   conout := open ("CON","w")
  5794.   filein := &input
  5795. # filein := open (a[1], "r") | stop ("Couldn't open input file.")
  5796.  
  5797.   write (conout, "In response to the query, y or Y will cause the line to")
  5798.   write (conout, "be copied to standard output, n or N will cause the line")
  5799.   write (conout, "not to be copied, and q will cause the no more lines to")
  5800.   write (conout, "be copied.")
  5801.  
  5802.   while line := read (filein) do
  5803.     {
  5804.     write (conout, line)
  5805.     write (conout, "copy?")
  5806. #   while answer := read (conin) do
  5807. #   while answer := getche () do
  5808.     while answer := getch () do
  5809.       {
  5810.       if answer == "" then answer := " "
  5811.       case answer of
  5812.         {
  5813.         "y" | "Y" | "c" | "C" :
  5814.           {
  5815.           write (line)
  5816.           break
  5817.           }
  5818.  
  5819.         "n" | "N" : break
  5820.  
  5821.         "q" | "Q" : break break
  5822.  
  5823.         " " | char (10) | char (13) : next
  5824.  
  5825.         default :
  5826.           {
  5827.           writes (conout, answer, " (char code ", ord (answer))
  5828.           write (conout, ") is not understood.  Use Y, y, N, or n.")
  5829.           write (conout, line)
  5830.           write (conout, "copy?")
  5831.           }
  5832.         }
  5833.       }
  5834.     }
  5835.   return
  5836. end
  5837.  
  5838. From icon-group-sender  Tue Apr  5 15:26:08 1988
  5839. Received: by bocklin.arizona.edu; Tue, 5 Apr 88 15:26:11 MST
  5840. Return-Path: <goer@sophist.uchicago.edu>
  5841. Date: Tue, 5 Apr 88 17:20:59 CDT
  5842. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  5843. Message-Id: <8804052220.AA05921@sophist.uchicago.edu>
  5844. To: icon-group@arizona.edu
  5845. Subject: Bad idea?  Good idea?
  5846. Errors-To: icon-group-errors
  5847.  
  5848.  
  5849. When doing text and language processing of various sorts, especially when
  5850. doing parsing based on pattern-matching procedures, I run into a situation
  5851. where I want to have disjoint if-then constructions.
  5852.  
  5853. An example:  Suppose I want to find the sequences (each beginning a word) -
  5854.  
  5855.             LIK:T.OB
  5856.             B.IK:TOB
  5857.             K.IK:TOB
  5858.             W:BIK:TOB
  5859.             W:KIK:TOB
  5860.             etc.
  5861.  
  5862. (the main consideration here is that if W: starts the word, then "." may not
  5863. follow B and K and L), I would create a procedure that said something like:
  5864.  
  5865.             while arb() & tab(many(' ')) &
  5866.                   hit := (="W:" | "") || tab(any('LKB')) ||
  5867.                          ="K:T" || .....
  5868.             do suspend hit
  5869.  
  5870. The trouble here is that what I really want to do is tie the occurrence of
  5871. W: at the beginning of the word into the presence of "." 
  5872.  
  5873. Right now, I am generally stuck admitting strings I don't want, or else
  5874. writing out many, many pattern-matchers that cover much of the same
  5875. ground.  This example is only a small one.  If I could just be granted 
  5876. a shorthand notation for tying what one expression produces to the suc-
  5877. cess or failure of another one, much of my language processing could
  5878. be simplified.  Such devices are used quite often by linguists, especially
  5879. when talking about phonological rules.  It's part of the power of formal
  5880. grammar and its appropriate notation.  It allows much to be stated in a
  5881. very small space.  Elegance.
  5882.  
  5883. Right now we have / and \ in Icon.  These check for the value &null, and
  5884. either suceed or fail, depending on which one is used, and whether &null
  5885. is found.  What I would want is something like this, but yet which checked
  5886. for any result I specified.  Unlike / and \, however, it would set a marker
  5887. to the value "succeed" or "fail."  This marker could then be tied to
  5888. any other expression at that &level, and it would be evaluated only if the
  5889. marker had the value "succeed."  Otherwise, it would simply be ignored.
  5890. To do all this, we can use, say // or \\.  On the left is the desired
  5891. result, on the left is the expression proper:
  5892.  
  5893.       while arb() & tab(many(' ')) &
  5894.             hit := "W."\\(="W:"|"") || tab(any('LKB')) ||
  5895.                    \\(="." ||) etc.
  5896.  
  5897. "W:"//(="W:"|"") means that if (="W:"|"") produces "W:", then some
  5898. invisible marker gets set to "succeed".  The next expression preceded
  5899. by // then is evaluated.  If (="W."|"") does not produce "W:", then
  5900. the next expression preceded by // would be ignored.  \\ would work the
  5901. opposite way (if "W:" was produced, then the next expression preceded
  5902. by \\ would not be evaluated).
  5903.  
  5904. Is this totally absurd?  Is this a bad idea?  Should I go home and stuff
  5905. my head under my pillow for sticking my neck out and embarrassing myself?
  5906.  
  5907. Uncertain of myself....
  5908.  
  5909.                                                   -Richard L. Goerwitz
  5910.                                                   goer@sophist.uchicago.edu
  5911.                                                   !ihnp4!gargoyle!sophist!goer
  5912.  
  5913. From icon-group-sender  Wed Apr  6 12:01:38 1988
  5914. Received: by bocklin.arizona.edu; Wed, 6 Apr 88 12:01:41 MST
  5915. Date: Wed,  6 Apr 88 14:00:08 CDT
  5916. From: D.S.Cargo MN67-2D13 593-2822 <DSCARGO@CIM-VAX.HONEYWELL.COM>
  5917. Subject: Particulars on Icon 7 for MS-DOS where bug believed found
  5918. To: icon-group@arizona.edu
  5919. X-Vms-Mail-To: EXOS%"icon-group@megaron.arizona.edu"
  5920. Message-Id: <880406140008.00000367081@CIM-VAX.HONEYWELL.COM>
  5921. Errors-To: icon-group-errors
  5922.  
  5923. Running the following program produced the output included below it.
  5924. I trust this is sufficient to identify the Icon version used with my
  5925. yesno.icn program sent earlier.
  5926.  
  5927. procedure main()
  5928.   write (&version)
  5929.   write (&host)
  5930.   every write (&features)
  5931. end
  5932.  
  5933. Icon Version 7.0.  January 16, 1988.
  5934. MS-DOS (FR + MS-DOS functions) ex Microsoft C Version 4.0
  5935. MS-DOS
  5936. MS-DOS extensions
  5937. co-expressions
  5938. overflow checking
  5939. environment variables
  5940. error traceback
  5941. string invocation
  5942. fixed regions
  5943.  
  5944. From icon-group-sender  Wed Apr  6 18:33:26 1988
  5945. Received: by bocklin.arizona.edu; Wed, 6 Apr 88 18:33:30 MST
  5946. Date: Wed, 6 Apr 88 16:59:28 mst
  5947. From: naucse!sbw (Steve Wampler)
  5948. Message-Id: <8804062359.AA07625@naucse>
  5949. To: arizona!icon-group
  5950. Subject: another example of co-expressions
  5951. Errors-To: icon-group-errors
  5952.  
  5953.  
  5954. Recent postings prompt me to provide the following illustration of
  5955. a simple use of co-expressions to "capture" a result-sequence.
  5956.  
  5957. I regularly want to scan the command line arguments looking for
  5958. various options.  Often some options flag the next argument has
  5959. providing some specific value.  The '!' operator is a very
  5960. elegant means of generating the command line arguments, but
  5961. isn't directly applicable to this problem (because of the feature
  5962. in the second sentence of this paragraph).  An example of the
  5963. co-expression use in this problem follows:
  5964.  
  5965.     procedure main(args)
  5966.             ...
  5967.         nextarg := create !args
  5968.             while arg := @nextarg do
  5969.                case arg of {
  5970.                   "-r" : &random := integer(@nextarg)
  5971.                   "-n" : {
  5972.                          name := @nextarg
  5973.                          new_grade := @nextarg
  5974.                           }
  5975.                   default: put(flist,arg)
  5976.                    }
  5977.         ...
  5978.  
  5979. Note that
  5980.  
  5981.     every arg := !args do ...
  5982.  
  5983. will not work in this situation.  The other alternatives of
  5984. (i) subscripting through the list ala 'C', 'Pascal', etc.
  5985. and (ii) using pop(args) to pull items out of the list are
  5986. (i) ugly, requiring an extra variable, extra work, etc. and
  5987. (ii) destructive to the argument list, rendering it useless
  5988. for later access.
  5989.  
  5990. From icon-group-sender  Thu Apr  7 08:44:01 1988
  5991. Received: by bocklin.arizona.edu; Thu, 7 Apr 88 08:44:04 MST
  5992. From: ihnp4!ihuxy!nowlin
  5993. Message-Id: <8804071543.AA01091@megaron.arizona.edu>
  5994. Message-Version: 2
  5995. >To: /addr=ihnp4!arizona!icon-group
  5996. Date: Thu 07 Apr 1988 08:25 CDT
  5997. End-Of-Header: 
  5998. Email-Version: 2
  5999. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  6000. To: arizona!icon-group
  6001. Subject: Re: another example of co-expressions
  6002. Ua-Message-Id: <post.nowlin.Thu 07 Apr 1988 08:18 CDT>
  6003. End-Of-Protocol: 
  6004. Content-Length: 1420
  6005. Errors-To: icon-group-errors
  6006.  
  6007. This is the best example of using co-expressions to a allow a generator to
  6008. be invoked from different expressions that I've seen.  Very illustrative.
  6009.  
  6010. > Recent postings prompt me to provide the following illustration of
  6011. > a simple use of co-expressions to "capture" a result-sequence.
  6012. >     procedure main(args)
  6013. >             ...
  6014. >         nextarg := create !args
  6015. >             while arg := @nextarg do
  6016. >                case arg of {
  6017. >                   "-r" : &random := integer(@nextarg)
  6018. >                   "-n" : {
  6019. >                          name := @nextarg
  6020. >                          new_grade := @nextarg
  6021. >                           }
  6022. >                   default: put(flist,arg)
  6023. >                    }
  6024. >         ...
  6025. > Note that
  6026. >     every arg := !args do ...
  6027. > will not work in this situation.
  6028.  
  6029. Joe Hall had an application that's a good example of parallel generation
  6030. using co-expressions.  He wanted to print the values in the new generator
  6031. keyword &collections (V7) with labels in front.  This example program
  6032. contains a procedure to do that using co-expressions.
  6033.  
  6034. procedure main()
  6035.     write(gc_cnt())
  6036.     collect()
  6037.     write(gc_cnt())
  6038. end
  6039.  
  6040. procedure gc_cnt()
  6041.     static    gc_text
  6042.     initial    gc_text := [ "total ", "static", "string", "block " ]
  6043.  
  6044.     label := create !gc_text
  6045.     value := create &collections
  6046.  
  6047.     write("\nGarbage Collections:")
  6048.     while write(@label,right(integer(@value),8))
  6049. end
  6050.  
  6051. Jerry Nowlin
  6052. (...!ihnp4!ihuxy!nowlin)
  6053.  
  6054. From icon-group-sender  Thu Apr  7 09:40:38 1988
  6055. Received: by bocklin.arizona.edu; Thu, 7 Apr 88 09:40:41 MST
  6056. Date: Thu, 7 Apr 88 09:40:36 MST
  6057. From: "Kenneth Walker" <kwalker>
  6058. Message-Id: <8804071640.AA04410@megaron.arizona.edu>
  6059. In-Reply-To: <8804052220.AA05921@sophist.uchicago.edu>
  6060. To: icon-group
  6061. Subject: Re:  Bad idea?  Good idea?
  6062. Errors-To: icon-group-errors
  6063.  
  6064. > Date: Tue, 5 Apr 88 17:20:59 CDT
  6065. > From: Richard Goerwitz <goer@sophist.uchicago.edu>
  6066. > [justification for proposal deleted] 
  6067. > Right now we have / and \ in Icon.  These check for the value &null, and
  6068. > either suceed or fail, depending on which one is used, and whether &null
  6069. > is found.  What I would want is something like this, but yet which checked
  6070. > for any result I specified.  Unlike / and \, however, it would set a marker
  6071. > to the value "succeed" or "fail."  This marker could then be tied to
  6072. > any other expression at that &level, and it would be evaluated only if the
  6073. > marker had the value "succeed."  Otherwise, it would simply be ignored.
  6074. > To do all this, we can use, say // or \\.  On the left is the desired
  6075. > result, on the left is the expression proper:
  6076. >       while arb() & tab(many(' ')) &
  6077. >             hit := "W."\\(="W:"|"") || tab(any('LKB')) ||
  6078. >                    \\(="." ||) etc.
  6079. > "W:"//(="W:"|"") means that if (="W:"|"") produces "W:", then some
  6080. > invisible marker gets set to "succeed".  The next expression preceded
  6081. > by // then is evaluated.  If (="W."|"") does not produce "W:", then
  6082. > the next expression preceded by // would be ignored.  \\ would work the
  6083. > opposite way (if "W:" was produced, then the next expression preceded
  6084. > by \\ would not be evaluated).
  6085.  
  6086. Is the following a reasonable characterization of the proposal?
  6087.  
  6088.    expr1 // expr2 
  6089.  
  6090. is equivalent to 
  6091.  
  6092.    {
  6093.    invisable_marker := &null
  6094.    2(t1 := expr1,
  6095.      t2 := expr1,
  6096.      if t1 === t2 then
  6097.         invisable_marker := 0  # an arbitrary non-null value
  6098.      else
  6099.         0                      # something other than failure
  6100.     )
  6101.    }
  6102.  
  6103. and
  6104.  
  6105.    //expr
  6106.  
  6107. is equivalent to
  6108.  
  6109.    if \invisable_marker then expr
  6110.  
  6111. I have two reactions to this proposal. One is that it is somewhat
  6112. specialized: you are setting a flag (marker) based on an implicit
  6113. comparison. It seems to me that it would be more general to simply
  6114. set it based on the success or failure of an explicit expression.
  6115. Judging from your example, you want to produce the value of the
  6116. expression even when the comparison fails, but I think your needs
  6117. are rather specialized in this respect.
  6118.  
  6119. My second reaction is that it is somewhat limited in that you can
  6120. only have one flag active per procedure call. I occasionally want
  6121. several "boolean" flags at one time.
  6122.  
  6123. At present the best way to handle flags seems to be to have variables
  6124. with null/non-null values an to use the unary operators / and \ to
  6125. test them. It would be more elagant to have real true/false values
  6126. with some operator which would succeed/fail based on those values.
  6127. Perhaps some control structure like the following would be useful
  6128.  
  6129.    variable <some-operator> expr
  6130.  
  6131. which has the following effect
  6132.  
  6133.   if temp := expr then {
  6134.       variable := &true
  6135.       temp
  6136.       }
  6137.    else
  6138.       variable := &false
  6139.       &fail
  6140.        }
  6141.  
  6142. except that the expression for variable would be evaluated before
  6143. expr.
  6144.  
  6145. Such a feature is probably not quite useful enough to justify the
  6146. additonal burden on the language.
  6147.  
  6148. From icon-group-sender  Fri Apr  8 09:30:52 1988
  6149. Received: by bocklin.arizona.edu; Fri, 8 Apr 88 09:30:55 MST
  6150. Date: Fri, 8 Apr 88 09:30:49 MST
  6151. From: "Gregg Townsend" <gmt>
  6152. Message-Id: <8804081630.AA04527@megaron.arizona.edu>
  6153. In-Reply-To: <46251@Wayne-MTS>
  6154. To: icon-group
  6155. Subject: Re: another example of co-expressions
  6156. Errors-To: icon-group-errors
  6157.  
  6158. [Really From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu]
  6159.  
  6160. So far I've seen three examples of why coexpressions are useful (including
  6161. my own).  But all three of them use one-way transmission only.  Does anyone
  6162. have an example of two-way transmission being used in as natural a way?
  6163.  
  6164. Paul Abrahams
  6165.  
  6166. From icon-group-sender  Mon Apr 11 18:16:56 1988
  6167. Received: by bocklin.arizona.edu; Mon, 11 Apr 88 18:17:00 MST
  6168. Date: Thu, 7 Apr 88 09:40:36 MST
  6169. From: "Kenneth Walker" <arizona.edu!kwalker%cogsci.Berkeley.EDU@ucbvax.Berkeley.EDU>
  6170. Message-Id: <8804071640.AA04410@megaron.arizona.edu>
  6171. In-Reply-To: <8804052220.AA05921@sophist.uchicago.edu>
  6172. To: icon-group@arizona.edu
  6173. Subject: Re:  Bad idea?  Good idea?
  6174. Errors-To: arizona.edu!icon-group-errors%cogsci.Berkeley.EDU@ucbvax.Berkeley.EDU
  6175. Errors-To: icon-group-errors
  6176.  
  6177. > Date: Tue, 5 Apr 88 17:20:59 CDT
  6178. > From: Richard Goerwitz <goer@sophist.uchicago.edu>
  6179. > [justification for proposal deleted] 
  6180. > Right now we have / and \ in Icon.  These check for the value &null, and
  6181. > either suceed or fail, depending on which one is used, and whether &null
  6182. > is found.  What I would want is something like this, but yet which checked
  6183. > for any result I specified.  Unlike / and \, however, it would set a marker
  6184. > to the value "succeed" or "fail."  This marker could then be tied to
  6185. > any other expression at that &level, and it would be evaluated only if the
  6186. > marker had the value "succeed."  Otherwise, it would simply be ignored.
  6187. > To do all this, we can use, say // or \\.  On the left is the desired
  6188. > result, on the left is the expression proper:
  6189. >       while arb() & tab(many(' ')) &
  6190. >             hit := "W."\\(="W:"|"") || tab(any('LKB')) ||
  6191. >                    \\(="." ||) etc.
  6192. > "W:"//(="W:"|"") means that if (="W:"|"") produces "W:", then some
  6193. > invisible marker gets set to "succeed".  The next expression preceded
  6194. > by // then is evaluated.  If (="W."|"") does not produce "W:", then
  6195. > the next expression preceded by // would be ignored.  \\ would work the
  6196. > opposite way (if "W:" was produced, then the next expression preceded
  6197. > by \\ would not be evaluated).
  6198.  
  6199. Is the following a reasonable characterization of the proposal?
  6200.  
  6201.    expr1 // expr2 
  6202.  
  6203. is equivalent to 
  6204.  
  6205.    {
  6206.    invisable_marker := &null
  6207.    2(t1 := expr1,
  6208.      t2 := expr1,
  6209.      if t1 === t2 then
  6210.         invisable_marker := 0  # an arbitrary non-null value
  6211.      else
  6212.         0                      # something other than failure
  6213.     )
  6214.    }
  6215.  
  6216. and
  6217.  
  6218.    //expr
  6219.  
  6220. is equivalent to
  6221.  
  6222.    if \invisable_marker then expr
  6223.  
  6224. I have two reactions to this proposal. One is that it is somewhat
  6225. specialized: you are setting a flag (marker) based on an implicit
  6226. comparison. It seems to me that it would be more general to simply
  6227. set it based on the success or failure of an explicit expression.
  6228. Judging from your example, you want to produce the value of the
  6229. expression even when the comparison fails, but I think your needs
  6230. are rather specialized in this respect.
  6231.  
  6232. My second reaction is that it is somewhat limited in that you can
  6233. only have one flag active per procedure call. I occasionally want
  6234. several "boolean" flags at one time.
  6235.  
  6236. At present the best way to handle flags seems to be to have variables
  6237. with null/non-null values an to use the unary operators / and \ to
  6238. test them. It would be more elagant to have real true/false values
  6239. with some operator which would succeed/fail based on those values.
  6240. Perhaps some control structure like the following would be useful
  6241.  
  6242.    variable <some-operator> expr
  6243.  
  6244. which has the following effect
  6245.  
  6246.   if temp := expr then {
  6247.       variable := &true
  6248.       temp
  6249.       }
  6250.    else
  6251.       variable := &false
  6252.       &fail
  6253.        }
  6254.  
  6255. except that the expression for variable would be evaluated before
  6256. expr.
  6257.  
  6258. Such a feature is probably not quite useful enough to justify the
  6259. additonal burden on the language.
  6260.  
  6261. From icon-group-sender  Mon Apr 11 20:10:49 1988
  6262. Received: by bocklin.arizona.edu; Mon, 11 Apr 88 20:10:52 MST
  6263. Date: Fri, 8 Apr 88 09:30:49 MST
  6264. From: "Gregg Townsend" <arizona.edu!gmt%cogsci.Berkeley.EDU@ucbvax.Berkeley.EDU>
  6265. Message-Id: <8804081630.AA04527@megaron.arizona.edu>
  6266. In-Reply-To: <46251@Wayne-MTS>
  6267. To: icon-group@arizona.edu
  6268. Subject: Re: another example of co-expressions
  6269. Errors-To: arizona.edu!icon-group-errors%cogsci.Berkeley.EDU@ucbvax.Berkeley.EDU
  6270. Errors-To: icon-group-errors
  6271.  
  6272. [Really From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu]
  6273.  
  6274. So far I've seen three examples of why coexpressions are useful (including
  6275. my own).  But all three of them use one-way transmission only.  Does anyone
  6276. have an example of two-way transmission being used in as natural a way?
  6277.  
  6278. Paul Abrahams
  6279.  
  6280. From icon-group-sender  Mon Apr 11 21:58:07 1988
  6281. Received: by bocklin.arizona.edu; Mon, 11 Apr 88 21:58:11 MST
  6282. Date: Mon, 11 Apr 88 21:58:05 MST
  6283. From: "David Gudeman" <gudeman>
  6284. Message-Id: <8804120458.AA13859@megaron.arizona.edu>
  6285. To: icon-group
  6286. In-Reply-To: <8804071640.AA04410@megaron.arizona.edu>
  6287. Subject:  Bad idea?  Good idea?
  6288. Errors-To: icon-group-errors
  6289.  
  6290.    Date: Thu, 7 Apr 88 09:40:36 MST
  6291.    From: "Kenneth Walker" <kwalker@arizona.edu>
  6292.    ...
  6293.    At present the best way to handle flags seems to be to have variables
  6294.    with null/non-null values an to use the unary operators / and \ to
  6295.    test them. It would be more elagant to have real true/false values
  6296.    with some operator which would succeed/fail based on those values.
  6297.    ...
  6298.  
  6299. I don't agree that true/false values are in any way elegant.  In fact
  6300. I've always thought they were awkward and artificial, and one of my
  6301. favorite things about Icon is the way it gets rid of booleans.  In
  6302. languages with boolean values the expression part of the language is
  6303. functional (meaning that everything returns a value).  Relations are
  6304. not functional, so when relations are needed, they are crammed into
  6305. functions that return booleans.  Ick.
  6306.  
  6307. Take Pascal as an example.  There are two different kinds of contexts
  6308. in Pascal (ignoring declarations).  One is the context in which
  6309. statements may appear such as after a "begin" or a "then".  The other
  6310. context is for expressions, such as after a ":=" or inside another
  6311. expression.  Look at a Pascal syntax to see what I mean.  Now a
  6312. statement is something that has an affect on the state of the
  6313. computer, such as changing a variable, or changing the flow of
  6314. control.  An expression is something that produces a value, and
  6315. generally has no other affect (that is, expressions are not supposed
  6316. to change variables or the flow of control).  Relations such as
  6317. "equals" and "parent of" don't really fit either category.  They
  6318. aren't supposed to affect the state of the computer, and they aren't
  6319. supposed to return a value, they are supposed to be true or false (not
  6320. _return_ true or false).
  6321.  
  6322. Wirth chose to force relations into expressions rather than creating a
  6323. new sort of context.  Well, if two contexts are good, why aren't three
  6324. better?  Or if it is good to combine contexts, then why not combine
  6325. statements and expressions as Icon does?  By the way, this should not
  6326. be taken of a criticism of Pascal only, _most_ procedural languages do
  6327. this, including Algol and C.
  6328.  
  6329. Sorry if I ran on, this is one of my favorite nits to pick on.
  6330.  
  6331.                     David Gudeman
  6332.  
  6333.                         Department of Computer Science
  6334. gudeman@arizona.edu                Gould-Simpson Science Building
  6335. {allegra,cmcl2,ihnp4,noao}!arizona!gudeman  The University of Arizona
  6336. 602-621-2858                    Tucson, AZ 85721
  6337.  
  6338. From icon-group-sender  Thu Apr 14 11:48:51 1988
  6339. Received: by bocklin.arizona.edu; Thu, 14 Apr 88 11:48:54 MST
  6340. Date: Thu, 14 Apr 88 13:43:11 CDT
  6341. From: David S. Cargo MN67-2F08 593-2822 <DSCARGO@CIM-VAX.HONEYWELL.COM>
  6342. Subject: environment variables
  6343. To: icon-group@arizona.edu
  6344. X-Vms-Mail-To: EXOS%"icon-group@megaron.arizona.edu"
  6345. Message-Id: <880414134311.00000330071@CIM-VAX.HONEYWELL.COM>
  6346. Errors-To: icon-group-errors
  6347.  
  6348. The new version of MS-DOS Icon can examine individual environment variables.
  6349. Is it reasonable to add the capability to see ALL the environment variables
  6350. (probably as a list of list, or perhaps as a table)?  The C runtimes for
  6351. MS-DOS also allow a peek at the command line (typically as argument 0).
  6352. I could see some utility with that too.
  6353.  
  6354. Anybody else have an opinion?
  6355.  
  6356. David S. Cargo (DSCARGO@CIM-VAX.HONEYWELL.COM)
  6357.  
  6358. From icon-group-sender  Sun Apr 17 12:44:24 1988
  6359. Received: by bocklin.arizona.edu; Sun, 17 Apr 88 12:44:26 MST
  6360. Return-Path: <goer@sophist.uchicago.edu>
  6361. Date: Sun, 17 Apr 88 14:12:57 CDT
  6362. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  6363. Message-Id: <8804171912.AA05765@sophist.uchicago.edu>
  6364. To: icon-group@arizona.edu
  6365. Subject: suspending
  6366. Errors-To: icon-group-errors
  6367.  
  6368. Can someone with more experience than I explain why these two are not equival-
  6369. ent:
  6370.  
  6371.             while suspend str || @E
  6372.  
  6373.             while str2 := @E
  6374.             do suspend str1 || str2
  6375.  
  6376. where E is a coexpression that returns a string.  What I'm finding is that
  6377. @E gets successfully produces two results in the second case (in my program,
  6378. it's supposed to produce two results), while the first fails when resumed for
  6379. the second time.
  6380.  
  6381. If you want, I can give more context; I think, though, that I must be over-
  6382. looking something fairly simple.
  6383.  
  6384.                                                   -Richard L. Goerwitz
  6385.                                                   goer@sophist.uchicago.edu
  6386.                                                   !ihnp4!gargoyle!sophist!goer
  6387.  
  6388. From icon-group-sender  Sun Apr 17 16:52:26 1988
  6389. Received: by bocklin.arizona.edu; Sun, 17 Apr 88 16:52:29 MST
  6390. Date: 17 Apr 88 03:43:25 GMT
  6391. From: corre@csd4.milw.wisc.edu  (Alan D Corre)
  6392. Organization: University of Wisconsin-Milwaukee
  6393. Subject: Re: Bad idea?  Good idea?
  6394. Message-Id: <5574@uwmcsd1.UUCP>
  6395. References: <8804071640.AA04410@megaron.arizona.edu>, <8804120458.AA13859@megaron.arizona.edu>
  6396. Sender: icon-group-request@arizona.edu
  6397. To: icon-group@arizona.edu
  6398. Errors-To: icon-group-errors
  6399.  
  6400.  
  6401. It seems to me that the main problem with booleans in Icon is that
  6402. there isn't a neat way to flip them. If ZAZO is a boolean, then in Pascal
  6403.                ZAZO := NOT ZAZO
  6404. makes ZAZO true if it is false and vice versa. In Icon I would write
  6405.           /ZAZO := 1 | ZAZO := &null
  6406. which seems to me much harder to read. Is there a better way to do it?
  6407.  
  6408. From icon-group-sender  Sun Apr 17 17:36:14 1988
  6409. Received: by bocklin.arizona.edu; Sun, 17 Apr 88 17:36:18 MST
  6410. Date: Sun, 17 Apr 88 15:38:36 mst
  6411. From: naucse!sbw (Steve Wampler)
  6412. Message-Id: <8804172238.AA21859@naucse>
  6413. To: arizona!icon-group
  6414. Subject: Explanation of prime seive
  6415. Errors-To: icon-group-errors
  6416.  
  6417.  
  6418. I was asked by a couple of people about two weeks ago to provide an
  6419. explanation of the prime number seive I posted to this group.  I'm
  6420. sorry this took so long, but things have been busy (so what else is
  6421. new?).
  6422.  
  6423. Before I launch into this, I want to point out that this type of
  6424. use of co-expressions is NOT typical - it is much more common to
  6425. use co-expressions as means of controlling access to result sequences.
  6426.  
  6427. The basic idea of the program is to construct a 'cascade' of independent
  6428. routines.  Except for the first and the last routine, each is a 'filter'
  6429. that checks to see if a potential prime is divisible by a known prime.
  6430. Since a potential prime that passes completely through the filters becomes
  6431. a known prime, the last routine in the cascade has to add a 'filter'
  6432. to the cascade to test subsequent potential primes against this new
  6433. known prime (this last routine, dubbed the 'sink' also prints the
  6434. value of the newly discovered prime).  The first routine in the cascade
  6435. is responsible for producing potential primes (and is hence the 'source'
  6436. of all numbers fed through the cascade).  For each potential prime, the
  6437. source also establishes the sequence of filters the number is to passed
  6438. through.
  6439.  
  6440. If a filter discovers that the current potential prime is divisible by
  6441. its known prime, then it simply restarts the source, which produces the
  6442. next prime, and so on.  If a filter discovers that the current potential
  6443. prime is not divisible by its known prime (and hence, still a potential
  6444. prime), it simply starts up the next filter to continue the potential
  6445. prime's journey down the cascade.
  6446.  
  6447. The important parts of the actual code are reproduced below, annotated
  6448. to reflect the role each has in the above description:
  6449.  
  6450. (1)
  6451.   global num,    # It turns out to be easiest in Icon to pass the
  6452.         #   potential prime via a global, so this is it.
  6453.      cascade,    # the cascade of filters, global so that
  6454.             #   both the source and the sink can manipulate it
  6455.      nextfilter,    # the sequence of filters in the cascade
  6456.      source    # see comments above
  6457.  
  6458. (2)
  6459.    source := create {                   # start the cascade on possible primes
  6460.                 every num := seq(2) do
  6461.                    @@(nextfilter := create !cascade)
  6462.                 }
  6463.  
  6464.     This is the source mentioned above.  It's perhaps clearer if
  6465.     the code is 'spread out' some:
  6466.  
  6467.    source := create {
  6468.             every num := seq(2) do {    # generate the potential primes
  6469.            nextfilter := create !cascade    # sequence of filters
  6470.            first_filter := @nextfilter
  6471.                    @first_filter    # pass the potential prime to the
  6472.                     #   first filter in the cascade
  6473.                    }
  6474.                 }
  6475.  
  6476. (3)    # at this point, the source hasn't been executed, just constructed
  6477. (4)    #  so construct an initial cascade, with just the sink in it.
  6478.     #  this means that the first potential prime produced by the source
  6479.     #  will reach the sink and become the first known prime (which
  6480.     #  is why 'seq(2)' was used above).
  6481.    cascade := list()
  6482.    put(cascade, create sink())         # the first number (2) is assumed to
  6483.                                         #   be a prime.
  6484.     # in retrospect, this is cleaner as:
  6485.    cascade := [create sink()]
  6486.  
  6487.     # start up the source, to get everything rolling
  6488.    @source
  6489.  
  6490. (5)    # the sink is only reached when 'num' is known to be prime...
  6491.  
  6492.    procedure sink()                # have a prime, display it and
  6493.    local prime                     #   add a new filter to the cascade
  6494.  
  6495.    repeat {
  6496.     # num must be a 'known' prime...
  6497.       write(prime := num)
  6498.     # for performance reasons, it is better to test against small primes
  6499.         # early in the cascade.  since the primes are found in increasing
  6500.     # order, this next line puts the new filter for the newly discovered
  6501.     # prime at the end of the cascade.
  6502.       put(cascade, create filter(prime))   
  6503.     # however, the end of the cascade HAS to remain the sink, so
  6504.     # new filter should have gone in just before the sink.  this
  6505.     # next line fixes that by moving the sink after the new filter.
  6506.       cascade[-2] :=: cascade[-1]
  6507.     # restart the source to get the next potential prime started down
  6508.     # this new cascade.
  6509.       @source
  6510.       }
  6511.  
  6512.    end
  6513.  
  6514. (5) # Each filter does a simple test for relative primeness, then uses the
  6515.     #   outcome to either continue the potential prime down the cascade or
  6516.     #   to start a new potential prime down the cascade
  6517.    procedure filter(prime)              # test to see if num is a multiple
  6518.                                         #   of prime
  6519.    repeat {
  6520.      if num % prime = 0 then @source    # num wasn't prime, get next number.
  6521.      else @@nextfilter            # num is still a potential prime.
  6522.                     # @nextfilter supplies the next
  6523.                     # filter, which is then activated
  6524.                     # to test 'num' against its known
  6525.                     # prime or, if it's the sink, to
  6526.                     # display 'num' and add a new filter.
  6527.      }
  6528.  
  6529.    end
  6530.  
  6531. I hope this helps explain the operation.  Please don't think that this
  6532. is an efficient operation - it was written (originally) to show that
  6533. some of the behaviour of coroutines could be mimiked using co-expressions.
  6534. (If one had a bank of cpus and some syncronizing mechanism, then all the
  6535. co-expressions (with minor modifications) could be running in parallel,
  6536. with different potential primes being processed by different filters
  6537. in the cascade.  The 'sink' would then be adding cpu's into the process.)
  6538.  
  6539. It also shows that the call-graph for a program need not be a tree, as
  6540. is the case in many languages - the co-expression mechanism allows the
  6541. transfer of control among procedures in non-hierarchical form.  (Hmm,
  6542. I suppose this could be used to produce one of the world's slowest
  6543. finite state machine simulations!)
  6544.  
  6545. Again, let me finish by repeating that this is NOT the usual use of
  6546. co-expressions, which are remarkably simple devices in themselves.
  6547. I think the fact that transfer of control is not hierarchical is what
  6548. is causing people the most trouble in understanding how this operates.
  6549.  
  6550. Sorry this is so long.
  6551.  
  6552. From icon-group-sender  Sun Apr 17 23:49:41 1988
  6553. Received: by bocklin.arizona.edu; Sun, 17 Apr 88 23:49:44 MST
  6554. Date: 18 Apr 88 02:59:40 GMT
  6555. From: mo@uunet.uu.net  (Mike O'Dell)
  6556. Organization: UUNET Communications Services, Arlington, VA
  6557. Subject: icon implementation for SUNs
  6558. Message-Id: <11640@uunet.UU.NET>
  6559. Sender: icon-group-request@arizona.edu
  6560. To: icon-group@arizona.edu
  6561. Errors-To: icon-group-errors
  6562.  
  6563. Can someone give me a pointer to an implementation
  6564. of Icon for SUN workstations (SUN-3/68020 critters)?
  6565. We need to do some serious data hacking,
  6566. and icon seems to be the best choice.
  6567. Is the distribution online somewhere, or is
  6568. it voluminous enough that tape is the best way?
  6569.  
  6570.     -Mike O'Dell
  6571.  
  6572. From icon-group-sender  Mon Apr 18 05:37:45 1988
  6573. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 05:37:48 MST
  6574. Date: Mon, 18 Apr 88 13:35:52 BST
  6575. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - Sun UK TSE)
  6576. Message-Id: <8804181235.AA08725@stevie.nuksun.uucp>
  6577. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  6578. Subject: Re: icon implementation for SUNs
  6579. Errors-To: icon-group-errors
  6580.  
  6581. >From: sunuk!sun!uunet.uu.net!mo  (Mike O'Dell)
  6582. >Can someone give me a pointer to an implementation
  6583. >of Icon for SUN workstations (SUN-3/68020 critters)?
  6584. >We need to do some serious data hacking,
  6585. >and icon seems to be the best choice.
  6586. >Is the distribution online somewhere, or is
  6587. >it voluminous enough that tape is the best way?
  6588.  
  6589. v7 appears to work fine on both Sun-3 and Sun-2 hardware.  I have not
  6590. yet had time to attempt an implementation for Sun-4, a situation which
  6591. is likely to continue indefinitely.
  6592.  
  6593. Note that there are implementations named "sun2" and "sun3".  In the
  6594. past these referred to operating system version.  However, compiling
  6595. the "sun2" version gives you a translation system suitable for both
  6596. types of machine - here we run Sun-2 under SunOS 3.0, and Sun-3 under
  6597. 3.0 and 3.5.  Everything seems to run fine.  Compile "sun2" on a Sun-2
  6598. unless you want to fiddle with the CFLAGS to set the machine type.
  6599.  
  6600. The "sun3" system won't build on a Sun-2 due to 68020 assembly code
  6601. being generated from "rover.c" during the iconx build.
  6602.  
  6603. The Icon v7 distribution weighed in at 2519040 bytes - make your own
  6604. mind up about a network transfer - that's how it was obtained for me.
  6605.  
  6606. Steve Holden                    sholden@sun.com
  6607. Necessity is a mother.            sholden@{sun,sunuk}.uucp
  6608.  
  6609. From icon-group-sender  Mon Apr 18 12:09:35 1988
  6610. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 12:09:38 MST
  6611. Return-Path: <goer@sophist.uchicago.edu>
  6612. Date: Mon, 18 Apr 88 14:03:27 CDT
  6613. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  6614. Message-Id: <8804181903.AA08436@sophist.uchicago.edu>
  6615. To: icon-group@arizona.edu
  6616. Subject: Still don't understand (thick head?)
  6617. Errors-To: icon-group-errors
  6618.  
  6619.  
  6620. I still don't quite understand why the following cut-down (hence inane) program
  6621. only outputs "A":
  6622.  
  6623. procedure main()
  6624.   S := create WriteString()
  6625.   while write(@S)
  6626. end
  6627.  
  6628. procedure WriteString()
  6629.   SS := create WriteString2()
  6630.   while suspend @SS
  6631. end
  6632.  
  6633. procedure WriteString2()
  6634.   every suspend !"AbCdEfGh"
  6635. end
  6636.  
  6637. I would expect this to do the same thing as:
  6638.  
  6639. procedure main()
  6640.   S := create WriteString()
  6641.   while write(@S)
  6642. end
  6643.  
  6644. procedure WriteString()
  6645.   SS := create WriteString2()
  6646.   while s := @SS
  6647.   do suspend s
  6648. end
  6649.  
  6650. procedure WriteString2()
  6651.   every suspend !"AbCdEfGh"
  6652. end
  6653.  
  6654. The only difference here is in the middle procedure, where we have either
  6655. while s := @SS do suspend s; or while suspend @SS.  I guess I thought that
  6656. they would do the same thing, namely reactivate SS over and over again, until
  6657. it fails.  In the first case, the result produced gets assigned to a variable
  6658. (s), then the material in the do-clause is evaluated, resulting in the sus-
  6659. pension of what SS has just produced.  In the second, case, I would have 
  6660. thought that the same thing should happen, only in more truncated form, namely
  6661. that the expression "suspend @SS" would be repeatedly evaluated, each time
  6662. popping another result off of SS, then suspending it - until @SS fails.
  6663.  
  6664. This is an extremely silly mistake, I know, but could someone take another
  6665. crack at explaining it all to me?  (P.S.  I do know the difference between
  6666. every, while, and that coexpressions are not generators [i.e. every @e will
  6667. produce one result].  I'm just hitting a blind spot here.)
  6668.  
  6669. From icon-group-sender  Mon Apr 18 12:15:57 1988
  6670. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 12:16:00 MST
  6671. Date: Mon, 18 Apr 88 12:15:35 MST
  6672. From: "Ralph Griswold" <ralph>
  6673. Message-Id: <8804181915.AA07427@megaron.arizona.edu>
  6674. To: goer@sophist.uchicago.edu
  6675. Subject: Re:  Still don't understand (thick head?)
  6676. Cc: icon-group
  6677. In-Reply-To: <8804181903.AA08436@sophist.uchicago.edu>
  6678. Errors-To: icon-group-errors
  6679.  
  6680. The argument of suspend is repeatedly *resumed*, not repeatedly
  6681. evaluated.  For an analogy, try
  6682.  
  6683.     suspend read()
  6684.  
  6685. and see what you get (at most one read).
  6686.  
  6687.      Ralph Griswold / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  6688.      +1 602 621 6609   ralph@Arizona.EDU     {allegra|noao|ihnp4}!arizona!ralph
  6689.  
  6690.  
  6691. From icon-group-sender  Mon Apr 18 12:55:01 1988
  6692. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 12:55:07 MST
  6693. Date: Mon, 18 Apr 88 12:54:58 MST
  6694. From: "Kenneth Walker" <kwalker>
  6695. Message-Id: <8804181954.AA09155@megaron.arizona.edu>
  6696. In-Reply-To: <8804181903.AA08436@sophist.uchicago.edu>
  6697. To: icon-group
  6698. Subject: Re:  Still don't understand (thick head?)
  6699. Errors-To: icon-group-errors
  6700.  
  6701. > Date: Mon, 18 Apr 88 14:03:27 CDT
  6702. > From: Richard Goerwitz <goer@sophist.uchicago.edu>
  6703.   ...
  6704. > The only difference here is in the middle procedure, where we have either
  6705. > while s := @SS do suspend s; or while suspend @SS.
  6706.   ...
  6707. > In the second, case, I would have 
  6708. > thought that the same thing should happen, only in more truncated form, namely
  6709. > that the expression "suspend @SS" would be repeatedly evaluated, each time
  6710. > popping another result off of SS, then suspending it - until @SS fails.
  6711.  
  6712. A critical point to notice is that suspend itself always fails after it
  6713. has exhasted the generators in its argument. This means that the while
  6714. will terminate after the first evaluation of the suspend expression.
  6715.  
  6716.      Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  6717.      +1 602 621 2858  kwalker@Arizona.EDU   {allegra|noao|ihnp4}!arizona!kwalker
  6718.  
  6719. From icon-group-sender  Mon Apr 18 18:00:55 1988
  6720. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 18:00:58 MST
  6721. Return-Path: <goer@sophist.uchicago.edu>
  6722. Date: Mon, 18 Apr 88 19:54:55 CDT
  6723. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  6724. Message-Id: <8804190054.AA09145@sophist.uchicago.edu>
  6725. To: kwalker@arizona.edu
  6726. Subject: Re:  Still don't understand (thick head?)
  6727. Cc: icon-group@arizona.edu
  6728. Errors-To: icon-group-errors
  6729.  
  6730. So suspend is just like "every" and "while."  For some reason, I had it in
  6731. my head that "suspend" just saved all local variables, and returned, then passed
  6732. control on to what follows when resumed.
  6733.  
  6734. In order to cause resumption of suspend's argument,  I was writing things like
  6735.  
  6736.      every suspend
  6737.  
  6738. and to bring about repeated evaluation of its argument, I was writing
  6739.  
  6740.     every suspend,
  6741.  
  6742. and the like.  The fact is that when I wrote "while suspend" I was really get-
  6743. ting back what I thought I was getting when I wrote "every suspend"!  In fact,
  6744. I needn't have written anything but "suspend."  Writing "every suspend" is as
  6745. silly as writing "every every"!
  6746.  
  6747. Many thanks to those who helped me hammer this seemingly basic fact out.  I
  6748. send this to the icon-group not out of any masochistic desire to embarrass
  6749. myself, but because I know not everyone who reads this is an advanced Icon pro-
  6750. grammer.  Maybe I'll be able to stop someone else from making a similar mis-
  6751. take.
  6752.  
  6753. One further question, by the way:  Why is it that the version 7 executables,
  6754. though large, do not show much (any?) decrease in performance over their
  6755. version 6 counterparts?  In many cases, I could swear that there is even a
  6756. speedup.  Although I do not have any old executables arount, it also seems
  6757. to me that the .icx files under version 7 are smaller than their version 6
  6758. counterparts.  Obviously the move from 6 to 7 involved some major implemen-
  6759. tation change:  Could someone clue me in to what is going on here?  Are we
  6760. moving closer to compiled code (drool, pant, pant)?
  6761.  
  6762. Again, many thanks for the patience....
  6763.  
  6764.                                                   -Richard L. Goerwitz
  6765.                                                   goer@sophist.uchicago.edu
  6766.                                                   !ihnp4!gargoyle!sophist!goer
  6767.  
  6768. From icon-group-sender  Mon Apr 18 18:09:54 1988
  6769. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 18:09:56 MST
  6770. From: ihnp4!ihcup!pax
  6771. Message-Id: <8804190109.AA01683@megaron.arizona.edu>
  6772. Message-Version: 2
  6773. >To: /addr=ihlpe!orf, /addr=ihnp4!arizona!icon-group
  6774. Date: Mon 18 Apr 1988 15:38 cst
  6775. End-Of-Header: 
  6776. Email-Version: 2
  6777. X-Postmark: joe.t.hall attrd ihp2b524 55513 3124167285 ihcup!pax
  6778. To: arizona!icon-group
  6779. Cc: ihlpe!orf
  6780. Subject: V7 for SUN3
  6781. Ua-Message-Id: <post.pax.Mon 18 Apr 1988 13:21 cst>
  6782. End-Of-Protocol: 
  6783. Content-Length: 378
  6784. Errors-To: icon-group-errors
  6785.  
  6786. Mike,
  6787.  
  6788. It looks like we'll do a SUN3 implementation sometime in the near future
  6789. and you could get from that the binary files for the language.  Otherwise,
  6790. you'll need the full tape from Arizona.
  6791.  
  6792. Joe T. Hall
  6793. AT&T Bell Laboratories
  6794. 200 Park Plaza, Room IHP 2B-524
  6795. Naperville, Illinois 60566-7050
  6796. USA
  6797. ihnp4!ihcup!pax
  6798. tel:+1 312 416-7285
  6799. fax: +1 312 416-7480
  6800. tlx:157294384(JTHALL)
  6801.  
  6802. From icon-group-sender  Mon Apr 18 18:10:01 1988
  6803. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 18:10:06 MST
  6804. Date: Mon, 18 Apr 88 18:09:58 MST
  6805. From: ihnp4!ihlpf!nevin1
  6806. Message-Id: <8804190109.AA01695@megaron.arizona.edu>
  6807. To: arizona!icon-group
  6808. Subject: Re: environment variables
  6809. Errors-To: icon-group-errors
  6810.  
  6811. >The new version of MS-DOS Icon can examine individual environment variables.
  6812. >Is it reasonable to add the capability to see ALL the environment variables
  6813. >(probably as a list of list, or perhaps as a table)?
  6814.  
  6815. If this capability were added to the language (the ability to get all the
  6816. environment variables), I would like to see it implemented as a generator.
  6817. This built-in generator should return the names of all the environment
  6818. variables, since in conjunction with getenv() all the information about the
  6819. environment variables can be deduced.
  6820.  
  6821.  _ __            NEVIN J. LIBER    ..!ihnp4!ihlpf!nevin1    (312) 510-6194
  6822. ' )  )                The secret compartment of my ring I fill
  6823.  /  / _ , __o  ____        with an Underdog super-energy pill.
  6824. /  (_</_\/ <__/ / <_    These are solely MY opinions, not AT&T's, blah blah blah
  6825.  
  6826.  
  6827. From icon-group-sender  Mon Apr 18 18:09:57 1988
  6828. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 18:10:01 MST
  6829. Date: Mon, 18 Apr 88 18:09:55 MST
  6830. From: ihnp4!ihlpf!nevin1
  6831. Message-Id: <8804190109.AA01690@megaron.arizona.edu>
  6832. To: arizona!icon-group
  6833. Subject: Re: Still don't understand (thich head?)
  6834. Errors-To: icon-group-errors
  6835.  
  6836. >The only difference here is in the middle procedure, where we have either
  6837. >while s := @SS do suspend s; or while suspend @SS.  I guess I thought that
  6838. >they would do the same thing, namely reactivate SS over and over again, until
  6839. >it fails.  In the first case, the result produced gets assigned to a variable
  6840. >(s), then the material in the do-clause is evaluated, resulting in the sus-
  6841. >pension of what SS has just produced.  In the second, case, I would have 
  6842. >thought that the same thing should happen, only in more truncated form, namely
  6843. >that the expression "suspend @SS" would be repeatedly evaluated, each time
  6844. >popping another result off of SS, then suspending it - until @SS fails.
  6845.  
  6846. In Icon, the value of 'suspend' is fail.  If you try the following program:
  6847.  
  6848.     procedure main()
  6849.  
  6850.     nevin := create liber()
  6851.     write(@nevin)
  6852.     write(@nevin)
  6853.  
  6854.     end
  6855.  
  6856.  
  6857.     procedure liber()
  6858.  
  6859.     x := 1
  6860.     x := suspend 3
  6861.     return x
  6862.  
  6863.     end
  6864.  
  6865. you get:
  6866.  
  6867.     3
  6868.     1
  6869.  
  6870. which means that the assignment 'x := suspend 3' failed, which can only
  6871. happen if the value of 'suspend' is fail.  This is why
  6872. 'while suspend @s' and 'while ss := @s do suspend ss' are not equivalent;
  6873. the former goes until 'suspend' fails (which is just as the procedure is
  6874. resumed @s) but the latter goes until 'ss := @s' fails.
  6875.  
  6876. If you look at a TRACE of your first program, you will see that
  6877. WriteString() fails just after it is reactivated; it does not call
  6878. WriteString2() a second time.
  6879.  
  6880. Hope this helps,
  6881.  
  6882.  _ __            NEVIN J. LIBER    ..!ihnp4!ihlpf!nevin1    (312) 510-6194
  6883. ' )  )                The secret compartment of my ring I fill
  6884.  /  / _ , __o  ____        with an Underdog super-energy pill.
  6885. /  (_</_\/ <__/ / <_    These are solely MY opinions, not AT&T's, blah blah blah
  6886.  
  6887.  
  6888. From icon-group-sender  Mon Apr 18 18:20:17 1988
  6889. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 18:20:22 MST
  6890. Date: Mon, 18 Apr 88 18:20:14 MST
  6891. From: "Ralph Griswold" <ralph>
  6892. Message-Id: <8804190120.AA03857@megaron.arizona.edu>
  6893. To: icon-group
  6894. Subject: getting all environment variables
  6895. Errors-To: icon-group-errors
  6896.  
  6897. As noted, a generator is the natural mechanism for
  6898. generating a sequence of values.  It could take the
  6899. form of a keyword:  &environment (or some other suitable
  6900. name).
  6901.  
  6902.      Ralph Griswold / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  6903.      +1 602 621 6609   ralph@Arizona.EDU     {allegra|noao|ihnp4}!arizona!ralph
  6904.  
  6905.  
  6906. From icon-group-sender  Mon Apr 18 21:40:31 1988
  6907. Received: by bocklin.arizona.edu; Mon, 18 Apr 88 21:40:34 MST
  6908. Date: Mon, 18 Apr 88 21:40:29 MST
  6909. From: "Kenneth Walker" <kwalker>
  6910. Message-Id: <8804190440.AA09819@megaron.arizona.edu>
  6911. To: icon-group
  6912. Subject: v7 performance
  6913. Errors-To: icon-group-errors
  6914.  
  6915.  
  6916. > Date: Mon, 18 Apr 88 19:54:55 CDT
  6917. > From: Richard Goerwitz <goer@sophist.uchicago.edu>
  6918. > One further question, by the way:  Why is it that the version 7 executables,
  6919. > though large, do not show much (any?) decrease in performance over their
  6920. > version 6 counterparts?  In many cases, I could swear that there is even a
  6921. > speedup.  Although I do not have any old executables arount, it also seems
  6922. > to me that the .icx files under version 7 are smaller than their version 6
  6923. > counterparts.  Obviously the move from 6 to 7 involved some major implemen-
  6924. > tation change:  Could someone clue me in to what is going on here?  Are we
  6925. > moving closer to compiled code (drool, pant, pant)?
  6926.  
  6927. Most of the increase in the size of iconx in version 7 is due to additional
  6928. features. If these features are not being used they do not affect
  6929. performance. There have been a number of changes which can affect
  6930. performance. Some probably slow things down while others may speed things
  6931. up a little. I wouldn't expect much change in performance for most programs.
  6932. I just compared the sizes of a couple i-code files produced by Version
  6933. 6 and Version 7 under Unix on a Vax. I came up with larger files
  6934. under Version 7. The changes to the implementation in Version 7 are
  6935. to implement the new features, fix some bugs, and make it a little
  6936. easier to port. It does not represent movement toward a compiler.
  6937.  
  6938.      Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  6939.      +1 602 621 2858  kwalker@Arizona.EDU   {allegra|noao|ihnp4}!arizona!kwalker
  6940.  
  6941. From icon-group-sender  Sun Apr 24 16:29:49 1988
  6942. Received: by bocklin.arizona.edu; Sun, 24 Apr 88 16:29:51 MST
  6943. Date: Sun, 24 Apr 88 16:27:57 PDT
  6944. From: wgg@june.cs.washington.edu (William Griswold)
  6945. Return-Path: <wgg@june.cs.washington.edu>
  6946. Message-Id: <8804242327.AA08935@june.cs.washington.edu>
  6947. To: icon-group@arizona.edu
  6948. Subject: object oriented Icon
  6949. Errors-To: icon-group-errors
  6950.  
  6951.  
  6952. I've been thinking about building an object-oriented version of Icon using
  6953. variant translators (and maybe some minor mods to icont/iconx).  Does anybody 
  6954. know of anyone who has tried to do this?  Any opinions on such an attempt?
  6955.    
  6956.                            Bill Griswold
  6957.                         wgg@june.cs.washington.edu
  6958.  
  6959.  
  6960. From icon-group-sender  Mon Apr 25 02:31:45 1988
  6961. Received: by bocklin.arizona.edu; Mon, 25 Apr 88 02:31:48 MST
  6962. Date: Mon, 25 Apr 88 02:31:31 MST
  6963. From: "David Gudeman" <gudeman>
  6964. Message-Id: <8804250931.AA25208@megaron.arizona.edu>
  6965. To: wgg@june.cs.washington.edu
  6966. Cc: icon-group@arizona.edu
  6967. In-Reply-To: <8804242327.AA08935@june.cs.washington.edu>
  6968. Subject: object oriented Icon
  6969. Errors-To: icon-group-errors
  6970.  
  6971. What do you mean by "object-oriented"?  I can think of at least two
  6972. different definitions that might apply here...
  6973.  
  6974. From icon-group-sender  Mon Apr 25 02:47:23 1988
  6975. Received: by bocklin.arizona.edu; Mon, 25 Apr 88 02:47:26 MST
  6976. Date: Mon, 25 Apr 88 02:45:21 PDT
  6977. From: wgg@june.cs.washington.edu (William Griswold)
  6978. Return-Path: <wgg@june.cs.washington.edu>
  6979. Message-Id: <8804250945.AA19922@june.cs.washington.edu>
  6980. To: gudeman@arizona.edu, wgg@june.cs.washington.edu
  6981. Subject: Re:  object oriented Icon
  6982. Cc: icon-group@arizona.edu
  6983. Errors-To: icon-group-errors
  6984.  
  6985.     From: "David Gudeman" <gudeman@arizona.edu>
  6986.     To: wgg@june.cs.washington.edu
  6987.     Cc: icon-group@arizona.edu
  6988.     Subject: object oriented Icon
  6989.     Status: R
  6990.  
  6991.     What do you mean by "object-oriented"?  I can think of at least two
  6992.     different definitions that might apply here...
  6993.  
  6994. I'll tell you what I think if you'll tell me what you want or what you'd
  6995. expect. 
  6996.  
  6997. Basically, I'm talking about a language that supports:
  6998.  
  6999.     1) Inheritance
  7000.        The language should have a powerful way to relate the datatypes
  7001.        used in a program, both in type definition and during execution.
  7002.  
  7003.     2) Encapsulation
  7004.        It should be possible to describe a type in terms of the "behavior"
  7005.        of a set of operations, hiding the representation of the type.
  7006.  
  7007.     3) Objects as first-class citizens
  7008.        Instances of a type should be dynamically instantiable with
  7009.        independent state, valid as arguments to procedures, and
  7010.        returnable from procedures as values. 
  7011.  
  7012. These ideas are demonstrated in languages such as Smalltalk, C++, and DEC's 
  7013. Trellis/Owl, with minor variations and additions. 
  7014.  
  7015. Icon currently does not support the first two design goals.  Languages such
  7016. as Ada and Modula do not meet the third design goal.
  7017.  
  7018. An object-oriented language could certainly support more or less than these 
  7019. features.  Many of the design decisions would be influenced by Icon.  For 
  7020. example, I would not suggest supporting static (sub)typing, which many modern 
  7021. OO languages support.  But I am considering allowing user-definition of Icon
  7022. operators.
  7023.  
  7024.                         Bill Griswold
  7025.  
  7026.  
  7027. From icon-group-sender  Mon Apr 25 22:33:55 1988
  7028. Received: by bocklin.arizona.edu; Mon, 25 Apr 88 22:33:58 MST
  7029. Date: Mon, 25 Apr 88 22:31:39 MST
  7030. From: "David Gudeman" <gudeman>
  7031. Message-Id: <8804260531.AA13965@megaron.arizona.edu>
  7032. To: wgg@june.cs.washington.edu
  7033. Cc: icon-group
  7034. In-Reply-To: <8804250945.AA19922@june.cs.washington.edu>
  7035. Subject:  object oriented Icon
  7036. Errors-To: icon-group-errors
  7037.  
  7038. I think inheritance and encapsulation are good ideas, but I don't like
  7039. it when they dominate the language.  In SmallTalk you sometimes have
  7040. to do strange things like create imaginary types just to write a
  7041. procedure.  SmallTalk-with-generators wouldn't appeal to me very much,
  7042. but if you're just talking about adding a type structure to Icon and
  7043. implementing modules of some sort, I'd really like see it.
  7044.  
  7045. From icon-group-sender  Tue Apr 26 08:58:40 1988
  7046. Received: by bocklin.arizona.edu; Tue, 26 Apr 88 08:58:44 MST
  7047. Date: Tue, 26 Apr 88 08:55:34 PDT
  7048. From: Michael Shafto <shafto@eos.arc.nasa.gov>
  7049. Message-Id: <8804261555.AA05301@eos.arc.nasa.gov>
  7050. To: gudeman@arizona.edu, wgg@june.cs.washington.edu
  7051. Subject: Re:  object oriented Icon
  7052. Cc: icon-group@arizona.edu, shafto@EOS.ARC.NASA.GOV
  7053. Errors-To: icon-group-errors
  7054.  
  7055. I would like to second Dave's comments and add one:  I had some
  7056. experience with LOOPS on early D-Machines; it was "built on top of"
  7057. Interlisp-D, an ugly and ineffective amalgam, to say the least.
  7058.  
  7059. I would actually like to see (easy for me to say, since no way
  7060. I'm going to be involved in implementing it!) an Icon-like language
  7061. (Icob?) which is built from the ground up to be an object-oriented
  7062. language, leaving out features of Icon that don't strongly support
  7063. or easily fit in with object-oriented programming.
  7064.  
  7065. No use creating the PL/1 of symbolic computing.  Better to create an
  7066. option which can be chosen for tasks that fit the object-oriented
  7067. paradigm.  I agree with Dave that object-oriented programming 
  7068. (like logic programming) is good for what it's good for, but not
  7069. as an all-purpose framework.
  7070.  
  7071. Mike Shafto
  7072.  
  7073. From icon-group-sender  Tue Apr 26 12:56:18 1988
  7074. Received: by bocklin.arizona.edu; Tue, 26 Apr 88 12:56:21 MST
  7075. Date: Tue, 26 Apr 88 12:56:17 MST
  7076. From: "David Gudeman" <gudeman>
  7077. Message-Id: <8804261956.AA13125@megaron.arizona.edu>
  7078. To: icon-group
  7079. In-Reply-To: <8804261555.AA05301@eos.arc.nasa.gov>
  7080. Subject:  object oriented Icon
  7081. Errors-To: icon-group-errors
  7082.  
  7083. Gee, I hate to do this when Mike was nice enough to agree with me, but
  7084. I'm afraid he missed my point and actually wants the opposite of what
  7085. I would like to see.  It was probably my own fault for being terse.
  7086. What I meant to say was that I don't like the idea of making Icon into
  7087. an OBJECT ORIENTED LANGUAGE or designing a new object oriented
  7088. language that is similar to Icon.  The problem with this approach is
  7089. exactly what Mike Shafto pointed out: "... object-oriented programming
  7090. (like logic programming) is good for what it's good for, but not as an
  7091. all-purpose framework".
  7092.  
  7093. Logic languages, object-oriented languages, pure functional languages,
  7094. constraint languages, etc., all suffer from this problem of being
  7095. really good for some things and really poor for other things.  I still
  7096. have faith that it is possible to design a language that is really
  7097. good for everything.  Icon is closer to that goal than most other
  7098. languages, and I think inheritance and better modularity would move it
  7099. closer to the goal.  But don't take out other important features while
  7100. you are doing it.
  7101.  
  7102. On the other hand, I don't like the idea of huge languages, I think
  7103. the perfect programming language will be quite simple and elegant when
  7104. we find it (maybe next year), but for now, it looks like adding
  7105. features and not removing any is the best way to go.  Of course I am
  7106. speaking as a person who doen't mind learning new software.  For that
  7107. large percentage of the population who don't like to learn new
  7108. software, adding features probably isn't as acceptable.
  7109.  
  7110. From icon-group-sender  Wed Apr 27 06:27:53 1988
  7111. Received: by bocklin.arizona.edu; Wed, 27 Apr 88 06:27:56 MST
  7112. Date: 27 Apr 88 07:27:39 GMT
  7113. From: cjeffery@arizona.edu  (Clinton Jeffery)
  7114. Organization: U of Arizona CS Dept, Tucson
  7115. Subject: Re: object oriented Icon
  7116. Message-Id: <5185@megaron.arizona.edu>
  7117. References: <8804261956.AA13125@megaron.arizona.edu>
  7118. Sender: icon-group-request@arizona.edu
  7119. To: icon-group@arizona.edu
  7120. Errors-To: icon-group-errors
  7121.  
  7122. From article <8804261956.AA13125@megaron.arizona.edu>, by gudeman@ARIZONA.EDU:
  7123. > "... object-oriented programming (like logic programming) is good
  7124. > for what it's good for, but not as an all-purpose framework".
  7125.  
  7126. In my ignorance, this is not at all clear to me.  In fact, I would state
  7127. the opposite--object oriented programming is a wonderful all-purpose
  7128. framework.  Smalltalk may be a specialized world unto itself, and it may
  7129. run dog-slow, but it is the FORTRAN of object-oriented languages...
  7130. At any rate, Dave, I would appreciate it if you or the original writer
  7131. would provide some support for this assertion.
  7132. -- 
  7133. | Clint Jeffery, University of Arizona Department of Computer Science
  7134. | cjeffery@arizona.edu -or- {ihnp4 noao}!arizona!cjeffery
  7135. --
  7136.  
  7137. From icon-group-sender  Wed Apr 27 08:39:19 1988
  7138. Received: by bocklin.arizona.edu; Wed, 27 Apr 88 08:39:22 MST
  7139. Date: Wed, 27 Apr 88 08:36:18 PDT
  7140. From: Michael Shafto <shafto@eos.arc.nasa.gov>
  7141. Message-Id: <8804271536.AA04688@eos.arc.nasa.gov>
  7142. To: cjeffery@arizona.edu, icon-group@arizona.edu
  7143. Subject: Re: object oriented Icon
  7144. Cc: shafto@AMES-AURORA.ARPA
  7145. Errors-To: icon-group-errors
  7146.  
  7147.  
  7148. >>From article <8804261956.AA13125@megaron.arizona.edu>, by gudeman@ARIZONA.EDU:
  7149. >> "... object-oriented programming (like logic programming) is good
  7150. >> for what it's good for, but not as an all-purpose framework".
  7151.  
  7152. >In my ignorance, this is not at all clear to me.  In fact, I would state
  7153. >the opposite--object oriented programming is a wonderful all-purpose
  7154. >framework.  Smalltalk may be a specialized world unto itself, and it may
  7155. >run dog-slow, but it is the FORTRAN of object-oriented languages...
  7156. >At any rate, Dave, I would appreciate it if you or the original writer
  7157. >would provide some support for this assertion.
  7158.  
  7159. As the original writer, I feel I should respond, however briefly:
  7160. I don't think personal opinions about programming languages should
  7161. extend to proselytizing (for or against).  To anyone who loves
  7162. Prolog, APL, Smalltalk, SNOBOL4, or (even) Lisp, I say:  "Right
  7163. on."  For the kinds of problems I have to deal with, which are
  7164. pretty mundane, and given my own background, which is pretty
  7165. mundane, I find the frameworks of both Smalltalk and Prolog
  7166. unnatural and awkward.  For certain kinds of database stuff,
  7167. Prolog is just the ticket.  I know people who have found Smalltalk
  7168. ideal for modeling physical systems made up of components which
  7169. communicate by sending and receiving messages.  But evaluating
  7170. 3+5 by sending the message "add 5" to the object 3?  I repeat, it's
  7171. not my goal to start a debate on the merits of Smalltalk, but
  7172. personally I don't consider it a general-purpose programming
  7173. language.
  7174.  
  7175. Mike Shafto
  7176.  
  7177.  
  7178. From icon-group-sender  Wed Apr 27 12:26:25 1988
  7179. Received: by bocklin.arizona.edu; Wed, 27 Apr 88 12:26:28 MST
  7180. Date: Wed, 27 Apr 88 12:23:59 PDT
  7181. From: wgg@june.cs.washington.edu (William Griswold)
  7182. Return-Path: <wgg@june.cs.washington.edu>
  7183. Message-Id: <8804271923.AA16088@june.cs.washington.edu>
  7184. To: icon-group@arizona.edu
  7185. Subject: Re: object oriented Icon
  7186. Errors-To: icon-group-errors
  7187.  
  7188. This message is in response to the many messages I have received
  7189. concerning the design of an ``object-oriented'' Icon.
  7190.  
  7191. The type of object-orientation I'm talking about wouldn't incorporate
  7192. the quirks of Smalltalk:  no message passing or anything like that.  In
  7193. fact it would have the quirks of Icon.  Expression evaluation and all
  7194. that would stay the same. 
  7195.  
  7196. The type of object-oriention I intend for Icon would support
  7197. ADT-oriented (i.e., typed) modules, with the added kick of procedure
  7198. fields in values in order to keep track of the operations that can
  7199. manipulate the value.  But of course there is the type structure
  7200. among the modules that allows sharing of operations in implementation
  7201. and execution....
  7202.  
  7203. I don't intend to remove any features of Icon, nor make old programs 
  7204. incompatible.  If you have a ten line program to write there will be 
  7205. no need or requirement to use the object-oriented features. 
  7206.  
  7207. Thanks for all your feedback!
  7208.  
  7209.                     Bill Griswold
  7210.  
  7211. From icon-group-sender  Wed Apr 27 18:21:54 1988
  7212. Received: by bocklin.arizona.edu; Wed, 27 Apr 88 18:21:57 MST
  7213. Date: Wed, 27 Apr 88 18:21:52 MST
  7214. From: "David Gudeman" <gudeman>
  7215. Message-Id: <8804280121.AA28479@megaron.arizona.edu>
  7216. To: icon-group
  7217. In-Reply-To: <5185@megaron.arizona.edu>
  7218. Subject: object oriented languages
  7219. Errors-To: icon-group-errors
  7220.  
  7221. Clinton asked for some support for my assertion that object oriented
  7222. languages are not a good all-purpose framework.  First, I would like
  7223. to say what I think a strict object oriented language is: it is a
  7224. language where the single model of computation is that of objects and
  7225. message passing.  That _isn't_ what Bill Griswold meant by "object
  7226. oriented Icon", as he made clear in his reply to my reply to his
  7227. original message.
  7228.  
  7229. I believe that the term "object oriented" has aquired another meaning,
  7230. Bill's meaning, originally as a misunderstanding.  In fact, the
  7231. hierarchical representation of data is seperable from the object
  7232. oriented paradigm, and what Bill wants to do is include this seperable
  7233. part of object oriented languages into Icon.  A pure object oriented
  7234. language wouldn't even have to have to have this hierarchical
  7235. organization.  I never meant to say that hierarchical organization is
  7236. not a good general purpose framework, but it is not a paradigm of
  7237. computation in and of itself.  It is only a way to structure data and
  7238. programs.
  7239.  
  7240. A paradigm of computation is a model of what we mean by "program".  An
  7241. assembly language program consists of a set of instructions put
  7242. together into a proceedure for getting the answer.  I call this the
  7243. proceedural paradigm.  An FP program consists of an expression that
  7244. represents the answer.  I call this the functional paradigm.  A
  7245. Smalltalk program consists an expression that represents messages
  7246. being passed to objects, where one of the objects sends the answer
  7247. back to the user.  I call this the object oriented paradigm.
  7248.  
  7249. I maintain that no single one of these paradigms is good for all types
  7250. of problems.  Any general-purpose language should support several
  7251. paradigms so that the programmer can write in whatever paradigm the
  7252. problem calls for, and doesn't have to force the problem into a
  7253. paradigm that is not natural for it.  Note that Icon contains all of
  7254. these paradigms: an assignment is an instruction, a monogenic
  7255. operation (like a + b) is an expression, and transmission to a
  7256. co-expression is message passing.
  7257.  
  7258. From icon-group-sender  Thu Apr 28 00:40:40 1988
  7259. Received: by bocklin.arizona.edu; Thu, 28 Apr 88 00:40:43 MST
  7260. Date: Thu, 28 Apr 88 00:38:40 PDT
  7261. From: wgg@june.cs.washington.edu (Manu Dibango)
  7262. Return-Path: <wgg@june.cs.washington.edu>
  7263. Message-Id: <8804280738.AA17065@june.cs.washington.edu>
  7264. To: icon-group@arizona.edu
  7265. Subject: Re:  object oriented languages
  7266. Errors-To: icon-group-errors
  7267.  
  7268. This is in response to David Gudeman's message concerning what he
  7269. considered to be the core of object-orientation:
  7270.  
  7271. Historically, you will find that a large number of those languages that
  7272. are considered object-oriented are not message-passing languages.  Some
  7273. that I know of are Simula, C++, and Trellis/Owl.  I contend that this
  7274. is more than an accident.
  7275.  
  7276. I think it is better to think of an OO language as supplying a set of certain
  7277. capabilities rather than a particular design supporting those capabilities, or
  7278. even a way of thinking about them.  For example:
  7279.  
  7280. (You could quibble with me here about the following definitions.  They aren't
  7281. intended to be fully accurate.)
  7282.  
  7283. "x + y" can mean "send the message `+ y' to `x'"    (Smalltalk)
  7284.          "apply `x''s `+' operator `x' and `y'"    (Owl)
  7285.  
  7286. These ways of describing "x + y" are equally valid as ways of thinking 
  7287. about the computation, and they are equally valid ways of implementing the 
  7288. computation.  There needn't be any relationship between the thought model and
  7289. the implementation (as long as you don't run into inconsistencies). 
  7290.  
  7291. Object orientation means to me that a value knows what can be done to it, and 
  7292. will do it when asked to.  It implies a close binding of state and the 
  7293. operations that can manipulate that state.  This close binding also permits
  7294. an operation to directly manipulate the state of the object from which it
  7295. was selected.  For example "matrix1.transpose()" might change the value of
  7296. matrix1 so that it is the transpose of its previous value.  
  7297.  
  7298. Note that this particular syntax suggests the operation is being selected
  7299. from matrix1 as a field in a record.  It corresponds to the second example
  7300. above.  In some systems it is actually implemented this way.  Theoreticians
  7301. think about it this way, too. 
  7302.  
  7303. I agree that object orientation is not a full programming paradigm.  In the
  7304. literature I have seen the model consistently used in a message-passing
  7305. framework, a procedural framework, and in a functional framework as well. 
  7306. The last prohibits an operation from *changing* a value, but not creating a
  7307. new one.  Thus object orientation has something to offer every model. 
  7308.  
  7309. OO starts to involve structuring of the name space, since different types can
  7310. have like-named operations.  You soon discover that like-named operations
  7311. often have similar semantics, and even implementations, so you'd like to
  7312. share them.  Once you admit to some sort of structuring and sharing, you
  7313. might as well go the whole way to hierarchical structuring, in my opinion,
  7314. though there are certainly systems which do not.  Object orientation easily
  7315. admits such a scheme because each value knows what a particular operation
  7316. name means to it.  So although OO does not imply such a type structure, it
  7317. yields it effortlessly. 
  7318.  
  7319. There are many details that I have omitted, but I hope you get the central
  7320. idea that I am driving at:  I don't mean to suggest that anybody's model
  7321. of OO is wrong, just that very likely it is compatible with mine.
  7322.  
  7323.  
  7324.                     Bill Griswold
  7325.  
  7326. From icon-group-sender  Thu Apr 28 05:02:00 1988
  7327. Received: by bocklin.arizona.edu; Thu, 28 Apr 88 05:02:05 MST
  7328. Date: Thu, 28 Apr 88 05:01:58 MST
  7329. From: "Ralph Griswold" <ralph>
  7330. Message-Id: <8804281201.AA21253@megaron.arizona.edu>
  7331. To: icon-group
  7332. Subject: Forwarded Mail
  7333. Errors-To: icon-group-errors
  7334.  
  7335.  
  7336. I am sending along the following mail, which is self-explanatory.
  7337. ====================================================================
  7338.    
  7339.    Re: Icon user-community and Icon-project resources.
  7340.    
  7341.    Yes, indeed I do realize that you have limited resources.  In fact, I am
  7342.    amazed at how much you can get done, given your circumstances.  The help
  7343.    you offer your user community, and the quality of your implementations
  7344.    (few bugs) leads many, I would think, to treat Icon like a commercially-
  7345.    supported product.  The few bug-reports we see are often worded like com-
  7346.    plaints to a major software house about one of their top products!
  7347.    
  7348.    This is not to belittle Icon itself, mind you.  I suspect that, even if
  7349.    you people were less professional, Icon would still be useful to a lot
  7350.    of individuals.  Frankly, I have little knowledge of the theoretical is-
  7351.    sues that motivated Icon's development.  I use it because it is simple
  7352.    and powerful, and well-suited to text-manipulation.  Occasionally, I hear
  7353.    people complain that no decent debugger is available for it.  This gives
  7354.    me a chuckle, because I make such few errors when programming in Icon.
  7355.    Big programs I write often compile and run without serious error.  In C,
  7356.    on the other hand, I usually walk away from first-time tries at compiling
  7357.    programs, so that I don't have to watch the error messages that inevitably
  7358.    appear.
  7359.    
  7360.    One matter that came up in the context of this discussion, by the way, was
  7361.    the question of maintaining upward-compatibility.  I know that I, as many
  7362.    others, have some very large directories full of Icon programs that would
  7363.    be a pain to alter.  However, I would rather give you folks a free hand in
  7364.    developing the language in as elegant and consistent fashion as seems use-
  7365.    ful.  If you want to add a feature - say the limited application of dynamic
  7366.    variables, or something else that might present compatibility problems - I
  7367.    would rather that you did it than worry about miffing users.  After all, one
  7368.    of the joys of Icon right now is that it is not a commercial product.  It is,
  7369.    in a sense, still in development.  I feel very strongly that you people
  7370.    should be free to refine the language while its definition remains in your
  7371.    hands.
  7372.    
  7373.    If you think it appropriate (this I leave in your hands), please send a copy
  7374.    of this over to the Icon-group to be distributed.  I would be very interested
  7375.    in knowing whether others feel as I do.
  7376.    
  7377.                                                  -Richard L. Goerwitz
  7378.                                                  goer@sophist.uchicago.edu
  7379.                                                  !ihnp4!gargoyle!sophist!goer
  7380.    
  7381.  
  7382. ================================================================================
  7383.      Ralph Griswold / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  7384.      +1 602 621 6609   ralph@Arizona.EDU     {allegra|noao|ihnp4}!arizona!ralph
  7385.  
  7386.  
  7387. From icon-group-sender  Thu Apr 28 11:26:31 1988
  7388. Received: by bocklin.arizona.edu; Thu, 28 Apr 88 11:26:34 MST
  7389. Date: Thu, 28 Apr 88 11:25:29 MST
  7390. From: "David Gudeman" <gudeman>
  7391. Message-Id: <8804281825.AA10836@megaron.arizona.edu>
  7392. To: wgg@june.cs.washington.edu
  7393. Cc: icon-group
  7394. In-Reply-To: <8804280738.AA17065@june.cs.washington.edu>
  7395. Subject:  object oriented languages
  7396. Errors-To: icon-group-errors
  7397.  
  7398. This seems like a good time to admit that I'm really not that familiar
  7399. with the history of OO programming, so my belief that the term has
  7400. changed meaning is not that well-founded.  I'll accept your definition
  7401. with the proviso that my previous remarks about OO programming applied
  7402. to _my_ definition of the term.
  7403.  
  7404. One question though, your last message implied that "object oriented"
  7405. just means that the language has operator overloading, and the
  7406. hierarchical organization is not necessary.  This means that Algol68
  7407. is object oriented.  Is that right?
  7408.  
  7409. From icon-group-sender  Thu Apr 28 15:18:08 1988
  7410. Received: by bocklin.arizona.edu; Thu, 28 Apr 88 15:18:11 MST
  7411. From: Jeff Dalton <jeff%aiva.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK>
  7412. Date: Thu, 28 Apr 88 22:59:18 bst
  7413. Message-Id: <18285.8804282159@aiva.ed.ac.uk>
  7414. To: gudeman@arizona.edu
  7415. Subject: Re:  object oriented languages
  7416. Cc: icon-group@arizona.edu
  7417. Errors-To: icon-group-errors
  7418.  
  7419. > Date: Thu, 28 Apr 88 11:25:29 MST
  7420. > From: David Gudeman <gudeman@edu.arizona>
  7421. > Subject: object oriented languages
  7422. > One question though, your last message implied that "object oriented"
  7423. > just means that the language has operator overloading, and the
  7424. > hierarchical organization is not necessary.  This means that Algol68
  7425. > is object oriented.  Is that right?
  7426.  
  7427. Some (e.g., Peter Wegner in his OOPSLA '87 paper) say
  7428.  
  7429.      object-oriented = objects + classes + inheritance
  7430.  
  7431. I would say this is too restrictive.  Anyway, Algol 68 doesn't really
  7432. have objects, although heap allocated structures might do.
  7433.  
  7434. From icon-group-sender  Thu Apr 28 15:20:58 1988
  7435. Received: by bocklin.arizona.edu; Thu, 28 Apr 88 15:21:02 MST
  7436. Date: Thu, 28 Apr 88 15:19:13 PDT
  7437. From: wgg@june.cs.washington.edu (William Griswold)
  7438. Return-Path: <wgg@june.cs.washington.edu>
  7439. Message-Id: <8804282219.AA04623@june.cs.washington.edu>
  7440. To: icon-group@arizona.edu
  7441. Subject: Re: object-oriented Icon
  7442. Errors-To: icon-group-errors
  7443.  
  7444.  
  7445. A lot of the recent messages directed at me have concerned the nature
  7446. of object orientation, rather than of (object oriented) Icon.  In order 
  7447. to avoid flooding the network (and my mailbox!), there is a paper I can
  7448. recommend: 
  7449.  
  7450. L. Cardelli, P. Wegner, "On Understanding Types, Data Abstraction, and
  7451. Polymorphism", ACM Computing Surveys, Vol. 17, No. 4, Dec.  1985.
  7452.  
  7453. In my opinion, it is an excellent survey of the work in the areas of 
  7454. polymorphism and object orientation.  It is very readable, unlike some
  7455. stuff in this area.  They say it much better than I could, if less
  7456. succinctly. 
  7457.  
  7458.                         Bill Griswold
  7459.  
  7460. From icon-group-sender  Thu Apr 28 15:30:24 1988
  7461. Received: by bocklin.arizona.edu; Thu, 28 Apr 88 15:30:28 MST
  7462. From: ihnp4!ihuxy!nowlin
  7463. Message-Id: <8804282230.AA28219@megaron.arizona.edu>
  7464. Message-Version: 2
  7465. >To: /addr=ihnp4!arizona!icon-group
  7466. Date: Thu 28 Apr 1988 17:05 CDT
  7467. End-Of-Header: 
  7468. Email-Version: 2
  7469. X-Postmark: jerry.d.nowlin attrd ix1c461 55621 3129790441 ihuxy!nowlin
  7470. To: arizona!icon-group
  7471. Subject: Re: object oriented Icon
  7472. Ua-Message-Id: <post.nowlin.Thu 28 Apr 1988 16:41 CDT>
  7473. End-Of-Protocol: 
  7474. Content-Length: 1497
  7475. Errors-To: icon-group-errors
  7476.  
  7477. I know less about OOP then I care to let on...but.  It would seem to me
  7478. that Icon already lends itself to this kind of programming without even
  7479. adding anything to the language.
  7480.  
  7481. I've written programs that manipulate lists of records that contains fields
  7482. that are additional lists or procedures to operate on other fields in the
  7483. records.  By careful programming you can have values in a list take
  7484. advantage of other values in the same list or of values in the list that
  7485. contains the list their in.  This same scheme can be carried on as many
  7486. levels deep as you want to go.
  7487.  
  7488. The difficulty is in knowing about the list you're a member of.  It is not
  7489. by any means automatic.  This makes schemes like inheritance difficult to
  7490. implement but not impossible and certainly much easier than with languages
  7491. like ordinary C.
  7492.  
  7493. I have a feeling from my C++ experience (minimal) that there aren't may
  7494. things I would want to do in C++ instead of Icon either.  Even if the tasks
  7495. really fit the C++ model well.  Icon is just much more intuitive to
  7496. formulate solutions with and certainly easier to program in.
  7497.  
  7498. If you concentrate on the "object" in OOP, Icon has all the data types you
  7499. need to get started.  Adding built-ins to make inheritance more intuitive
  7500. (like C++) would be nice but I get by.  Some of the other things about C++
  7501. are more like bells&whistles then real necessities of OOP.  For example,
  7502. constructors and destructors are nice but are they needed for OOP?
  7503.  
  7504. Jerry Nowlin
  7505. (...!ihnp4!ihuxy!nowlin)
  7506.  
  7507. From icon-group-sender  Fri Apr 29 03:19:02 1988
  7508. Received: by bocklin.arizona.edu; Fri, 29 Apr 88 03:19:06 MST
  7509. Date: Fri, 29 Apr 88 11:15:48 BST
  7510. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - Sun UK TSE)
  7511. Message-Id: <8804291015.AA00553@stevie.nuksun.uucp>
  7512. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  7513. Subject: Re: object oriented Icon
  7514. Errors-To: icon-group-errors
  7515.  
  7516. "David Gudeman" <sunuk!sun!arizona.edu!gudeman> wrote:
  7517.  
  7518. > I still have faith that it is possible to design a language that is
  7519. > really good for everything
  7520.  
  7521. Well, how about English?  If we can't achieve a satisfactory universal
  7522. for direct person-person communications do we stand any chance in the
  7523. world of programming languages?  Then there are the questions of taste
  7524. in  progr am m ing style, etc.
  7525.  
  7526. [Sorry, my spacekey                                 just         started
  7527. to jam,i"ll      g et    back tothis    later!!!!!]
  7528.  
  7529. Steve
  7530.  
  7531. From icon-group-sender  Fri Apr 29 11:26:55 1988
  7532. Received: by bocklin.arizona.edu; Fri, 29 Apr 88 11:26:57 MST
  7533. Date: Fri, 29 Apr 88 11:26:51 MST
  7534. From: "David Gudeman" <gudeman>
  7535. Message-Id: <8804291826.AA19979@megaron.arizona.edu>
  7536. To: icon-group
  7537. In-Reply-To: <8804291015.AA00553@stevie.nuksun.uucp>
  7538. Subject: object oriented Icon
  7539. Errors-To: icon-group-errors
  7540.  
  7541. The analogy with English is not good for three reasons.  First English
  7542. was not designed, it evolved.  Second, English is not a formal system
  7543. with fixed rules for using it (yes, they be rules, but them rules if
  7544. freely violated, they do prevent not the understanding). Third,
  7545. English is used for more complex purposes than programming.
  7546.  
  7547. The last point prompts me to make the following restriction to my
  7548. earlier claim that
  7549.  
  7550.     > I still have faith that it is possible to design a language that
  7551.     > is really good for everything
  7552.  
  7553. "Everything" here means everything that universal programming
  7554. languages are typicaly used for.  It is not practical to ask a single
  7555. programming language to do everything that computers can do.
  7556.  
  7557. From icon-group-sender  Fri Apr 29 16:59:42 1988
  7558. Received: by bocklin.arizona.edu; Fri, 29 Apr 88 16:59:46 MST
  7559. Date: 29 Apr 88 03:17:25 GMT
  7560. From: cjeffery@arizona.edu  (Clinton Jeffery)
  7561. Organization: U of Arizona CS Dept, Tucson
  7562. Subject: Re:  object oriented languages
  7563. Message-Id: <5243@megaron.arizona.edu>
  7564. References: <8804280738.AA17065@june.cs.washington.edu>
  7565. Sender: icon-group-request@arizona.edu
  7566. To: icon-group@arizona.edu
  7567. Errors-To: icon-group-errors
  7568.  
  7569. From article <8804280738.AA17065@june.cs.washington.edu>, by wgg@june.cs.washington.EDU (Manu Dibango):
  7570. > There needn't be any relationship between the thought model and
  7571. > the implementation (as long as you don't run into inconsistencies). 
  7572.  
  7573. I just want to repeat one beautiful sentence from an excellent article.
  7574. As long as I can write "x+3", and get an ADD.L instruction, I want as
  7575. much support for abstractions as I can get!  Now, what I really want to
  7576. know, Bill, is: WHO IS MANU DIBANGO?!
  7577.  
  7578. Clint Jeffery
  7579. -- 
  7580. | Clint Jeffery, University of Arizona Department of Computer Science
  7581. | cjeffery@arizona.edu -or- {ihnp4 noao}!arizona!cjeffery
  7582. --
  7583.  
  7584. From icon-group-sender  Sun May  1 14:51:49 1988
  7585. Received: by bocklin.arizona.edu; Sun, 1 May 88 14:51:52 MST
  7586. Date: 1 May 88 00:24:09 GMT
  7587. From: mccarrol@topaz.rutgers.edu  (Mark C. Carroll <mccarrol@topaz.rutgers.edu>)
  7588. Organization: Rutgers Univ., New Brunswick, N.J.
  7589. Subject: Re: object oriented Icon
  7590. Message-Id: <Apr.30.20.23.56.1988.27451@topaz.rutgers.edu>
  7591. References: <8804271536.AA04688@eos.arc.nasa.gov>
  7592. Sender: icon-group-request@arizona.edu
  7593. To: icon-group@arizona.edu
  7594. Errors-To: icon-group-errors
  7595.  
  7596. This is in response to someone basically stating that they don't like
  7597. object oriented programming as a general purpose framework. I just
  7598. want to preface this with the fact that I have NEVER used an OOL. I've
  7599. read quite a lot about them, and consider them a wonderful idea, but I
  7600. may have severe misconceptions. Please correct me if I foul up. On
  7601. to my comments:
  7602.  
  7603. ]             I know people who have found Smalltalk
  7604. ]]ideal for modeling physical systems made up of components which
  7605. ]communicate by sending and receiving messages.  But evaluating
  7606. ]3+5 by sending the message "add 5" to the object 3? 
  7607.  
  7608.     I think you've missed to whole idea of object oriented
  7609. programming. The real idea isn't that you evaluate 3+5 by sending
  7610. the message "add 5" to 3. It's that no matter WHAT type 3 and 5 are,
  7611. you can ALWAYS use +. The beauty of OOLs is the fact that types are
  7612. not quite as "significant" ( Wrong word I know, but it gets my general
  7613. idea across). As an example, look at sorting. We'll use the < operator
  7614. rather than +. I can write a simple sort procedure in an OOL, and the
  7615. SAME code will work for integers, strings, cardinals, floats, and just
  7616. about anything else where I define the < comparison. The advantage
  7617. isn't because it's sending a comparison message, it's because the
  7618. comparison function to the data type, so I can use it on ANY data type
  7619. with the comparison function bound to it.
  7620.  
  7621. ] I repeat, it's
  7622. ]not my goal to start a debate on the merits of Smalltalk, but
  7623. ]personally I don't consider it a general-purpose programming
  7624. ]language.
  7625. ]
  7626.     I don't know if smalltalk is a good GP language. I expect it
  7627. is NOT. But some aspects of it's philosophy are certainly useful for
  7628. nearly any application. I honestly can't think of any situation where
  7629. it would become a disadvantage to have the ability to bind function
  7630. calls to data types, which is what I see as the primary advantage of
  7631. OOLs.
  7632.  
  7633.  
  7634. ]Mike Shafto
  7635.  
  7636.         <MC>
  7637.  
  7638.     by the way, how do I send followups to comp.lang.misc? That's
  7639. where they belong, but I honestly don't know how. Sorry!
  7640. -- 
  7641. <MC>=Mark C. Carroll,Rutgers CS Student| I won't wear your white feather
  7642. mail to: ARPA: CARROLL@AIM.RUTGERS.EDU | I won't carry your white flag
  7643.    UUCP: mccarrol@topaz.rutgers.edu    | I will swear to have no nation
  7644.    (backbone)!rutgers!topaz!mccarrol   | But I'm PROUD to hold MY heart
  7645.  
  7646. From icon-group-sender  Sun May  1 23:11:33 1988
  7647. Received: by bocklin.arizona.edu; Sun, 1 May 88 23:11:38 MST
  7648. Date: Sun, 1 May 88 23:10:55 MST
  7649. From: "David Gudeman" <gudeman>
  7650. Message-Id: <8805020610.AA27944@megaron.arizona.edu>
  7651. To: mccarrol@topaz.rutgers.edu
  7652. Cc: icon-group@arizona.edu
  7653. In-Reply-To: mccarrol@topaz.rutgers.edu  (Mark C. Carroll's message of 1 May 88 00:24:09 GMT <Apr.30.20.23.56.1988.27451@topaz.rutgers.edu>
  7654. Subject: object oriented Icon
  7655. Errors-To: icon-group-errors
  7656.  
  7657.    From: Mark C. Carroll
  7658.  
  7659.    This is in response to someone basically stating that they don't like
  7660.    object oriented programming as a general purpose framework...
  7661.  
  7662.        I think you've missed to whole idea of object oriented
  7663.    programming. The real idea isn't that you evaluate 3+5 by sending
  7664.    the message "add 5" to 3. It's that no matter WHAT type 3 and 5 are,
  7665.    you can ALWAYS use +.
  7666.  
  7667. I think this is exactly the problem.  The term "object oriented" seems
  7668. to imply more than just a hierarchy of types and operator overloading,
  7669. so a lot of people (including myself) assume that it refers to the
  7670. message-passing paradigm.  Obviously most people _are_ only refering
  7671. to the type organization and operator overloading, so those of us who
  7672. take things too literally will just have to adjust.  I have always
  7673. prefered operator overloading to Icon's multiple operators, but Ralph
  7674. Griswold feels otherwise (or did when Icon was designed).
  7675.  
  7676.    ... I honestly can't think of any situation where it would become a
  7677.    disadvantage to have the ability to bind function calls to data
  7678.    types...
  7679.  
  7680. This would be a disadvantage is if the _only_ way to create a function
  7681. is to make it part of a data type, but Bill said he doesn't intend to
  7682. do this.
  7683.  
  7684.    ... by the way, how do I send followups to comp.lang.misc? That's
  7685.    where they belong, but I honestly don't know how. Sorry! 
  7686.  
  7687. Normally I would agree, but there is so little traffic on this group
  7688. that I really don't think anyone will complain if the discussion goes
  7689. a little far afield.
  7690.  
  7691. From icon-group-sender  Sun May  1 23:26:19 1988
  7692. Received: by bocklin.arizona.edu; Sun, 1 May 88 23:26:22 MST
  7693. Date: Sun, 1 May 88 23:26:17 MST
  7694. From: "David Gudeman" <gudeman>
  7695. Message-Id: <8805020626.AA28525@megaron.arizona.edu>
  7696. To: icon-group
  7697. In-Reply-To: <8805020610.AA27944@megaron.arizona.edu>
  7698. Subject: Icon group
  7699. Errors-To: icon-group-errors
  7700.  
  7701.    Date: Sun, 1 May 88 23:10:55 MST
  7702.    From: "David Gudeman" <gudeman>
  7703.  
  7704. (Yes, I'm replying to my own message.  Something I said struck a
  7705. chord, probably because I think a lot like myself.  Also, I talk too
  7706. much.)
  7707.  
  7708. >  ... there is so little traffic on this group that I really don't
  7709. >  think anyone will complain if the discussion goes a little far
  7710. >  afield.
  7711.  
  7712. Which brings up an interesting point.  Why is there so little traffic
  7713. on this group?  Surely it's not because there isn't much to say about
  7714. Icon.  The Icon-project gets a lot of mail that would be interesting
  7715. to Icon group, why isn't it sent there?  A lot of people are doing
  7716. interesting work in Icon that I would like to hear about, and a lot of
  7717. people are doing research on Icon that I would like to hear about.  So
  7718. far Bill Griswold is the only one who has really talked about research
  7719. in this forum.
  7720.  
  7721. I thought it showed a lot of guts, leaving himself wide open for a
  7722. thousand suggestions about how to do Object Oriented Icon.  He got a
  7723. few, but I would have liked to see more (whether Bill wanted to see
  7724. more is an open question).
  7725.  
  7726. From icon-group-sender  Wed May  4 04:08:35 1988
  7727. Received: by bocklin.arizona.edu; Wed, 4 May 88 04:08:41 MST
  7728. From: Gordon Joly <gcj%maths.qmc.ac.uk@NSS.Cs.Ucl.AC.UK>
  7729. Date: Wed, 4 May 88 09:35:28 BST
  7730. Message-Id: <6888.8805040835@qmcms.maths.qmc.ac.uk>
  7731. To: cjeffery@arizona.edu, icon-group@arizona.edu
  7732. Subject: Re:  object oriented languages
  7733. Errors-To: icon-group-errors
  7734.  
  7735. >
  7736. >                                             Now, what I really want to
  7737. >know, Bill, is: WHO IS MANU DIBANGO?!
  7738. >
  7739. >Clint Jeffery
  7740. >-- 
  7741. >| Clint Jeffery, University of Arizona Department of Computer Science
  7742. >| cjeffery@arizona.edu -or- {ihnp4 noao}!arizona!cjeffery
  7743. >--
  7744. >
  7745. To the list and Clint,
  7746. A musician of note, of course.
  7747. Gordon Joly.
  7748.  
  7749. From icon-group-sender  Fri May  6 04:43:22 1988
  7750. Received: by bocklin.arizona.edu; Fri, 6 May 88 04:43:25 MST
  7751. Return-Path: <goer@sophist.uchicago.edu>
  7752. Date: Fri, 6 May 88 05:25:34 CDT
  7753. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  7754. Message-Id: <8805061025.AA03273@sophist.uchicago.edu>
  7755. To: icon-group@arizona.edu
  7756. Subject: user-defined control-structures
  7757. Errors-To: icon-group-errors
  7758.  
  7759. Thanks to everyone who posted on coroutines.  The prime number sieve was the
  7760. most useful.  After reading it, and then the explanation that came a week or
  7761. so later, I went out and started using coroutines as if I had been using them
  7762. from the very beginning.  I can't see how I lived without them!
  7763.  
  7764. Now I have another query:  How is it exactly that one defines ones own control
  7765. structures?  There is a technical report out on this, I know.  Does someone
  7766. have some simple examples of how these can be of use in everyday programming?
  7767.  
  7768. Last query:  Has anyone ever toyed with the idea of having entire loop-struc-
  7769. tures return values (the last value produced before termination either by
  7770. failure of the expression or by a break or return expression)?
  7771.  
  7772.                                                   -Richard L. Goerwitz
  7773.                                                   goer@sophist.uchicago.edu
  7774.                                                   !ihnp4!gargoyle!sophist!goer
  7775.  
  7776. From icon-group-sender  Fri May  6 13:20:15 1988
  7777. Received: by bocklin.arizona.edu; Fri, 6 May 88 13:20:18 MST
  7778. Date: Fri, 6 May 88 13:20:13 MST
  7779. From: ihnp4!ihlpf!nevin1
  7780. Message-Id: <8805062020.AA20810@megaron.arizona.edu>
  7781. To: arizona!icon-group
  7782. Subject: C++ and Icon (was: object oriented Icon)
  7783. Errors-To: icon-group-errors
  7784.  
  7785. With all this talk of adding object-oriented extensions to Icon, let me
  7786. propose a different approach.
  7787.  
  7788. Since C++ is already an object-oriented language (I really don't want
  7789. to get into the debate on whether this is true or not; for this
  7790. discusssion, please assume that it is), why not start out by adding
  7791. Icon extensions to C++ (starting with the Icon types and defining the
  7792. operators so that they act as close to Icon as possible).  We would
  7793. then have a language which is like Icon and also allows object-oriented
  7794. features such as data abstraction and encapsulation.
  7795.  
  7796. I do realize that all of the Icon features cannot easily be
  7797. incorporated into C++ (generators, for example, would probably be very
  7798. tough to implement, although I know that Tim Budd did a little research
  7799. into adding them to C.  Personally, I would hate to give up this
  7800. feature), but this would allow us a rather straight forward way of
  7801. seeing whether or not the object-oriented programming paradigm would be
  7802. a useful extension to Icon.  If it is, we can then propose a useful
  7803. syntax for adding it to Icon.  If not, maybe all those people who
  7804. really want Icon compilers would be able to use the Icon extensions in
  7805. C++ as a substitute.
  7806.  
  7807. -- 
  7808.  _ __            NEVIN J. LIBER    ..!ihnp4!ihlpf!nevin1    (312) 510-6194
  7809. ' )  )                "The secret compartment of my ring I fill
  7810.  /  / _ , __o  ____         with an Underdog super-energy pill."
  7811. /  (_</_\/ <__/ / <_    These are solely MY opinions, not AT&T's, blah blah blah
  7812.  
  7813.  
  7814.  
  7815.  
  7816. From icon-group-sender  Fri May  6 14:09:49 1988
  7817. Received: by bocklin.arizona.edu; Fri, 6 May 88 14:09:52 MST
  7818. Date: Fri, 6 May 88 14:04:53 PDT
  7819. From: wgg@june.cs.washington.edu (William Griswold)
  7820. Return-Path: <wgg@june.cs.washington.edu>
  7821. Message-Id: <8805062104.AA27041@june.cs.washington.edu>
  7822. To: icon-group@arizona.edu
  7823. Subject: Re:  C++ and Icon (was: object oriented Icon)
  7824. Errors-To: icon-group-errors
  7825.  
  7826.  
  7827. This message is in response to:
  7828.     From: ihnp4!ihlpf!nevin1@arizona.edu
  7829.     Date: Fri, 6 May 88 13:20:13 MST
  7830.  
  7831.     Since C++ is already an object-oriented language (...), why not start
  7832.     out by adding Icon extensions to C++ (starting with the Icon types
  7833.     and defining the operators so that they act as close to Icon as
  7834.     possible).  We would then have a language which is like Icon and also
  7835.     allows object-oriented features such as data abstraction and 
  7836.     encapsulation. 
  7837.  
  7838.     I do realize that all of the Icon features cannot easily be 
  7839.     incorporated into C++ (generators, for example, would probably be
  7840.     very tough to implement, although I know that Tim Budd did a little
  7841.     research into adding them to C.  Personally, I would hate to give up
  7842.     this feature), but this would allow us a rather straight forward way
  7843.     of seeing whether or not the object-oriented programming paradigm
  7844.     would be a useful extension to Icon.  If it is, we can then propose a
  7845.     useful syntax for adding it to Icon.  If not, maybe all those people
  7846.     who really want Icon compilers would be able to use the Icon
  7847.     extensions in C++ as a substitute. 
  7848.  
  7849. I'm afraid that Icon is sufficiently different from C++ that you
  7850. would not find it worthwhile to get C++ to do things the Icon way. 
  7851. It's not just generators, but the entire expression evaluation
  7852. mechanism of Icon that would need to be implemented.  Before
  7853. considering doing this, consider implementing PROLOG expression
  7854. evaluation in C++, or LISP's LAMBDA expressions. 
  7855.  
  7856. There are many avenues for trying OO in Icon.  I have a number of
  7857. techniques that would take a day or so, one or two that would take a
  7858. week, and a complete implementation that would take longer.  I feel
  7859. no need to prototype in C++, when I can prototype in Icon so easily
  7860. (having garbage collection, dynamic typing, fast compilation,
  7861. tracing, expression stack dumps, etc.).  The presence of the variant
  7862. translator facility distributed with Icon also makes Icon an attractive
  7863. place to prototype.
  7864.  
  7865. I'll stick my neck out and say some enhancement of the encapsulation
  7866. and abstraction mechanisms in Icon *must* be a useful addition. 
  7867. These are intellectual mechanisms that are thousands of years old and
  7868. used in numerous disciplines.  OO is one manifestation (and one of
  7869. the most general) of such mechanisms in programming languages. 
  7870.  
  7871. For these reasons I see no reason to not work directly with Icon.  I 
  7872. should mention that the techniques used in the implementation of C++ 
  7873. are familier to me, and would be used in part in any design and
  7874. implementation of an OO Icon that I would undertake. 
  7875.  
  7876. Thanks again for all your input!
  7877.  
  7878.                     Bill Griswold
  7879.  
  7880.  
  7881. From icon-group-sender  Fri May  6 14:10:44 1988
  7882. Received: by bocklin.arizona.edu; Fri, 6 May 88 14:10:47 MST
  7883. Date: Fri, 6 May 88 14:10:36 MST
  7884. From: "Kenneth Walker" <kwalker>
  7885. Message-Id: <8805062110.AA24615@megaron.arizona.edu>
  7886. In-Reply-To: <8805062020.AA20810@megaron.arizona.edu>
  7887. To: icon-group
  7888. Subject: Re:  C++ and Icon (was: object oriented Icon)
  7889. Errors-To: icon-group-errors
  7890.  
  7891.     Date: Fri, 6 May 88 13:20:13 MST
  7892.     From: ihnp4!ihlpf!nevin1
  7893.     
  7894.         ...
  7895.  
  7896.     why not start out by adding
  7897.     Icon extensions to C++ (starting with the Icon types and defining the
  7898.     operators so that they act as close to Icon as possible).  We would
  7899.     then have a language which is like Icon and also allows object-oriented
  7900.     features such as data abstraction and encapsulation.
  7901.     
  7902.     I do realize that all of the Icon features cannot easily be
  7903.     incorporated into C++ (generators, for example, would probably be very
  7904.     tough to implement, although I know that Tim Budd did a little research
  7905.     into adding them to C.
  7906.  
  7907. Without generators (or something similar to produce alternates) goal directed
  7908. evaluation makes no sense. To my mind, goal directed evaluation, generators,
  7909. and the accompanying control structures are the heart of Icon. It is true
  7910. that many peaple use Icon because of its high level data structures
  7911. and automatic memory management, but these are not the features which
  7912. realy distinguish Icon from other languages.
  7913.  
  7914. I don't know much about C++; I suspect it would be useful to add
  7915. high level data structures to it. However, I am more excited in
  7916. seeing what happens when data abstraction and encapsulation are added
  7917. to Icon with it generators and control stratagies.
  7918.  
  7919.      Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  7920.      +1 602 621 2858  kwalker@Arizona.EDU   {allegra|noao|ihnp4}!arizona!kwalker
  7921.  
  7922. From icon-group-sender  Fri May  6 19:34:30 1988
  7923. Received: by bocklin.arizona.edu; Fri, 6 May 88 19:34:33 MST
  7924. Date: Fri, 6 May 88 19:22:34 mst
  7925. From: naucse!sbw (Steve Wampler)
  7926. Message-Id: <8805070222.AA25364@naucse>
  7927. To: arizona!icon-group
  7928. Errors-To: icon-group-errors
  7929.  
  7930. Subject: Re:  C++ and Icon (was: object oriented Icon)
  7931.  
  7932. Just to muddy the waters...
  7933.  
  7934. A long time ago I looked at, and a friend of mine briefly implemented
  7935. a facility called 'procs' - a procedure that shared the environment
  7936. of the defining procedure (i.e. procs were constructed inside of
  7937. procedures).  They had some utility (not much, however) - for one thing,
  7938. they could be treated as an abstraction of a thunk and used to implement
  7939. pass-by-name parameter passing techniques (much as the &x operator
  7940. in C can be treated as an abstraction of pass-by-reference).
  7941.  
  7942. However, the implementation was never developed to the point it could
  7943. have been.
  7944.  
  7945. Now, suppose one extended the idea so that the environment of the
  7946. defining procedure existed as long as the procs it defined did.
  7947. Presto, encapsulation, internal abstract data types, etc.  For example,
  7948. here's a (loosely implemented) stack:
  7949.  
  7950.     procedure new_stack()
  7951.            local stack_store, push_proc, pop_proc
  7952.  
  7953.            stack_store := []    # implement internally as a list
  7954.  
  7955.            push_proc := proc(value) {    # pardon the syntax
  7956.                            push(stack_store,value)
  7957.                            }
  7958.            pop_proc  := proc() {
  7959.                            return pop(stack_store)
  7960.                            }
  7961.            return [push_proc,pop_proc]
  7962.     end
  7963.  
  7964. One could create stacks then with:  (sorry about the names)
  7965.  
  7966.     next_stack := new_stack()
  7967.     stack_1_push := next_stack[1]
  7968.     stack_1_pop  := next_stack[2]
  7969.  
  7970.     next_stack := new_stack()
  7971.     stack_2_push := next_stack[1]
  7972.     stack_2_pop  := next_stack[2]
  7973.  
  7974. Or some such nonsense.  I suspect that reimplementing procs (aside
  7975. from syntactic arguments) is really just a matter of diddling a bit
  7976. with the code for implementing co-expressions, but then again everything
  7977. seems easy Friday evening.
  7978.  
  7979. From icon-group-sender  Sat May  7 07:41:47 1988
  7980. Received: by bocklin.arizona.edu; Sat, 7 May 88 07:41:50 MST
  7981. Date: 6 May 88 17:58:53 GMT
  7982. From: ihnp4!ihlpf!nevin1@ucbvax.Berkeley.EDU  (00704a-Liber)
  7983. Organization: AT&T Bell Laboratories - Naperville, Illinois
  7984. Subject: C++ and Icon (was: object oriented Icon)
  7985. Message-Id: <4672@ihlpf.ATT.COM>
  7986. References: <8804282230.AA28219@megaron.arizona.edu>
  7987. Sender: icon-group-request@arizona.edu
  7988. To: icon-group@arizona.edu
  7989. Errors-To: icon-group-errors
  7990.  
  7991. With all this talk of adding object-oriented extensions to Icon, let me
  7992. propose a different approach.
  7993.  
  7994. Since C++ is already an object-oriented language (I really don't want
  7995. to get into the debate on whether this is true or not; for this
  7996. discusssion, please assume that it is), why not start out by adding
  7997. Icon extensions to C++ (starting with the Icon types and defining the
  7998. operators so that they act as close to Icon as possible).  We would
  7999. then have a language which is like Icon and also allows object-oriented
  8000. features such as data abstraction and encapsulation.
  8001.  
  8002. I do realize that all of the Icon features cannot easily be
  8003. incorporated into C++ (generators, for example, would probably be very
  8004. tough to implement, although I know that Tim Budd did a little research
  8005. into adding them to C.  Personally, I would hate to give up this
  8006. feature), but this would allow us a rather straight forward way of
  8007. seeing whether or not the object-oriented programming paradigm would be
  8008. a useful extension to Icon.  If it is, we can then propose a useful
  8009. syntax for adding it to Icon.  If not, maybe all those people who
  8010. really want Icon compilers would be able to use the Icon extensions in
  8011. C++ as a substitute.
  8012.  
  8013. -- 
  8014.  _ __            NEVIN J. LIBER    ..!ihnp4!ihlpf!nevin1    (312) 510-6194
  8015. ' )  )                "The secret compartment of my ring I fill
  8016.  /  / _ , __o  ____         with an Underdog super-energy pill."
  8017. /  (_</_\/ <__/ / <_    These are solely MY opinions, not AT&T's, blah blah blah
  8018.  
  8019. From icon-group-sender  Sat May  7 16:10:05 1988
  8020. Received: by bocklin.arizona.edu; Sat, 7 May 88 16:10:10 MST
  8021. Date: Sat, 7 May 88 16:04:25 PDT
  8022. From: wgg@june.cs.washington.edu (William Griswold)
  8023. Return-Path: <wgg@june.cs.washington.edu>
  8024. Message-Id: <8805072304.AA09918@june.cs.washington.edu>
  8025. To: icon-group@arizona.edu
  8026. Subject: Re:  encapsulation with "procs"
  8027. Errors-To: icon-group-errors
  8028.  
  8029.  
  8030. Sbw's use of procs to implement encapsulation is very similar to the way
  8031. modern lisps such as T implement their version of object orientation.
  8032. This is enhanced by the availability of lambda expressions, suggesting
  8033. that the "unevaluated expression" facility in Ken Walker's Icon variant
  8034. could be useful in this regard (as a generalization of procs).  
  8035. There are more angles to this OO thing than I had anticipated!
  8036.  
  8037.                     Bill Griswold
  8038.  
  8039. From icon-group-sender  Mon May  9 11:33:53 1988
  8040. Received: by bocklin.arizona.edu; Mon, 9 May 88 11:33:59 MST
  8041. Date: Mon, 9 May 88 10:52:00 BST
  8042. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - Sun UK TSE)
  8043. Message-Id: <8805090952.AA09263@stevie.nuksun.uucp>
  8044. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  8045. Subject: Object Orientation
  8046. Errors-To: icon-group-errors
  8047.  
  8048. There are object-oriented _languages_, and object-oriented _systems_.
  8049. I would put Simula in the former category (a fixed set of classes
  8050. can be used in a program in which they are defined), and Smalltalk-80
  8051. in the latter (it has not only encapsulation of procedures within
  8052. "packages" and property inheritance to offer subclassing, as does
  8053. Simula, it also contains the ability for run-time refinement of the
  8054. class hierarchy and is therefore capable of compiling programs).
  8055.  
  8056. Surely a weakness of Icon is its inability to create expressions
  8057. dynamically, unless anyone has got up to devious tricks I know nothing
  8058. of.
  8059.  
  8060. An object-oriented system needs to be able to create dynamic procedure
  8061. bindings, and to create data objects with procedural values which can
  8062. then be executed at a later date [or perhaps millisecond].  Given an
  8063. execution abstraction based on a stack, however, it would be possible
  8064. to create a minimal set if co-expressions to perform each Icon
  8065. operation on a global stack.  It would then be possible to "compile" an
  8066. expression into a list of co-expressions which operated sequentially on
  8067. the stack.
  8068.  
  8069. Object-orientation should, in my opinion, be addable to any language
  8070. with "extensible" data structures [Icon tables, PostScript dictionaries]
  8071. and the ability to store "expression values" [Icon co-expressions,
  8072. PostScript procs].  However, the syntax would not necessarily most
  8073. effectively be that of the underlying implementation language.  In an
  8074. environment with dynamic procedure binding message-passing somehow seems
  8075. the natural way to establish communications between objects, but I can't
  8076. see how message sending would fit into the current syntax.
  8077.  
  8078. I quote the PostScript parallels because of the (so-called) object-
  8079. oriented extensions Sun have provided, implemented in PostScript, as a
  8080. part of the NeWS system.  Postscript's being an interpreted language
  8081. makes it much easier to add the required abstractions to implement an
  8082. object-oriented system rather than simply a language.  This overcomes the
  8083. restrictions on richness imposed by the static nature of the class
  8084. hierarchy in compiled langauges such as Simula or C++.
  8085.  
  8086. To be fair I should point out that not everybody accepts these
  8087. extensions as a "good thing", and there seems to be some feeling that
  8088. production  graphics languages should leave "fancy tricks" to hard-core
  8089. experimental languages [such as Icon?].  Personally I do not regard this
  8090. as a religious discussion.
  8091.  
  8092.  
  8093. Steve Holden                    sholden@sun.com
  8094.                         sholden@{sun,sunuk}.uucp
  8095. "everything seems easy Friday evening."    [Steve Wampler]
  8096.  
  8097.  
  8098. From icon-group-sender  Mon May  9 17:32:41 1988
  8099. Received: by bocklin.arizona.edu; Mon, 9 May 88 17:32:44 MST
  8100. Return-Path: <goer@sophist.uchicago.edu>
  8101. Date: Mon, 9 May 88 18:42:34 CDT
  8102. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  8103. Message-Id: <8805092342.AA07866@sophist.uchicago.edu>
  8104. To: icon-group@arizona.edu
  8105. Subject: user-defined control structures
  8106. Errors-To: icon-group-errors
  8107.  
  8108. I don't remember if I posted on this or not.  If I did, then many apologies.
  8109. I owe many thanks to the folks who offered examples of using coexpressions to
  8110. do coroutines.  After reading a few letters, I now feel quite comfortable with
  8111. them, and in fact can't see how I lived without them.
  8112.  
  8113. Has anyone made any use of the capability Icon offers for user-defined control
  8114. structures, using the alternate call syntax p{} ?  If so, maybe a word or tow
  8115. could be offered to the group on this subject.
  8116.  
  8117.                                                   -Richard L. Goerwitz
  8118.                                                   goer@sophist.uchicago.edu
  8119.                                                   !ihnp4!gargoyle!sophist!goer
  8120.  
  8121. From icon-group-sender  Mon May  9 17:32:44 1988
  8122. Received: by bocklin.arizona.edu; Mon, 9 May 88 17:32:48 MST
  8123. Return-Path: <goer@sophist.uchicago.edu>
  8124. Date: Mon, 9 May 88 18:34:39 CDT
  8125. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  8126. Message-Id: <8805092334.AA07855@sophist.uchicago.edu>
  8127. To: icon-group@arizona.edu
  8128. Subject: creating expressions & procedures on the fly
  8129. Errors-To: icon-group-errors
  8130.  
  8131. Just a few loose bits of information that might be relevant:
  8132.  
  8133. We have seen a few hints about an experimental feature whereby one could
  8134. create procedures more elegantly at run-time ("expression data-type" or some-
  8135. thing).  I don't recall exactly, and if I say more than this, I'll end up dis-
  8136. playing my ignorance for everyone in the group.  Besides, as I understand the
  8137. situation, there are no plans to implement it.  Maybe Ken Walker would be kind
  8138. enough to explain the issues involved here (he once wrote to me about it, but
  8139. I can't find the letter just now).
  8140.  
  8141. You know, I was hoping to use the new call-by-string facility to have Icon
  8142. programs that essentially extend themselves.  However, the feature seems to
  8143. have been written more to facilitate writing other languages in Icon than
  8144. to allow for Lisp-like self-extension.  I wonder how difficult it would be
  8145. to generalize the call-by-string function to help interconnect programs and
  8146. data.  Or would this end up being a useless kludge?
  8147.  
  8148.                                                   -Richard L. Goerwitz
  8149.                                                   goer@sophist.uchicago.edu
  8150.                                                   !ihnp4!gargoyle!sophist!goer
  8151.  
  8152. From icon-group-sender  Tue May 10 15:01:33 1988
  8153. Received: by bocklin.arizona.edu; Tue, 10 May 88 15:01:37 MST
  8154. Date: Tue, 10 May 88 14:40:34 MST
  8155. From: "Kenneth Walker" <kwalker>
  8156. Message-Id: <8805102140.AA08117@megaron.arizona.edu>
  8157. In-Reply-To: <8805092334.AA07855@sophist.uchicago.edu>
  8158. To: icon-group
  8159. Subject: Re:  creating expressions & procedures on the fly
  8160. Errors-To: icon-group-errors
  8161.  
  8162. > Date: Mon, 9 May 88 18:34:39 CDT
  8163. > From: Richard Goerwitz <goer@sophist.uchicago.edu>
  8164. > We have seen a few hints about an experimental feature whereby one could
  8165. > create procedures more elegantly at run-time ("expression data-type" or some-
  8166. > thing).  I don't recall exactly, and if I say more than this, I'll end up dis-
  8167. > playing my ignorance for everyone in the group.  Besides, as I understand the
  8168. > situation, there are no plans to implement it.  Maybe Ken Walker would be kind
  8169. > enough to explain the issues involved here (he once wrote to me about it, but
  8170. > I can't find the letter just now).
  8171.  
  8172. Actually 2 versions of this feature have been implemented in an experimental
  8173. version of Icon (there is presently no plan to put it in a released
  8174. version of Icon, though). The first version is described in the U of A
  8175. Technical Report TR 86-20 "An Expression Data Type for Icon". The 2nd
  8176. version is a merger with co-expressions, called c-expressions.
  8177.  
  8178. A c-expression is very much like a co-expression, except that instead of
  8179. making private copies of local variables, it actually share these
  8180. variables with the procedure creating it. For those of you familiar
  8181. with language implementation techniques, this means that procedure frames
  8182. mush be heap allocated instead of stack allocated, so that local variables
  8183. can outlive the procedure invocation (the c-expression can be put in a
  8184. global variable or returned from the procedure). For programs doing a lot
  8185. of procedure calls this can increase the amount of garbage collection. 
  8186. This problem is familiar to Lisp implementors (because of closures) and
  8187. there are techniques for determining when a procedure frame can safely
  8188. be stack allocated in a language containing this type of feature.
  8189. However, I never got around to using such a technique with c-expressions.
  8190.  
  8191. Another differnece is that c-expressions do not support value transmition,
  8192. they only support the unary form of @. I don't think this is an
  8193. inherent restriction, but it didn't seem worth the bother to implement
  8194. in an experimental version. The one thing that makes c-expressions truly
  8195. different, is the fact that they can be invoked with the ! operator. This
  8196. causes the c-expression to generate all of its results starting from the
  8197. beginning, instead of just producing the next one as when activated by @.
  8198. In this context you can think of a c-expression as a (possibly) generative
  8199. procedure which takes no arguments, with ! corresponding to procedure
  8200. invocation.
  8201.  
  8202. The motivation for c-expressions was simulating SNOBOL4 patterns by 
  8203. "capturing" Icon matching expressions. For this purpose, they need
  8204. a very compact syntax to be convenient, even so corresponding SNOBOL4
  8205. patterns are smaller. My original idea was to use a full scale
  8206. dyanmic procedure facility, but I was dissuaded. Such a facility
  8207. requires synatax for declaring parameters and local variables (and
  8208. requires extending Icon scoping rules to handle such nested contexts);
  8209. this syntax would be bulky. Of course there could be a separate compact
  8210. notation for dynamically creating parameterless procedures and ! could
  8211. still be used for invocation with no arguments (in this case procedure
  8212. rather the c-expression invocation).
  8213.  
  8214. In an Icon with dynamic procedure creation, should "c-expressions" be
  8215. moved from co-expressions to procedures, or it there some elegant way to
  8216. merge co-expressions and these dynamically created procedures?
  8217.  
  8218. I did experiment a little with dynamically created procedures. They
  8219. are fun to play with. The implementation used a variant translator
  8220. and a personalized interpreter, but I don't think I will admit to
  8221. the techniques used; they were rather gross and the implementation
  8222. was not quite right.
  8223.  
  8224. (I guess I have rambled on enough for now.)
  8225.  
  8226.      Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  8227.      +1 602 621 2858  kwalker@Arizona.EDU   {allegra|noao|ihnp4}!arizona!kwalker
  8228.  
  8229. From icon-group-sender  Tue May 10 15:02:03 1988
  8230. Received: by bocklin.arizona.edu; Tue, 10 May 88 15:02:07 MST
  8231. Message-Id: <8805101429.AA17587@megaron.arizona.edu>
  8232. Date: Tue, 10 May 88 09:07 CST
  8233. From: "Many people would rather die than think; in fact, most do."
  8234.  <UNOCC07%zeus@crcvms.unl.edu>
  8235. Subject: call-by-string procedures?
  8236. To: icon-group@arizona.edu
  8237. X-Vms-To: CRCVMS::IN%"icon-group@arizona.edu"
  8238. Errors-To: icon-group-errors
  8239.  
  8240. While working on my project for our school's Icon class, I came across something
  8241. that I realy would love to see in future versions of Icon, and the last message
  8242. I just got from Richard G. via the Icon-Group reminded me of it...
  8243.      
  8244. I have several (very small) routines that print VT220 escape codes to turn on
  8245. various text attributes, like inverse, underscore, etc, and I came across the
  8246. problem of passing the routine name {set_inverse(), in this case} to a "print"
  8247. procedure.  Then, I wanted to call the routine just by the string that had
  8248. "set_inverse" in it like such: s()  (where s was the string).  No such luck.
  8249.      
  8250. As it turned out, the program was rather large, so I just put in a case
  8251. statement to handle the seperate types, and went out to fiddle around with the
  8252. example of call-by-string in the version7.docs file, but I couldn't get it to
  8253. work satisfactoraly (sp?!).
  8254.      
  8255. Am I doing something wrong?  Any help on this would be greatly apprecciated!
  8256.      
  8257. -/ Dave Capligner /---------------+--------------------------------------------
  8258.   Microcomputer Specialist        | Internet: UNOCC07%ZEUS.DNET@FERGVAX.UNL.EDU
  8259.   Campus Computing                | UUCP:     ihnp4!unocss!dent
  8260.   University of Nebraska at Omaha | ARPAnet:  dent@fergvax.unl.edu
  8261.   Omaha, NE 68182                 | Bitnet:   dc3a+@andrew.cmu.edu
  8262.      
  8263.  
  8264. From icon-group-sender  Tue May 10 21:43:30 1988
  8265. Received: by bocklin.arizona.edu; Tue, 10 May 88 21:43:35 MST
  8266. Date: Tue, 10 May 88 21:43:28 MST
  8267. From: "Tom Hicks" <trh>
  8268. Message-Id: <8805110443.AA26874@megaron.arizona.edu>
  8269. To: icon-group
  8270. Subject: precedence chart
  8271. Errors-To: icon-group-errors
  8272.  
  8273. Has anyone ever sat down and created a precedence chart (like the one
  8274. in the SNOBOL4 (green) reference book) which shows the precedence
  8275. hierarchy and associativity of all the operators for Icon? I am
  8276. aware that this information is available within the Icon grammar
  8277. (Icon book appendix A?) but was wondering if anyone had taken the
  8278. trouble to dig it out and summarize it. Such a document would be
  8279. immensely handy.
  8280.  
  8281. From icon-group-sender  Tue May 17 06:31:25 1988
  8282. Received: by bocklin.arizona.edu; Tue, 17 May 88 06:31:28 MST
  8283. Message-Id: <8805171331.AA01547@megaron.arizona.edu>
  8284. Date: Mon, 16 May 88 22:00 CST
  8285. From: "Many people would rather die than think; in fact, most do."
  8286.  <UNOCC07%zeus@crcvms.unl.edu>
  8287. Subject: string invocation followup
  8288. To: icon-group@arizona.edu
  8289. X-Vms-To: CRCVMS::IN%"icon-group@arizona.edu"
  8290. Errors-To: icon-group-errors
  8291.  
  8292. My sincerest appologies for not seeing something obvious in my methods of
  8293. string invocation...  I realize now how to do it.  Apparently, one can
  8294. simply say    dosomething := "set_inverse"    if "set_inverse" is a procedure
  8295. name, and then just    dosomething   by itself will work.  I think I was
  8296. making it too difficult.  It turns out to be quite simple.
  8297.      
  8298. Thanks, however, to those of you that sent me mail about it!
  8299.      
  8300. -/ Dave Capligner /---------------+--------------------------------------------
  8301.   Microcomputer Specialist        | Internet: UNOCC07%ZEUS.DNET@FERGVAX.UNL.EDU
  8302.   Campus Computing                | UUCP:     ihnp4!unocss!dent
  8303.   University of Nebraska at Omaha | ARPAnet:  dent@fergvax.unl.edu
  8304.   Omaha, NE 68182                 | Bitnet:   dc3a+@andrew.cmu.edu
  8305.  
  8306. From icon-group-sender  Tue May 17 06:31:23 1988
  8307. Received: by bocklin.arizona.edu; Tue, 17 May 88 06:31:27 MST
  8308. Message-Id: <8805171331.AA01543@megaron.arizona.edu>
  8309. Date: Mon, 16 May 88 22:13 CST
  8310. From: "Many people would rather die than think; in fact, most do."
  8311.  <UNOCC07%zeus@crcvms.unl.edu>
  8312. Subject: Custom iconx: fxsys.c ?
  8313. To: icon-group@arizona.edu
  8314. X-Vms-To: CRCVMS::IN%"icon-group@arizona.edu"
  8315. Errors-To: icon-group-errors
  8316.  
  8317. I recently discovered a desperate need for single-key input from our VMS-based
  8318. ICON (v7), but reads(file,1) doesn't quite do it... I need unbuffered input,
  8319. without moving the whole project into MS-DOS. :-)  So, while looking around
  8320. in the v7/src/iconx directory, I noticed "fxtras.c", and more relevantly,
  8321. "fxsys.c", which contains the (prototype?) function "readc()"
  8322.      
  8323. Two questons:  is readc() what I want? (I'm not sure from the code; I'm not
  8324. an extremely proficient C programmer), and if it is...
  8325.      
  8326. How do I install it?  I tried the obvious method of defining "SysFcns" (i think
  8327. that was the appropriate name) in the config.h file, and when that didn't work,
  8328. I even added a statement "DefFcn(readc)" in "fdefs.h", right after a similar
  8329. one for the fsize() function, which is also in fxsys.c (so I figured that it
  8330. was a good guess).  That won't seem to do it either.  Do I have to recompile
  8331. icont, itran, and ilink as well?  It didn't appear that they would be directly
  8332. affected by including fxsys in the iconx make, but... ?
  8333.      
  8334. Thanks in advance for any help anyone may be able to offer!
  8335.      
  8336. -/ Dave Capligner /---------------+--------------------------------------------
  8337.   Microcomputer Specialist        | Internet: UNOCC07%ZEUS.DNET@FERGVAX.UNL.EDU
  8338.   Campus Computing                | UUCP:     ihnp4!unocss!dent
  8339.   University of Nebraska at Omaha | ARPAnet:  dent@fergvax.unl.edu
  8340.   Omaha, NE 68182                 | Bitnet:   dc3a+@andrew.cmu.edu
  8341.      
  8342.  
  8343. From icon-group-sender  Tue May 17 18:57:30 1988
  8344. Received: by bocklin.arizona.edu; Tue, 17 May 88 18:57:33 MST
  8345. Return-Path: <goer@sophist.uchicago.edu>
  8346. Date: Tue, 17 May 88 16:06:20 CDT
  8347. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  8348. Message-Id: <8805172106.AA20179@sophist.uchicago.edu>
  8349. To: icon-group@arizona.edu
  8350. Subject: "call-by-string"
  8351. Errors-To: icon-group-errors
  8352.  
  8353. Just a followup to Dave Capligner's bit on string invocation....
  8354.  
  8355. The thing I like about string invocation is that I can use it instead of
  8356. setting a flag.  It can make things much more clear.  Say I use one of
  8357. two output routines, depending on the value of the first argument:
  8358.  
  8359.   procedure main(a)
  8360.     Output := ( if a[1] == "a" then "FullOutput" else "PartialOutput" )
  8361.     etc....
  8362.  
  8363.   end
  8364.  
  8365.   procedure FullOutput(args)
  8366.     # Gives fully tabulated output
  8367.     etc...
  8368.   end
  8369.  
  8370.   procedure PartialOutput(args)
  8371.     # Gives a brief, one-line output
  8372.     etc...
  8373.   end
  8374.  
  8375. This way, I can call Output() in the main procedure, and not worry about
  8376. checking for some flag.  Not only this, but the variable name "Output"
  8377. is transparent.
  8378.  
  8379.  
  8380.                                                   -Richard L. Goerwitz
  8381.                                                   goer@sophist.uchicago.edu
  8382.                                                   !ihnp4!gargoyle!sophist!goer
  8383.  
  8384. P.S.  I know I keep harping on this, but has anyone fooled with defining
  8385.       their own control structures (using p{})?  I'd really like to hear
  8386.       if someone knows what they are doing in this area....
  8387.  
  8388. From icon-group-sender  Tue May 17 19:13:15 1988
  8389. Received: by bocklin.arizona.edu; Tue, 17 May 88 19:13:19 MST
  8390. Date: Tue, 17 May 88 19:10:33 MST
  8391. From: "Ralph Griswold" <ralph>
  8392. Message-Id: <8805180210.AA24973@megaron.arizona.edu>
  8393. To: goer@sophist.uchicago.edu, icon-group@arizona.edu
  8394. Subject: Programmer-Defined Control Structures
  8395. In-Reply-To: <8805172106.AA20179@sophist.uchicago.edu>
  8396. Errors-To: icon-group-errors
  8397.  
  8398. Since no one else has commented on this repeated request, I'll
  8399. make a comment or two.
  8400.  
  8401. The p{...} syntax was introduced into Icon as a method of experimenting
  8402. with the control of expression evaluation in Icon and in particular to
  8403. make it possible to define control structures (albiet somewhat awkwardly)
  8404. in the same sense procedures are commonly defined to augment the
  8405. built-in function repertoire.
  8406.  
  8407. Some time ago when extensible programming languages were the rage,
  8408. there were several proposals for programmer-defined control structures.
  8409. These proposals mostly came to nothing.  There are probably several
  8410. reasons for this, but it seems to me the main one is that the built-in
  8411. control structures provide the facilities that are needed in most
  8412. programming languages and there was little real motivation for defining
  8413. more.
  8414.  
  8415. I originally thought that the richness of expression evaluation in Icon
  8416. (compared to "flat" languages in which all expressions produce exactly
  8417. one result) provided more need for programmer-defined control structures.
  8418.  
  8419. There are papers with examples of programmer-defined control structures
  8420. and the Icon program library has collections and examples.
  8421.  
  8422. It seems, however, that programmer-defined control structures are rarely
  8423. used.  Perhaps there really is not the need.  Perhaps the mechanism is
  8424. awkward.  Perhaps it takes too much work.  Or perhaps this is fertile,
  8425. unexplored territory.
  8426.  
  8427. From a personal viewpoint, I used programmer-defined control structures
  8428. rarely -- and then only for "parallel" evaluation.
  8429.  
  8430. From icon-group-sender  Wed May 18 00:59:10 1988
  8431. Received: by bocklin.arizona.edu; Wed, 18 May 88 00:59:13 MST
  8432. Date: Wed, 18 May 88 08:57:16 BST
  8433. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - Sun UK TSE)
  8434. Message-Id: <8805180757.AA18714@stevie.nuksun.uucp>
  8435. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  8436. Subject: Re: "call-by-string"
  8437. Errors-To: icon-group-errors
  8438.  
  8439. Richard Goerwitz writes:
  8440.  
  8441.     The thing I like about string invocation is that I can use it
  8442.     instead of setting a flag.  It can make things much more
  8443.     clear.  Say I use one of two output routines, depending on the
  8444.     value of the first argument:
  8445.     
  8446.       procedure main(a)
  8447.         Output := ( if a[1] == "a" then "FullOutput" else "PartialOutput" )
  8448.         etc....
  8449.     
  8450.       end
  8451.  
  8452.     [ rest of program omitted]
  8453.  
  8454. If you substitute "prcedure-valued variables" for "string invocation"
  8455. above the same holds true.  Since I'm not a source freak (I _use_ Icon
  8456. rather than poke about with its insides to further research interests)
  8457. I don't know whether it is any more efficient, but it seems to me much
  8458. more obvious and elegant to write:
  8459.  
  8460. procedure  main(a)
  8461.         Output := ( if a[1] == "a" then Fullout else Partialout )
  8462.         Output(a)
  8463. end
  8464.  
  8465. procedure Fullout(x)
  8466.         every write(!x)
  8467. end
  8468.  
  8469. procedure Partialout(x)
  8470.         write(*x," arguments")
  8471. end
  8472.  
  8473. When you run this program you get the following results:
  8474.  
  8475. stevie% t a b c
  8476. a
  8477. b
  8478. c
  8479. stevie% t b c a
  8480. 3 arguments
  8481.  
  8482. So why use a string when the natural data type is a procedure --
  8483. or is there some subtle point I'm missing?
  8484.  
  8485.  
  8486. Steve Holden                    sholden@sun.com
  8487.                         sholden@{sun,sunuk}.uucp
  8488. "No FM in the field from where I write...."    [Marty Reynolds]
  8489.  
  8490. From icon-group-sender  Wed May 18 21:00:21 1988
  8491. Received: by bocklin.arizona.edu; Wed, 18 May 88 21:00:25 MST
  8492. Return-Path: <goer@sophist.uchicago.edu>
  8493. Date: Wed, 18 May 88 22:03:49 CDT
  8494. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  8495. Message-Id: <8805190303.AA21819@sophist.uchicago.edu>
  8496. To: icon-group@arizona.edu
  8497. Subject: not missing anything
  8498. Errors-To: icon-group-errors
  8499.  
  8500. I don't think you are missing anything, Marty (may I presume?).  I was the
  8501. one who was missing something.  It never occurred to me to use procedure
  8502. valued variables, rather than string-valued ones.  Now that I've had the
  8503. chance to try out your examples, I like your way better....
  8504.  
  8505.                                                   -Richard L. Goerwitz
  8506.                                                   goer@sophist.uchicago.edu
  8507.                                                   !ihnp4!gargoyle!sophist!goer
  8508.  
  8509. From icon-group-sender  Thu May 19 01:48:11 1988
  8510. Received: by bocklin.arizona.edu; Thu, 19 May 88 01:48:13 MST
  8511. Date: Thu, 19 May 88 09:45:56 BST
  8512. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - Sun UK TSE)
  8513. Message-Id: <8805190845.AA23503@stevie.nuksun.uucp>
  8514. To: sunuk!sun!sophist.uchicago.edu!goer@Sun.COM
  8515. Subject: Re:  not missing anything
  8516. Cc: sunuk!sun!arizona.edu!icon-group@Sun.COM
  8517. Errors-To: icon-group-errors
  8518.  
  8519. Marty was responsible for the quote, which came from the well-worn
  8520. phrase RTFM much used by tech. support in Sun (Read the F*******
  8521. Manual) - not to customers, I would add.  I really am Steve Holden,
  8522. and yes, you may presume.  If I don't get called Steve I tend to
  8523. assume I'm in trouble!
  8524.  
  8525. I'm glad you prefer the procedure valued variables.
  8526.  
  8527.  Steve
  8528.  
  8529. From icon-group-request  Tue May 24 23:36:54 1988
  8530. Received: from megaron.arizona.edu by bocklin.arizona.edu; Tue, 24 May 88 23:36:54 MST
  8531. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu; Tue, 24 May 88 23:36:24 MST
  8532. Received: by ucbvax.Berkeley.EDU (5.59/1.28)
  8533.     id AA19466; Tue, 24 May 88 16:19:23 PDT
  8534. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  8535.     for icon-group@arizona.edu (icon-group@arizona.edu)
  8536.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  8537. Date: 24 May 88 00:08:07 GMT
  8538. From: portal!cup.portal.com!JJ@uunet.uu.net
  8539. Organization: The Portal System (TM)
  8540. Subject: HELP ME!!!
  8541. Message-Id: <5811@cup.portal.com>
  8542. Sender: icon-group-request@arizona.edu
  8543. To: icon-group@arizona.edu
  8544.  
  8545. Poor College Student needs Your Help!!   :-(
  8546.  
  8547. Hi.  I just finished my junior year in college, and now I'm
  8548. faced with a major problem.  I can't afford to pay for my senior
  8549. year.  I've tried everything.  I can't get any more student loans,
  8550. I don't qualify for any more scholarships, and my parents are as
  8551. broke as am I.  So as you can see, I've got a major problem.  But
  8552. as far as I can see, there is only one solution, to go forward.
  8553. I've come along way, and there is no chance in hell that I'm going
  8554. to drop out now!  I'm not a quiter, and I'm not going to give up.
  8555.  
  8556. But here is why I'm telling you all this.  I want to ask a favor of every
  8557. one out here on the net.  If each of you would just send me a one
  8558. dollar bill, I will be able to finish college and go on with my life.
  8559. I'm sure a dollar is not much to any of you, but just think how it
  8560. could change a person's life.  I'd really like to encourage all of you
  8561. to help me out, I've no other place to go, no other doors to knock
  8562. on.  I'm counting on all of you to help me! (PLEASE!)
  8563. If you would like to help a poor boy out, please send $1 (you can
  8564. of course send more if you want!!  :-)
  8565.  
  8566. Jay-Jay's College Fund
  8567. PO BOX 5631
  8568. Lincoln, NE  68505
  8569.  
  8570. PS.  Please don't flame me for posting this to so many newsgroups,
  8571. I really am in dire need of help, and if any of you were as desparate
  8572. as I am, you just might resort to the same thing I am.  Also, please
  8573. don't tell me to get a job!  I already have one and work over 25 hrs
  8574. a week, plus get in all my classes, plus find time to study!  So hey,
  8575. please consider it!  It would really mean a lot to me.  Thank you!
  8576.  
  8577. NOTE: Any extra money I receive will go to a scholarship fund to help
  8578. others in the same situation.  :-)
  8579.  
  8580. From icon-group-request  Wed May 25 14:32:36 1988
  8581. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 25 May 88 14:32:36 MST
  8582. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu; Wed, 25 May 88 14:32:17 MST
  8583. Received: by ucbvax.Berkeley.EDU (5.59/1.28)
  8584.     id AA26089; Tue, 24 May 88 23:34:03 PDT
  8585. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  8586.     for icon-group@arizona.edu (icon-group@arizona.edu)
  8587.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  8588. Date: 25 May 88 05:52:05 GMT
  8589. From: kaon!gide.uchicago.edu!max@oddjob.uchicago.edu  (Max Ziff)
  8590. Organization: University of Chicago
  8591. Subject: modeling mutual evaluation
  8592. Message-Id: <305@kaon.uchicago.edu>
  8593. Sender: icon-group-request@arizona.edu
  8594. To: icon-group@arizona.edu
  8595.  
  8596.  
  8597. How can mutual evaluation be modeled?
  8598.  
  8599. I recently needed to implement an algorithm for finding a perfect hash function
  8600. for a fixed set of keys.  I read Richard Cichelli's "Minimal Perfect Hash
  8601. Functions Made Simple" (in Comm ACM, 1983, 1) where he suggests a simple
  8602. heuristic and backtracking, and I immediately thought of the eight queens 
  8603. problem, and modeled my program after the one in the book:
  8604.  
  8605. global hashcodes,mapvals,maxval
  8606.  
  8607. procedure main()
  8608.     hashcodes := table(-1)
  8609.     mapvals := table(-1)
  8610.     maxval := 6
  8611.     (h("jun"), h("sep"), h("dec"), h("aug"), h("jan"), h("feb"),
  8612.     h("jul"), h("apr"), h("oct"), h("may"), h("mar"), h("nov"))
  8613.     hlist := sort(mapvals)
  8614.     i := 0
  8615.     while pair := hlist[i +:= 1] do
  8616.     write (pair[1],pair[2])
  8617. end
  8618.  
  8619. procedure h(s)
  8620.     if hashcodes[(hashval := (hashchar(s[2]) + hashchar(s[3])))] = -1
  8621.     then suspend hashcodes[hashval] <- hashval
  8622. end
  8623.  
  8624. procedure hashchar(s)
  8625.     if (mapvals[s] ~= -1) then return mapvals[s]
  8626.     suspend mapvals[s] <- 0 to maxval
  8627. end
  8628.  
  8629. The program works fine, and I was pleased by how easy it was to throw 
  8630. together.  But I'd like not to have to "hardwire" the keys in the code.  
  8631. Suppose the keys are in a list:
  8632.  
  8633.     keys := ["jun", "sep", "dec", "aug", "jan", "feb", 
  8634.     "jul", "apr", "oct", "may", "mar", "nov"]
  8635.  
  8636. With what can I replace the mutual evaluation expression to get the same
  8637. backtracking effect?  To be more specific, suppose I want a function, call it
  8638. "mutual-map-proc" of two arguments: a procedure and a co-expression, such that
  8639. the function models the mutual evaluation of the procedure on each value
  8640. returned by the co-expression.  Thus I could replace the mutual evaluation 
  8641. in my program with:
  8642.  
  8643.     mutual-map-proc(h, create !keys)
  8644.  
  8645. and the function call in the eight queens program on page 153 of the icon book
  8646. could be replaced by 
  8647.  
  8648.     mutual-map-proc(q, create 1 to 8)
  8649.     
  8650. (except, of course, that this would not have the side effect of printing out
  8651. the solution).
  8652.  
  8653. Am I off-course?  Any ideas?
  8654.  
  8655. Donald Ziff               ARTFL Project, University of Chicago 
  8656.                           1050 E. 59th Street, Chicago, Illinois   60637
  8657.  
  8658.                           ...ihnp4!gargoyle!sphinx!maxz
  8659.                           max@gide.UChicago.{EDU,BITNET,MAILNET,CSNET}
  8660.  
  8661. From icon-group-request  Wed May 25 16:01:03 1988
  8662. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 25 May 88 16:01:03 MST
  8663. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu; Wed, 25 May 88 16:00:32 MST
  8664. Received: by ucbvax.Berkeley.EDU (5.59/1.28)
  8665.     id AA03697; Wed, 25 May 88 09:16:22 PDT
  8666. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  8667.     for icon-group@arizona.edu (icon-group@arizona.edu)
  8668.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  8669. Date: 25 May 88 15:10:19 GMT
  8670. From: cd@bu-cs.bu.edu  (Clarence K. Din)
  8671. Organization: Boston Univ.
  8672. Subject: Re: HELP ME!!!
  8673. Message-Id: <22861@bu-cs.BU.EDU>
  8674. References: <5811@cup.portal.com>
  8675. Sender: icon-group-request@arizona.edu
  8676. To: icon-group@arizona.edu
  8677.  
  8678. In article <5811@cup.portal.com> JJ@cup.portal.com writes:
  8679. >Poor College Student needs Your Help!!   :-(
  8680. >
  8681. >Hi.  I just finished my junior year in college, and now I'm
  8682. >faced with a major problem.  I can't afford to pay for my senior
  8683. >year.  I've tried everything.  I can't get any more student loans,
  8684. >I don't qualify for any more scholarships, and my parents are as
  8685. >broke as am I.  So as you can see, I've got a major problem.
  8686.  
  8687. Hey, we all have problems, buddy.
  8688.  
  8689. >But as far as I can see, there is only one solution, to go forward.
  8690. >I've come along way, and there is no chance in hell that I'm going
  8691. >to drop out now!  I'm not a quiter, and I'm not going to give up.
  8692.  
  8693. That's a lot of hoopla.  If you had the motivation, determination,
  8694. and intelligence, you'd find yourself a decent part-time job.
  8695.  
  8696. >But here is why I'm telling you all this.  I want to ask a favor of every
  8697. >one out here on the net.  If each of you would just send me a one
  8698. >dollar bill, I will be able to finish college and go on with my life.
  8699. >I'm sure a dollar is not much to any of you, but just think how it
  8700. >could change a person's life.  I'd really like to encourage all of you
  8701. >to help me out, I've no other place to go, no other doors to knock
  8702. >on.  I'm counting on all of you to help me! (PLEASE!)
  8703.  
  8704. Remember the ol' exec in the airport terminal routine (y'know, where
  8705. some bum dresses up like some well-to-do feeb and asks people for
  8706. money because "he missed his flight and has to call his wife, but has
  8707. no pocket change or transportation fare"?).
  8708.  
  8709. >Jay-Jay's College Fund
  8710. >PO BOX 5631           <<--- hmmm... a box number...
  8711. >Lincoln, NE  68505
  8712. > Also, please
  8713. >don't tell me to get a job!  I already have one and work over 25 hrs
  8714. >a week, plus get in all my classes, plus find time to study!  So hey,
  8715. >please consider it!  It would really mean a lot to me.  Thank you!
  8716.  
  8717. Big deal.  I work more than 25 hours a week; I get no money and
  8718. tuition here at BU, including everything, is $18000.  Hey, people,
  8719. if you have any of that money, send it to me!
  8720.  
  8721. >NOTE: Any extra money I receive will go to a scholarship fund to help
  8722. >others in the same situation.  :-)
  8723.  
  8724. Sure.  Sure.  It'll all go in your back pocket.
  8725.  
  8726.  
  8727. Sincerely,
  8728.  
  8729. Clarence K. Din
  8730. cd@bu-cs.bu.edu
  8731. .
  8732.  
  8733. From gudeman  Wed May 25 16:15:42 1988
  8734. Received: from megaron.arizona.edu by bocklin.arizona.edu; Wed, 25 May 88 16:15:42 MST
  8735. Date: Wed, 25 May 88 16:15:41 MST
  8736. From: "David Gudeman" <gudeman>
  8737. Message-Id: <8805252315.AA13334@megaron.arizona.edu>
  8738. Received: by megaron.arizona.edu; Wed, 25 May 88 16:15:41 MST
  8739. To: icon-group
  8740. In-Reply-To: <305@kaon.uchicago.edu>
  8741. Subject: modeling mutual evaluation
  8742.  
  8743. >From: kaon!gide.uchicago.edu!max@oddjob.uchicago.edu  (Max Ziff)
  8744. >
  8745. >How can mutual evaluation be modeled?
  8746. >...
  8747. >    keys := ["jun", "sep", "dec", "aug", "jan", "feb", 
  8748. >       "jul", "apr", "oct", "may", "mar", "nov"]
  8749. >
  8750. >With what can I replace the mutual evaluation expression to get the same
  8751. >backtracking effect?  To be more specific, suppose I want a function, call it
  8752. >"mutual-map-proc" of two arguments: a procedure and a co-expression, such that
  8753. >the function models the mutual evaluation of the procedure on each value
  8754. >returned by the co-expression.  Thus I could replace the mutual evaluation 
  8755. >in my program with:
  8756. >
  8757. >    mutual-map-proc(h, create !keys)
  8758.  
  8759. As long as you already have a list, why turn it into a co-expression?
  8760. Here is a function that maps a procedure over a list using mutual
  8761. evaluation of each call.  Your program would use the expression
  8762.  
  8763.     mutual-eval-map(h, keys)
  8764. ----------------------------------------------------------------------
  8765. # call p(x) for each x in ls with backtracking into previous calls.
  8766. #        mutual_eval_map(p,ls)
  8767. # is equivalent to
  8768. #        (p(ls[1]), p(ls[2]),..., p(ls[*ls]))
  8769. # An optional third argument i means to start at ls[i] instead of
  8770. # ls[1].  Notice that i is needed for recursive calls.
  8771. procedure mutual_eval_map(p,ls,i)
  8772.     /i := 1
  8773.     if i = *ls then suspend p(ls[i])
  8774.     else suspend p(ls[i]) & mutual_eval_map(p,ls,i+1)
  8775. end
  8776.  
  8777. From DSCARGO@CIM-VAX.HONEYWELL.COM  Thu May 26 07:26:19 1988
  8778. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 26 May 88 07:26:19 MST
  8779. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu; Thu, 26 May 88 07:26:12 MST
  8780. Received: by CIM-VAX id <0000126E0B1@CIM-VAX.HONEYWELL.COM> ;
  8781.        Thu, 26 May 88 09:24:29 CDT
  8782. Date: Thu, 26 May 88 09:20:42 CDT
  8783. From: David S. Cargo MN67-2F08 593-2822 <DSCARGO@CIM-VAX.HONEYWELL.COM>
  8784. Subject: Decompiling
  8785. To: icon-group@arizona.edu
  8786. X-Vms-Mail-To: EXOS%"icon-group@arizona.edu"
  8787. Message-Id: <880526092042.0000126E0B1@CIM-VAX.HONEYWELL.COM>
  8788.  
  8789. Sorry if this message seems like a repeat.  I never got a network echo from
  8790. the first one, so I don't know if it got through originally.
  8791.  
  8792. I accidently deleted a .icn file on my MS-DOS system.  Is there any way to
  8793. turn a version 7 .icx file back into Icon source?  Even approximately?
  8794. The structure of some of the algorithms I sometimes use are hard to recreate.
  8795. I figure I'm not the only person who has had this problem, so I thought it
  8796. was worth bringing up to the whole group.
  8797.  
  8798. David S. Cargo (DSCARGO@CIM-VAX.HONEYWELL.COM)
  8799.  
  8800. From ralph  Thu May 26 07:47:51 1988
  8801. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 26 May 88 07:47:51 MST
  8802. Date: Thu, 26 May 88 07:43:15 MST
  8803. From: "Ralph Griswold" <ralph>
  8804. Message-Id: <8805261443.AA12612@megaron.arizona.edu>
  8805. Received: by megaron.arizona.edu; Thu, 26 May 88 07:43:15 MST
  8806. To: DSCARGO@CIM-VAX.HONEYWELL.COM, icon-group@arizona.edu
  8807. Subject: Re:  Decompiling
  8808. In-Reply-To: <880526092042.0000126E0B1@CIM-VAX.HONEYWELL.COM>
  8809.  
  8810. As far as I know, there is no program around to decompile an an Icon
  8811. icode file back into a source file.  If I'm mistaken, and some one
  8812. has done this, we'd like to have a copy.
  8813.  
  8814. Note that the structure of an icode file varies with the Icon version
  8815. and with the architecture on which it was created.  Also, some information
  8816. is lost (like the names of record fields) in per-Version 7 icode files.
  8817. I'm not sure, off hand, if other information is lost.
  8818.  
  8819. From sunuk!nuksun!stevie!steveh@Sun.COM  Thu May 26 15:26:31 1988
  8820. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 26 May 88 15:26:31 MST
  8821. Received: from SUN.COM by megaron.arizona.edu; Thu, 26 May 88 15:26:21 MST
  8822. Received: from snail.sun.com by Sun.COM (4.0/SMI-4.0)
  8823.     id AA04552; Thu, 26 May 88 00:50:30 PDT
  8824. Received: from uk.sun.com (sunuk) by snail.sun.com (4.0/SMI-3.2)
  8825.     id AA06630; Thu, 26 May 88 00:47:50 PDT
  8826. Received: from Nuksun.Europe.Sun.COM (inuksun) by uk.sun.com (3.2/SMI-3.2)
  8827.     id AA17232; Thu, 26 May 88 08:51:39 BST
  8828. Received: from stevie.nuksun.uucp by Nuksun.Europe.Sun.COM (1.1/SMI-3.2)
  8829.     id AA02425; Thu, 26 May 88 09:51:52 -0100
  8830. Received: by stevie.nuksun.uucp (3.2/SMI-3.2)
  8831.     id AA17361; Thu, 26 May 88 08:51:38 BST
  8832. Date: Thu, 26 May 88 08:51:38 BST
  8833. From: sunuk!nuksun!stevie!steveh@Sun.COM (Steve Holden - Sun UK TSE)
  8834. Message-Id: <8805260751.AA17361@stevie.nuksun.uucp>
  8835. To: sunuk!sun!arizona.edu!icon-group@Sun.COM
  8836. Subject: Re: HELP ME!!!
  8837.  
  8838. I trust the origin of this mail will be traced - my copy only comes
  8839. in with headers from Arizona - and the appropriate wires cut.  A
  8840. case begins to emerge for sender authorisation.
  8841.  
  8842. Steve
  8843.  
  8844. From gmt  Thu May 26 16:45:01 1988
  8845. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 26 May 88 16:45:01 MST
  8846. Date: Thu, 26 May 88 16:44:58 MST
  8847. From: "Gregg Townsend" <gmt>
  8848. Message-Id: <8805262344.AA23839@megaron.arizona.edu>
  8849. Received: by megaron.arizona.edu; Thu, 26 May 88 16:44:58 MST
  8850. In-Reply-To: <8805260751.AA17361@stevie.nuksun.uucp>
  8851. To: icon-group
  8852. Subject: Re: HELP ME!!!
  8853.  
  8854. JJ's plea for money was sent to nearly every usenet newsgroup and mailing list,
  8855. so we weren't singled out.  Of course, there is a huge uproar; it's reported
  8856. that JJ's account has been cancelled, and other actions are also being proposed.
  8857. Further discussions should probably be directed to the "news.misc" newsgroup;
  8858. let's get back to Icon here.
  8859.  
  8860.     Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  8861.     +1 602 621 4325      gmt@Arizona.EDU       110 57 16 W / 32 13 45 N / +758m
  8862.  
  8863. From bruce@stride.stride.com  Thu May 26 17:36:13 1988
  8864. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 26 May 88 17:36:13 MST
  8865. Received: from UXC.CSO.UIUC.EDU by megaron.arizona.edu; Thu, 26 May 88 17:36:05 MST
  8866. Received: by uxc.cso.uiuc.edu (5.51/9.7)
  8867.     id AA08062; Thu, 26 May 88 19:33:58 CDT
  8868. Received: by stride.Stride.COM (5.51/UUCP-Project/rel-1.0/11-05-86)
  8869.     id AA23865; Thu, 26 May 88 09:04:27 PDT
  8870. Date: Thu, 26 May 88 09:04:27 PDT
  8871. From: bruce@stride.Stride.COM (Bruce Robertson)
  8872. Message-Id: <8805261604.AA23865@stride.Stride.COM>
  8873. To: JJ@cup.portal.com
  8874. Cc: icon-group@arizona.edu
  8875. In-Reply-To: JJ@cup.portal.com's message of 24 May 88 00:08:07 GMT <5811@cup.portal.com>
  8876. Subject: HELP ME!!!
  8877.  
  8878. If your current job isn't enough to pay your tuition, then try taking
  8879. fewer classes.  Why do you have to get through college in four years?
  8880.  
  8881. You obviously haven't learned anything in your first three years of
  8882. college, as the errors in spelling and grammar indicate.
  8883.  
  8884. From mcvax!cerisi.cerisi.Fr!ol@uunet.UU.NET  Thu May 26 21:37:42 1988
  8885. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 26 May 88 21:37:42 MST
  8886. Received: from uunet.UU.NET by megaron.arizona.edu; Thu, 26 May 88 21:37:33 MST
  8887. Received: from mcvax.UUCP by uunet.UU.NET (5.54/1.14) with UUCP 
  8888.     id AA23347; Fri, 27 May 88 00:35:28 EDT
  8889. Received: by mcvax.cwi.nl; Fri, 27 May 88 06:25:16 +0200 (MET)
  8890. Received: from mirsa.inria.Fr by inria.inria.fr; Thu, 26 May 88 21:46:13 +0200 (MET)
  8891. Message-Id: <8805261946.AA13697@inria.inria.fr>
  8892. Posted: Thu, 26 May 88 21:44:48 -0100
  8893. Date: Thu, 26 May 88 21:44:48 -0100
  8894. Posted-Date: Thu, 26 May 88 21:44:48 -0100
  8895. From: olivier lecarme <mcvax!cerisi.cerisi.Fr!ol@uunet.UU.NET>
  8896. To: icon-group@arizona.edu
  8897. In-Reply-To: "Ralph Griswold"'s message of Thu, 26 May 88 07:43:15 MST <8805261443.AA12612@megaron.arizona.edu>
  8898. Subject:  Decompiling
  8899.  
  8900. Decompiling in itself is a difficult and fascinating subject, but I
  8901. think that in the case of Icon there is much less information lost than
  8902. for any other language implementation I know of. I evaluate the work to
  8903. be feasible as a final project for a team of three or four undergraduate
  8904. students. Is Ralph of the same opinion?
  8905.  
  8906. By the way, I have another student team working on an Icon indenting
  8907. prettyprinter, written in Icon of course. Are any people interested?
  8908.  
  8909. Olivier Lecarme, University of Nice, France
  8910.  
  8911. From ralph  Thu May 26 22:03:57 1988
  8912. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 26 May 88 22:03:57 MST
  8913. Date: Thu, 26 May 88 22:03:55 MST
  8914. From: "Ralph Griswold" <ralph>
  8915. Message-Id: <8805270503.AA05447@megaron.arizona.edu>
  8916. Received: by megaron.arizona.edu; Thu, 26 May 88 22:03:55 MST
  8917. To: icon-group@arizona.edu, mcvax!cerisi.cerisi.Fr!ol@uunet.UU.NET
  8918. Subject: Re:  Decompiling
  8919. In-Reply-To: <8805261946.AA13697@inria.inria.fr>
  8920.  
  8921. I'm really not sure how hard it is to decompile an Icon icode file.
  8922. I once tried to write a decompiler for Icon ucode files (closer to
  8923. the source than icode files) and found it unexpectedly difficult.  I
  8924. did not pursue the matter, so I really cannot make a definitive
  8925. comment.
  8926.  
  8927. It certainly is an interesting project.
  8928.  
  8929.      Ralph Griswold / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  8930.      +1 602 621 6609   ralph@Arizona.EDU     {allegra|noao|ihnp4}!arizona!ralph
  8931.  
  8932.  
  8933. From UNOCC07%zeus@crcvms.unl.edu  Mon May 30 17:36:11 1988
  8934. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 30 May 88 17:36:11 MST
  8935. Message-Id: <8805310036.AA13635@megaron.arizona.edu>
  8936. Received: from rvax.ccit.arizona.edu by megaron.arizona.edu; Mon, 30 May 88 17:36:10 MST
  8937. Received: from BITNET-GATEWAY by rvax.ccit.arizona.edu; Mon, 30 May 88 17:32 MST
  8938. Date: Sun, 29 May 88 13:55 CST
  8939. From: "Many people would rather die than think; in fact, most do."
  8940.  <UNOCC07%zeus@crcvms.unl.edu>
  8941. Subject: The future implementations of Icon
  8942. To: ICON-GROUP@arizona.edu
  8943. X-Vms-To: CRCVMS::IN%"ICON-GROUP@ARIZONA.EDU"
  8944.  
  8945. In my recent attempts to implement single-key input (non-buffered) for
  8946. Icon version 7 under VAX/VMS 4.7, I picked up the book "The Implementation
  8947. of the Icon Programming Language," and boy did that help!  I've now got
  8948. a synchronous readc() function that pauses until a key is pressed, and returns
  8949. that key.  I'll probably expand this to an asynchronous version that returns
  8950. &null if there aren't any characters in the buffer or something.. I haven't
  8951. really thought to much about that one.
  8952.  
  8953. But on to the point of this post.  In the back of the book, included in
  8954. the "projects" section (Appendix E), I noticed a few things that seem to be
  8955. near completion for newer versions of Icon.. (The book refers to version 6
  8956. something, I think)  Most notably "operators", which I've been wondering
  8957. about.  The "call-by-string" feature in Icon version 7 looks like a precursor
  8958. to user-defined operators.  But, what /are/ user-defined operators, and how
  8959. might they be implemented (as well as what use will they find)?  When I first
  8960. glanced over the projects, I had an idea of something like this:
  8961.  
  8962. operator "#"(a,b)
  8963.   if (MIN < a < b < MAX) then return b
  8964. end        # (failure implied)
  8965.  
  8966. which would define the "#" character to do something trivial (I couldn't
  8967. think of a usefull example off the top of my head), and could then be called
  8968. like:
  8969.  
  8970.   x := a # b
  8971.  
  8972. (for a trivial example :-)
  8973.  
  8974. Am I close?  Does anyone have any thoughts on this?
  8975.  
  8976. Something else I saw was "Design and implement a terminal-independant
  8977. windowing package for Icon."  Wouldn't it just be simpler to implement Icon
  8978. commands to perform Curses functions?  (as an example)  I'm not sure of the
  8979. complexity of that one..  (Incidentally, I have a "windowing package" for
  8980. Icon, but it's not terminal-independant.  I did restrict it to VT-100 codes
  8981. though, and VT-100's are pretty common so...)
  8982.  
  8983. -/ Dave Caplinger /---------------+--------------------------------------------
  8984.   Microcomputer Specialist        | Internet: UNOCC07%ZEUS.DNET@FERGVAX.UNL.EDU
  8985.   Campus Computing                | UUCP:     ihnp4!unocss!dent
  8986.   University of Nebraska at Omaha | ARPAnet:  dent@fergvax.unl.edu
  8987.   Omaha, NE 68182                 | Bitnet:   dc3a+@andrew.cmu.edu
  8988.  
  8989.  
  8990. From ralph  Mon May 30 17:46:00 1988
  8991. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 30 May 88 17:46:00 MST
  8992. Date: Mon, 30 May 88 17:45:57 MST
  8993. From: "Ralph Griswold" <ralph>
  8994. Message-Id: <8805310045.AA14047@megaron.arizona.edu>
  8995. Received: by megaron.arizona.edu; Mon, 30 May 88 17:45:57 MST
  8996. To: ICON-GROUP@arizona.edu, UNOCC07%zeus@crcvms.unl.edu
  8997. Subject: Re:  The future implementations of Icon
  8998. In-Reply-To: <8805310036.AA13635@megaron.arizona.edu>
  8999.  
  9000. To the best of my knowledge, nothing has been done with programmer-defined
  9001. operators.  There are lots of approaches, both in terms of language design
  9002. and in terms of implementation.  The real problem is that they would
  9003. have a potentially serious impact on efficiency. Right now, the meanings
  9004. of operator symbols are known to the translator and the source-language
  9005. is connected firmly to the code to be executed. If operators could be
  9006. redefined, a level of indirectness would be needed.
  9007.  
  9008. Not that efficiency is everything -- witness many features in Icon where
  9009. user flexibility takes precedence over efficiency.  The question is --
  9010. is there enough need for programmer-defined operators to justify the
  9011. costs.
  9012.  
  9013. Incidentally, you shouldn't take the projects in the Icon implementation
  9014. book to be a blueprint for future developments in the Icon language.  Granted,
  9015. some of the projects fall into this category.  Others are things that might
  9016. be useful in a "private" version of Icon.  Some are wishful thinking.
  9017. Some are designed to the useful exercises for person who want to work
  9018. on the implementation of Icon.
  9019.  
  9020.  
  9021.    Ralph Griswold / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  9022.    +1 602 621 6609   ralph@Arizona.EDU     {allegra|noao|ihnp4}!arizona!ralph
  9023.  
  9024.  
  9025.