home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group91a.txt < prev    next >
Internet Message Format  |  1991-06-13  |  433KB

  1. From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu  Tue Jan  1 09:42:36 1991
  2. Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  3.     id AA00177; Tue, 1 Jan 91 09:42:36 -0700
  4. Received: by uwm.edu; id AA01354; Tue, 1 Jan 91 08:34:39 -0600
  5. Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
  6.           Tue,  1 Jan 91 08:01:24 CDT
  7. Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
  8.           Tue, 1 Jan 1991 07:32 CST
  9. Date: Tue, 1 Jan 1991 07:31 CST
  10. From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
  11. Subject: Happy New Year ! Black Jack Game.
  12. To: icon-group@cs.arizona.edu
  13. Message-Id: <C3284CA4006019D9@mis.mcw.edu>
  14. X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
  15. X-Envelope-To: icon-group@cs.arizona.edu
  16. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  17.  
  18.  
  19. Happy New Year! After considering all the good advice on the draw poker game
  20. I kloojed together a simple version of black jack. It's about 291 lines.
  21. The shuffling on the draw poker game also wasn't very good, so this game
  22. uses the technique in the IPL which I think is more correct anyway. Enjoy!
  23.  
  24. Yours truly,
  25. Chris Tenaglia (System Manager) | Medical College of Wisconsin
  26. 8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  27. (414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  28.  
  29. #########################################################
  30. #                                                       #
  31. # BJ.ICN            12/19/90          BY TENAGLIA       #
  32. #                                                       #
  33. # SIMPLE BUT FUN BLACK JACK GAME. WORKS ON ANSI SCREEN. #
  34. # USAGE : iconx bj   [starting credits]                 #
  35. #                                                       #
  36. #########################################################
  37. global deck, message, lookup,
  38.        user_money,  host_money,
  39.        user_hand,   host_hand
  40.  
  41. procedure main(param)
  42.   user_money := integer(param[1]) | 3 ; host_money := user_money
  43.   write(screen("cls"),"               ",screen("top"),screen("hinv"),
  44.         "BLACK JACK",screen("norm"))
  45.   write("               ",screen("bot"),screen("hinv"),
  46.         "BLACK JACK",screen("norm"))
  47.   bonus := 0
  48.   repeat
  49.     {
  50.     if not any('y',(map(input(at(1,4)   || screen("under") ||
  51.                    "Want to play? y/n :"|| screen("norm")  ||
  52.                    screen("eeol")))[1])) then break
  53.     writes(at(1,4),screen("eeos"))
  54.     display_score()
  55.     deck    := shuffle()
  56.     message := ""
  57.     user_hand := []          ; host_hand := []
  58.     put(user_hand,pop(deck)) ; put(host_hand,pop(deck))
  59.     put(user_hand,pop(deck)) ; put(host_hand,pop(deck))
  60.     user_points := first(host_hand[1])
  61.     if user_points > 21 then
  62.       {
  63.       writes(at(1,14),user_points," points. You went over. You loose.")
  64.       user_money -:= 1 ; host_money +:= 1 + bonus ; bonus := 0
  65.       display_score()
  66.       next
  67.       }
  68.     display_host(2)
  69.     host_points := second(user_points)
  70.     if host_points > 21 then
  71.       {
  72.       writes(at(50,23),host_points," points. ",&host," went over.")
  73.       writes(at(1,14),screen("hiblink"),"You win.",screen("norm"))
  74.       host_money -:= 1 ; user_money +:= 1 + bonus ; bonus := 0
  75.       display_score()
  76.       next
  77.       }
  78.     if host_points = user_points then
  79.       {
  80.       writes(at(1,23),screen("hiblink"),"It's a draw at ",user_points,
  81.             ". The ANTY goes to bonus.",screen("norm"))
  82.       bonus +:= 2 ; host_money -:= 1 ; user_money -:= 1
  83.       display_score()
  84.       next
  85.       }
  86.     writes(at(20,13),user_points," points for user.")
  87.     writes(at(1,15),host_points," points for ",&host)
  88.     if user_points < host_points then
  89.       {
  90.       write(at(1,23),screen("hiblink"),&host," wins.",
  91.             screen("norm"),screen("eeol"))
  92.       user_money -:= 1 ; host_money +:= 1 + bonus ; bonus := 0
  93.       display_score()
  94.       next
  95.       } else {
  96.       writes(at(1,13),screen("hiblink"),"You win.",screen("norm"),screen("eeol"))
  97.       user_money +:= 1 + bonus ; host_money -:= 1 ; bonus := 0
  98.       display_score()
  99.       next
  100.       }
  101.     }
  102.   write(screen("clear"))
  103.   end
  104.  
  105. #
  106. # THIS PROCEDURE ALLOWS THE USER TO PLAY AND TAKE HITS
  107. #
  108. procedure first(host_card)
  109.   display_user()
  110.   display_host(1)
  111.   points := value(user_hand)   # just in case
  112.   writes(at(1,10),"(",points,") ")
  113.   repeat
  114.     if any('hy',map(input(at(1,23) || "Hit ? y/n :" || screen("eeol")))) then
  115.       {
  116.       put(user_hand,pop(deck))
  117.       display_user()
  118.       if (points := value(user_hand)) > 21 then return points
  119.       writes(at(1,10),"(",points,") ")
  120.       } else break
  121.   (points > 0) | (points := value(user_hand))
  122.   writes(at(1,10),"(",points,") ")
  123.   write(at(60,12),"You stay with ",points)
  124.   return points
  125.   end
  126.  
  127. #
  128. # THIS SECOND PROCEDURE IS THE HOST PLAYING AGAINST THE USER
  129. #
  130. procedure second(ceiling)
  131.   static limits
  132.   initial limits := [14,14,15,15,19,16,17,18]
  133.   stop_at := ?limits ; points := 0
  134.   until (points := value(host_hand)) > stop_at do
  135.     {
  136.     if points > ceiling then return points
  137.     writes(at(1,20),"(",points,") ")
  138.     write(at(1,23),screen("eeol"),&host," will take a hit.",screen("eeol"))
  139.     put(host_hand,pop(deck))
  140.     display_host(2)
  141.     }
  142.   (points > 0) | (points := value(host_hand))
  143.   writes(at(1,20),"(",points,") ")
  144.   return points
  145.   end
  146.  
  147. #
  148. # THIS ROUTINE DISPLAYS THE CURRENT SCORE
  149. #
  150. procedure display_score()
  151.   writes(screen("nocursor"))
  152.   writes(screen("dim"),at(1,8),"Credits",screen("norm"))
  153.   writes(screen("high"),at(1,9),right(user_money,7),screen("norm"))
  154.   writes(screen("dim"),at(1,18),"Credits",screen("norm"))
  155.   writes(screen("high"),at(1,19),right(host_money,7),screen("norm"))
  156.   end
  157. #
  158. # THIS PROCEDURE EVALUATES THE POINTS OF A HAND. IT TRIES TO MAKE THEM
  159. # AS HIGH AS POSSIBLE WITHOUT GOING OVER 21.
  160. #
  161. procedure value(sample)
  162.   hand     := copy(sample)
  163.   possible := []
  164.   repeat
  165.     {
  166.     sum := 0
  167.     every card := !hand do sum +:= lookup[card[1]]
  168.     put(possible,sum)
  169.     if Aces(hand) == "none" then break else
  170.       every i := 1 to *hand do if hand[i][1] == "A" then hand[i][1] := "a"
  171.     }
  172.   every score := !possible do
  173.     if score <= 21 then return score
  174.   return possible[1]
  175.   end
  176.  
  177. #
  178. # ARE THERE ANY 11 POINT ACES LEFT IN HAND
  179. #
  180. procedure Aces(cards)
  181.   every look := !cards do if look[1] == "A" then return "some"
  182.   return "none"
  183.   end
  184.  
  185. #
  186. # THIS ROUTINE DISPLAYS THE USER HAND AND STATUS
  187. #
  188. procedure display_user()
  189.   writes(screen("nocursor"),at(4,7),screen("hinv"),"USER",screen("norm"))
  190.   x := 10 ; y := 5
  191.   every card := !user_hand do
  192.     {
  193.     display(card,x,y)
  194.     x +:= 7
  195.     }
  196.   end
  197.  
  198. #
  199. # THIS ROUTINE DISPLAYS THE HOST HAND AND STATUS
  200. #
  201. procedure display_host(flag)
  202.   writes(screen("nocursor"),at(1,17),screen("hinv"),&host,screen("norm"))
  203.   x := 10 ; y := 15 ; /flag := 0
  204.   every card := !host_hand do
  205.     {
  206.     if (flag=1) & (x=10) then card := "XX"
  207.     display(card,x,y)
  208.     x +:= 7
  209.     }
  210.   end
  211.  
  212. #
  213. # THIS ROUTINE DISPLAYS A GIVEN CARD AT A GIVEN X,Y SCREEN LOCATION
  214. #
  215. procedure display(card,x,y)
  216.     all := [] ; j := y
  217.     if find(card[2],"CS") then card := screen("hinv") || card || screen("norm")
  218.     shape := [at(x,(j+:=1)) || screen("gchar") || "lqqqqqqqk"]
  219.     put(shape,at(x,(j+:=1)) || "x " || card || "    x")
  220.     put(shape,at(x,(j+:=1)) || "x       x")
  221.     put(shape,at(x,(j+:=1)) || "x       x")
  222.     put(shape,at(x,(j+:=1)) || "x       x")
  223.     put(shape,at(x,(j+:=1)) || "x    " || card || " x")
  224.     put(shape,at(x,(j+:=1)) || "mqqqqqqqj" || screen("nchar"))
  225.     put(all,shape)
  226.     x +:= 14
  227.   while shape := pop(all) do every writes(!shape)
  228.   end
  229.  
  230. #
  231. # THIS ROUTINE SHUFFLES THE CARD DECK
  232. #
  233. procedure shuffle()
  234.   static faces, suits
  235.   local cards, i
  236.   initial {
  237.           &random := map(&clock,":","7")   # initial on multiple shuffles
  238.           faces   := ["2","3","4","5","6","7","8","9","T","J","Q","K","A"]
  239.           suits   := ["D","H","C","S"]
  240.           lookup  := table(0)
  241.           every i := 2 to 9 do insert(lookup,string(i),i)
  242.           insert(lookup,"T",10)
  243.           insert(lookup,"J",10)
  244.           insert(lookup,"Q",10)
  245.           insert(lookup,"K",10)
  246.           insert(lookup,"A",11)
  247.           insert(lookup,"a",1)
  248.           }
  249.   cards   := []
  250.   every put(cards,!faces || !suits)
  251.   every i := *cards to 2 by -1 do cards[?i] :=: cards[i]
  252.   return cards
  253.   end
  254.  
  255. #
  256. # THIS ROUTINE PARSES A STRING WITH RESPECT TO SOME DELIMITER
  257. #
  258. procedure parse(line,delims)
  259.   static chars
  260.   chars  := &cset -- delims
  261.   tokens := []
  262.   line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
  263.   return tokens
  264.   end
  265.  
  266. #
  267. # THIS ROUTINE PROMPTS FOR INPUT AND RETURNS A STRING
  268. #
  269. procedure input(prompt)
  270.   writes(screen("cursor"),prompt)
  271.   return read()
  272.   end
  273.  
  274.  
  275. #
  276. # THIS ROUTINE SETS THE VIDEO OUTPUT ATTRIBUTES FOR VT102 OR LATER
  277. # COMPATIBLE TERMINALS.
  278. #
  279. procedure screen(attr)
  280.   case attr of
  281.     {
  282.     "cls"  : return "\e[2J\e[H"  # CLEAR SCREEN
  283.     "clear": return "\e[2J\e[H"  # CLEAR SCREEN
  284.     "top"  : return "\e#3"       # UPPER HALF CHARACTERS
  285.     "bot"  : return "\e#4"       # LOWER HALF CHARACTERS
  286.     "fat"  : return "\e#6"       # SINGLE HEIGHT FAT LETTERS
  287.     "thin" : return "\e#5"       # NORMAL SIZED CHARACTERS
  288.     "hinv" : return "\e[1;7m"    # HIGH INTENSITY & INVERSE
  289.     "norm" : return "\e[m"       # RESTORE NORMAL VIDEO ATTRIBUTES
  290.     "dim"  : return "\e[2m"      # LOW INTENSITY VIDEO
  291.     "blink": return "\e[5m"      # VIDEO BLINKING ATTRIBUTE
  292.   "hiblink": return "\e[1;5m"    # HIGH INTENSITY BLINKING
  293.     "under": return "\e[4m"      # VIDEO UNDERLINING ATTRIBUTE
  294.     "high" : return "\e[1m"      # VIDEO HIGH INTENSITY ATTRIBUTE
  295.     "inv"  : return "\e[7m"      # VIDEO INVERSE ATTRIBUTE
  296.     "eeol" : return "\e[K"       # ERASE TO END OF LINE
  297.     "esol" : return "\e[1K"      # ERASE TO START OF LINE
  298.     "eeos" : return "\e[J"       # ERASE TO END OF SCREEN
  299.     "gchar": return "\e(0"       # TURN ON ANSI GRAPHICS MODE
  300.     "nchar": return "\e(B"       # TURN OFF ANSI GRAPHICS MODE
  301.     "light": return "\e[?5h"     # LIGHT COLORED SCREEN
  302.     "dark" : return "\e[?5l"     # DARK  COLORED SCREEN
  303.     "80"   : return "\e[?3l"     # 80    COLUMNS ON SCREEN
  304.     "132"  : return "\e[?3h"     # 132   COLUMNS ON SCREEN
  305.     "smooth": return "\e[?4h"    # SMOOTH SCREEN SCROLLING
  306.     "jump" : return "\e[?4l"     # JUMP   SCREEN SCROLLING
  307.     "cursor": return "\e[?25h"   # MAKE SURE CURSOR IS VISIBLE
  308.   "nocursor": return "\e[?25l"   # HIDE THE CURSOR
  309.     default: return "("||attr||")"
  310.     }
  311.   end
  312.  
  313. #
  314. # THIS ROUTINE SETS THE CURSOR TO A GIVEN X (COL) Y(ROW) SCREEN LOCATION
  315. #
  316. procedure at(x,y)
  317.   return "\e[" || y || ";" || x || "f"
  318.   end
  319.  
  320.  
  321.  
  322. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Tue Jan  1 20:06:36 1991
  323. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  324.     id AA12591; Tue, 1 Jan 91 20:06:36 -0700
  325. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  326.     id AA04966; Tue, 1 Jan 91 22:06:27 -0500
  327. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Tue, 1 Jan 91 22:03:41 EST
  328. Date: Tue, 1 Jan 91 16:34:36 EST
  329. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  330. To: icon-group@cs.arizona.edu
  331. Message-Id: <281696@Wayne-MTS>
  332. Subject: Message conventions
  333.  
  334.  
  335. This isn't exactly an Icon question, but.....
  336.  
  337. I've noticed that in many of the postings to icon-group, the messages have
  338. excerpts from previous messages preceded by "> ".  Could anyone let me know
  339. what software you're using to get this effect, and how you're using it? 
  340. Thanks. 
  341.  
  342. Paul Abrahams
  343. abrahams%wayne-mts@um.cc.umich.edu
  344.  
  345. From icon-group-request@arizona.edu  Tue Jan  1 21:52:02 1991
  346. Resent-From: icon-group-request@arizona.edu
  347. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  348.     id AA14616; Tue, 1 Jan 91 21:52:02 -0700
  349. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Tue, 1 Jan 91 21:51 MST
  350. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA29802; Tue, 1 Jan 91 20:44:27
  351.  -0800
  352. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  353.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  354.  usenet@ucbvax.Berkeley.EDU if you have questions)
  355. Resent-Date: Tue, 1 Jan 91 21:51 MST
  356. Date: 2 Jan 91 02:56:21 GMT
  357. From: netnews.upenn.edu!msuinfo!midway!quads.uchicago.edu!goer@rutgers.edu
  358. Subject: bj, part 3 of 3
  359. Sender: icon-group-request@arizona.edu
  360. Resent-To: icon-group@cs.arizona.edu
  361. To: icon-group@arizona.edu
  362. Resent-Message-Id: <DEC4BED6C699400483@Arizona.edu>
  363. Message-Id: <1991Jan2.025621.21511@midway.uchicago.edu>
  364. Organization: University of Chicago
  365. X-Envelope-To: icon-group@CS.Arizona.EDU
  366. X-Vms-To: icon-group@Arizona.edu
  367. References: <1991Jan2.025428.21379@midway.uchicago.edu>
  368.  
  369.  
  370. stty: Operation not supported on socket
  371. ---- Cut Here and feed the following to sh ----
  372. #!/bin/sh
  373. # this is bj.03 (part 3 of a multipart archive)
  374. # do not concatenate these parts, unpack them in order with /bin/sh
  375. # file itlibdos.icn continued
  376. #
  377. if test ! -r _shar_seq_.tmp; then
  378.     echo 'Please unpack part 1 first!'
  379.     exit 1
  380. fi
  381. (read Scheck
  382.  if test "$Scheck" != 3; then
  383.     echo Please unpack part "$Scheck" next!
  384.     exit 1
  385.  else
  386.     exit 0
  387.  fi
  388. ) < _shar_seq_.tmp || exit 1
  389. if test ! -f _shar_wnt_.tmp; then
  390.     echo 'x - still skipping itlibdos.icn'
  391. else
  392. echo 'x - continuing file itlibdos.icn'
  393. sed 's/^X//' << 'SHAR_EOF' >> 'itlibdos.icn' &&
  394. X    range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
  395. X    er("igoto",colline || " out of range " || (\range|""),9)
  396. X    } 
  397. X
  398. X    # Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
  399. X    increment := -1
  400. X    outstr := ""
  401. X    
  402. X    cm ? {
  403. X    while outstr ||:= tab(find("%")) do {
  404. X        tab(match("%"))
  405. X        chr := move(1)
  406. X        if case chr of {
  407. X        "." :  outstr ||:= char(line + increment)
  408. X        "+" :  outstr ||:= char(line + ord(move(1)) + increment)
  409. X        "d" :  {
  410. X            str := string(line + increment)
  411. X            outstr ||:= right(str, integer(tab(any('23'))), "0") | str
  412. X        }
  413. X        }
  414. X        then line :=: col
  415. X        else {
  416. X        case chr of {
  417. X            "n" :  line := ixor(line,96) & col := ixor(col,96)
  418. X            "i" :  increment := 0
  419. X            "r" :  line :=: col
  420. X            "%" :  outstr ||:= "%"
  421. X            "B" :  line := ior(ishift(line / 10, 4), line % 10)
  422. X            ">" :  {
  423. X            x := move(1); y := move(1)
  424. X            line > ord(x) & line +:= ord(y)
  425. X            &null
  426. X            }
  427. X        } | er("goto","bad termcap entry",5)
  428. X        }
  429. X    }
  430. X    return outstr || tab(0)
  431. X    }
  432. X
  433. Xend
  434. X
  435. X
  436. X
  437. Xprocedure iputs(cp, affcnt)
  438. X
  439. X    # Writes cp to the screen.  Use this instead of writes() for
  440. X    # compatibility with the Unix version (which will need to send
  441. X    # null padding in some cases).  Iputs() also does a useful type
  442. X    # check.
  443. X
  444. X    static num_chars
  445. X    initial num_chars := &digits ++ '.'
  446. X
  447. X    type(cp) == "string" |
  448. X    er("iputs","you can't iputs() a non-string value!",10)
  449. X
  450. X    cp ? {
  451. X    if tab(many(num_chars)) & ="*" then
  452. X        stop("iputs:  MS-DOS termcap files shouldn't specify padding.")
  453. X    writes(tab(0))
  454. X    }
  455. X
  456. X    return
  457. X
  458. Xend
  459. SHAR_EOF
  460. echo 'File itlibdos.icn is complete' &&
  461. true || echo 'restore of itlibdos.icn failed'
  462. rm -f _shar_wnt_.tmp
  463. fi
  464. # ============= termcap.dos ==============
  465. if test -f 'termcap.dos' -a X"$1" != X"-c"; then
  466.     echo 'x - skipping termcap.dos (File already exists)'
  467.     rm -f _shar_wnt_.tmp
  468. else
  469. > _shar_wnt_.tmp
  470. echo 'x - extracting termcap.dos (Text)'
  471. sed 's/^X//' << 'SHAR_EOF' > 'termcap.dos' &&
  472. Xansi|color|ansi-color|ibm|ibmpc|ANSI.SYS color:\
  473. X    :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
  474. X    :cl=\E[H\E[2J:ce=\E[K:\
  475. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  476. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  477. X    :ti=\E[0;44m:te=\E[0m:\
  478. X    :so=\E[1;35;44m:se=\E[0;44m:\
  479. X    :us=\E[1;31;44m:ue=\E[0;44m:\
  480. X    :mb=\E[5m:md=\E[1m:me=\E[0;44m:
  481. Xmono|ansi-mono|ANSI.SYS:\
  482. X    :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
  483. X    :cl=\E[H\E[2J:ce=\E[K:\
  484. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  485. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  486. X    :so=\E[1m:se=\E[m:us=\E[4m:ue=\E[m:\
  487. X    :mb=\E[5m:md=\E[1m:me=\E[m:
  488. Xnnansi-mono|NNANSI.SYS:\
  489. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  490. X    :cl=\E[2J:cd=\E[J:ce=\E[K:\
  491. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  492. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  493. X    :so=\E[1m:se=\E[2m:\
  494. X    :us=\E[4m:ue=\E[24m:\
  495. X    :mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[m:\
  496. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  497. Xnnansi|nnansi-color|NNANSI.SYS color:\
  498. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  499. X    :cl=\E[2J:cd=\E[J:ce=\E[K:\
  500. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  501. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  502. X    :ti=\E[0;44m:te=\E[0m:\
  503. X    :so=\E[1;35;44m:se=\E[2;37m:\
  504. X    :us=\E[4m:ue=\E[24m:\
  505. X    :mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[0;44m:\
  506. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  507. Xnansi-mono|zansi-mono|N/ZANSI.SYS:\
  508. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  509. X    :cl=\E[2J:ce=\E[K:\
  510. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  511. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  512. X    :ti=\E[0m:te=\E[0m:\
  513. X    :so=\E[1;35m:se=\E[0m:\
  514. X    :us=\E[1;31m:ue=\E[0m:\
  515. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:\
  516. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  517. Xnansi|zansi|nansi-color|zansi-color|N/ZANSI.SYS color:\
  518. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  519. X    :cl=\E[2J:ce=\E[K:\
  520. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  521. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  522. X    :ti=\E[0;44m:te=\E[0m:\
  523. X    :so=\E[1;35;44m:se=\E[0;44m:\
  524. X    :us=\E[1;31;44m:ue=\E[0;44m:\
  525. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[0;44m:\
  526. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  527. XAX|ANSI X3.64|full ANSI X3.64 (1977) standard:\
  528. X    :co#80:li#24:bs:pt:am:mi:bl=^G:le=^H:\
  529. X    :cl=\E[2J:ce=\E[K:cd=\E[J:\
  530. X    :ho=\E[H:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:\
  531. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  532. X    :UP=\E[%dA:DO=\E[%dB:LE=\E[%dC:RI=\E[%dD:\
  533. X    :so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\
  534. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:as=^N:ae=^O:\
  535. X    :ku=\E[A:kd=\E[B:kl=\E[C:kr=\E[D:kb=^H:\
  536. X    :kn#4:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\
  537. X    :im=\E[4h:ei=\E[4l:al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:sf=\ED:sr=\EM:
  538. SHAR_EOF
  539. true || echo 'restore of termcap.dos failed'
  540. rm -f _shar_wnt_.tmp
  541. fi
  542. # ============= README ==============
  543. if test -f 'README' -a X"$1" != X"-c"; then
  544.     echo 'x - skipping README (File already exists)'
  545.     rm -f _shar_wnt_.tmp
  546. else
  547. > _shar_wnt_.tmp
  548. echo 'x - extracting README (Text)'
  549. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  550. XThis package is a simple UNIX port of Chris Tenaglia's blackjack
  551. Xgame for full ANSI terminals.  Because of the structure of the
  552. Xoriginal program (read: because I was lazy) this port won't work
  553. Xwith magic cookie terminals.  It works best on terminals that have
  554. Xboldface, reverse, dim, and blink modes.  If any of these are mis-
  555. Xsing, the appearance of the game will be somewhat altered.  Ter-
  556. Xminals must be at least 24x80.
  557. X
  558. XTo make for UNIX, just copy Makefile.dist to Makefile and type
  559. X"make."  If all goes well, and you have root priviledges, su to
  560. Xroot and type "make install."  You'll have to edit the makefile
  561. Xto reflect local file structures and conventions.
  562. X
  563. XIncluded with this distribution is also a DOS implementation of
  564. Xthe itlib routines and a termcap file.  To run this program on a
  565. XDOS system, first compile using
  566. X
  567. X     icont -o bj bj.icn itlibdos.icn
  568. X
  569. XRead the directions in the file itlibdos.icn for instructions as
  570. Xto how to install a termcap file.  NOTE WELL:  THE TERMCAP FOR
  571. XDOS IS NOT TERRIBLY GOOD, AND IN ORDER TO GET IT TO WORK, YOU
  572. XWILL CERTAINLY NEED TO FIX IT UP.  I don't use DOS much, and will
  573. Xjust have to hope that some any revisions that get made will make
  574. Xtheir way back to me.
  575. X
  576. XNaturally, UNIX users can erase all the DOS files ("rm *dos*").
  577. XDOS users can erase itlibdos.icn and Makefile.dist.  If anything
  578. Xgoes awry, or if a standard terminal such as a VT-XXX or and
  579. XANSI fails to run bj, please let me know.  I expect that older
  580. Xterminals without a full assortment of modes - if they run it
  581. Xat all - will not do so very smartly.
  582. X
  583. XEnjoy Chris's game, and have a good 1991!
  584. X
  585. X-Richard Goerwitz (goer@sophist.uchicago.edu)
  586. SHAR_EOF
  587. true || echo 'restore of README failed'
  588. rm -f _shar_wnt_.tmp
  589. fi
  590. # ============= Makefile.dist ==============
  591. if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
  592.     echo 'x - skipping Makefile.dist (File already exists)'
  593.     rm -f _shar_wnt_.tmp
  594. else
  595. > _shar_wnt_.tmp
  596. echo 'x - extracting Makefile.dist (Text)'
  597. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
  598. X# Don't change this unless you know what you are doing :-).
  599. XPROGNAME = bj
  600. X
  601. X# Please edit these to reflect your local file structure & conventions.
  602. XDESTDIR = /usr/local/bin
  603. XOWNER = bin
  604. XGROUP = bin
  605. X
  606. X# Please don't change these.
  607. XSRC = $(PROGNAME).icn itlib.icn
  608. X
  609. X# I hope you won't have to use this.
  610. X# DEBUGFLAG = -t
  611. X
  612. X$(PROGNAME): $(SRC)
  613. X    /usr/local/bin/icont $(DEBUGFLAG) -o $(PROGNAME) $(SRC)
  614. X
  615. X# Pessimistic assumptions regarding the environment (in particular,
  616. X# I don't assume you have the BSD "install" shell script).
  617. Xinstall: $(PROGNAME)
  618. X    @sh -c "test -d $(DESTDIR) || (mkdir $(DESTDIR) && chmod 755 $(DESTDIR))"
  619. X    cp $(PROGNAME) $(DESTDIR)/
  620. X    chgrp $(GROUP) $(DESTDIR)/$(PROGNAME)
  621. X    chown $(OWNER) $(DESTDIR)/$(PROGNAME)
  622. X    @echo "\nInstallation done.\n"
  623. X
  624. SHAR_EOF
  625. true || echo 'restore of Makefile.dist failed'
  626. rm -f _shar_wnt_.tmp
  627. fi
  628. rm -f _shar_seq_.tmp
  629. echo You have unpacked the last part
  630. exit 0
  631.  
  632. From icon-group-request@arizona.edu  Tue Jan  1 21:52:26 1991
  633. Resent-From: icon-group-request@arizona.edu
  634. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  635.     id AA14625; Tue, 1 Jan 91 21:52:26 -0700
  636. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Tue, 1 Jan 91 21:51 MST
  637. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA29795; Tue, 1 Jan 91 20:44:06
  638.  -0800
  639. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  640.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  641.  usenet@ucbvax.Berkeley.EDU if you have questions)
  642. Resent-Date: Tue, 1 Jan 91 21:51 MST
  643. Date: 2 Jan 91 02:55:23 GMT
  644. From: netnews.upenn.edu!msuinfo!midway!quads.uchicago.edu!goer@rutgers.edu
  645. Subject: bj, part 2 of 3
  646. Sender: icon-group-request@arizona.edu
  647. Resent-To: icon-group@cs.arizona.edu
  648. To: icon-group@arizona.edu
  649. Resent-Message-Id: <DEC4AF716E39400484@Arizona.edu>
  650. Message-Id: <1991Jan2.025523.21456@midway.uchicago.edu>
  651. Organization: University of Chicago
  652. X-Envelope-To: icon-group@CS.Arizona.EDU
  653. X-Vms-To: icon-group@Arizona.edu
  654. References: <1991Jan2.025428.21379@midway.uchicago.edu>
  655.  
  656.  
  657. stty: Operation not supported on socket
  658. ---- Cut Here and feed the following to sh ----
  659. #!/bin/sh
  660. # this is bj.02 (part 2 of a multipart archive)
  661. # do not concatenate these parts, unpack them in order with /bin/sh
  662. # file itlib.icn continued
  663. #
  664. if test ! -r _shar_seq_.tmp; then
  665.     echo 'Please unpack part 1 first!'
  666.     exit 1
  667. fi
  668. (read Scheck
  669.  if test "$Scheck" != 2; then
  670.     echo Please unpack part "$Scheck" next!
  671.     exit 1
  672.  else
  673.     exit 0
  674.  fi
  675. ) < _shar_seq_.tmp || exit 1
  676. if test ! -f _shar_wnt_.tmp; then
  677.     echo 'x - still skipping itlib.icn'
  678. else
  679. echo 'x - continuing file itlib.icn'
  680. sed 's/^X//' << 'SHAR_EOF' >> 'itlib.icn' &&
  681. X                     (tab(find(":")+1), tab(0)))
  682. X            return entry
  683. X            }
  684. X            else {
  685. X            \line := &null # must precede the next line
  686. X            entry ||:= trim(trim(tab(0),'\\'),':')
  687. X            }
  688. X        }
  689. X        }
  690. X    }
  691. X    }
  692. X
  693. X    close(f)
  694. X    er("getentry","can't find and/or process your termcap entry",3)
  695. Xend
  696. X
  697. X
  698. X
  699. Xprocedure read_file(f)
  700. X
  701. X    # Suspends all non #-initial lines in the file f.
  702. X    # Removes leading tabs and spaces from lines before suspending
  703. X    # them.
  704. X
  705. X    local line
  706. X
  707. X    \f | er("read_tcap_file","no valid termcap file found",3)
  708. X    while line := read(f) do {
  709. X    match("#",line) & next
  710. X    line ?:= (tab(many('\t ')) | &null, tab(0))
  711. X    suspend line
  712. X    }
  713. X
  714. X    fail
  715. X
  716. Xend
  717. X
  718. X
  719. X
  720. Xprocedure maketc_table(entry)
  721. X
  722. X    # Maketc_table(s) (where s is a valid termcap entry for some
  723. X    # terminal-type): Returns a table in which the keys are termcap
  724. X    # capability designators, and the values are the entries in
  725. X    # "entry" for those designators.
  726. X
  727. X    local k, v
  728. X
  729. X    /entry & er("maketc_table","no entry given",8)
  730. X    if entry[-1] ~== ":" then entry ||:= ":"
  731. X    
  732. X    /tc_table := table()
  733. X
  734. X    entry ? {
  735. X
  736. X    tab(find(":")+1)    # tab past initial (name) field
  737. X
  738. X    while tab((find(":")+1) \ 1) ? {
  739. X        &subject == "" & next
  740. X        if k := 1(move(2), ="=")
  741. X        then tc_table[k] := Decode(tab(find(":")))
  742. X        else if k := 1(move(2), ="#")
  743. X        then tc_table[k] := integer(tab(find(":")))
  744. X        else if k := 1(tab(find(":")), pos(-1))
  745. X        then tc_table[k] := true()
  746. X        else er("maketc_table", "your termcap file has a bad entry",3)
  747. X    }
  748. X    }
  749. X
  750. X    return tc_table
  751. X
  752. Xend
  753. X
  754. X
  755. X
  756. Xprocedure getval(id)
  757. X
  758. X    /tc_table := maketc_table(getentry(getname())) |
  759. X    er("getval","can't make a table for your terminal",4)
  760. X
  761. X    return \tc_table[id] | fail
  762. X    # er("getval","the current terminal doesn't support "||id,7)
  763. X
  764. Xend
  765. X
  766. X
  767. X
  768. Xprocedure Decode(s)
  769. X
  770. X    # Does things like turn ^ plus a letter into a genuine control
  771. X    # character.
  772. X
  773. X    new_s := ""
  774. X
  775. X    s ? {
  776. X
  777. X    while new_s ||:= tab(upto('\\^')) do {
  778. X        chr := move(1)
  779. X        if chr == "\\" then {
  780. X        new_s ||:= {
  781. X            case chr2 := move(1) of {
  782. X            "\\" : "\\"
  783. X            "^"  : "^"
  784. X            "E"  : "\e"
  785. X            "b"  : "\b"
  786. X            "f"  : "\f"
  787. X            "n"  : "\n"
  788. X            "r"  : "\r"
  789. X            "t"  : "\t"
  790. X            default : {
  791. X                if any(&digits,chr2) then {
  792. X                char(integer("8r"||chr2||move(2 to 0 by -1))) |
  793. X                    er("Decode","bad termcap entry",3)
  794. X                }
  795. X               else chr2
  796. X            }
  797. X            }
  798. X        }
  799. X        }
  800. X        else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
  801. X    }
  802. X    new_s ||:= tab(0)
  803. X    }
  804. X
  805. X    return new_s
  806. X
  807. Xend
  808. X
  809. X
  810. X
  811. Xprocedure igoto(cm,col,line)
  812. X
  813. X    local colline, range, increment, str, outstr, chr, x, y
  814. X
  815. X    if col > (tc_table["co"]) | line > (tc_table["li"]) then {
  816. X    colline := string(\col) || "," || string(\line) | string(\col|line)
  817. X    range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
  818. X    er("igoto",colline || " out of range " || (\range|""),9)
  819. X    } 
  820. X
  821. X    # Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
  822. X    increment := -1
  823. X    outstr := ""
  824. X    
  825. X    cm ? {
  826. X    while outstr ||:= tab(find("%")) do {
  827. X        tab(match("%"))
  828. X        chr := move(1)
  829. X        if case chr of {
  830. X        "." :  outstr ||:= char(line + increment)
  831. X        "+" :  outstr ||:= char(line + ord(move(1)) + increment)
  832. X        "d" :  {
  833. X            str := string(line + increment)
  834. X            outstr ||:= right(str, integer(tab(any('23'))), "0") | str
  835. X        }
  836. X        }
  837. X        then line :=: col
  838. X        else {
  839. X        case chr of {
  840. X            "n" :  line := ixor(line,96) & col := ixor(col,96)
  841. X            "i" :  increment := 0
  842. X            "r" :  line :=: col
  843. X            "%" :  outstr ||:= "%"
  844. X            "B" :  line := ior(ishift(line / 10, 4), line % 10)
  845. X            ">" :  {
  846. X            x := move(1); y := move(1)
  847. X            line > ord(x) & line +:= ord(y)
  848. X            &null
  849. X            }
  850. X        } | er("goto","bad termcap entry",5)
  851. X        }
  852. X    }
  853. X    return outstr || tab(0)
  854. X    }
  855. X
  856. Xend
  857. X
  858. X
  859. X
  860. Xprocedure iputs(cp, affcnt)
  861. X
  862. X    local baud_rates, char_rates, i, delay, PC
  863. X    static num_chars, char_times
  864. X    # global tty_speed
  865. X
  866. X    initial {
  867. X    num_chars := &digits ++ '.'
  868. X    char_times := table()
  869. X    # Baud rates in decimal, not octal (as in termio.h)
  870. X    baud_rates := [0,7,8,9,10,11,12,13,14,15]
  871. X    char_rates := [0,333,166,83,55,41,20,10,10,10]
  872. X    every i := 1 to *baud_rates do {
  873. X        char_times[baud_rates[i]] := char_rates[i]
  874. X    }
  875. X    }
  876. X
  877. X    type(cp) == "string" |
  878. X    er("iputs","you can't iputs() a non-string value!",10)
  879. X
  880. X    cp ? {
  881. X    delay := tab(many(num_chars))
  882. X    if ="*" then {
  883. X        delay *:= \affcnt |
  884. X        er("iputs","affected line count missing",6)
  885. X    }
  886. X    writes(tab(0))
  887. X    }
  888. X
  889. X    if (\delay, tty_speed ~= 0) then {
  890. X    PC := tc_table["pc"] | "\000"
  891. X    char_time := char_times[tty_speed] | (return "speed error")
  892. X    delay := (delay * char_time) + (char_time / 2)
  893. X    every 1 to delay by 10
  894. X    do writes(PC)
  895. X    }
  896. X
  897. X    return
  898. X
  899. Xend
  900. X
  901. X
  902. X
  903. Xprocedure getspeed()
  904. X
  905. X    local stty_g, stty_output, c_cflag, o_speed
  906. X
  907. X    stty_g := open("/bin/stty -g 2>&1","pr") |
  908. X    er("getspeed","Can't access your stty command.",4)
  909. X    stty_output := !stty_g
  910. X    close(stty_g)
  911. X
  912. X    \stty_output ? {
  913. X    # tab to the third field of the output of the stty -g cmd
  914. X        tab(find(":")+1) & tab(find(":")+1) &
  915. X    c_cflag := integer("16r"||tab(find(":")))
  916. X    } | er("getspeed","Unable to unwind your stty -g output.",4)
  917. X
  918. X    o_speed := iand(15,c_cflag)
  919. X    return o_speed
  920. X
  921. Xend
  922. SHAR_EOF
  923. echo 'File itlib.icn is complete' &&
  924. true || echo 'restore of itlib.icn failed'
  925. rm -f _shar_wnt_.tmp
  926. fi
  927. # ============= itlibdos.icn ==============
  928. if test -f 'itlibdos.icn' -a X"$1" != X"-c"; then
  929.     echo 'x - skipping itlibdos.icn (File already exists)'
  930.     rm -f _shar_wnt_.tmp
  931. else
  932. > _shar_wnt_.tmp
  933. echo 'x - extracting itlibdos.icn (Text)'
  934. sed 's/^X//' << 'SHAR_EOF' > 'itlibdos.icn' &&
  935. X##########################################################################
  936. X#    
  937. X#    Name:    itlibdos.icn
  938. X#    
  939. X#    Title:    Icon termlib-type tools (MS-DOS version)
  940. X#    
  941. X#    Author:    Richard L. Goerwitz
  942. X#
  943. X#    Version: 1.12
  944. X#
  945. X###########################################################################
  946. X#
  947. X#  I place this and future versions of itlibdos in the public domain - RLG
  948. X#
  949. X###########################################################################
  950. X#
  951. X#  The following library represents a series of rough functional
  952. X#  equivalents to the standard Unix low-level termcap routines.  They
  953. X#  are not meant as exact termlib clones.  Nor are they enhanced to
  954. X#  take care of magic cookie terminals, terminals that use \D in their
  955. X#  termcap entries, or, in short, anything I felt would not affect my
  956. X#  normal, day-to-day work with ANSI and vt100 terminals.
  957. X#
  958. X#  Requires:  An MS-DOS platform & co-expressions.  The MS-DOS version
  959. X#  is a port of the Unix version.  Software you write for this library
  960. X#  can be made to run under Unix simply by substituting the Unix ver-
  961. X#  sion of this library.  See below for additional notes on how to use
  962. X#  this MS-DOS port.
  963. X#
  964. X#  setname(term)
  965. X#    Use only if you wish to initialize itermlib for a terminal
  966. X#  other than what your current environment specifies.  "Term" is the
  967. X#  name of the termcap entry to use.  Normally this initialization is
  968. X#  done automatically, and need not concern the user.
  969. X#
  970. X#  getval(id)
  971. X#    Works something like tgetnum, tgetflag, and tgetstr.  In the
  972. X#  spirit of Icon, all three have been collapsed into one routine.
  973. X#  Integer valued caps are returned as integers, strings as strings,
  974. X#  and flags as records (if a flag is set, then type(flag) will return
  975. X#  "true").  Absence of a given capability is signalled by procedure
  976. X#  failure.
  977. X#
  978. X#  igoto(cm,destcol,destline) - NB:  default 1 offset (*not* zero)!
  979. X#    Analogous to tgoto.  "Cm" is the cursor movement command for
  980. X#  the current terminal, as obtained via getval("cm").  Igoto()
  981. X#  returns a string which, when output via iputs, will cause the
  982. X#  cursor to move to column "destcol" and line "destline."  Column and
  983. X#  line are always calculated using a *one* offset.  This is far more
  984. X#  Iconish than the normal zero offset used by tgoto.  If you want to
  985. X#  go to the first square on your screen, then include in your program
  986. X#  "iputs(igoto(getval("cm"),1,1))."
  987. X#
  988. X#  iputs(cp,affcnt)
  989. X#    Equivalent to tputs.  "Cp" is a string obtained via getval(),
  990. X#  or, in the case of "cm," via igoto(getval("cm"),x,y).  Affcnt is a
  991. X#  count of affected lines.  It is only relevant for terminals which
  992. X#  specify proportional (starred) delays in their termcap entries.
  993. X#
  994. X#  Notes on the MS-DOS version:
  995. X#    There are two basic reasons for using the I/O routines
  996. X#  contained in this package.  First, by using a set of generalized
  997. X#  routines, your code will become much more readable.  Secondly, by
  998. X#  using a high level interface, you can avoid the cardinal
  999. X#  programming error of hard coding things like screen length and
  1000. X#  escape codes into your programs.
  1001. X#    To use this collection of programs, you must do two things.
  1002. X#  First, you must add the line "device=ansi.sys" (or the name of some
  1003. X#  other driver, like zansi.sys, nansi.sys, or nnansi.sys [=new
  1004. X#  nansi.sys]) to your config.sys file.  Secondly, you must add two
  1005. X#  lines to your autoexec.bat file:  1) "set TERM=ansi-mono" and 2)
  1006. X#  "set TERMCAP=\location\termcap."  The purpose of setting the TERM
  1007. X#  variable is to tell this program what driver you are using.  If you
  1008. X#  have a color system, use "ansi-color" instead of "ansi-mono," and
  1009. X#  if you are using nansi or zansi instead of vanilla ansi, use one of
  1010. X#  these names instead of the "ansi" (e.g. "zansi-mono").  The purpose
  1011. X#  of setting TERMCAP is to make it possible to determine where the
  1012. X#  termcap file is located.  The termcap file (which should have been
  1013. X#  packed with this library as termcap.dos) is a short database of all
  1014. X#  the escape sequences used by the various terminal drivers.  Set
  1015. X#  TERMCAP so that it reflects the location of this file (which should
  1016. X#  be renamed as termcap, for the sake of consistency with the Unix
  1017. X#  version).  Naturally, you must change "\location\" above to reflect
  1018. X#  the correct path on your system.
  1019. X#    Although I make no pretense here of providing here a complete
  1020. X#  introduction to the format of the termcap database file, it will be
  1021. X#  useful, I think, to explain a few basic facts about how to use this
  1022. X#  program in conjunction with it.  If, say, you want to clear the
  1023. X#  screen, add the line,
  1024. X#
  1025. X#    iputs(getval("cl"))
  1026. X#
  1027. X#  to your program.  The function iputs() outputs screen control
  1028. X#  sequences.  Getval retrieves a specific sequence from the termcap
  1029. X#  file.  The string "cl" is the symbol used in the termcap file to
  1030. X#  mark the code used to clear the screen.  By executing the
  1031. X#  expression "iputs(getval("cl"))," you are 1) looking up the "cl"
  1032. X#  (clear) code in the termcap database entry for your terminal, and
  1033. X#  the 2) outputting that sequence to the screen.
  1034. X#    Some other useful termcap symbols are "ce" (clear to end of
  1035. X#  line), "ho" (go to the top left square on the screen), "so" (begin
  1036. X#  standout mode), and "se" (end standout mode).  To output a
  1037. X#  boldfaced string, str, to the screen, you would write -
  1038. X#
  1039. X#    iputs(getval("so"))
  1040. X#    writes(str)
  1041. X#    iputs(getval("se"))
  1042. X#
  1043. X#  You could write "iputs(getval("so") || str || getval("se")), but
  1044. X#  this would only work for DOS.  Some Unix terminals require padding,
  1045. X#  and iputs() handles them specially.  Normally you should not worry
  1046. X#  about Unix quirks under DOS.  It is in general wise, though, to
  1047. X#  separate out screen control sequences, and output them via iputs().
  1048. X#    It is also heartily to be recommended that MS-DOS programmers
  1049. X#  try not to assume that everyone will be using a 25-line screen.
  1050. X#  Some terminals are 24-line.  Some 43.  Some have variable window
  1051. X#  sizes.  If you want to put a status line on, say, the 2nd-to-last
  1052. X#  line of the screen, then determine what that line is by executing
  1053. X#  "getval("li")."  The termcap database holds not only string-valued
  1054. X#  sequences, but numeric ones as well.  The value of "li" tells you
  1055. X#  how many lines the terminal has (compare "co," which will tell you
  1056. X#  how many columns).  To go to the beginning of the second-to-last
  1057. X#  line on the screen, type in:
  1058. X#
  1059. X#    iputs(igoto(getval("cm"), 1, getval("li")-1))
  1060. X#
  1061. X#  The "cm" capability is a special capability, and needs to be output
  1062. X#  via igoto(cm,x,y), where cm is the sequence telling your computer
  1063. X#  to move the cursor to a specified spot, x is the column, and y is
  1064. X#  the row.  The expression "getval("li")-1" will return the number of
  1065. X#  the second-to-last line on your screen.
  1066. X#
  1067. X##########################################################################
  1068. X#
  1069. X#  Requires: MS-DOS, coexpressions
  1070. X#
  1071. X#  See also: iscreen.icn (a set of companion utilities) 
  1072. X#
  1073. X##########################################################################
  1074. X
  1075. X
  1076. Xglobal tc_table
  1077. Xrecord true()
  1078. X
  1079. X
  1080. Xprocedure check_features()
  1081. X
  1082. X    local in_params, line
  1083. X
  1084. X    initial {
  1085. X    find("ms-dos",map(&features)) |
  1086. X        er("check_features","MS-DOS system required",1)
  1087. X    find("o-expres",&features) |
  1088. X        er("check_features","co-expressions not implemented - &$#!",1)
  1089. X    }
  1090. X
  1091. X    return
  1092. X
  1093. Xend
  1094. X
  1095. X
  1096. X
  1097. Xprocedure setname(name)
  1098. X
  1099. X    # Sets current terminal type to "name" and builds a new termcap
  1100. X    # capability database (residing in tc_table).  Fails if unable to
  1101. X    # find a termcap entry for terminal type "name."  If you want it
  1102. X    # to terminate with an error message under these circumstances,
  1103. X    # comment out "| fail" below, and uncomment the er() line.
  1104. X
  1105. X    #tc_table is global
  1106. X    
  1107. X    check_features()
  1108. X
  1109. X    tc_table := maketc_table(getentry(name)) | fail
  1110. X    # er("setname","no termcap entry found for "||name,3)
  1111. X    return
  1112. X
  1113. Xend
  1114. X
  1115. X
  1116. X
  1117. Xprocedure getname()
  1118. X
  1119. X    # Getname() first checks to be sure we're running under DOS, and,
  1120. X    # if so, tries to figure out what the current terminal type is,
  1121. X    # checking the value of the environment variable TERM, and if this
  1122. X    # is unsuccessful, defaulting to "mono."
  1123. X
  1124. X    local term, tset_output
  1125. X
  1126. X    check_features()
  1127. X    term := getenv("TERM") | "mono"
  1128. X    
  1129. X    return \term |
  1130. X    er("getname","can't seem to determine your terminal type",1)
  1131. X
  1132. Xend
  1133. X
  1134. X
  1135. X
  1136. Xprocedure er(func,msg,errnum)
  1137. X
  1138. X    # short error processing utility
  1139. X    write(&errout,func,":  ",msg)
  1140. X    exit(errnum)
  1141. X
  1142. Xend
  1143. X
  1144. X
  1145. X
  1146. Xprocedure getentry(name, termcap_string)
  1147. X
  1148. X    # "Name" designates the current terminal type.  Getentry() scans
  1149. X    # the current environment for the variable TERMCAP.  If the
  1150. X    # TERMCAP string represents a termcap entry for a terminal of type
  1151. X    # "name," then getentry() returns the TERMCAP string.  Otherwise,
  1152. X    # getentry() will check to see if TERMCAP is a file name.  If so,
  1153. X    # getentry() will scan that file for an entry corresponding to
  1154. X    # "name."  If the TERMCAP string does not designate a filename,
  1155. X    # getentry() will look through ./termcap for the correct entry.
  1156. X    # Whatever the input file, if an entry for terminal "name" is
  1157. X    # found, getentry() returns that entry.  Otherwise, getentry()
  1158. X    # fails.
  1159. X
  1160. X    local f, getline, line, nm, ent1, ent2
  1161. X
  1162. X    /termcap_string := getenv("TERMCAP")
  1163. X
  1164. X    if \termcap_string ? (not match("\\"), pos(0) | tab(find("|")+1), =name)
  1165. X    then return termcap_string
  1166. X    else {
  1167. X
  1168. X    # The logic here probably isn't clear.  The idea is to try to use
  1169. X    # the termcap environment variable successively as 1) a termcap en-
  1170. X    # try and then 2) as a termcap file.  If neither works, 3) go to
  1171. X    # the ./termcap file.  The else clause here does 2 and, if ne-
  1172. X    # cessary, 3.  The "\termcap_string ? (not match..." expression
  1173. X    # handles 1.
  1174. X
  1175. X    if find("\\",\termcap_string)
  1176. X    then f := open(termcap_string)
  1177. X    /f := open("termcap") |
  1178. X        er("getentry","I can't access your termcap file",1)
  1179. X
  1180. X    getline := create read_file(f)
  1181. X    
  1182. X    while line := @getline do {
  1183. X        if line ? (pos(1) | tab(find("|")+1), =name, any(':|')) then {
  1184. X        entry := ""
  1185. X        while (\line | @getline) ? {
  1186. X            if entry ||:= 1(tab(find(":")+1), pos(0))
  1187. X            then {
  1188. X            close(f)
  1189. X            # if entry ends in tc= then add in the named tc entry
  1190. X            entry ?:= tab(find("tc=")) ||
  1191. X                # recursively fetch the new termcap entry
  1192. X                (move(3), getentry(tab(find(":"))) ?
  1193. X                    # remove the name field from the new entry
  1194. X                     (tab(find(":")+1), tab(0)))
  1195. X            return entry
  1196. X            }
  1197. X            else {
  1198. X            \line := &null # must precede the next line
  1199. X            entry ||:= trim(trim(tab(0),'\\'),':')
  1200. X            }
  1201. X        }
  1202. X        }
  1203. X    }
  1204. X    }
  1205. X
  1206. X    close(f)
  1207. X    er("getentry","can't find and/or process your termcap entry",3)
  1208. Xend
  1209. X
  1210. X
  1211. X
  1212. Xprocedure read_file(f)
  1213. X
  1214. X    # Suspends all non #-initial lines in the file f.
  1215. X    # Removes leading tabs and spaces from lines before suspending
  1216. X    # them.
  1217. X
  1218. X    local line
  1219. X
  1220. X    \f | er("read_tcap_file","no valid termcap file found",3)
  1221. X    while line := read(f) do {
  1222. X    match("#",line) & next
  1223. X    line ?:= (tab(many('\t ')) | &null, tab(0))
  1224. X    suspend line
  1225. X    }
  1226. X
  1227. X    fail
  1228. X
  1229. Xend
  1230. X
  1231. X
  1232. X
  1233. Xprocedure maketc_table(entry)
  1234. X
  1235. X    # Maketc_table(s) (where s is a valid termcap entry for some
  1236. X    # terminal-type): Returns a table in which the keys are termcap
  1237. X    # capability designators, and the values are the entries in
  1238. X    # "entry" for those designators.
  1239. X
  1240. X    local k, v
  1241. X
  1242. X    /entry & er("maketc_table","no entry given",8)
  1243. X    if entry[-1] ~== ":" then entry ||:= ":"
  1244. X    
  1245. X    tc_table := table()
  1246. X
  1247. X    entry ? {
  1248. X
  1249. X    tab(find(":")+1)    # tab past initial (name) field
  1250. X
  1251. X    while tab((find(":")+1) \ 1) ? {
  1252. X
  1253. X        &subject == "" & next
  1254. X        if k := 1(move(2), ="=")
  1255. X        then tc_table[k] := Decode(tab(find(":")))
  1256. X        else if k := 1(move(2), ="#")
  1257. X        then tc_table[k] := integer(tab(find(":")))
  1258. X        else if k := 1(tab(find(":")), pos(-1))
  1259. X        then tc_table[k] := true()
  1260. X        else er("maketc_table", "your termcap file has a bad entry",3)
  1261. X    }
  1262. X    }
  1263. X
  1264. X    return tc_table
  1265. X
  1266. Xend
  1267. X
  1268. X
  1269. X
  1270. Xprocedure getval(id)
  1271. X
  1272. X    /tc_table := maketc_table(getentry(getname())) |
  1273. X    er("getval","can't make a table for your terminal",4)
  1274. X
  1275. X    return \tc_table[id] | fail
  1276. X    # er("getval","the current terminal doesn't support "||id,7)
  1277. X
  1278. Xend
  1279. X
  1280. X
  1281. X
  1282. Xprocedure Decode(s)
  1283. X
  1284. X    # Does things like turn ^ plus a letter into a genuine control
  1285. X    # character.
  1286. X
  1287. X    new_s := ""
  1288. X
  1289. X    s ? {
  1290. X    while new_s ||:= tab(upto('\\^')) do {
  1291. X        chr := move(1)
  1292. X        if chr == "\\" then {
  1293. X        new_s ||:= {
  1294. X            case chr2 := move(1) of {
  1295. X            "\\" : "\\"
  1296. X            "^"  : "^"
  1297. X            "E"  : "\e"
  1298. X            "b"  : "\b"
  1299. X            "f"  : "\f"
  1300. X            "n"  : "\n"
  1301. X            "r"  : "\r"
  1302. X            "t"  : "\t"
  1303. X            default : {
  1304. X                if any(&digits,chr2) then {
  1305. X                char(integer("8r"||chr2||move(2 to 0 by -1))) |
  1306. X                    er("Decode","bad termcap entry",3)
  1307. X                }
  1308. X               else chr2
  1309. X            }
  1310. X            }
  1311. X        }
  1312. X        }
  1313. X        else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
  1314. X    }
  1315. X    new_s ||:= tab(0)
  1316. X    }
  1317. X
  1318. X    return new_s
  1319. X
  1320. Xend
  1321. X
  1322. X
  1323. X
  1324. Xprocedure igoto(cm,col,line)
  1325. X
  1326. X    local colline, range, increment, str, outstr, chr, x, y
  1327. X
  1328. X    if col > (tc_table["co"]) | line > (tc_table["li"]) then {
  1329. X    colline := string(\col) || "," || string(\line) | string(\col|line)
  1330. SHAR_EOF
  1331. true || echo 'restore of itlibdos.icn failed'
  1332. fi
  1333. echo 'End of  part 2'
  1334. echo 'File itlibdos.icn is continued in part 3'
  1335. echo 3 > _shar_seq_.tmp
  1336. exit 0
  1337.  
  1338. From icon-group-request@arizona.edu  Tue Jan  1 21:52:55 1991
  1339. Resent-From: icon-group-request@arizona.edu
  1340. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  1341.     id AA14640; Tue, 1 Jan 91 21:52:55 -0700
  1342. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Tue, 1 Jan 91 21:51 MST
  1343. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA29778; Tue, 1 Jan 91 20:43:37
  1344.  -0800
  1345. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  1346.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  1347.  usenet@ucbvax.Berkeley.EDU if you have questions)
  1348. Resent-Date: Tue, 1 Jan 91 21:52 MST
  1349. Date: 2 Jan 91 02:54:28 GMT
  1350. From: netnews.upenn.edu!msuinfo!midway!quads.uchicago.edu!goer@rutgers.edu
  1351. Subject: UNIX port of bj, part 1 of 3
  1352. Sender: icon-group-request@arizona.edu
  1353. Resent-To: icon-group@cs.arizona.edu
  1354. To: icon-group@arizona.edu
  1355. Resent-Message-Id: <DEC49C5CF08940048B@Arizona.edu>
  1356. Message-Id: <1991Jan2.025428.21379@midway.uchicago.edu>
  1357. Organization: University of Chicago
  1358. X-Envelope-To: icon-group@CS.Arizona.EDU
  1359. X-Vms-To: icon-group@Arizona.edu
  1360.  
  1361. Tenaglia's blackjack game was very cleanly written, and I ported
  1362. it before dinner tonight.  Some of the character graphics and fonts
  1363. couldn't be reproduced portably using standard Unix terminals, so
  1364. I had to remove them.  Oh well.
  1365.  
  1366. Needless to say, I haven't tested this program terribly thoroughly
  1367. on any system but my own, and even there some bugs might remain.
  1368. Still, I don't expect that anyone will encounter any big problems
  1369. running it (or fixing it up).
  1370.  
  1371. It's a nice game.  In fact, I must hurry up, since my son is breathing
  1372. down my neck to let him have the console so that he can run it here at
  1373. home.  Here's the first of three shell archives.
  1374.  
  1375. -Richard (goer@sophist.uchicago.edu)
  1376.  
  1377.  
  1378. stty: Operation not supported on socket
  1379. ---- Cut Here and feed the following to sh ----
  1380. #!/bin/sh
  1381. # This is a shell archive (produced by shar 3.49)
  1382. # To extract the files from this archive, save it to a file, remove
  1383. # everything above the "!/bin/sh" line above, and type "sh file_name".
  1384. #
  1385. # made 01/02/1991 02:37 UTC by goer@sophist.uchicago.edu
  1386. # Source directory /u/richard/Bj
  1387. #
  1388. # existing files will NOT be overwritten unless -c is specified
  1389. # This format requires very little intelligence at unshar time.
  1390. # "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
  1391. #
  1392. # This is part 1 of a multipart archive                                    
  1393. # do not concatenate these parts, unpack them in order with /bin/sh        
  1394. #
  1395. # This shar contains:
  1396. # length  mode       name
  1397. # ------ ---------- ------------------------------------------
  1398. #  10389 -r--r--r-- bj.icn
  1399. #  12240 -r--r--r-- itlib.icn
  1400. #  14586 -r--r--r-- itlibdos.icn
  1401. #   2391 -r--r--r-- termcap.dos
  1402. #   1654 -rw-r--r-- README
  1403. #    754 -rw-r--r-- Makefile.dist
  1404. #
  1405. if test -r _shar_seq_.tmp; then
  1406.     echo 'Must unpack archives in sequence!'
  1407.     echo Please unpack part `cat _shar_seq_.tmp` next
  1408.     exit 1
  1409. fi
  1410. # ============= bj.icn ==============
  1411. if test -f 'bj.icn' -a X"$1" != X"-c"; then
  1412.     echo 'x - skipping bj.icn (File already exists)'
  1413.     rm -f _shar_wnt_.tmp
  1414. else
  1415. > _shar_wnt_.tmp
  1416. echo 'x - extracting bj.icn (Text)'
  1417. sed 's/^X//' << 'SHAR_EOF' > 'bj.icn' &&
  1418. X############################################################################
  1419. X#
  1420. X#    Names:     bj.icn
  1421. X#
  1422. X#    Title:     blackjack game
  1423. X#
  1424. X#    Author:     Chris Tenaglia (modified by Richard L. Goerwitz)
  1425. X#
  1426. X#    Version: 1.1
  1427. X#
  1428. X############################################################################
  1429. X#  
  1430. X#  Simple but fun blackjack game.  The original version was for an ANSI
  1431. X#  screen.  This version has been modified to work with the Unix termcap
  1432. X#  database file.
  1433. X#
  1434. X############################################################################
  1435. X#
  1436. X#  Links: 
  1437. X#
  1438. X############################################################################
  1439. X
  1440. Xglobal deck, message, lookup,
  1441. X       user_money,  host_money,
  1442. X       user_hand,   host_hand
  1443. X
  1444. Xprocedure main(param)
  1445. X  user_money := integer(param[1]) | 3 ; host_money := user_money
  1446. X  write(screen("cls"))
  1447. X#  Most terminals don't do oversize characters like this.
  1448. X#  write(screen("cls"),"               ",screen("top"),screen("hinv"),
  1449. X#        "BLACK JACK",screen("norm"))
  1450. X#  write("               ",screen("bot"),screen("hinv"),
  1451. X#        "BLACK JACK",screen("norm"))
  1452. X  write(screen("high"),"  ---- BLACK JACK ----",screen("norm"))
  1453. X  bonus := 0
  1454. X  repeat
  1455. X    {
  1456. X    if not any('y',(map(input(at(1,3) || "  " || screen("under") ||
  1457. X                   "Play a game? y/n : "|| screen("norm") ||
  1458. X                   screen("eeol")))[1])) then break
  1459. X    every writes(at(1,3|4),screen("eeos"))
  1460. X    display_score()
  1461. X    deck    := shuffle()
  1462. X    message := ""
  1463. X    user_hand := []          ; host_hand := []
  1464. X    put(user_hand,pop(deck)) ; put(host_hand,pop(deck))
  1465. X    put(user_hand,pop(deck)) ; put(host_hand,pop(deck))
  1466. X    user_points := first(host_hand[1])
  1467. X    if user_points > 21 then
  1468. X      {
  1469. X      writes(at(1,13),user_points," points. You went over. You lose.")
  1470. X      user_money -:= 1 ; host_money +:= 1 + bonus ; bonus := 0
  1471. X      display_score()
  1472. X      next
  1473. X      }
  1474. X    display_host(2)
  1475. X    host_points := second(user_points)
  1476. X    if host_points > 21 then
  1477. X      {
  1478. X      writes(at(50,22),host_points," points. ",&host ? tab(find(" ")),
  1479. X         " went over.")
  1480. X      writes(at(1,13),screen("hiblink"),"You win.",screen("norm"))
  1481. X      host_money -:= 1 ; user_money +:= 1 + bonus ; bonus := 0
  1482. X      display_score()
  1483. X      next
  1484. X      }
  1485. X    if host_points = user_points then
  1486. X      {
  1487. X      writes(at(1,22),screen("hiblink"),"It's a draw at ",user_points,
  1488. X            ". The ANTY goes to bonus.",screen("norm"))
  1489. X      bonus +:= 2 ; host_money -:= 1 ; user_money -:= 1
  1490. X      display_score()
  1491. X      next
  1492. X      }
  1493. X    writes(at(20,12),user_points," points for user.")
  1494. X    writes(at(1,14),host_points," points for ",&host ? tab(find(" ")))
  1495. X    if user_points < host_points then
  1496. X      {
  1497. X      write(at(1,22),screen("hiblink"),&host ? tab(find(" "))," wins.",
  1498. X            screen("norm"),screen("eeol"))
  1499. X      user_money -:= 1 ; host_money +:= 1 + bonus ; bonus := 0
  1500. X      display_score()
  1501. X      next
  1502. X      } else {
  1503. X      writes(at(1,12),screen("hiblink"),"You win.",screen("norm"),
  1504. X         screen("eeol"))
  1505. X      user_money +:= 1 + bonus ; host_money -:= 1 ; bonus := 0
  1506. X      display_score()
  1507. X      next
  1508. X      }
  1509. X    }
  1510. X  write(screen("clear"))
  1511. X  end
  1512. X
  1513. X#
  1514. X# THIS PROCEDURE ALLOWS THE USER TO PLAY AND TAKE HITS
  1515. X#
  1516. Xprocedure first(host_card)
  1517. X  display_user()
  1518. X  display_host(1)
  1519. X  points := value(user_hand)   # just in case
  1520. X  writes(at(1,9),"(",points,") ")
  1521. X  repeat
  1522. X    if any('hy',map(input(at(1,23) || "Hit ? y/n : " || screen("eeol")))) then
  1523. X      {
  1524. X      put(user_hand,pop(deck))
  1525. X      display_user()
  1526. X      if (points := value(user_hand)) > 21 then return points
  1527. X      writes(at(1,9),"(",points,") ")
  1528. X      } else break
  1529. X  (points > 0) | (points := value(user_hand))
  1530. X  writes(at(1,9),"(",points,") ")
  1531. X  write(at(60,11),"You stay with ",points)
  1532. X  return points
  1533. X  end
  1534. X
  1535. X#
  1536. X# THIS SECOND PROCEDURE IS THE HOST PLAYING AGAINST THE USER
  1537. X#
  1538. Xprocedure second(ceiling)
  1539. X  static limits
  1540. X  initial limits := [14,14,15,15,19,16,17,18]
  1541. X  stop_at := ?limits ; points := 0
  1542. X  until (points := value(host_hand)) > stop_at do
  1543. X    {
  1544. X    if points > ceiling then return points
  1545. X    writes(at(1,19),"(",points,") ")
  1546. X#    write(at(1,22),screen("eeol"),&host," will take a hit.",screen("eeol"))
  1547. X    write(at(1,22),screen("eeol"),&host ? tab(find(" ")),
  1548. X      " will take a hit.",screen("eeol"))
  1549. X    put(host_hand,pop(deck))
  1550. X    display_host(2)
  1551. X    }
  1552. X  (points > 0) | (points := value(host_hand))
  1553. X  writes(at(1,19),"(",points,") ")
  1554. X  return points
  1555. X  end
  1556. X
  1557. X#
  1558. X# THIS ROUTINE DISPLAYS THE CURRENT SCORE
  1559. X#
  1560. Xprocedure display_score()
  1561. X  writes(screen("nocursor"))
  1562. X  writes(screen("dim"),at(1,7),"Credits",screen("norm"))
  1563. X  writes(screen("high"),at(1,8),right(user_money,7),screen("norm"))
  1564. X  writes(screen("dim"),at(1,17),"Credits",screen("norm"))
  1565. X  writes(screen("high"),at(1,18),right(host_money,7),screen("norm"))
  1566. X  end
  1567. X#
  1568. X# THIS PROCEDURE EVALUATES THE POINTS OF A HAND. IT TRIES TO MAKE THEM
  1569. X# AS HIGH AS POSSIBLE WITHOUT GOING OVER 21.
  1570. X#
  1571. Xprocedure value(sample)
  1572. X  hand     := copy(sample)
  1573. X  possible := []
  1574. X  repeat
  1575. X    {
  1576. X    sum := 0
  1577. X    every card := !hand do sum +:= lookup[card[1]]
  1578. X    put(possible,sum)
  1579. X    if Aces(hand) == "none" then break else
  1580. X      every i := 1 to *hand do if hand[i][1] == "A" then hand[i][1] := "a"
  1581. X    }
  1582. X  every score := !possible do
  1583. X    if score <= 21 then return score
  1584. X  return possible[1]
  1585. X  end
  1586. X
  1587. X#
  1588. X# ARE THERE ANY 11 POINT ACES LEFT IN HAND
  1589. X#
  1590. Xprocedure Aces(cards)
  1591. X  every look := !cards do if look[1] == "A" then return "some"
  1592. X  return "none"
  1593. X  end
  1594. X
  1595. X#
  1596. X# THIS ROUTINE DISPLAYS THE USER HAND AND STATUS
  1597. X#
  1598. Xprocedure display_user()
  1599. X  writes(screen("nocursor"),at(1,6),screen("hinv"),"USER",screen("norm"))
  1600. X  x := 10 ; y := 4
  1601. X  every card := !user_hand do
  1602. X    {
  1603. X    display(card,x,y)
  1604. X    x +:= 7
  1605. X    }
  1606. X  end
  1607. X
  1608. X#
  1609. X# THIS ROUTINE DISPLAYS THE HOST HAND AND STATUS
  1610. X#
  1611. Xprocedure display_host(flag)
  1612. X  writes(screen("nocursor"),at(1,16),screen("hinv"),
  1613. X     &host ? tab(find(" ")),screen("norm"))
  1614. X  x := 10 ; y := 14 ; /flag := 0
  1615. X  every card := !host_hand do
  1616. X    {
  1617. X    if (flag=1) & (x=10) then card := "XX"
  1618. X    display(card,x,y)
  1619. X    x +:= 7
  1620. X    }
  1621. X  end
  1622. X
  1623. X#
  1624. X# THIS ROUTINE DISPLAYS A GIVEN CARD AT A GIVEN X,Y SCREEN LOCATION
  1625. X#
  1626. Xprocedure display(card,x,y)
  1627. X    all := [] ; j := y
  1628. X    if find(card[2],"CS") then card := screen("hinv") || card || screen("norm")
  1629. X#    shape := [at(x,(j+:=1)) || screen("gchar") || "lqqqqqqqk"]
  1630. X    shape := [at(x,(j+:=1)) || screen("inv") || "         " || screen("norm")]
  1631. X    put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
  1632. X    " " || card || "    " || screen("inv") || " " || screen("norm"))
  1633. X    put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
  1634. X    "       " || screen("inv") || " " || screen("norm"))
  1635. X    put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
  1636. X    "       " || screen("inv") || " " || screen("norm"))
  1637. X    put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
  1638. X    "       " || screen("inv") || " " || screen("norm"))
  1639. X#    put(shape,at(x,(j+:=1)) || "x       x")
  1640. X#    put(shape,at(x,(j+:=1)) || "x       x")
  1641. X    put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
  1642. X    "    " || card || " " || screen("inv") || " " || screen("norm"))
  1643. X#    put(shape,at(x,(j+:=1)) || "mqqqqqqqj" || screen("nchar"))
  1644. X    put(shape,at(x,(j+:=1)) || screen("inv") || "         " || screen("norm"))
  1645. X    put(all,shape)
  1646. X    x +:= 14
  1647. X  while shape := pop(all) do every writes(!shape)
  1648. X  end
  1649. X
  1650. X#
  1651. X# THIS ROUTINE SHUFFLES THE CARD DECK
  1652. X#
  1653. Xprocedure shuffle()
  1654. X  static faces, suits
  1655. X  local cards, i
  1656. X  initial {
  1657. X          &random := map(&clock,":","7")   # initial on multiple shuffles
  1658. X          faces   := ["2","3","4","5","6","7","8","9","T","J","Q","K","A"]
  1659. X          suits   := ["D","H","C","S"]
  1660. X          lookup  := table(0)
  1661. X          every i := 2 to 9 do insert(lookup,string(i),i)
  1662. X          insert(lookup,"T",10)
  1663. X          insert(lookup,"J",10)
  1664. X          insert(lookup,"Q",10)
  1665. X          insert(lookup,"K",10)
  1666. X          insert(lookup,"A",11)
  1667. X          insert(lookup,"a",1)
  1668. X          }
  1669. X  cards   := []
  1670. X  every put(cards,!faces || !suits)
  1671. X  every i := *cards to 2 by -1 do cards[?i] :=: cards[i]
  1672. X  return cards
  1673. X  end
  1674. X
  1675. X#
  1676. X# THIS ROUTINE PARSES A STRING WITH RESPECT TO SOME DELIMITER
  1677. X#
  1678. Xprocedure parse(line,delims)
  1679. X  static chars
  1680. X  chars  := &cset -- delims
  1681. X  tokens := []
  1682. X  line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
  1683. X  return tokens
  1684. X  end
  1685. X
  1686. X#
  1687. X# THIS ROUTINE PROMPTS FOR INPUT AND RETURNS A STRING
  1688. X#
  1689. Xprocedure input(prompt)
  1690. X  writes(screen("cursor"),prompt)
  1691. X  return read()
  1692. X  end
  1693. X
  1694. X
  1695. X#
  1696. X# THIS ROUTINE SETS THE VIDEO OUTPUT ATTRIBUTES FOR VT102 OR LATER
  1697. X# COMPATIBLE TERMINALS.
  1698. X#
  1699. Xprocedure screen(attr)
  1700. X  initial if getval("ug"|"mg"|"sg") > 0 then
  1701. X    er("screen","oops, magic cookie terminal!",34)
  1702. X  return {
  1703. X    case attr of
  1704. X      {
  1705. X      "cls"  : getval("cl")
  1706. X      "clear": getval("cl")
  1707. X      # HIGH INTENSITY & INVERSE
  1708. X      "hinv" : (getval("md") | "") || getval("so")
  1709. X      "norm" : (getval("se") | "") || (getval("me") | "") || (getval("ue")|"")
  1710. X      # LOW INTENSITY VIDEO
  1711. X      "dim"  : getval("mh"|"me")
  1712. X      "blink": getval("mb"|"md"|"so")
  1713. X      # HIGH INTENSITY BLINKING
  1714. X      "hiblink": (getval("md") | "") || getval("mb") | getval("so")
  1715. X      "under": getval("us"|"md"|"so")
  1716. X      "high" : getval("md"|"so"|"ul")
  1717. X      "inv"  : getval("so"|"md"|"ul")
  1718. X      # ERASE TO END OF LINE
  1719. X      "eeol" : getval("ce")
  1720. X      # ERASE TO START OF LINE
  1721. X      "esol" : getval("cb")
  1722. X      # ERASE TO END OF SCREEN
  1723. X      "eeos" : getval("cd")
  1724. X      # MAKE CURSOR INVISIBLE
  1725. X      "cursor": getval("vi"|"CO") | ""
  1726. X      # MAKE CURSOR VISIBLE
  1727. X      "nocursor": getval("ve"|"CF") | ""
  1728. X#      # START ALTERNATE FONT      <- very non-portable
  1729. X#      "gchar": getval("as") | ""
  1730. X#      # END ALTERNATE FONT
  1731. X#      "nchar": getval("ae") | ""
  1732. X#      "light": return "\e[?5h"     # LIGHT COLORED SCREEN
  1733. X#      "dark" : return "\e[?5l"     # DARK  COLORED SCREEN
  1734. X#      "80"   : return "\e[?3l"     # 80    COLUMNS ON SCREEN
  1735. X#      "132"  : return "\e[?3h"     # 132   COLUMNS ON SCREEN
  1736. X#      "smooth": return "\e[?4h"    # SMOOTH SCREEN SCROLLING
  1737. X#      "jump" : return "\e[?4l"     # JUMP   SCREEN SCROLLING
  1738. X      default : er("screen",attr||" is just too weird for most terminals",34)
  1739. X      } | er("screen","I just can't cope with your terminal.",35)
  1740. X    }
  1741. X  end
  1742. X
  1743. X#
  1744. X# THIS ROUTINE SETS THE CURSOR TO A GIVEN X (COL) Y(ROW) SCREEN LOCATION
  1745. X#
  1746. Xprocedure at(x,y)
  1747. X#  return "\e[" || y || ";" || x || "f"
  1748. X  return igoto(getval("cm"),x,y)
  1749. X  end
  1750. X
  1751. SHAR_EOF
  1752. true || echo 'restore of bj.icn failed'
  1753. rm -f _shar_wnt_.tmp
  1754. fi
  1755. # ============= itlib.icn ==============
  1756. if test -f 'itlib.icn' -a X"$1" != X"-c"; then
  1757.     echo 'x - skipping itlib.icn (File already exists)'
  1758.     rm -f _shar_wnt_.tmp
  1759. else
  1760. > _shar_wnt_.tmp
  1761. echo 'x - extracting itlib.icn (Text)'
  1762. sed 's/^X//' << 'SHAR_EOF' > 'itlib.icn' &&
  1763. X########################################################################
  1764. X#    
  1765. X#    Name:    itlib.icn
  1766. X#    
  1767. X#    Title:    Icon termlib-type tools
  1768. X#    
  1769. X#    Author:    Richard L. Goerwitz
  1770. X#
  1771. X#    Version: 1.23
  1772. X#
  1773. X#########################################################################
  1774. X#
  1775. X#  I place this and future versions of itlib in the public domain - RLG
  1776. X#
  1777. X#########################################################################
  1778. X#
  1779. X#  The following library represents a series of rough functional
  1780. X#  equivalents to the standard Unix low-level termcap routines.  They
  1781. X#  are not meant as exact termlib clones.  Nor are they enhanced to
  1782. X#  take care of magic cookie terminals, terminals that use \D in their
  1783. X#  termcap entries, or, in short, anything I felt would not affect my
  1784. X#  normal, day-to-day work with ANSI and vt100 terminals.
  1785. X#
  1786. X#  Requires:  A unix platform & co-expressions.  There is an MS-DOS
  1787. X#  version, itlibdos.icn.
  1788. X#
  1789. X#  setname(term)
  1790. X#    Use only if you wish to initialize itermlib for a terminal
  1791. X#  other than what your current environment specifies.  "Term" is the
  1792. X#  name of the termcap entry to use.  Normally this initialization is
  1793. X#  done automatically, and need not concern the user.
  1794. X#
  1795. X#  getval(id)
  1796. X#    Works something like tgetnum, tgetflag, and tgetstr.  In the
  1797. X#  spirit of Icon, all three have been collapsed into one routine.
  1798. X#  Integer valued caps are returned as integers, strings as strings,
  1799. X#  and flags as records (if a flag is set, then type(flag) will return
  1800. X#  "true").  Absence of a given capability is signalled by procedure
  1801. X#  failure.
  1802. X#
  1803. X#  igoto(cm,destcol,destline) - NB:  default 1 offset (*not* zero)!
  1804. X#    Analogous to tgoto.  "Cm" is the cursor movement command for
  1805. X#  the current terminal, as obtained via getval("cm").  Igoto()
  1806. X#  returns a string which, when output via iputs, will cause the
  1807. X#  cursor to move to column "destcol" and line "destline."  Column and
  1808. X#  line are always calculated using a *one* offset.  This is far more
  1809. X#  Iconish than the normal zero offset used by tgoto.  If you want to
  1810. X#  go to the first square on your screen, then include in your program
  1811. X#  "iputs(igoto(getval("cm"),1,1))."
  1812. X#
  1813. X#  iputs(cp,affcnt)
  1814. X#    Equivalent to tputs.  "Cp" is a string obtained via getval(),
  1815. X#  or, in the case of "cm," via igoto(getval("cm"),x,y).  Affcnt is a
  1816. X#  count of affected lines.  It is only relevant for terminals which
  1817. X#  specify proportional (starred) delays in their termcap entries.
  1818. X#
  1819. X#  Bugs:  I have not tested these routines on terminals that require
  1820. X#  padding.  These routines WILL NOT WORK if your machines stty com-
  1821. X#  mand has no -g option (tisk, tisk).  This includes NeXT worksta-
  1822. X#  tions, and some others that I haven't had time to pinpoint.
  1823. X#
  1824. X##########################################################################
  1825. X#
  1826. X#  Requires: UNIX, co-expressions
  1827. X#
  1828. X#  See also: iscreen.icn (a set of companion utilities)
  1829. X#
  1830. X##########################################################################
  1831. X
  1832. X
  1833. Xglobal tc_table, tty_speed
  1834. Xrecord true()
  1835. X
  1836. X
  1837. Xprocedure check_features()
  1838. X
  1839. X    local in_params, line
  1840. X    # global tty_speed
  1841. X
  1842. X    initial {
  1843. X    find("unix",map(&features)) |
  1844. X        er("check_features","unix system required",1)
  1845. X    find("o-expres",&features) |
  1846. X        er("check_features","co-expressions not implemented - &$#!",1)
  1847. X    system("/bin/stty tabs") |
  1848. X        er("check_features","can't set tabs option",1)
  1849. X    }
  1850. X
  1851. X    # clumsy, clumsy, clumsy, and probably won't work on all systems
  1852. X    tty_speed := getspeed()
  1853. X    return "term characteristics reset; features check out"
  1854. X
  1855. Xend
  1856. X
  1857. X
  1858. X
  1859. Xprocedure setname(name)
  1860. X
  1861. X    # Sets current terminal type to "name" and builds a new termcap
  1862. X    # capability database (residing in tc_table).  Fails if unable to
  1863. X    # find a termcap entry for terminal type "name."  If you want it
  1864. X    # to terminate with an error message under these circumstances,
  1865. X    # comment out "| fail" below, and uncomment the er() line.
  1866. X
  1867. X    #tc_table is global
  1868. X    
  1869. X    check_features()
  1870. X
  1871. X    tc_table := table()
  1872. X    tc_table := maketc_table(getentry(name)) | fail
  1873. X    # er("setname","no termcap entry found for "||name,3)
  1874. X    return "successfully reset for terminal " || name
  1875. X
  1876. Xend
  1877. X
  1878. X
  1879. X
  1880. Xprocedure getname()
  1881. X
  1882. X    # Getname() first checks to be sure we're running under Unix, and,
  1883. X    # if so, tries to figure out what the current terminal type is,
  1884. X    # checking successively the value of the environment variable
  1885. X    # TERM, and then the output of "tset -".  Terminates with an error
  1886. X    # message if the terminal type cannot be ascertained.
  1887. X
  1888. X    local term, tset_output
  1889. X
  1890. X    check_features()
  1891. X
  1892. X    if not (term := getenv("TERM")) then {
  1893. X    tset_output := open("/bin/tset -","pr") |
  1894. X        er("getname","can't find tset command",1)
  1895. X    term := !tset_output
  1896. X    close(tset_output)
  1897. X    }
  1898. X    return \term |
  1899. X    er("getname","can't seem to determine your terminal type",1)
  1900. X
  1901. Xend
  1902. X
  1903. X
  1904. X
  1905. Xprocedure er(func,msg,errnum)
  1906. X
  1907. X    # short error processing utility
  1908. X    write(&errout,func,":  ",msg)
  1909. X    exit(errnum)
  1910. X
  1911. Xend
  1912. X
  1913. X
  1914. X
  1915. Xprocedure getentry(name, termcap_string)
  1916. X
  1917. X    # "Name" designates the current terminal type.  Getentry() scans
  1918. X    # the current environment for the variable TERMCAP.  If the
  1919. X    # TERMCAP string represents a termcap entry for a terminal of type
  1920. X    # "name," then getentry() returns the TERMCAP string.  Otherwise,
  1921. X    # getentry() will check to see if TERMCAP is a file name.  If so,
  1922. X    # getentry() will scan that file for an entry corresponding to
  1923. X    # "name."  If the TERMCAP string does not designate a filename,
  1924. X    # getentry() will scan /etc/termcap for the correct entry.
  1925. X    # Whatever the input file, if an entry for terminal "name" is
  1926. X    # found, getentry() returns that entry.  Otherwise, getentry()
  1927. X    # fails.
  1928. X
  1929. X    local f, getline, line, nm, ent1, ent2
  1930. X
  1931. X    # You can force getentry() to use a specific termcap file by cal-
  1932. X    # ling it with a second argument - the name of the termcap file
  1933. X    # to use instead of the regular one, or the one specified in the
  1934. X    # termcap environment variable.
  1935. X    /termcap_string := getenv("TERMCAP")
  1936. X
  1937. X    if \termcap_string ? (not match("/"), pos(0) | tab(find("|")+1), =name)
  1938. X    then return termcap_string
  1939. X    else {
  1940. X
  1941. X    # The logic here probably isn't clear.  The idea is to try to use
  1942. X    # the termcap environment variable successively as 1) a termcap en-
  1943. X    # try and then 2) as a termcap file.  If neither works, 3) go to
  1944. X    # the /etc/termcap file.  The else clause here does 2 and, if ne-
  1945. X    # cessary, 3.  The "\termcap_string ? (not match..." expression
  1946. X    # handles 1.
  1947. X
  1948. X    if find("/",\termcap_string)
  1949. X    then f := open(termcap_string)
  1950. X    /f := open("/etc/termcap") |
  1951. X        er("getentry","I can't access your /etc/termcap file",1)
  1952. X
  1953. X    getline := create read_file(f)
  1954. X    
  1955. X    while line := @getline do {
  1956. X        if line ? (pos(1) | tab(find("|")+1), =name, any(':|')) then {
  1957. X        entry := ""
  1958. X        while (\line | @getline) ? {
  1959. X            if entry ||:= 1(tab(find(":")+1), pos(0))
  1960. X            then {
  1961. X            close(f)
  1962. X            # if entry ends in tc= then add in the named tc entry
  1963. X            entry ?:= tab(find("tc=")) ||
  1964. X                # recursively fetch the new termcap entry
  1965. X                (move(3), getentry(tab(find(":"))) ?
  1966. X                    # remove the name field from the new entry
  1967. SHAR_EOF
  1968. true || echo 'restore of itlib.icn failed'
  1969. fi
  1970. echo 'End of  part 1'
  1971. echo 'File itlib.icn is continued in part 2'
  1972. echo 2 > _shar_seq_.tmp
  1973. exit 0
  1974.  
  1975. From @mirsa.inria.fr:ol@cerisi.cerisi.Fr  Wed Jan  2 10:48:58 1991
  1976. Resent-From: @mirsa.inria.fr:ol@cerisi.cerisi.Fr
  1977. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  1978.     id AA07953; Wed, 2 Jan 91 10:48:58 -0700
  1979. Received: from MIRSA.INRIA.FR by Arizona.edu; Wed, 2 Jan 91 10:48 MST
  1980. Received: from cerisi.cerisi.fr by mirsa.inria.fr with SMTP (5.61+++/IDA-1.2.8)
  1981.  id AA18029; Wed, 2 Jan 91 18:51:41 +0100
  1982. Resent-Date: Wed, 2 Jan 91 10:48 MST
  1983. Date: Wed, 2 Jan 91 18:46:33 -0100
  1984. From: Lecarme Olivier <ol@cerisi.cerisi.Fr>
  1985. Subject: itlib on alt.sources
  1986. Resent-To: icon-group@cs.arizona.edu
  1987. To: goer@ellis.uchicago.edu
  1988. Cc: icon-group@arizona.edu
  1989. Resent-Message-Id: <DE582B363BD9400B03@Arizona.edu>
  1990. Message-Id: <9101021751.AA18029@mirsa.inria.fr>
  1991. Posted-Date: Wed, 2 Jan 91 18:46:33 -0100
  1992. In-Reply-To: goer@ellis.uchicago.edu's message of 21 Dec 90 06:13:05 GMT
  1993.  <1990Dec21.061305.25347@midway.uchicago.edu>
  1994. X-Envelope-To: icon-group@CS.Arizona.EDU
  1995. X-Vms-To: goer@ellis.uchicago.edu
  1996. X-Vms-Cc: icon-group@Arizona.edu
  1997.  
  1998. Since I don't even know what is alt.sources, I would be interested in a
  1999. copy of your Icon termlib-like routines.
  2000.  
  2001. Thanks, and my best season's greetings!
  2002.  
  2003.  
  2004.                 Olivier Lecarme
  2005.  
  2006. From icon-group-request@arizona.edu  Wed Jan  2 10:53:36 1991
  2007. Resent-From: icon-group-request@arizona.edu
  2008. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2009.     id AA08189; Wed, 2 Jan 91 10:53:36 -0700
  2010. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 2 Jan 91 10:52 MST
  2011. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA13494; Wed, 2 Jan 91 09:49:39
  2012.  -0800
  2013. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2014.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2015.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2016. Resent-Date: Wed, 2 Jan 91 10:52 MST
  2017. Date: 2 Jan 91 16:39:09 GMT
  2018. From: netnews.upenn.edu!msuinfo!midway!ellis.uchicago.edu!goer@rutgers.edu
  2019. Subject: bj
  2020. Sender: icon-group-request@arizona.edu
  2021. Resent-To: icon-group@cs.arizona.edu
  2022. To: icon-group@arizona.edu
  2023. Resent-Message-Id: <DE579E47E529400B19@Arizona.edu>
  2024. Message-Id: <1991Jan2.163909.6723@midway.uchicago.edu>
  2025. Organization: University of Chicago
  2026. X-Envelope-To: icon-group@CS.Arizona.EDU
  2027. X-Vms-To: icon-group@Arizona.edu
  2028.  
  2029. I noticed that on terms without boldfacing, you can make bj a
  2030. bit more flexible by going to the routine screen() and changing
  2031. the line that says
  2032.  
  2033.       # LOW INTENSITY VIDEO
  2034.       "dim"  : getval("mh"|"me")
  2035.  
  2036. so that it says
  2037.  
  2038.       # LOW INTENSITY VIDEO
  2039.       "dim"  : getval("mh"|"me"|"se")
  2040.  
  2041. or something like that.  The idea is that if you can't do a dim,
  2042. try just turning off bold or reverse attributes.
  2043.  
  2044. Note that the "old" way meant that if a terminal couldn't bold-
  2045. face or dim, bj would abort saying that your terminal was too
  2046. stupid, which in fact it was.
  2047.  
  2048. -Richard
  2049.  
  2050. From icon-group-request@arizona.edu  Wed Jan  2 13:24:56 1991
  2051. Resent-From: icon-group-request@arizona.edu
  2052. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2053.     id AA14108; Wed, 2 Jan 91 13:24:56 -0700
  2054. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 2 Jan 91 13:24 MST
  2055. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA17570; Wed, 2 Jan 91 12:13:22
  2056.  -0800
  2057. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2058.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2059.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2060. Resent-Date: Wed, 2 Jan 91 13:24 MST
  2061. Date: 2 Jan 91 17:59:57 GMT
  2062. From: tron!beser@uunet.uu.net
  2063. Subject: RE: itlib on alt.sources
  2064. Sender: icon-group-request@arizona.edu
  2065. Resent-To: icon-group@cs.arizona.edu
  2066. To: icon-group@arizona.edu
  2067. Resent-Message-Id: <DE4264EBF429400DB6@Arizona.edu>
  2068. Message-Id: <685@tron.UUCP>
  2069. Organization: Westinghouse Electronic Systems Group, Baltimore, MD, USA
  2070. X-Envelope-To: icon-group@CS.Arizona.EDU
  2071. X-Vms-To: icon-group@Arizona.edu
  2072. References: <1990Dec21.061305.25347@midway.uchicago.edu>
  2073.  
  2074.  
  2075.  
  2076. Given the ability to call c routines from icon, and for c routines
  2077. to call icon, has anyone done an Xwindows interface for icon? If not,
  2078. I volunteer (ugh). In order to do this, I need the following
  2079. information.
  2080.  
  2081. I looked for Griswald's book on implementation of icon, and no one
  2082. has it. Anywhere. What I need is a better discription than what the
  2083. tech reference that came with rev 8 has (which refers to Griswald's
  2084. book). I have written interpretive interfaces before, and I have
  2085. a rough idea how it may work, but I would appreciate someone sending
  2086. me any information on icon calling conventions and function
  2087. return conventions. Or at least where to look. 
  2088.  
  2089. Handling callbacks from X would be done through C interfaces to ICON.
  2090. The callbacks would be registered through the runtime and would
  2091. return through the runtime. My confusion is about how the status
  2092. information, or pointers to X structures would be passed back to ICON. 
  2093.  
  2094. Anyone willing to help, kindly let me know through email.
  2095.  
  2096. Eric Beser
  2097. Westinghouse Aerospace Software Engineering
  2098. beser@tron.bwi.wec.com
  2099.  
  2100. From icon-group-request@arizona.edu  Wed Jan  2 19:30:47 1991
  2101. Resent-From: icon-group-request@arizona.edu
  2102. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2103.     id AA00444; Wed, 2 Jan 91 19:30:47 -0700
  2104. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 2 Jan 91 16:21 MST
  2105. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA22451; Wed, 2 Jan 91 15:15:02
  2106.  -0800
  2107. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2108.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2109.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2110. Resent-Date: Wed, 2 Jan 91 16:21 MST
  2111. Date: 2 Jan 91 11:57:01 GMT
  2112. From: hsi!mlfarm!ron@uunet.uu.net
  2113. Subject: Message conventions
  2114. Sender: icon-group-request@arizona.edu
  2115. Resent-To: icon-group@cs.arizona.edu
  2116. To: icon-group@arizona.edu
  2117. Resent-Message-Id: <DE29A8C75BD9401092@Arizona.edu>
  2118. Message-Id: <675@mlfarm.com>
  2119. Organization: Maple Lawn Farm, Stonington, CT
  2120. X-Envelope-To: icon-group@CS.Arizona.EDU
  2121. X-Vms-To: icon-group@Arizona.edu
  2122.  
  2123. Paul Abrahams writes:
  2124.  
  2125.  > I've noticed that in many of the postings to icon-group, the messages have
  2126.  > excerpts from previous messages preceded by "> ".  Could anyone let me know
  2127.  > what software you're using to get this effect, and how you're using it? 
  2128.  > Thanks. 
  2129.  
  2130. The convention is used by many mailers and news readers, including the
  2131. Gnu Emacs mail readers, Elm, rn, and others.  Here is a short icon
  2132. program which will accomplish the same thing.  You can either pipe a
  2133. news-article or mail-item to `reply' directly from your mail or news
  2134. reader, or save the news-article or mail-item in a file and run
  2135. `reply' with the file as input.  You will have to customize edstr and
  2136. host to suit your editor and system, and may have to customize the
  2137. addressing conventions at the end of the code.  This should work for
  2138. Unix or ms-dos (the ms-dos is untested).  It may be useful on VMS or
  2139. other operating systems with some modifications.
  2140.  
  2141. ---------------------------[reply.icn]---------------------------
  2142. # reply.icn
  2143. # ron@mlfarm.com, 2 Jan 91
  2144. # usage: reply < news-article or mail-item
  2145. #
  2146. # Configure edstr and host as needed for your editor and mail feed.
  2147.  
  2148. procedure main()
  2149.  
  2150.   find("UNIX",&features) & {
  2151.     console := "/dev/tty"
  2152.     tmpfile := "/tmp/"
  2153.   }
  2154.   find("MS-DOS",&features) & {
  2155.     console := "CON"
  2156.     tmpfile := ""
  2157.   }
  2158.   &clock ? while tab(upto(&digits)) do tmpfile ||:= tab(many(&digits))
  2159.   tmpfile ||:= ".tmp"
  2160.  
  2161.   edstr := "vi " || tmpfile || " < " || console
  2162.   host := "mlfarm.com"
  2163.  
  2164.   eoh := 0
  2165.   reply := open(tmpfile, "w") | stop("reply: cannot open temp file")
  2166.   while s := read() do {
  2167.     eoh = 1 & {
  2168.       write(reply, " > ", s)
  2169.       next
  2170.     }
  2171.     (match("From: ", s) | match("Reply-To: ", s)) & {
  2172.       start := s[find(" ",s)+1:0]
  2173.       if find("<", s) then {
  2174.     fullname := trim(start ? tab(upto("<")))
  2175.     address := s[find("<",s)+1:find(">",s)] 
  2176.       }
  2177.       else {
  2178.     address := trim(start ? tab(upto("(")) | tab(0))
  2179.     fullname := s[find("(",s)+1:find(")",s)]
  2180.       }
  2181.       quoter := (\fullname | address)
  2182.     }
  2183.     match("Date: ", s) & date := s[7:0]
  2184.     match("Message-Id: ", s) & id := s[find("<",s):find(">",s)+1]
  2185.     match("Subject: ", s) & subject := s
  2186.     match("Newsgroup: ", s) & newsgroup := (s ? tab(upto(",")) | tab(0))
  2187.     (\address & not any(&ascii, s)) & {
  2188.       eoh := 1
  2189.       write(reply, "In-reply-to: ", quoter, "'s message of ", date);
  2190.       \subject & write(reply, subject)
  2191.       \newsgroup & write(reply, newsgroup)
  2192.       write(reply, "\nIn ", id, ", ", quoter, " writes:\n")
  2193.     }
  2194.   }
  2195.   system(edstr)
  2196.   stdin := open(console, "r")
  2197.   writes("Send y/n? ")
  2198.   upto('nN',read(stdin)) & {
  2199.     remove(tmpfile)
  2200.     stop("Reply aborted.")
  2201.   }
  2202.   find("@",address) & address ? {
  2203.     name := tab(upto("@"))
  2204.     move(1)
  2205.     address := (tab(upto(" ")) | tab(0)) || "!" || name
  2206.   }
  2207.   address ||:= "@" || host
  2208.   mailstr := "mail " || address || " < " || tmpfile
  2209.   system(mailstr)
  2210.   write("Reply sent to " || address)
  2211.   remove(tmpfile)
  2212. end
  2213. -------------------------------[end]------------------------------
  2214. --
  2215.  
  2216. Ronald Florence            ron@mlfarm.com
  2217.  
  2218. From icon-group-request@arizona.edu  Thu Jan  3 02:21:58 1991
  2219. Resent-From: icon-group-request@arizona.edu
  2220. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2221.     id AA12117; Thu, 3 Jan 91 02:21:58 -0700
  2222. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Thu, 3 Jan 91 02:21 MST
  2223. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA06120; Thu, 3 Jan 91 01:07:33
  2224.  -0800
  2225. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2226.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2227.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2228. Resent-Date: Thu, 3 Jan 91 02:21 MST
  2229. Date: 3 Jan 91 07:07:58 GMT
  2230. From: midway!ellis.uchicago.edu!goer@uunet.uu.net
  2231. Subject: RE:  Icon as a teaching language
  2232. Sender: icon-group-request@arizona.edu
  2233. Resent-To: icon-group@cs.arizona.edu
  2234. To: icon-group@arizona.edu
  2235. Resent-Message-Id: <DDD5D6274EE94015AF@Arizona.edu>
  2236. Message-Id: <1991Jan3.070758.28164@midway.uchicago.edu>
  2237. Organization: University of Chicago
  2238. X-Envelope-To: icon-group@CS.Arizona.EDU
  2239. X-Vms-To: icon-group@Arizona.edu
  2240. References: <9012261840.AA07710@june.cs.washington.edu>
  2241.  
  2242. In article <9012261840.AA07710@june.cs.washington.edu> Bill Griswold writes:
  2243. >
  2244. >>With the Christmas vacation upon us and a 12-year old around the
  2245. >>house, I wonder if anyone has had experience with Icon as a first
  2246. >>structured language....
  2247. ...
  2248. >Unfortunately Icon isn't interactively interpretive, so you can't
  2249. >run-as-you-program.  I've written a little line-oriented interpreter loop
  2250. >for Icon, but it changes the syntax and doesn't allow procedures....
  2251.  
  2252. Has anyone written an Icon interpreter?  (Bill, could you post yours??)
  2253. It surely is the case that my son functions better using interpreters.
  2254. I also would not mind the ability to test out code fragments using an
  2255. Icon interpreter, even a rough and fairly fragmentary one.
  2256.  
  2257. -Richard (goer@sophist.uchicago.edu)
  2258.  
  2259. From icon-group-request@arizona.edu  Thu Jan  3 08:09:04 1991
  2260. Resent-From: icon-group-request@arizona.edu
  2261. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2262.     id AA24614; Thu, 3 Jan 91 08:09:04 -0700
  2263. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Thu, 3 Jan 91 08:08 MST
  2264. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA11765; Thu, 3 Jan 91 06:56:31
  2265.  -0800
  2266. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2267.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2268.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2269. Resent-Date: Thu, 3 Jan 91 08:08 MST
  2270. Date: 3 Jan 91 13:08:43 GMT
  2271. From: bbn.com!nic!hri!sparc9!rolandi@apple.com
  2272. Subject: RE:  Icon as a teaching language
  2273. Sender: icon-group-request@arizona.edu
  2274. Resent-To: icon-group@cs.arizona.edu
  2275. To: icon-group@arizona.edu
  2276. Resent-Message-Id: <DDA55BB5F1A940182A@Arizona.edu>
  2277. Message-Id: <1991Jan3.130843.2179@hri.com>
  2278. Organization: Horizon Research
  2279. X-Envelope-To: icon-group@CS.Arizona.EDU
  2280. X-Vms-To: icon-group@Arizona.edu
  2281. References: <1991Jan3.070758.28164@midway.uchicago.edu>,
  2282.  <9012261840.AA07710@june.cs.washington.edu>
  2283.  
  2284. In article <1991Jan3.070758.28164@midway.uchicago.edu>,
  2285. goer@ellis.uchicago.edu (Richard L. Goerwitz) writes:
  2286. > In article <9012261840.AA07710@june.cs.washington.edu> Bill Griswold writes:
  2287. > >
  2288. > >>With the Christmas vacation upon us and a 12-year old around the
  2289. > >>house, I wonder if anyone has had experience with Icon as a first
  2290. > >>structured language....
  2291. > ...
  2292. > >Unfortunately Icon isn't interactively interpretive, so you can't
  2293. > >run-as-you-program.  I've written a little line-oriented interpreter loop
  2294. > >for Icon, but it changes the syntax and doesn't allow procedures....
  2295. > Has anyone written an Icon interpreter?  (Bill, could you post yours??)
  2296. > It surely is the case that my son functions better using interpreters.
  2297. > I also would not mind the ability to test out code fragments using an
  2298. > Icon interpreter, even a rough and fairly fragmentary one.
  2299. > -Richard (goer@sophist.uchicago.edu)
  2300.  
  2301.  
  2302. i too would like to obtain an icon interpreter.  has the potential to set
  2303. a "post BASIC" first language standard been considered at the project?
  2304.  
  2305. --
  2306. ------------------------------------------------------------------------------
  2307.  
  2308.                             Walter G. Rolandi          
  2309.                           Horizon Research, Inc.       
  2310.                              1432 Main Street          
  2311.                          Waltham, MA  02154  USA       
  2312.                               (617) 466 8367           
  2313.                                                        
  2314.                              rolandi@hri.com           
  2315. ------------------------------------------------------------------------------
  2316.  
  2317. From nowlin@iwtqg.att.com  Thu Jan  3 10:05:44 1991
  2318. Message-Id: <9101031705.AA28146@megaron.cs.arizona.edu>
  2319. Received: from att.att.com by megaron.cs.arizona.edu (5.61/15) via SMTP
  2320.     id AA28146; Thu, 3 Jan 91 10:05:44 -0700
  2321. From: nowlin@iwtqg.att.com
  2322. Date: Thu, 3 Jan 91 07:55 CST
  2323. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  2324. To: icon-group@cs.arizona.edu
  2325. Subject: Re: icon interpreter
  2326.  
  2327. I did an Icon interpreter a number of years ago when we had some people who
  2328. wanted to use Icon but didn't want to have to learn an editor.  It's been
  2329. so long I just went back and changed the cset I'd defined for digits to use
  2330. &digits.  I vouch for general sanity but it hasn't been tested or used a
  2331. long time.
  2332.  
  2333. This program is kind of like an interactive version of BASIC in that Icon
  2334. expressions are entered with line numbers and you can resequence them list
  2335. them etc. and execute all the lines entered.  There is no editor built
  2336. in.  You have to retype a line to change it.  Anyway here it is.
  2337. Documentation is lacking but there is a "?" help command that lists all the
  2338. other commands.  It sounds like what was requested.  Anyway it can be used
  2339. as a starting place.
  2340.  
  2341. Jerry Nowlin
  2342. (...!att!iwtqg!nowlin)
  2343.  
  2344. ============================> cut here <===================================
  2345.  
  2346. global    WHITE,    # the white space cset
  2347.     MFLAG,    # the modified flag
  2348.     PRTBL    # the program table
  2349.  
  2350. procedure main(arg)
  2351.  
  2352. #    define the needed cset
  2353.     WHITE := ' \t\n\f'
  2354.  
  2355. #    initialize the program table
  2356.     PRTBL := table()
  2357.  
  2358. #    initialize the modified flag
  2359.     MFLAG := 0
  2360.  
  2361. #    get all the input
  2362.     writes("Icon> ")
  2363.     while line := read() do {
  2364.  
  2365. #        scan the input line
  2366.         line ? {
  2367.  
  2368. #            skip any initial white space
  2369.             tab(many(WHITE))
  2370.  
  2371. #            check for program lines (they have line numbers)
  2372.             if lno := tab(many(&digits)) & tab(many(WHITE)) then {
  2373.  
  2374. #                get the program line
  2375.                 pline := tab(0)
  2376.  
  2377. #                store the line in the program table
  2378.                 PRTBL[numeric(lno)] := pline
  2379.  
  2380. #                set the modified flag
  2381.                 MFLAG +:= 1
  2382.             }
  2383.  
  2384. #            read command
  2385.             else if (tab(upto(WHITE)) | tab(0)) ==
  2386.                 ("read" | "r") then {
  2387.                 readprog()
  2388.  
  2389. #                clear the modified flag
  2390.                 MFLAG := 0
  2391.             }
  2392.  
  2393. #            write command
  2394.             else if (tab(upto(WHITE)) | tab(0)) ==
  2395.                 ("write" | "w") then {
  2396.                 writeprog()
  2397.  
  2398. #                clear the modified flag
  2399.                 MFLAG := 0
  2400.             }
  2401.  
  2402. #            delete command
  2403.             else if (tab(upto(WHITE)) | tab(0)) ==
  2404.                 ("delete" | "d") then {
  2405.                 delprog()
  2406.  
  2407. #                set the modified flag
  2408.                 MFLAG +:= 1
  2409.             }
  2410.  
  2411. #            sequence command
  2412.             else if (tab(upto(WHITE)) | tab(0)) ==
  2413.                 ("sequence" | "s") then {
  2414.                 seqprog()
  2415.             }
  2416.  
  2417. #            list command
  2418.             else if (tab(upto(WHITE)) | tab(0)) ==
  2419.                 ("list" | "l") then {
  2420.                 listprog()
  2421.             }
  2422.  
  2423. #            execute command
  2424.             else if (tab(upto(WHITE)) | tab(0)) ==
  2425.                 ("execute" | "e") then {
  2426.                 execprog()
  2427.             }
  2428.  
  2429. #            help command
  2430.             else if (tab(upto(WHITE)) | tab(0)) ==
  2431.                 ("help" | "h" | "?") then {
  2432.                 helpprog()
  2433.             }
  2434.  
  2435. #            quit command
  2436.             else if (tab(upto(WHITE)) | tab(0)) ==
  2437.                 ("quit" | "q") then {
  2438.                 quitprog()
  2439.             }
  2440.  
  2441. #            invalid syntax input
  2442.             else {
  2443.                 write("Syntax Error: ",line)
  2444.                 helpprog()
  2445.             }
  2446.         }
  2447.         writes("Icon> ")
  2448.     }
  2449.  
  2450. end
  2451.  
  2452. procedure execprog()
  2453.  
  2454.     static    tmpfile
  2455.  
  2456.     initial tmpfile := "TMPFILE.icn"
  2457.  
  2458. #    get any runtime arguments
  2459.     runargs := tab(0)
  2460.  
  2461. #    create the temporary Icon file
  2462.     (out := open(tmpfile,"w")) |
  2463.  
  2464. #    or mention the problem and fail
  2465.     (write("I can't open '",tmpfile,"' for writing") & fail)
  2466.  
  2467. #    sort the program table
  2468.     prog := sort(PRTBL)
  2469.  
  2470. #    put the program in the file
  2471.     every line := !prog do {
  2472.         write(out,line[2])
  2473.     }
  2474.     close(out)
  2475.  
  2476. #    format the command to execute the program
  2477.     command := "icont -s " || tmpfile || " -x " || runargs
  2478.  
  2479. #    add the command to remove the temporary file
  2480.     command ||:= " ; rm -f " || tmpfile
  2481.  
  2482. #    execute the command
  2483.     system(command)
  2484.  
  2485. end
  2486.  
  2487. procedure seqprog()
  2488.  
  2489. #    initialize the sequencing numbers
  2490.     begno := incno := 10
  2491.  
  2492. #    skip any white space
  2493.     tab(many(WHITE))
  2494.  
  2495. #    get an initial line number
  2496.     begno := numeric(tab(many(&digits)))
  2497.  
  2498. #    skip any white space
  2499.     tab(many(WHITE))
  2500.  
  2501. #    get a increment number
  2502.     incno := numeric(tab(many(&digits)))
  2503.  
  2504. #    sort the program table
  2505.     prog := sort(PRTBL)
  2506.  
  2507. #    reinitialize it
  2508.     PRTBL := table()
  2509.  
  2510. #    sequence the program lines starting with begno by incno
  2511.     lno := begno
  2512.     every l := !prog do {
  2513.         PRTBL[lno] := l[2]
  2514.         lno +:= incno
  2515.     }
  2516.  
  2517. end
  2518.  
  2519. procedure readprog()
  2520.  
  2521. #    get a possible command line file name
  2522.     tab(many(WHITE))
  2523.     readfile := tab(upto(WHITE) | 0)
  2524.  
  2525. #    if there was no file with the command get one
  2526.     if /readfile | *readfile = 0 then {
  2527.         writes("Read file name: ")
  2528.         readfile := read()
  2529.     }
  2530.  
  2531. #    make sure a modified file has been written
  2532.     if MFLAG > 0 then {
  2533.         writes("Write before reading over current program? ")
  2534.         response := read()
  2535.         if any('yY',response) then
  2536.             writeprog()
  2537.     }
  2538.  
  2539. #    initialize the program table
  2540.     PRTBL := table()
  2541.  
  2542. #    read the program from the read file
  2543.     in := open(readfile,"r")
  2544.     lno := 10
  2545.     every line := !in do {
  2546.         PRTBL[lno] := line
  2547.         lno +:= 10
  2548.     }
  2549.     close(in)
  2550.  
  2551. #    tell them what you did
  2552.     write("Read '",readfile,"'...",*PRTBL," lines")
  2553.  
  2554. end
  2555.  
  2556. procedure writeprog()
  2557.  
  2558. #    get a possible command line file name
  2559.     tab(many(WHITE))
  2560.     writefile := tab(upto(WHITE) | 0)
  2561.  
  2562. #    if there was no file with the command get one
  2563.     if /writefile | *writefile = 0 then {
  2564.         writes("Write file name: ")
  2565.         writefile := read()
  2566.     }
  2567.  
  2568. #    sort the program table
  2569.     prog := sort(PRTBL)
  2570.  
  2571. #    write the program to the write file
  2572.     out := open(writefile,"w")
  2573.     every l := !prog do {
  2574.         write(out,l[2])
  2575.     }
  2576.     close(out)
  2577.  
  2578. #    tell them what you did
  2579.     write("Write '",writefile,"'...",*PRTBL," lines")
  2580.  
  2581. end
  2582.  
  2583. procedure delprog()
  2584.  
  2585. #    initialize the line numbers
  2586.     begno := 0
  2587.     endno := 99999
  2588.  
  2589. #    skip any white space
  2590.     tab(many(WHITE))
  2591.  
  2592. #    get an initial line number
  2593.     begno := endno := numeric(tab(many(&digits)))
  2594.  
  2595. #    skip any white space
  2596.     tab(many(WHITE))
  2597.  
  2598. #    get a final line number
  2599.     endno := numeric(tab(many(&digits)))
  2600.  
  2601. #    sort the program table
  2602.     prog := sort(PRTBL)
  2603.  
  2604. #    reinitialize it
  2605.     PRTBL := table()
  2606.  
  2607. #    delete the program lines between the optional numbers
  2608.     every l := !prog do {
  2609.         lno := numeric(l[1])
  2610.         if (lno < begno) | (lno > endno) then PRTBL[lno] := l[2]
  2611.     }
  2612.  
  2613. end
  2614.  
  2615. procedure listprog()
  2616.  
  2617. #    initialize the line numbers
  2618.     begno := 0
  2619.     endno := 99999
  2620.  
  2621. #    skip any white space
  2622.     tab(many(WHITE))
  2623.  
  2624. #    get an initial line number
  2625.     begno := endno := numeric(tab(many(&digits)))
  2626.  
  2627. #    skip any white space
  2628.     tab(many(WHITE))
  2629.  
  2630. #    get a final line number
  2631.     endno := numeric(tab(many(&digits)))
  2632.  
  2633. #    sort the program table
  2634.     prog := sort(PRTBL)
  2635.  
  2636. #    list the program lines between the optional numbers
  2637.     every l := !prog do {
  2638.         lno := numeric(l[1])
  2639.         if (lno >= begno) & (lno <= endno) then
  2640.             write(right(lno,5),": ",l[2])
  2641.         if lno > endno then break
  2642.     }
  2643.  
  2644. end
  2645.  
  2646. procedure helpprog()
  2647.  
  2648.     static helpmsg
  2649.  
  2650. #    define the help message
  2651.     initial {
  2652.         helpmsg := [
  2653.         "<<< Icon Expression Syntax >>>",
  2654.         "",
  2655.         "lineno expression",
  2656.         "",
  2657.         "<<< Command Summary >>>",
  2658.         " (1st character works)",
  2659.         "",
  2660.         "read [ file ]",
  2661.         "write [ file ]",
  2662.         "list [ begno [ endno ] ]",
  2663.         "delete [ begno [ endno ] ]",
  2664.         "sequence [ begno [ increment ] ]",
  2665.         "execute [ args ]",
  2666.         "quit",
  2667.         "help"
  2668.         ]
  2669.     }
  2670.  
  2671. #    print it
  2672.     every write(!helpmsg)
  2673.  
  2674. end
  2675.  
  2676. procedure quitprog()
  2677.  
  2678. #    make sure a modified file has been written
  2679.     if MFLAG > 0 then {
  2680.         writes("Write before quitting? ")
  2681.         response := read()
  2682.         if any('yY',response) then
  2683.             writeprog()
  2684.     }
  2685.  
  2686.     stop("Goodbye.")
  2687.  
  2688. end
  2689.  
  2690. From wgg@cs.washington.edu  Thu Jan  3 12:48:51 1991
  2691. Resent-From: wgg@cs.washington.edu
  2692. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2693.     id AA04153; Thu, 3 Jan 91 12:48:51 -0700
  2694. Return-Path: wgg@cs.washington.edu
  2695. Received: from june.cs.washington.edu by Arizona.edu; Thu, 3 Jan 91 12:48 MST
  2696. Received: by june.cs.washington.edu (5.64/7.0jh) id AA08905; Thu, 3 Jan 91
  2697.  11:47:59 -0800
  2698. Resent-Date: Thu, 3 Jan 91 12:48 MST
  2699. Date: Thu, 3 Jan 91 11:47:59 -0800
  2700. From: wgg@cs.washington.edu
  2701. Subject: RE:  Icon as a teaching language
  2702. Resent-To: icon-group@cs.arizona.edu
  2703. To: icon-group@arizona.edu, midway!ellis.uchicago.edu!goer@uunet.uu.net
  2704. Resent-Message-Id: <DD7E3F0706B9401CAC@Arizona.edu>
  2705. Message-Id: <9101031947.AA08905@june.cs.washington.edu>
  2706. X-Envelope-To: icon-group@CS.Arizona.EDU
  2707. X-Vms-To: icon-group@Arizona.edu, midway!ellis.uchicago.edu!goer@uunet.uu.net
  2708.  
  2709. I'm afraid my interpreter is not for Icon, but a language much more limited
  2710. (and syntactically bogus) than Icon.  It was fun to build, but it shows
  2711. the limitations of line-based input in spades.
  2712.  
  2713.                         bill
  2714.  
  2715. From icon-group-request@arizona.edu  Thu Jan  3 23:08:19 1991
  2716. Resent-From: icon-group-request@arizona.edu
  2717. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2718.     id AA24914; Thu, 3 Jan 91 23:08:19 -0700
  2719. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Thu, 3 Jan 91 23:07 MST
  2720. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA04683; Thu, 3 Jan 91 22:05:28
  2721.  -0800
  2722. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2723.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2724.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2725. Resent-Date: Thu, 3 Jan 91 23:08 MST
  2726. Date: 4 Jan 91 06:03:46 GMT
  2727. From: zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.edu
  2728. Subject: ANSI C to KNR C converter in Icon
  2729. Sender: icon-group-request@arizona.edu
  2730. Resent-To: icon-group@cs.arizona.edu
  2731. To: icon-group@arizona.edu
  2732. Resent-Message-Id: <DD27B86AD7E9401597@Arizona.edu>
  2733. Message-Id: <3532@bruce.cs.monash.OZ.AU>
  2734. Organization: Monash Uni. Computer Science, Australia
  2735. X-Envelope-To: icon-group@CS.Arizona.EDU
  2736. X-Vms-To: icon-group@Arizona.edu
  2737.  
  2738. am considering writing one in Icon.  However if anyone has already done
  2739. this I would be pleased to have a copy.
  2740.  
  2741. From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu  Fri Jan  4 19:13:05 1991
  2742. Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  2743.     id AA03376; Fri, 4 Jan 91 19:13:05 -0700
  2744. Received: by uwm.edu; id AA02327; Fri, 4 Jan 91 20:12:19 -0600
  2745. Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
  2746.           Fri,  4 Jan 91 14:12:07 CDT
  2747. Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
  2748.           Fri, 4 Jan 1991 13:49 CST
  2749. Date: Fri, 4 Jan 1991 13:49 CST
  2750. From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
  2751. Subject: Icon Interpreters
  2752. To: icon-group@cs.arizona.edu
  2753. Message-Id: <5360256BE06002C4@mis.mcw.edu>
  2754. X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
  2755. X-Envelope-To: icon-group@cs.arizona.edu
  2756. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  2757.  
  2758.  
  2759. I was just thinking about the Icon interpreter dialogs. Something I have,
  2760. and posted several months back might be considered along those lines.
  2761. I posted a file analyzer and filter called igrep. Syntax...
  2762. igrep from_file [to_file]
  2763. Upon invokation it prompts for icon expressions. Certain variables are
  2764. global, such as 'line' which is the current line being read, 'num' the
  2765. record count (how many lines have been read). 'items' is a global list
  2766. to put stuff into. 'group' is a global set to insert things into. 'count'
  2767. is a global table for tallying things. 'parse' is a procedure that splits
  2768. a string into a list based on a delimiter cset. 'ebcdic' is a string that
  2769. can be mapped to string(&cset) to do ascii-ebcdic translation. etc,...
  2770.  
  2771. Whatever is 'returned' gets written to the specified outputfile or screen.
  2772. Finally, if there was anything put into 'items', 'group', or 'count', they
  2773. get dumped likewise as a summary.
  2774.  
  2775. Mechanically the igrep program takes the expressions, imbeds them into a
  2776. an icon program in a list structure, writes it as 'grepawk.icn', compiles,
  2777. and runs it. No syntax or correctness checking is done at expression entry
  2778. time. Finally, the 'grepawk' modules are deleted (unless a keep flag was set).
  2779. The expressions can also be recorded to or recovered from a scratch file.
  2780.  
  2781. It may not be a good tool to teach structured programming, but it might be
  2782. for even earlier to learn about variables, and operations on variables.
  2783. I can repost it if there's some interest.
  2784.  
  2785. Chris Tenaglia (System Manager) | Medical College of Wisconsin
  2786. 8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  2787. (414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  2788.  
  2789.  
  2790. From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu  Fri Jan  4 19:17:00 1991
  2791. Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  2792.     id AA03455; Fri, 4 Jan 91 19:17:00 -0700
  2793. Received: by uwm.edu; id AA02377; Fri, 4 Jan 91 20:16:29 -0600
  2794. Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
  2795.           Fri,  4 Jan 91 17:15:32 CDT
  2796. Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
  2797.           Fri, 4 Jan 1991 17:00 CST
  2798. Date: Fri, 4 Jan 1991 17:00 CST
  2799. From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
  2800. Subject: Icon Interpreters
  2801. To: icon-group@cs.arizona.edu
  2802. Message-Id: <6E06E4A6C04007D5@mis.mcw.edu>
  2803. X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
  2804. X-Envelope-To: icon-group@cs.arizona.edu
  2805. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  2806.  
  2807.  
  2808. Going through my libraries some more I also have something I call basED.
  2809. It's a BASIC style text editer. It was deigned for oddball terminals and
  2810. teletypes. I used it in the past on TEK4010 terminal emulators to write
  2811. graphics programs by piping icon output through unix plot. I have a
  2812. library of plot() procedures that generate the sequences plot looks for
  2813. much along the line of screen() or itlib.
  2814.  
  2815. From basED one could enter line-numbered code. Save it, un-numbered,
  2816. compile, link, and run programs from inside basED. It was real
  2817. handy. Not quite an interpreter, not quite a shell. It's about 620
  2818. lines so I won't post it unless I some requests
  2819. come through. It's written for VMS, but I recall that porting to
  2820. unix was probably less than an hour once one is familiar with the
  2821. code. It's too big for MSDOS.
  2822.  
  2823. Chris Tenaglia (System Manager) | Medical College of Wisconsin
  2824. 8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  2825. (414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  2826.  
  2827.  
  2828. From icon-group-request@arizona.edu  Sat Jan  5 14:25:41 1991
  2829. Resent-From: icon-group-request@arizona.edu
  2830. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2831.     id AA03079; Sat, 5 Jan 91 14:25:41 -0700
  2832. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Sat, 5 Jan 91 14:25 MST
  2833. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA19182; Sat, 5 Jan 91 13:12:05
  2834.  -0800
  2835. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2836.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2837.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2838. Resent-Date: Sat, 5 Jan 91 14:25 MST
  2839. Date: 5 Jan 91 18:05:11 GMT
  2840. From: hsi!mlfarm!ron@uunet.uu.net
  2841. Subject: RE: Message conventions
  2842. Sender: icon-group-request@arizona.edu
  2843. Resent-To: icon-group@cs.arizona.edu
  2844. To: icon-group@arizona.edu
  2845. Resent-Message-Id: <DBDE66CF6E49403512@Arizona.edu>
  2846. Message-Id: <678@mlfarm.com>
  2847. Organization: Maple Lawn Farm, Stonington, CT
  2848. X-Envelope-To: icon-group@CS.Arizona.EDU
  2849. X-Vms-To: icon-group@Arizona.edu
  2850. References: <675@mlfarm.com>
  2851.  
  2852. The version of reply.icn I posted earlier contained a subtle bug that
  2853. could break on some obscure headers.  The version below fixes the bug,
  2854. adds additional functionality, and thanks to Richard Goerwitz,
  2855. includes more robust code to create a temporary filename.  I've also
  2856. substituted some of Richard's elegant constructions for my quick and
  2857. dirty Icon hacks.
  2858.  
  2859. [Ralph -- use this version, please.]
  2860.  
  2861.  
  2862. ----------------------------[reply.icn, 1.1]---------------------------
  2863. # reply.icn - replies to news or mail
  2864. # version 1.1 (ron@mlfarm.com, 5 Jan 91)
  2865. #
  2866. # usage: reply [quote-prefix] < news-article or mail-item
  2867. #
  2868. # Configuration:
  2869. #   - change smarthost to the name of your upstream mail feed.
  2870. #   - change the default editor for your operating system, or use the
  2871. #     EDITOR environment variable.
  2872. #   - if your upstream mail feed will not accept addresses in the format
  2873. #     site.domain!user@upstream-host.domain, you may need to change the
  2874. #     address parsing code.
  2875. #
  2876. # The default quote-prefix is " > ".
  2877.  
  2878. procedure main(arg)
  2879.   
  2880.   smarthost := "mlfarm.com"
  2881.  
  2882.   if find("UNIX", &features) then {
  2883.     console := "/dev/tty"
  2884.     tmpdir := "/tmp/"
  2885.     editor := "/bin/vi"
  2886.   }
  2887.   else if find("MS-DOS", &features) then {
  2888.     console := "CON"
  2889.     tmpdir := ""
  2890.     editor := "edlin"
  2891.   }
  2892.   else stop("reply: unsupported operating system")
  2893.  
  2894.   every tmpfile := tmpdir || "reply." || right(1 to 999,3,"0") do
  2895.     close(open(tmpfile)) | break
  2896.   reply := open(tmpfile, "w") | stop("reply: cannot open temp file")
  2897.   every s := !&input do s ? {
  2898.     =("From: " | "Reply-To: ") & {
  2899.       if find("<") then {
  2900.     fullname := trim(tab(upto('<')))
  2901.     address := (move(1), tab(find(">")))
  2902.       }
  2903.       else {
  2904.     address := trim(tab(upto('(') | 0))
  2905.     fullname := (move(1), tab(find(")")))
  2906.       }
  2907.       quoter := (\fullname | address)
  2908.     }
  2909.     =("Date: ") & date := tab(0)
  2910.     =("Message-Id: ") & id := (tab(find("<")), tab(find(">")+1))
  2911.     match("Subject: ") & subject := s
  2912.     match("Newsgroups: ") & newsgroup := tab(upto(',') | 0)
  2913.     match("References: ") & refs := s
  2914.     (\address & *s = 0) & {
  2915.       write(reply, "In-reply-to: ", quoter, "'s message of ", date);
  2916.       \subject & write(reply, subject)
  2917.       \newsgroup & write(reply, newsgroup)
  2918.       \refs & write(reply, refs || " " || id)
  2919.       write(reply, "\nIn ", id, ", ", quoter, " writes:\n")
  2920.       break
  2921.     }
  2922.   }
  2923.   
  2924.   prefix := \arg[1] | " > "
  2925.   every write(reply, prefix, !&input)
  2926.  
  2927.   edstr := (getenv("EDITOR") | editor) || " " || tmpfile || " < " || console
  2928.   system(edstr)
  2929.   stdin := open(console, "r")
  2930.   writes("Send y/n? ")
  2931.   upto('nN',read(stdin)) & {
  2932.     remove(tmpfile)
  2933.     stop("Reply aborted.")
  2934.   }
  2935.   find("@",address) & address ? {
  2936.     name := tab(upto('@'))
  2937.     address := (move(1), tab(upto(' ') | 0)) || "!" || name
  2938.   }
  2939.   address ||:= "@" || smarthost
  2940.   mailstr := "mail " || address || " < " || tmpfile
  2941.   system(mailstr)
  2942.   write("Reply sent to " || address)
  2943.   remove(tmpfile)
  2944. end
  2945. ----------------------------------[eof]--------------------------------
  2946. --
  2947.  
  2948. Ronald Florence            ron@mlfarm.com
  2949.  
  2950. From icon-group-request@arizona.edu  Sun Jan  6 16:27:17 1991
  2951. Resent-From: icon-group-request@arizona.edu
  2952. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2953.     id AA10022; Sun, 6 Jan 91 16:27:17 -0700
  2954. Received: from UCBVAX.Berkeley.EDU by Arizona.edu; Sun, 6 Jan 91 16:26 MST
  2955. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12786; Sun, 6 Jan 91 15:11:45
  2956.  -0800
  2957. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2958.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2959.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2960. Resent-Date: Sun, 6 Jan 91 16:26 MST
  2961. Date: 6 Jan 91 17:59:12 GMT
  2962. From: hsi!mlfarm!ron@uunet.uu.net
  2963. Subject: RE: Message conventions
  2964. Sender: icon-group-request@arizona.edu
  2965. Resent-To: icon-group@cs.arizona.edu
  2966. To: icon-group@arizona.edu
  2967. Resent-Message-Id: <DB04453B52E14003BD@Arizona.edu>
  2968. Message-Id: <685@mlfarm.com>
  2969. Organization: Maple Lawn Farm, Stonington, CT
  2970. X-Envelope-To: icon-group@CS.Arizona.EDU
  2971. X-Vms-To: icon-group@Arizona.edu
  2972. References: <675@mlfarm.com>, <678@mlfarm.com>
  2973.  
  2974. Oops!  Some mailers and news-posters use Message-ID; others use
  2975. Message-Id.  To make reply.icn robust enough to get both, change
  2976. "Message-Id: " in line 48 to "Message-I".
  2977. --
  2978.  
  2979. Ronald Florence            ron@mlfarm.com
  2980.  
  2981. From KKTK_KOTUS@cc.Helsinki.FI  Mon Jan  7 00:17:49 1991
  2982. Resent-From: KKTK_KOTUS@cc.Helsinki.FI
  2983. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  2984.     id AA19855; Mon, 7 Jan 91 00:17:49 -0700
  2985. Received: from hylka.Helsinki.FI by Arizona.edu; Mon, 7 Jan 91 00:17 MST
  2986. Resent-Date: Mon, 7 Jan 91 00:17 MST
  2987. Date: Mon, 7 Jan 1991 09:16 EET
  2988. From: KKTK_KOTUS@cc.Helsinki.FI
  2989. Subject: Computational morphology
  2990. Resent-To: icon-group@cs.arizona.edu
  2991. To: icon-group@arizona.edu
  2992. Resent-Message-Id: <DAC28D1535014006C5@Arizona.edu>
  2993. Message-Id: <88D0169D20C04EE9@cc.Helsinki.FI>
  2994. X-Envelope-To: icon-group@CS.Arizona.EDU
  2995. X-Vms-To: IN%"icon-group@arizona.edu"
  2996.  
  2997. Hi,
  2998.  
  2999. is anybody out there doing computational morphology with Icon? I have
  3000. myself written a stem generator for Finnish noun stems with Icon and would
  3001. like to hear about people who have done same sort of things for any
  3002. language (which has enough morphology to tackle with.)
  3003.  
  3004.  
  3005. Kimmo Kettunen
  3006. KKTK_KOTUS@CC.HELSINKI.FI
  3007.  
  3008. From icon-group-request@arizona.edu  Tue Jan  8 16:32:16 1991
  3009. Resent-From: icon-group-request@arizona.edu
  3010. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  3011.     id AA08234; Tue, 8 Jan 91 16:32:16 -0700
  3012. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Tue, 8 Jan 91 16:31 MST
  3013. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA24700; Tue, 8 Jan 91 15:17:17
  3014.  -0800
  3015. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3016.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3017.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3018. Resent-Date: Tue, 8 Jan 91 16:32 MST
  3019. Date: 8 Jan 91 03:19:56 GMT
  3020. From: hsi!mlfarm!ron@uunet.uu.net
  3021. Subject: RE: Message conventions
  3022. Sender: icon-group-request@arizona.edu
  3023. Resent-To: icon-group@cs.arizona.edu
  3024. To: icon-group@arizona.edu
  3025. Resent-Message-Id: <D971377EA291402416@Arizona.edu>
  3026. Message-Id: <686@mlfarm.com>
  3027. Organization: Maple Lawn Farm, Stonington, CT
  3028. X-Envelope-To: icon-group@CS.Arizona.EDU
  3029. X-Vms-To: icon-group@Arizona.edu
  3030. References: <685@mlfarm.com>, <9101071716.AA29398@hpsdel.sde.hp.com>
  3031.  
  3032. Walter Underwood <hsi!hpsdel.sde.hp.com!wunder> writes:
  3033.  
  3034.  >    Oops!  Some mailers and news-posters use Message-ID; others use
  3035.  >    Message-Id.
  3036.  > 
  3037.  > The tags on header lines should be matched ignoring upper/lower case.
  3038.  > "mEsSaGe-iD:" is a perfectly legal tag, and equivalent to "Message-ID:".
  3039.  > The program may never see random case tags, but it will probably see all
  3040.  > upper case tags.  Anyway, the "right" fix is a case-insensitive match.
  3041.  
  3042. Walter is right (he even quoted RFC 822).  I'll spare everyone another
  3043. posting of reply.icn.  If anyone wants a version with the fix, write
  3044. me.  
  3045. --
  3046.  
  3047. Ronald Florence            ron@mlfarm.com
  3048.  
  3049. From icon-group-request@arizona.edu  Wed Jan  9 09:48:14 1991
  3050. Resent-From: icon-group-request@arizona.edu
  3051. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  3052.     id AA10914; Wed, 9 Jan 91 09:48:14 -0700
  3053. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 9 Jan 91 09:47 MST
  3054. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12892; Wed, 9 Jan 91 08:33:36
  3055.  -0800
  3056. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3057.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3058.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3059. Resent-Date: Wed, 9 Jan 91 09:48 MST
  3060. Date: 9 Jan 91 12:20:56 GMT
  3061. From: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net
  3062. Subject: a small problem
  3063. Sender: icon-group-request@arizona.edu
  3064. Resent-To: icon-group@cs.arizona.edu
  3065. To: icon-group@arizona.edu
  3066. Resent-Message-Id: <D8E07EA07131402CB6@Arizona.edu>
  3067. Message-Id: <1716@hslrswi.hasler.ascom.ch>
  3068. Organization: Hasler AG
  3069. X-Envelope-To: icon-group@CS.Arizona.EDU
  3070. X-Vms-To: icon-group@Arizona.edu
  3071.  
  3072.  
  3073. I'm new to this string scanning stuff, and I'm having difficulty finding
  3074. a nice clean way to perform the following simple calculation.
  3075.  
  3076. I have a string, S, in which I want to know the number of characters
  3077. which are used by any of several known substrings.  There is no problem
  3078. with overlapping substrings.
  3079.  
  3080. Here is a small example to show exactly what I mean:
  3081.  
  3082.     count := 0
  3083.     every  s ? find ("whizzy" | "ding")  do  count +:= 1
  3084.  
  3085. This would do what I want if I merely wanted to count the number of
  3086. occurrences of the substrings "whizzy" and "ding".  However, what I
  3087. want to do is know the total number of characters in s which are
  3088. used for these substrings, however many times they may occur.
  3089.  
  3090. I'm hoping to find something with an elegance approaching that of
  3091. the above example.  Brute force solutions need not apply.
  3092.  
  3093.  
  3094. P.S.  The real-life problem is that I have ANSI control sequences
  3095. embedded in a string which wants to be centered.
  3096.  
  3097. NHA
  3098. ---
  3099. PAPER:  Norman Azadian; Hasler AG; Belpstrasse 23; 3000 Berne 14; Switzerland
  3100. X.400:  naz@hslrswi.hasler
  3101. UUCP:   ...{uunet,ukc,mcvax,...}!cernvax!hslrswi!naz
  3102. VOICE:  +41 31 63 2178            BITNET: naz%hslrswi.UUCP@cernvax.BITNET
  3103. -- 
  3104. PAPER:  Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
  3105. INTERNET:  naz%hslrswi.uucp@uunet.uu.net
  3106. UUCP:   ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
  3107. VOICE:  +41 31 63 2178            BITNET: naz%hslrswi.UUCP@cernvax.BITNET
  3108.  
  3109. From icon-group-request@arizona.edu  Wed Jan  9 16:33:11 1991
  3110. Resent-From: icon-group-request@arizona.edu
  3111. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  3112.     id AA26645; Wed, 9 Jan 91 16:33:11 -0700
  3113. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 9 Jan 91 16:32 MST
  3114. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA00252; Wed, 9 Jan 91 15:28:46
  3115.  -0800
  3116. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3117.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3118.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3119. Resent-Date: Wed, 9 Jan 91 16:32 MST
  3120. Date: 9 Jan 91 15:33:30 GMT
  3121. From: hsi!mlfarm!ron@uunet.uu.net
  3122. Subject: post.icn (news poster)
  3123. Sender: icon-group-request@arizona.edu
  3124. Resent-To: icon-group@cs.arizona.edu
  3125. To: icon-group@arizona.edu
  3126. Resent-Message-Id: <D8A7EDD74BC1402633@Arizona.edu>
  3127. Message-Id: <689@mlfarm.com>
  3128. Organization: Maple Lawn Farm, Stonington, CT
  3129. X-Envelope-To: icon-group@CS.Arizona.EDU
  3130. X-Vms-To: icon-group@Arizona.edu
  3131.  
  3132. It won't put gnus-post or Pnews out of business, but it works, both
  3133. for original postings and follow-ups.  The code borrows from Richard
  3134. Goerwitz's tempname generator and from reply.icn.  The limited ms-dos
  3135. support is untested.  Perhaps someone can suggest how to include
  3136. support for VMS or other systems in this and reply.icn.
  3137.  
  3138. I hope this is useful to someone.
  3139. --
  3140.  
  3141. Ronald Florence            ron@mlfarm.com
  3142.  
  3143.  
  3144. #! /bin/sh
  3145. # This is a shell archive, meaning:
  3146. # 1. Remove everything above the #! /bin/sh line.
  3147. # 2. Save the resulting text in a file.
  3148. # 3. Execute the file with /bin/sh (not csh) to create:
  3149. #    post.icn
  3150. # This archive created: Wed Jan  9 10:26:12 1991
  3151. # By:    Ronald Florence (Maple Lawn Farm, Stonington, CT)
  3152. export PATH; PATH=/bin:/usr/bin:$PATH
  3153. if test -f 'post.icn'
  3154. then
  3155.     echo shar: "will not over-write existing file 'post.icn'"
  3156. else
  3157. cat << \SHAR_EOF > 'post.icn'
  3158. ############################################################################
  3159. #
  3160. #    Name:    post.icn
  3161. #
  3162. #    Title:    News Poster
  3163. #
  3164. #    Author:    Ronald Florence  (ron@mlfarm.com)
  3165. #
  3166. #    Date:    January 8, 1991
  3167. #
  3168. ############################################################################
  3169. #
  3170. #  This program posts a news article to Usenet via uux or mail.  
  3171. #  Given an optional argument (the name of a file containing a
  3172. #  news article), it creates a follow-up article, with an 
  3173. #  attribution and quoted text.
  3174. #
  3175. #      usage: post [news-article]
  3176. #
  3177. ############################################################################
  3178. #
  3179. #  Configure: smarthost, mode, editor or EDITOR environment variable.
  3180. #
  3181. ############################################################################
  3182. #
  3183. #  Requires: UNIX or MS-DOS.  
  3184. #  Bugs: ms-dos requires hard-coded system info.
  3185. #
  3186. ############################################################################
  3187.  
  3188. global sitename, domain, tz
  3189.  
  3190. procedure main(arg)
  3191.   
  3192.   smarthost := "news-feed"    # Your news feed.
  3193.   mode := "uux"            # Use "mail" for a sendnews feed.
  3194.   domain := ".UUCP"
  3195.  
  3196.   if (find("UNIX", &features) & find("pipes", &features)) then {
  3197.     console := "/dev/tty"
  3198.     tmpdir := "/tmp/"
  3199.     (inf := open("logname", "pr")) & (logname := !inf) & close(inf)
  3200.                 # Uuname sometimes pads with spaces.
  3201.     (inf := open("uuname -l", "pr")) & (sitename := trim(!inf)) & close(inf)
  3202.     (tz := getenv("TZ")) & tz ?:= (tab(many(&letters)), tab(upto(&letters)))
  3203.     sigfile := getenv("HOME") || "/.signature"
  3204.     editor := "/bin/vi"
  3205.   }
  3206.   else if find("MS-DOS", &features) then {
  3207.     console := "CON"
  3208.     tmpdir := ""
  3209.     logname := &null
  3210.     sitename := &null
  3211.     tz := &null            # Hours off GMT.
  3212.     sigfile := &null
  3213.     editor := "edlin"
  3214.   }
  3215.   (\logname & \sitename & \tz) | stop("post: missing system info")
  3216.   article := open(tmpfile := tempname(tmpdir), "w") | 
  3217.     stop("post: cannot write temp file")
  3218.   write(article, "Path: ", sitename, "!", logname)
  3219.   write(article, "From: ", logname, "@", sitename, domain)
  3220.  
  3221.   if \arg[1] then {
  3222.     inf := open(arg[1]) | {
  3223.       remove(tmpfile)
  3224.       stop("post: cannot read ", arg[1])
  3225.     }
  3226.     reply_headers(inf, article)
  3227.     every write(article, " > ", !inf)
  3228.     close(inf)
  3229.   }
  3230.   else {
  3231.     write(article, query("Newsgroups: "))
  3232.     write(article, query("Subject: "))
  3233.     every write(article, req_headers())
  3234.     write(article, "\n")
  3235.   }
  3236.   edstr := (getenv("EDITOR") | editor) || " " || tmpfile || " < " || console
  3237.   system(edstr)
  3238.   writes("Are you sure you want to post this to Usenet y/n? ")
  3239.   stdin := open(console)
  3240.   upto('nN', read(stdin)) & {
  3241.     remove(tmpfile)
  3242.     stop("Article aborted.")
  3243.   }
  3244.                 # Try to append the .signature.
  3245.   \sigfile & (inf := open(sigfile)) & {
  3246.     article := open(tmpfile, "a")
  3247.     write(article, "--")
  3248.     every write(article, !inf)
  3249.     close(inf)
  3250.   }
  3251.                 # Don't force an immediate poll.
  3252.   if find("uux", mode) then mode ||:= " - -r"
  3253.                 # Sendnews format requires an initial `N'.
  3254.   else if find("mail", mode) then {
  3255.     inf := open(tmpfile)
  3256.     outf := open(tmp2 := tempname(tmpdir), "w")
  3257.     every write(outf, "N", !inf)
  3258.     remove(tmpfile)
  3259.     rename(tmp2, tmpfile)
  3260.   }
  3261.   mode ||:= " " || smarthost || "!rnews < " || tmpfile
  3262.   (system(mode) = 0) & write("Article posted!")
  3263.   remove(tmpfile)
  3264. end
  3265.  
  3266.  
  3267. procedure tempname(dir)
  3268.     
  3269.   every temp_name := dir || "article." || right(1 to 999,3,"0") do {
  3270.     close(open(temp_name)) & next
  3271.     suspend \temp_name
  3272.   }
  3273. end
  3274.  
  3275.  
  3276. procedure reply_headers(infile, art)
  3277.  
  3278.   every s := !infile do s ? {
  3279.                 # Case-insensitive matches for headers.
  3280.     tab(match("from: ", map(&subject))) & {
  3281.       if find("<") then {
  3282.     fullname := trim(tab(upto('<')))
  3283.     address := (move(1), tab(find(">")))
  3284.       }
  3285.       else {
  3286.     address := trim(tab(upto('(') | 0))
  3287.     fullname := (move(1), tab(find(")")))
  3288.       }
  3289.       quoter := (\fullname | address)
  3290.     }
  3291.     tab(match("date: ", map(&subject))) & date := tab(0)
  3292.     tab(match("message-id: ", map(&subject))) & id := tab(0)
  3293.     match("subject: ", map(&subject)) & subject := s
  3294.     match("newsgroups: ", map(&subject)) & newsgroup := tab(upto(',') | 0)
  3295.     match("references: ", map(&subject)) & refs := s
  3296.     (\quoter & *s = 0) & {
  3297.                 # Newsgroup and subject are required.
  3298.       write(art, \newsgroup | query("Newsgroup: "))
  3299.       write(art, \subject | query("Subject: "))
  3300.                 # Message-ID and Date go here.
  3301.       every write(art, req_headers())
  3302.                 # Threaded readers need References.
  3303.       write(art, \refs | "References:", " ", id)
  3304.       write(art, "In-reply-to: ", quoter, "'s message of ", date)
  3305.       write(art, "\nIn ", id, ", ", quoter, " writes:\n")
  3306.       return 
  3307.     }
  3308.   }
  3309. end
  3310.  
  3311.  
  3312. procedure req_headers()
  3313.                 # Crude, but it's a unique id.
  3314.   uniq := "<"
  3315.   &date || &clock ? while tab(upto(&digits)) do uniq ||:= tab(many(&digits))
  3316.   uniq ||:= "@" || sitename || domain || ">"
  3317.                 # Date in RFC 822 format.
  3318.   &dateline ? {
  3319.     month := left((tab(find(" ")+1), tab(many(&letters))), 3) || " "
  3320.     date := (tab(upto(&digits)), tab(many(&digits))) || " " || month
  3321.     date ||:= (tab(upto(&digits)), right(tab(many(&digits)), 2))
  3322.   }
  3323.                 # GMT would be better; this is allowed.
  3324.   if (tz > 0) then zone := " -"
  3325.   else zone := " +"
  3326.   zone ||:= left(right(abs(tz), 2, "0"), 4, "0")
  3327.   suspend "Message-ID: " || uniq
  3328.   suspend "Date: " || date || " " || &clock || zone
  3329. end
  3330.  
  3331.  
  3332. procedure query(prompt)
  3333.  
  3334.   writes(prompt)
  3335.   ans := read()
  3336.   return prompt || ans
  3337. end
  3338.  
  3339. SHAR_EOF
  3340. if test 5403 -ne "`wc -c < 'post.icn'`"
  3341. then
  3342.     echo shar: "error transmitting 'post.icn'" '(should have been 5403 characters)'
  3343. fi
  3344. fi
  3345. exit 0
  3346. #    End of shell archive
  3347.  
  3348. --
  3349.  
  3350. Ronald Florence            ron@mlfarm.com
  3351.  
  3352. From nevin@apple.com  Wed Jan  9 21:54:45 1991
  3353. Received: from apple.com ([130.43.2.2]) by megaron.cs.arizona.edu (5.61/15) via SMTP
  3354.     id AA06447; Wed, 9 Jan 91 21:54:45 -0700
  3355. Received: from [90.1.0.10] by apple.com with SMTP (5.61/25-eef)
  3356.     id AA28618; Wed, 9 Jan 91 20:54:07 -0800
  3357.     for icon-group@cs.arizona.edu
  3358. Received: by goofy.apple.com (5.61/25-eef)
  3359.     id AA01800; Wed, 9 Jan 91 20:54:04 -0800
  3360.     for uunet!chx400!hslrsw!naz@internet-gateway.apple.com
  3361. Date: Wed, 9 Jan 91 20:54:04 -0800
  3362. From: Nevin Liber <nevin@apple.com>
  3363. Message-Id: <9101100454.AA01800@internal.apple.com>
  3364. To: icon-group@cs.arizona.edu
  3365. Subject: Re: a small problem
  3366. Cc: uunet!chx400!hslrsw!naz@goofy.apple.com
  3367.  
  3368. Norman Azadian writes:
  3369. > I have a string, S, in which I want to know the number of characters
  3370. > which are used by any of several known substrings.  There is no problem
  3371. > with overlapping substrings.
  3372.  
  3373. > Here is a small example to show exactly what I mean:
  3374.  
  3375. >     count := 0
  3376. >     every  s ? find ("whizzy" | "ding")  do  count +:= 1
  3377.  
  3378. > However, what I
  3379. > want to do is know the total number of characters in s which are
  3380. > used for these substrings, however many times they may occur.
  3381.  
  3382. The following will do the job:
  3383.  
  3384.     iCharacterCount := 0
  3385.     every find(sSubString := "whizzy" | "ding", sLine) do
  3386.         iCharacterCount +:= *sSubString
  3387.  
  3388. (Technically, this doesn't use string scanning, although it can be easily
  3389. modified to do so.  I tend to use string scanning only when I have to
  3390. actually parse something.)  This solution uses a temporary variable
  3391. (sSubString) to [implicitly] keep track of the length.
  3392.  
  3393. Additionally, I would keep the substrings in a set, making it
  3394. easy to add or remove substrings to be checking.  My code would look
  3395. something like:
  3396.  
  3397.     SSubStrings := set(["whizzy", "ding"])
  3398.     
  3399.     iCharacterCount := 0
  3400.     every find(sSubString := !SSubStrings, sLine) do
  3401.         iCharacterCount +:= *sSubString
  3402.  
  3403. I hope this is elegant enough for you. :-)
  3404. ___
  3405. NEVIN ":-)" LIBER
  3406.  email: nevin@apple.com        paper:    Apple Computer, Inc.
  3407.  voice: (408) 974-6491            20525 Mariani Avenue, MS: 71AB
  3408.  AppleLink: NEVIN.LIBER            Cupertino, California 95014
  3409.  
  3410. From icon-group-request@arizona.edu  Thu Jan 10 00:18:01 1991
  3411. Resent-From: icon-group-request@arizona.edu
  3412. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  3413.     id AA10464; Thu, 10 Jan 91 00:18:01 -0700
  3414. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Thu, 10 Jan 91 00:17 MST
  3415. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA16356; Wed, 9 Jan 91 23:07:53
  3416.  -0800
  3417. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3418.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3419.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3420. Resent-Date: Thu, 10 Jan 91 00:17 MST
  3421. Date: 10 Jan 91 05:57:44 GMT
  3422. From: midway!quads.uchicago.edu!goer@uunet.uu.net
  3423. Subject: RE: a small problem
  3424. Sender: icon-group-request@arizona.edu
  3425. Resent-To: icon-group@cs.arizona.edu
  3426. To: icon-group@arizona.edu
  3427. Resent-Message-Id: <D867059A1FD140390B@Arizona.edu>
  3428. Message-Id: <1991Jan10.055744.15170@midway.uchicago.edu>
  3429. Organization: University of Chicago
  3430. X-Envelope-To: icon-group@CS.Arizona.EDU
  3431. X-Vms-To: icon-group@Arizona.edu
  3432. References: <9101100454.AA01800@internal.apple.com>
  3433.  
  3434. In <9101100454.AA01800@internal.apple.com> nevin@APPLE.COM (Nevin Liber) writes:
  3435. >
  3436. >> ...what I
  3437. >> want to do is know the total number of characters in s which are
  3438. >> used for these substrings, however many times they may occur.
  3439. >
  3440. >The following will do the job:
  3441. >
  3442. >    iCharacterCount := 0
  3443. >    every find(sSubString := !SSubStrings, sLine) do
  3444. >        iCharacterCount +:= *sSubString
  3445.  
  3446. This is nice.  One thing, though, might be added:  If any of the strings
  3447. in set SSubStrings overlap, then the above solution won't work the way
  3448. Norman wants it to.  The substrings variable needs to be a list, with the
  3449. elements prioritized in some way (e.g. longest strings first):
  3450.  
  3451.     count := 0
  3452.     s ? while tab(find(tmp := !substrings)) do
  3453.         count +:= *=tmp
  3454.  
  3455. I haven't tested this code fragment.  Oh no! :-)
  3456.  
  3457. Question:  What is the best way to take a list of strings, remove those
  3458. strings which are substrings of some other string in the list, and then
  3459. sort by length?
  3460.  
  3461. -Richard (goer@sophist.uchicago.edu)
  3462.  
  3463. From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu  Thu Jan 10 07:05:46 1991
  3464. Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  3465.     id AA25697; Thu, 10 Jan 91 07:05:46 -0700
  3466. Received: by uwm.edu; id AA21186; Thu, 10 Jan 91 08:05:32 -0600
  3467. Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
  3468.           Thu, 10 Jan 91 07:39:53 CDT
  3469. Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
  3470.           Thu, 10 Jan 1991 06:15 CST
  3471. Date: Thu, 10 Jan 1991 06:15 CST
  3472. From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
  3473. Subject: Shell Archives
  3474. To: icon-group@cs.arizona.edu
  3475. Message-Id: <CAFC3229806003D5@mis.mcw.edu>
  3476. X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
  3477. X-Envelope-To: icon-group@cs.arizona.edu
  3478. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  3479.  
  3480.  
  3481. I've been gradually collecting software in unix shell archive format. I use
  3482. icon on a vms machine. Anyone out there who's already written an icon version
  3483. to unravel shell archives? I don't want to reinvent the wheel. Since most
  3484. icon folks are already in unix the reply should probably be emailed.
  3485.  
  3486. Thanx in advance.
  3487.  
  3488. Chris Tenaglia (System Manager) | Medical College of Wisconsin
  3489. 8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  3490. (414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  3491.  
  3492.  
  3493. From nevin@apple.com  Thu Jan 10 21:53:31 1991
  3494. Received: from apple.com by megaron.cs.arizona.edu (5.61/15) via SMTP
  3495.     id AA27026; Thu, 10 Jan 91 21:53:31 -0700
  3496. Received: from [90.1.0.10] by apple.com with SMTP (5.61/25-eef)
  3497.     id AA13136; Thu, 10 Jan 91 20:53:24 -0800
  3498.     for icon-group@cs.arizona.edu
  3499. Received: by goofy.apple.com (5.61/25-eef)
  3500.     id AA06745; Thu, 10 Jan 91 20:53:21 -0800
  3501.     for icon-group@cs.arizona.edu
  3502. Date: Thu, 10 Jan 91 20:53:21 -0800
  3503. From: Nevin Liber <nevin@apple.com>
  3504. Message-Id: <9101110453.AA06745@internal.apple.com>
  3505. To: icon-group@cs.arizona.edu
  3506. Subject: Re: A small problem
  3507.  
  3508. [Note:  the original poster does not need to worry about overlapping
  3509. strings, since he is only looking for ANSI control sequences.  This is
  3510. still an interesting problem, however.]
  3511.  
  3512. Richard (goer@sophist.uchicago.edu) writes:
  3513.  
  3514. > This is nice.  One thing, though, might be added:  If any of the strings
  3515. > in set SSubStrings overlap, then the above solution won't work the way
  3516. > Norman wants it to.  The substrings variable needs to be a list, with the
  3517. > elements prioritized in some way (e.g. longest strings first):
  3518.  
  3519. >     count := 0
  3520. >     s ? while tab(find(tmp := !substrings)) do
  3521. >         count +:= *tmp
  3522.  
  3523. > I haven't tested this code fragment.  Oh no! :-)
  3524.  
  3525. You may want to look at this code again.  It won't work as coded
  3526. ("while" won't generate all of the substrings).
  3527.  
  3528. Assuming that the code did work, I'm still not sure of the approach.
  3529. Look at the following case:
  3530.  
  3531. What happens if you have the following List of words to look for:
  3532.  
  3533.     ["bullwinkle", "rocky", "bull"]
  3534.  
  3535. and the sentence is:
  3536.  
  3537.     "rocky and bullwinkle had picked a fight with a really mean bull."
  3538.  
  3539. With your approach, I believe that "bullwinkle" would match first, and
  3540. "rocky" would never be found.
  3541.  
  3542.  
  3543. If you have overlapping strings, this problem becomes a bit more difficult.
  3544. One approach I was thinking of is to first analyze the set of
  3545. substrings, subtract lengths for smaller substrings contained in the
  3546. larger ones, and store the results in a table, such as:
  3547.  
  3548.     "bullwinkle" -> 6 (10 for bullwinkle - 4 for bull)
  3549.     "rocky" -> 5
  3550.     "bull" -> 4
  3551. ___
  3552. NEVIN ":-)" LIBER
  3553.  email: nevin@apple.com        paper:    Apple Computer, Inc.
  3554.  voice: (408) 974-6491            20525 Mariani Avenue, MS: 71AB
  3555.  AppleLink: NEVIN.LIBER            Cupertino, California 95014
  3556.  
  3557. From goer%sophist@gargoyle.uchicago.edu  Thu Jan 10 23:29:59 1991
  3558. Resent-From: goer%sophist@gargoyle.uchicago.edu
  3559. Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  3560.     id AA00524; Thu, 10 Jan 91 23:29:59 -0700
  3561. Return-Path: goer@sophist.uchicago.edu
  3562. Received: from gargoyle.uchicago.edu by Arizona.edu; Thu, 10 Jan 91 23:29 MST
  3563. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  3564.  (4.0/1.14) id AA25900; Fri, 11 Jan 91 00:29:23 CST
  3565. Received: by sophist (4.1/UofC3.1X) id AA06070; Fri, 11 Jan 91 00:32:10 CST
  3566. Resent-Date: Thu, 10 Jan 91 23:29 MST
  3567. Date: Fri, 11 Jan 91 00:32:10 CST
  3568. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  3569. Subject: hmmm
  3570. Resent-To: icon-group@cs.arizona.edu
  3571. To: icon-group@arizona.edu
  3572. Resent-Message-Id: <D7A487636A81404941@Arizona.edu>
  3573. Message-Id: <9101110632.AA06070@sophist>
  3574. X-Envelope-To: icon-group@CS.Arizona.EDU
  3575. X-Vms-To: icon-group@Arizona.edu
  3576.  
  3577.  
  3578.     >     count := 0
  3579.     >     s ? while tab(find(tmp := !substrings)) do
  3580.     >         count +:= *tmp
  3581.  
  3582.     > I haven't tested this code fragment.  Oh no! :-)
  3583.  
  3584.     You may want to look at this code again.  It won't work as coded
  3585.     ("while" won't generate all of the substrings).
  3586.  
  3587. I'm not sure what you mean.  The expression find(tmp := !substrings) will
  3588. pop elements off of the list, substrings, until a match is found.  Every
  3589. time a match is found, it will tab past it, and start looking for another
  3590. substring.  In point of fact, the while is not the determining factor here.
  3591. Rather, it is the success of find().  If in fact find() keeps failing (as
  3592. will eventually happen in most cases), backtracking could easily take us
  3593. through the entire substring list (regardless of the "while").
  3594.  
  3595.     Assuming that the code did work, I'm still not sure of the approach.
  3596.     Look at the following case:
  3597.  
  3598.     What happens if you have the following List of words to look for:
  3599.  
  3600.         ["bullwinkle", "rocky", "bull"]
  3601.  
  3602.     and the sentence is:
  3603.  
  3604.         "rocky and bullwinkle had picked a fight with a really..."
  3605.  
  3606.     With your approach, I believe that "bullwinkle" would match first, and
  3607.     "rocky" would never be found.
  3608.  
  3609. Ahhh.  On this point it seems you are right.  And I thought I was being so
  3610. clever.   I guess that's what I get for posting untested code.
  3611.  
  3612. As penance, I offer one brute-force solution:
  3613.  
  3614.     count := 0
  3615.     s ? every i := 1 to *&subject do
  3616.         count +:= (tab(i), *=!substrings)
  3617.  
  3618. Incidentally, this !substrings stuff bugs me a lot.  Anyone want to offer
  3619. us an fgrep-like utility that will use a deterministic finite state automa-
  3620. ton instead of endless backtracking?
  3621.  
  3622. -Richard (goer@sophist.uchicago.edu)
  3623.  
  3624.  
  3625. From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu  Sun Jan 13 07:31:45 1991
  3626. Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  3627.     id AA15480; Sun, 13 Jan 91 07:31:45 -0700
  3628. Received: by uwm.edu; id AA03806; Sun, 13 Jan 91 08:31:36 -0600
  3629. Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
  3630.           Sun, 13 Jan 91 08:28:03 CDT
  3631. Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
  3632.           Sun, 13 Jan 1991 07:54 CST
  3633. Date: Sun, 13 Jan 1991 07:54 CST
  3634. From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
  3635. Subject: VMS Shell Archive Facility
  3636. To: icon-group@cs.arizona.edu
  3637. Message-Id: <34526B3240600B5F@mis.mcw.edu>
  3638. X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
  3639. X-Envelope-To: icon-group@cs.arizona.edu
  3640. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  3641.  
  3642.  
  3643. Below is a shell archive that contains itself. I wrote it because I wanted
  3644. to extract some of the archived goodies that get posted here. I made it
  3645. for VMS and MS-DOS. I haven't tested the MS-DOS ;-) parts yet. I also can't
  3646. test the builder part as I have no unix system yet to test it. Maybe
  3647. someone can let me know if it works. Maybe someone will want to add support
  3648. for MACintosh, AMIGA, etc,... Maybe we should have an icon archiver, that's
  3649. hardware/os independent? Any comments?
  3650.  
  3651. Chris Tenaglia (System Manager) | Medical College of Wisconsin
  3652. 8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  3653. (414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  3654.  
  3655. #!/bin/sh
  3656. # This is shar.sh, a shell archive (sh.icn 1.0)
  3657. # made Sunday, January 13, 1991  7:47 am by tenaglia@mis.mcw.edu
  3658. # Source directory /usr53/tenaglia/i/
  3659. #
  3660. # existing files will Not be overwritten, hopefully
  3661. #
  3662. # This shar contains:
  3663. # length  mode       name
  3664. # ------ ---------- ------------------------------------------
  3665.  
  3666. #   7556 -rw-r--r-- sh.icn
  3667. #    928 -rw-r--r-- sh.txt
  3668. #
  3669. # Test of VMS Shell Archive Facility
  3670. # Does everything extract properly under unix?
  3671. #
  3672. # ============== sh.icn ==============
  3673. if test X"$1" != X"-c" -a -f 'sh.icn'; then
  3674.     echo "File already exists: skipping 'sh.icn'"
  3675. else
  3676. echo "x - extracting sh.icn (Text)"
  3677. sed 's/^X//' << 'SHEOF' > sh.icn &&
  3678. X##################################################################
  3679. X#                                                                #
  3680. X# SH.ICN                 01/11/91          BY TENAGLIA           #
  3681. X#                                                                #
  3682. X# PROGRAM HANDLES  UNIX SHELL ARCHIVES                           #
  3683. X# USAGE : sh archive [action] [target]                           #
  3684. X#         Where action is extract(default) list or build         #
  3685. X#         If action is list, target is ignored.                  #
  3686. X#         If action is extract (""), target is ignored           #
  3687. X#         If action id build, target is filespec to archive      #
  3688. X# NOTE :  Does not make split archives yet.                      #
  3689. X# NOTE :  Extraction doesn't check for overwrite, just does it.  #
  3690. X# NOTE :  shar 3.xx lengths include the leading X, and don't     #
  3691. X#         match here. This uses their real lengths.              #
  3692. X#                                                                #
  3693. X##################################################################
  3694. Xglobal os, files
  3695. Xprocedure main(param)
  3696. X  source := param[1]          | input("_Source:")
  3697. X  option := param[2]          | "extract"
  3698. X  target := param[3]          | "!nill"
  3699. X  work   := case option of
  3700. X    {
  3701. X    "list" : " Lister\n"
  3702. X    "build": " Builder\n"
  3703. X    default: " Extractor\n"
  3704. X    }
  3705. X  write("sh : Unix Shell Archive",work)
  3706. X  os     := getsys()
  3707. X  sum    := 0
  3708. X  if option == "build" then build(source)
  3709. X  (in    := open(source))     | stop("Can't open ",source)
  3710. X  while line := read(in) do
  3711. X    {
  3712. X    stuff := parse(line,'\"\'\t ')
  3713. X    if stuff[1] == "sed" & stuff[2] == "s/^X//" then
  3714. X      {
  3715. X      every i := 1 to *stuff do
  3716. X        {
  3717. X        if stuff[i] == "<<" then     { eof  := stuff[i+1] ; next }
  3718. X        if match("<<",stuff[i]) then { eof  := stuff[i][3:0] ; next }
  3719. X        if stuff[i] == ">>" then
  3720. X          {
  3721. X          name   := stuff[i+1]
  3722. X          method := "a"                # append
  3723. X          what   := "appended."
  3724. X          next
  3725. X          }
  3726. X        if match(">>",stuff[i]) then
  3727. X          {
  3728. X          name   := stuff[i][2:0]
  3729. X          method := "a"                # append
  3730. X          what   := "appended."
  3731. X          next
  3732. X          }
  3733. X        if stuff[i] == ">"  then
  3734. X          {
  3735. X          name   := stuff[i+1]
  3736. X          method := "w"                # create
  3737. X          what   := "written."
  3738. X          next
  3739. X          }
  3740. X        if match(">",stuff[i]) then
  3741. X          {
  3742. X          name   := stuff[i][2:0]
  3743. X          method := "w"                # create
  3744. X          what   := "written."
  3745. X          next
  3746. X          }
  3747. X        }
  3748. X      prog := extract(in,eof)
  3749. X      } else next
  3750. X    directory := if target == "!nill" then "" else target
  3751. X    (out := open(target||name,method)) | stop("Can't write ",name)
  3752. X    every stmt := !prog do
  3753. X      {
  3754. X      if option == "extract" then write(out,stmt)
  3755. X      sum +:= *stmt
  3756. X      }
  3757. X    if option == "extract"
  3758. X      then write(name," : ",sum," bytes ",what)
  3759. X      else write(name," : contains ",sum," bytes.")
  3760. X    sum := 0
  3761. X    close(out)
  3762. X    }
  3763. X  close(in)
  3764. X  end
  3765. X
  3766. X#
  3767. X# This routine extracts the shell archive for a module. It returns
  3768. X# the module in a list structure.
  3769. X#
  3770. Xprocedure extract(file,eofstr)
  3771. X  lst := []
  3772. X  until match(eofstr,(str := read(file))) do
  3773. X    put(lst,str[2:0])
  3774. X  return lst
  3775. X  end
  3776. X
  3777. X#
  3778. X# This routine builds a shell archive. archive is the archive to be made.
  3779. X# The rest of this is interactive.
  3780. X#
  3781. Xprocedure build(archive)
  3782. X  username  := input("Username  :")
  3783. X  directory := input("Directory :")
  3784. X  modules   := table([])
  3785. X  find(".",archive) | (archive ||:= ".sh")
  3786. X  (output   := open(archive,"w")) | stop("Can't write to ",archive)
  3787. X  comments  := ["#"] ; write("Enter Comments (blank line when done)")
  3788. X  repeat {
  3789. X  comment := input("Comment :")
  3790. X  if trim(comment) == "" then break
  3791. X  put(comments,"# " || comment) }
  3792. X  put(comments,"#")
  3793. X  begin := ["#!/bin/sh",
  3794. X            "# This is " || archive || ", a shell archive (sh.icn 1.0)",
  3795. X            "# made " || &dateline  || " by " || username,
  3796. X            "# Source directory "   || fsmap(directory),
  3797. X            "#", "# existing files will Not be overwritten, hopefully","#",
  3798. X            "# This shar contains:",
  3799. X            "# length  mode       name",
  3800. X            "# ------ ---------- ------------------------------------------",
  3801. X           ]
  3802. X  namelist := []
  3803. X  repeat {
  3804. X  name := input("File (blank when done) :")
  3805. X  if trim(name) == "" then break
  3806. X  (infile := open(directory||name)) | { write("Can't open ",directory,name) ; next }
  3807. X  code := [ "# ============== " || name || " ==============",
  3808. X            "if test X\"$1\" != X\"-c\" -a -f '" || name || "'; then",
  3809. X            "    echo \"File already exists: skipping '"  || name || "'\"",
  3810. X            "else",
  3811. X            "echo \"x - extracting " || name || " (Text)\"",
  3812. X            "sed 's/^X//' << 'SHEOF' > " || name || " &&" ]
  3813. X  measure := 0
  3814. X  while text := read(infile) do
  3815. X    {
  3816. X    measure +:= *text
  3817. X    put(code,"X" || text)
  3818. X    }
  3819. X  put(code,"SHEOF") ; close(infile)
  3820. X  put(begin,"# " || right(measure,6) || " -rw-r--r-- " || name)
  3821. X  insert(modules,name,copy(code)) ; put(namelist,name) }
  3822. X  output := open(archive,"a")
  3823. X  every write(output,!begin)
  3824. X  every write(output,!comments)
  3825. X  every file := !namelist do every write(output,!(modules[file]))
  3826. X  write(output,"#")
  3827. X  write(output,"# End of sh archive.")
  3828. X  close(output)
  3829. X  stop("sh archive written to ",archive)
  3830. X  end
  3831. X
  3832. X# # ============= README ==============                  this is what the
  3833. X# if test X"$1" != X"-c" -a -f 'README'; then            beginning of a shell
  3834. X#  echo "File already exists: skipping 'README'"         archive body should
  3835. X# else                                                   look like.
  3836. X# echo "x - extracting README (Text)"
  3837. X# sed 's/^X//' << 'SHAR_EOF' > README &&
  3838. X
  3839. X#
  3840. X# This routine parses a string with respect to some delimiter.
  3841. X# It returns the tokens in a list structure.
  3842. X#
  3843. Xprocedure parse(line,delims)
  3844. X  static chars
  3845. X  chars  := &cset -- delims
  3846. X  tokens := []
  3847. X  line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
  3848. X  return tokens
  3849. X  end
  3850. X
  3851. X#
  3852. X# This routine prompts for a string input. The entered string is returned.
  3853. X#
  3854. Xprocedure input(prompt)
  3855. X  writes(prompt)
  3856. X  return read()
  3857. X  end
  3858. X
  3859. X#
  3860. X# This procedure determines the os by examining &features.
  3861. X#
  3862. Xprocedure getsys()
  3863. X  files := "DIR "             # most logical initially
  3864. X  if &host == "MS-DOS" then
  3865. X    return &host
  3866. X  tmp := []
  3867. X  every feature := &features do
  3868. X    put(tmp,feature)
  3869. X  if tmp[1] ~== "VMS" then files := "ls "
  3870. X  return tmp[1]
  3871. X  end
  3872. X
  3873. X#
  3874. X# This routine maps the directory spec to unix style notation
  3875. X#
  3876. Xprocedure fsmap(spec)
  3877. X  if spec == "" then return spec
  3878. X  case os of
  3879. X    {
  3880. X    "VMS"    : { if (i := find(":",spec)) then
  3881. X                   {
  3882. X                   path := "/usr" || ord(spec[i-1]) || "/"
  3883. X                   if (x := find("[",spec)) then
  3884. X                     {
  3885. X                     y := find("]",spec)
  3886. X                     path ||:= map(spec[x+1:y],".","/") || "/"
  3887. X                     } else path ||:= spec[i+1:0] || "/"
  3888. X                   } else {
  3889. X                   if (x := find("[",spec)) then
  3890. X                     {
  3891. X                     y := find("]",spec)
  3892. X                     path := map(spec[x+1:y],".","/") || "/"
  3893. X                     } else path ||:= spec || "/"
  3894. X                   }
  3895. X                 return path
  3896. X               }
  3897. X    "MS-DOS" : { if find(":",spec) then
  3898. X                   {
  3899. X                   path := "/usr" || ord(map(spec[1])) - 96 || "/" ||
  3900. X                           map(spec[3:0],"\\","/")
  3901. X                   } else {
  3902. X                   path := map(spec,"\\","/")
  3903. X                   }
  3904. X                 (path[-1] == "/") | (path ||:= "/")
  3905. X               }
  3906. X    default  : { return spec }
  3907. X    }
  3908. X  end
  3909. X
  3910. SHEOF
  3911. # ============== sh.txt ==============
  3912. if test X"$1" != X"-c" -a -f 'sh.txt'; then
  3913.     echo "File already exists: skipping 'sh.txt'"
  3914. else
  3915. echo "x - extracting sh.txt (Text)"
  3916. sed 's/^X//' << 'SHEOF' > sh.txt &&
  3917. X
  3918. XThis is a shell archive utility for non-unix hosts. It can extract from
  3919. Xshell archives (no overwrite checking done). It can list archives. And
  3920. Xit can create archives. No actual shell script interpretation is done.
  3921. XFor extraction it reads the important stuff and extracts the files. For
  3922. Xbuilding, it runs through an interactive dialog.
  3923. X
  3924. XExamples : sh termlib1.sh             Extracts by default
  3925. X           sh mystuff build           Builds mystuff.sh archive
  3926. X           sh mgale.sh list           Lists modules of mgale archive
  3927. X
  3928. XI've written it primarily for VMS and MS-DOS. I haven't tested the MS-DOS
  3929. Xpart yet. Also since I don't have unix out there, someone out there in
  3930. Xunixland can test it to make sure that what it builds is extractable.
  3931. X
  3932. XYours truly,
  3933. X
  3934. XChris Tenaglia (System Manager) | Medical College of Wisconsin
  3935. X8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  3936. X(414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  3937. X
  3938. SHEOF
  3939. #
  3940. # End of sh archive.
  3941.  
  3942.  
  3943. From ralph  Mon Jan 14 05:54:53 1991
  3944. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  3945.     id AA24039; Mon, 14 Jan 91 05:54:53 -0700
  3946. Date: Mon, 14 Jan 91 05:54:50 MST
  3947. From: "Ralph Griswold" <ralph>
  3948. Message-Id: <9101141254.AA13162@cheltenham.cs.arizona.edu>
  3949. Received: by cheltenham.cs.arizona.edu; Mon, 14 Jan 91 05:54:50 MST
  3950. To: dave@cs.arizona.edu
  3951. Subject: Re:  Icon V8 for the Amiga?
  3952. Cc: icon-group
  3953.  
  3954. Version 8 of Icon was implemented for the Amiga about a year ago.  It's
  3955. part of our regular distribution.
  3956.  
  3957.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  3958.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  3959.  
  3960. From icon-group-request@arizona.edu  Mon Jan 14 11:04:25 1991
  3961. Resent-From: icon-group-request@arizona.edu
  3962. Received: from Arizona.edu (Osprey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  3963.     id AA04692; Mon, 14 Jan 91 11:04:25 -0700
  3964. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Sun, 13 Jan 91 17:36 MST
  3965. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA09315; Sun, 13 Jan 91
  3966.  16:23:07 -0800
  3967. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3968.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3969.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3970. Resent-Date: Sun, 13 Jan 91 17:36 MST
  3971. Date: 14 Jan 91 00:11:55 GMT
  3972. From: dave@arizona.edu
  3973. Subject: Icon V8 for the Amiga?
  3974. Sender: icon-group-request@arizona.edu
  3975. Resent-To: icon-group@cs.arizona.edu
  3976. To: icon-group@arizona.edu
  3977. Resent-Message-Id: <D57A6E6FA8D14062A5@Arizona.edu>
  3978. Message-Id: <661@caslon.cs.arizona.edu>
  3979. Organization: U of Arizona CS Dept, Tucson
  3980. X-Envelope-To: icon-group@CS.Arizona.EDU
  3981. X-Vms-To: icon-group@Arizona.edu
  3982.  
  3983. Is anyone working on a port of Icon V8 for the Amiga?
  3984.  
  3985. Dave Schaumann      | We've all got a mission in life, though we get into ruts;
  3986. dave@cs.arizona.edu | some are the cogs on the wheels, others just plain nuts.
  3987.                         -Daffy Duck.
  3988.  
  3989. From icon-group-request@arizona.edu  Mon Jan 14 11:18:39 1991
  3990. Resent-From: icon-group-request@arizona.edu
  3991. Received: from Arizona.edu (Osprey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  3992.     id AA05453; Mon, 14 Jan 91 11:18:39 -0700
  3993. Received: from ucbvax.Berkeley.EDU by Arizona.edu; Sat, 12 Jan 91 16:19 MST
  3994. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA03279; Sat, 12 Jan 91
  3995.  15:15:09 -0800
  3996. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3997.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3998.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3999. Resent-Date: Sat, 12 Jan 91 16:20 MST
  4000. Date: 12 Jan 91 13:52:18 GMT
  4001. From: hsi!mlfarm!ron@uunet.uu.net
  4002. Subject: RE: post.icn (news poster)
  4003. Sender: icon-group-request@arizona.edu
  4004. Resent-To: icon-group@cs.arizona.edu
  4005. To: icon-group@arizona.edu
  4006. Resent-Message-Id: <D64E3597DC11405083@Arizona.edu>
  4007. Message-Id: <693@mlfarm.com>
  4008. Organization: Maple Lawn Farm, Stonington, CT
  4009. X-Envelope-To: icon-group@CS.Arizona.EDU
  4010. X-Vms-To: icon-group@Arizona.edu
  4011. References: <689@mlfarm.com>
  4012.  
  4013. This patch will add (Full Name) to the From line of outgoing postings
  4014. from post.icn.  Most of the changes are added lines, so if you don't
  4015. have `patch' it shouldn't be too onerous to do manually.
  4016.  
  4017. If your passwd file keeps full names between a "-" and a "(", try
  4018. setting "unixtype" to "usg".  Use "bsd" for Xenix, V7 or other passwd
  4019. files which have the full name the first item after the colon in the
  4020. field.  The ms-dos support relies on a hard-coded full name (ugh!).  
  4021.  
  4022.  
  4023. *** post.icn~    Tue Jan  8 19:57:00 1991
  4024. --- post.icn    Thu Jan 10 23:15:24 1991
  4025. ***************
  4026. *** 19,25 ****
  4027.   #
  4028.   ############################################################################
  4029.   #
  4030. ! #  Configure: smarthost, mode, editor or EDITOR environment variable.
  4031.   #
  4032.   ############################################################################
  4033.   #
  4034. --- 19,25 ----
  4035.   #
  4036.   ############################################################################
  4037.   #
  4038. ! #  Configure: smarthost, mode, unixtype, editor or EDITOR env. variable.
  4039.   #
  4040.   ############################################################################
  4041.   #
  4042. ***************
  4043. *** 34,39 ****
  4044. --- 34,40 ----
  4045.     
  4046.     smarthost := "news-feed"    # Your news feed.
  4047.     mode := "uux"            # Use "mail" for a sendnews feed.
  4048. +   unixtype := "bsd"        # Use "usg" for "-Full Name(" passwd file.
  4049.     domain := ".UUCP"
  4050.   
  4051.     if (find("UNIX", &features) & find("pipes", &features)) then {
  4052. ***************
  4053. *** 43,48 ****
  4054. --- 44,57 ----
  4055.                   # Uuname sometimes pads with spaces.
  4056.       (inf := open("uuname -l", "pr")) & (sitename := trim(!inf)) & close(inf)
  4057.       (tz := getenv("TZ")) & tz ?:= (tab(many(&letters)), tab(upto(&letters)))
  4058. +     \logname & (inf := open("/etc/passwd")) & every s := !inf do s ? {
  4059. +       =(logname) & {
  4060. +     every tab(upto(':')+1) \4 
  4061. +     if find("bsd", unixtype) then fullname := tab(upto(':'))
  4062. +     else fullname := (tab(upto('-')+1), tab(upto('(')))
  4063. +     break
  4064. +       }    
  4065. +     }
  4066.       sigfile := getenv("HOME") || "/.signature"
  4067.       editor := "/bin/vi"
  4068.     }
  4069. ***************
  4070. *** 52,57 ****
  4071. --- 61,67 ----
  4072.       logname := &null
  4073.       sitename := &null
  4074.       tz := &null            # Hours off GMT.
  4075. +     fullname := &null
  4076.       sigfile := &null
  4077.       editor := "edlin"
  4078.     }
  4079. ***************
  4080. *** 59,65 ****
  4081.     article := open(tmpfile := tempname(tmpdir), "w") | 
  4082.       stop("post: cannot write temp file")
  4083.     write(article, "Path: ", sitename, "!", logname)
  4084. !   write(article, "From: ", logname, "@", sitename, domain)
  4085.   
  4086.     if \arg[1] then {
  4087.       inf := open(arg[1]) | {
  4088. --- 69,77 ----
  4089.     article := open(tmpfile := tempname(tmpdir), "w") | 
  4090.       stop("post: cannot write temp file")
  4091.     write(article, "Path: ", sitename, "!", logname)
  4092. !   writes(article, "From: ", logname, "@", sitename, domain)
  4093. !   \fullname & writes(article, " (", fullname, ")")
  4094. !   write(article)
  4095.   
  4096.     if \arg[1] then {
  4097.       inf := open(arg[1]) | {
  4098. --
  4099.  
  4100. Ronald Florence            ron@mlfarm.com
  4101.  
  4102. From icon-group-request@arizona.edu  Mon Jan 14 16:17:34 1991
  4103. Resent-From: icon-group-request@arizona.edu
  4104. Received: from MERLIN.TELCOM.ARIZONA.EDU by megaron.cs.arizona.edu (5.61/15) via SMTP
  4105.     id AA19400; Mon, 14 Jan 91 16:17:34 -0700
  4106. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 14 Jan
  4107.  1991 16:11 MST
  4108. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA07481; Mon, 14 Jan 91
  4109.  14:52:48 -0800
  4110. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4111.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4112.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4113. Resent-Date: Mon, 14 Jan 1991 16:17 MST
  4114. Date: 14 Jan 91 19:16:50 GMT
  4115. From: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net (Norman Azadian)
  4116. Subject: gripe
  4117. Sender: icon-group-request@arizona.edu
  4118. Resent-To: icon-group@cs.arizona.edu
  4119. To: icon-group@arizona.edu
  4120. Resent-Message-Id: <43B50DF0808009A8@Arizona.edu>
  4121. Message-Id: <1724@hslrswi.hasler.ascom.ch>
  4122. X-Envelope-To: icon-group@CS.Arizona.EDU
  4123. X-Vms-To: icon-group@Arizona.edu
  4124. Organization: Hasler AG
  4125.  
  4126.  
  4127. I spent a bunch of time this weekend fiddling with Icon library routines.
  4128. Have I overlooked a feature, or is Icon just amazingly deficient in this
  4129. department?  Sorely lacking is the ability to make something global at
  4130. the module (file) level, without making it public for the whole world.
  4131. This lack means that library files have to be very carefully coordinated
  4132. indeed, practically precluding the casual sharing of routines that the
  4133. net is so good for.
  4134.  
  4135. Have I missed something, or is there some good reason that this has
  4136. been excluded from the language, or has this subject already been
  4137. beaten to death in past net wars?
  4138.  
  4139. While I'm at it, I'd like to put in a gripe for the linker under DOS,
  4140. or to be more precise, under the MKS Toolkit running under DOS.  The
  4141. Toolkit gives me 80% of an unix environment on my measly AT clone, and
  4142. with good speed and features.  Best of all I can type paths as God
  4143. meant them to be typed, with forward slashes.  But the linker has
  4144. problems with this.  Either the files must be in the same directory,
  4145. or an absolute path has to be given, or one must do the link under DOS.
  4146. All of these options stink, but for now I'm using plan B.  I suspect
  4147. the linker considers pathname component separators to always be "\",
  4148. and so loses under the MKS Toolkit.  Fixing it is probably simple.
  4149.  
  4150. I believe open() has similar difficulties, but I've been able to
  4151. get around that without undue strain.
  4152. I've written a module, soon to be released at a net node near you,
  4153. which solves this problem for Icon programs.  By judicious fiddling
  4154. with what DOS calls the "switch character", one can convince programs
  4155. to work in both DOS and the MKS Toolkit, without loss of generality.
  4156. True it does dive into an undocumented DOS function (ugggh), but it
  4157. beats the alternative of running under DOS (yeccch).
  4158.  
  4159. NHA
  4160. ---
  4161. -- 
  4162. PAPER:  Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
  4163. INTERNET:  naz%hslrswi.uucp@uunet.uu.net
  4164. UUCP:   ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
  4165. VOICE:  +41 31 63 2178            BITNET: naz%hslrswi.UUCP@cernvax.BITNET
  4166.  
  4167. From icon-group-request@arizona.edu  Wed Jan 16 09:41:34 1991
  4168. Resent-From: icon-group-request@arizona.edu
  4169. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  4170.     id AA18548; Wed, 16 Jan 91 09:41:34 -0700
  4171. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 16 Jan
  4172.  1991 09:41 MST
  4173. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA02655; Wed, 16 Jan 91
  4174.  08:25:28 -0800
  4175. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4176.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4177.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4178. Resent-Date: Wed, 16 Jan 1991 09:41 MST
  4179. Date: 16 Jan 91 16:06:17 GMT
  4180. From: eru!hagbard!sunic!sics.se!sics!soder@bloom-beacon.mit.edu (Hakan
  4181.  Soderstrom)
  4182. Subject: Summary: exit codes from Icon programs
  4183. Sender: icon-group-request@arizona.edu
  4184. Resent-To: icon-group@cs.arizona.edu
  4185. To: icon-group@arizona.edu
  4186. Resent-Message-Id: <9EBB9E36108015BD@Arizona.edu>
  4187. Message-Id: <SODER.91Jan16170617@basm.inmic.se>
  4188. X-Envelope-To: icon-group@CS.Arizona.EDU
  4189. X-Vms-To: icon-group@Arizona.edu
  4190. Organization: Swedish Institute of Microelectronics, Kista
  4191.  
  4192. A while ago I thought I had a problem with Icon exit codes
  4193. under recent versions of SunOS. I wondered if anyone could
  4194. verify that an Icon program always exits by calling the Unix
  4195. 'exit' and promised to post a summary.
  4196.  
  4197. The summary is that without net response I had to resolve
  4198. the problem myself. Icon very carefully exits through a Unix
  4199. 'exit'. The problem I had turned out to be a C program which
  4200. piped its output into the Icon program and exited by just
  4201. flowing out of 'main'...
  4202.  
  4203. I would like to remove any stain of suspicion against Icon
  4204. that my previous posting might have caused among readers.
  4205. The project I am involved in has developed an
  4206. object-oriented database management system. In particular
  4207. its DDL and DML compilers include 17.000 lines of Icon code
  4208. and run on several major brands of Unix workstations.
  4209.  
  4210. So far, we have never found a bug in Icon. (For the sake of
  4211. portability we have avoided co-expressions, however.) Even
  4212. more remarkable is that among all the complaints we have had
  4213. about our system few, if any, have complained about the
  4214. execution speed of the compilers. Our implementation
  4215. technique is to implement lexer and parser as a C program,
  4216. using lex and yacc. An Icon program reads the resulting
  4217. parse tree and does all the semantic processing.
  4218.  
  4219. --
  4220. ----------------------------------------------------
  4221. Hakan Soderstrom             Phone: +46 (8) 752 1138
  4222. NMP-CAD                      Fax:   +46 (8) 750 8056
  4223. P.O. Box 1193                E-mail: soder@nmpcad.se
  4224. S-164 22 Kista, Sweden
  4225.  
  4226. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Wed Jan 16 10:15:31 1991
  4227. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  4228.     id AA19958; Wed, 16 Jan 91 10:15:31 -0700
  4229. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  4230.     id AA24948; Wed, 16 Jan 91 12:15:24 -0500
  4231. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 16 Jan 91 12:09:05 EST
  4232. Date: Wed, 16 Jan 91 12:04:10 EST
  4233. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  4234. To: icon-group@cs.arizona.edu
  4235. Message-Id: <285847@Wayne-MTS>
  4236. Subject: Usage of break
  4237.  
  4238.  
  4239. Today I ran into the kind of problem I'm sure most of us have now and then:
  4240. a single line in an Icon program whose behavior I just couldn't understand. 
  4241. What I wrote was:
  4242.  
  4243. repeat{
  4244.    ...
  4245.    until find("\\syntax", read(infile) | break)
  4246.    ...
  4247. }
  4248.  
  4249. The idea was to read lines until I found one containing `\syntax' or the
  4250. file was exhausted.  (I intended to throw out the `\syntax' line; I was
  4251. only interested in what followed it.)  I couldn't understand why the
  4252. expression was exiting immediately.
  4253.  
  4254. What I finally realized was that in the constructs
  4255.     while expr1 do expr2
  4256. and
  4257.     until expr1 do expr2
  4258. a `break' in expr1 terminates the construct in the same way as if it's in
  4259. expr2. I read page 19 of the Icon book fairly carefully, but not carefully
  4260. enough; it says that a break expression causes immediate termination of the
  4261. loop in which it occurs.  I had thought that `the loop' was just expr2, but
  4262. in fact it includes expr1 as well.  So the failure of `find' provoked the
  4263. evaluation of `break' ~(as a result of goal-directed evaluation) and
  4264. therefore the termination of the expression each time a line was read.
  4265.  
  4266. I do understand now what's going on, and it does make sense---but it isn't
  4267. what I initially expected.
  4268.  
  4269. Paul Abrahams
  4270. abrahams%wayne-mts@um.cc.umich.edu 
  4271.  
  4272. From icon-group-request@arizona.edu  Wed Jan 16 16:58:06 1991
  4273. Resent-From: icon-group-request@arizona.edu
  4274. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  4275.     id AA05808; Wed, 16 Jan 91 16:58:06 -0700
  4276. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 16 Jan
  4277.  1991 16:57 MST
  4278. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA16146; Wed, 16 Jan 91
  4279.  15:42:10 -0800
  4280. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4281.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4282.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4283. Resent-Date: Wed, 16 Jan 1991 16:57 MST
  4284. Date: 16 Jan 91 23:14:51 GMT
  4285. From: snorkelwacker.mit.edu!bu.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!quads.uchicago.edu!goer@apple.com
  4286.  (Richard L. Goerwitz)
  4287. Subject: RE: Usage of break
  4288. Sender: icon-group-request@arizona.edu
  4289. Resent-To: icon-group@cs.arizona.edu
  4290. To: icon-group@arizona.edu
  4291. Resent-Message-Id: <DBB58EC5E0801C17@Arizona.edu>
  4292. Message-Id: <1991Jan16.231451.7136@midway.uchicago.edu>
  4293. X-Envelope-To: icon-group@CS.Arizona.EDU
  4294. X-Vms-To: icon-group@Arizona.edu
  4295. Organization: University of Chicago
  4296. References: <285847@Wayne-MTS>
  4297.  
  4298. In <285847@Wayne-MTS> Paul_Abrahams%Wayne-MTS@UM.CC.UMICH.EDU writes:
  4299. >repeat  {
  4300. >   until find("\\syntax", read(infile) | break)
  4301. >}
  4302. >...I couldn't understand why the expression was exiting immediately.
  4303.  
  4304. Paul then went on to explain why the expression was exiting immediately.
  4305. His point is a good one, and I suspect that if there are new Icon pro-
  4306. grammers online reading this, the subtleties might evade easy under-
  4307. standing.  Let me endeavor to explain what is happening above for any-
  4308. one who feels a bit lost.
  4309.  
  4310. >repeat  {
  4311. >   until find("\\syntax", read(infile) | break)
  4312. >}
  4313.  
  4314. What happens here?  Well, repeat simply does whatever is in the curly
  4315. braces over and over again until a break, return, stop(), or exit() is
  4316. executed.  What is in the curly braces?  An "until" control structure.
  4317. What does the until do?  It executes its argument repeatedly until it
  4318. succeeds.  What is its argument?  It is a find function.  What does find
  4319. do?  It looks for a string in another string.  If it fails, its argu-
  4320. ments are resumed, until they are exhausted, at which point the entire
  4321. function fails, and the until re-executes it once again in an attempt
  4322. to get a result.
  4323.  
  4324. The trouble here is with the arguments of find.  Find will look for
  4325. "\\syntax" in the string produced by read(infile).  The function read()
  4326. is not a generator, so if the find fails, and read(infile) is resumed,
  4327. it cannot produce any more results.  It therefore fails.  In this case
  4328. though, read(infile) is not alone.  It is part of an expression con-
  4329. taining a vertical slash (|).  The expression
  4330.  
  4331.     a | b
  4332.  
  4333. is a generator, which produces all results of expression a, followed by
  4334. those of expression b.  In the above case,
  4335.  
  4336.     read(infile) | break
  4337.  
  4338. is resumed by find() when find fails to "find" the string "\\syntax" in
  4339. the string produced by read(infile).  The
  4340. expression read(infile) | break, when resumed, first tries to get another
  4341. result out of read(infile) but can't.  Having exhausted this expression
  4342. (expression a), it then tries expression b (the break).  The break then
  4343. exits the containing loop (repeat).
  4344.  
  4345. Note that the argument to until is not considered to be within the until
  4346. control loop.  This was Paul's (important) point.  If the code had run:
  4347.  
  4348.     until find("\\syntax", \line) do {
  4349.     line := read(intext) | break
  4350.     }
  4351.  
  4352. THEN the break would have terminated the until loop.
  4353.  
  4354. If until didn't work this way, things would be quite confusing.  The
  4355. "a" in "until a do b" is really an exit condition for the loop con-
  4356. sisting of expression b.  It is not so much part of the loop as it is
  4357. a specification for how the loop is to be executed.  A break there is
  4358. redundant because the success of "a" itself causes termination of the
  4359. loop.
  4360.  
  4361. Incidentally, the best way to read lines up to the first one containing
  4362. "\\syntax" is to let Icon's resumptive mechanisms do most of the work.
  4363. Try:
  4364.  
  4365.     find("\\syntax", !intext)
  4366.  
  4367. Find will keep failing, and keep on resuming its arguments, and then
  4368. keep on getting new lines from !intext until one of those lines has a
  4369. "\\syntax" in it.  If you need to store results, then the idea of a
  4370. control loop was perfect -
  4371.  
  4372.     every line := !&input do {
  4373.         find("\\syntax", line) & break
  4374.         etc...
  4375.     }
  4376.  
  4377. (whatever).
  4378.  
  4379. I hope that this helps beginners just starting to learn about Icon's
  4380. powerful backtracking mechanisms.  Many thanks to Paul for pointing
  4381. out the difficulty with break and exit conditions.
  4382.  
  4383. -Richard (goer@sophist.uchicago.edu)
  4384.  
  4385. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Wed Jan 16 20:26:08 1991
  4386. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  4387.     id AA11467; Wed, 16 Jan 91 20:26:08 -0700
  4388. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  4389.     id AA23473; Wed, 16 Jan 91 22:26:04 -0500
  4390. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 16 Jan 91 22:22:47 EST
  4391. Date: Wed, 16 Jan 91 18:18:40 EST
  4392. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  4393. To: icon-group@cs.arizona.edu
  4394. Message-Id: <285979@Wayne-MTS>
  4395. Subject: Semantics of compound expressions
  4396.  
  4397.  
  4398. Is there a full explanation of the semantics of compound expressions
  4399. somewhere in the Icon book?  It appears that in the expression
  4400.    {e1; e2; ... ; en}
  4401. the result is independent of whether e1 through e(n-1) succeed or fail
  4402. (though they are evaluated in bounded context as described on p. 85), and
  4403. the result sequence is then that of en.  But I can't find any explicit
  4404. statement of that.  Does such a statement exist?
  4405.  
  4406. Paul Abrahams
  4407. abrahams%wayne-mts@um.cc.umich.edu
  4408.  
  4409.  
  4410. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Wed Jan 16 20:26:17 1991
  4411. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  4412.     id AA11476; Wed, 16 Jan 91 20:26:17 -0700
  4413. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  4414.     id AA23480; Wed, 16 Jan 91 22:26:13 -0500
  4415. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 16 Jan 91 22:23:09 EST
  4416. Date: Wed, 16 Jan 91 18:19:40 EST
  4417. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  4418. To: icon-group@cs.arizona.edu
  4419. Message-Id: <285980@Wayne-MTS>
  4420. Subject: Overcoming inelegance?
  4421.  
  4422.  
  4423. Many times I've encountered the following problem: I have a procedure *p*
  4424. that each time it's called writes some material to a file *f*.  I want to
  4425. pass *f* as a command-line parameter and close *f* when I'm done.  There
  4426. are two inelegant ways to do this:
  4427.  
  4428. (1) Make the file name a global variable; open and close it outside of *p*.
  4429.  
  4430. (2) Jigger the parameters passed to *p* so that a special form of argument
  4431. indicates file opening or closing rather than data to be written.
  4432.  
  4433. Is there an elegant way?  (A similar problem exists for input.)
  4434.  
  4435. Paul Abrahams
  4436. abrahams%wayne-mts@um.cc.umich.edu
  4437.  
  4438.  
  4439. From goer%sophist@gargoyle.uchicago.edu  Thu Jan 17 10:12:49 1991
  4440. Resent-From: goer%sophist@gargoyle.uchicago.edu
  4441. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  4442.     id AA10652; Thu, 17 Jan 91 10:12:49 -0700
  4443. Return-Path: goer@sophist.uchicago.edu
  4444. Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Thu, 17
  4445.  Jan 1991 10:11 MST
  4446. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  4447.  (4.0/1.14) id AA07100; Thu, 17 Jan 91 11:11:49 CST
  4448. Received: by sophist (4.1/UofC3.1X) id AA10819; Thu, 17 Jan 91 11:14:34 CST
  4449. Resent-Date: Thu, 17 Jan 1991 10:12 MST
  4450. Date: Thu, 17 Jan 91 11:14:34 CST
  4451. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  4452. Subject: generalized io library
  4453. Resent-To: icon-group@cs.arizona.edu
  4454. To: icon-group@arizona.edu
  4455. Resent-Message-Id: <6C405705D080213A@Arizona.edu>
  4456. Message-Id: <9101171714.AA10819@sophist>
  4457. X-Envelope-To: icon-group@CS.Arizona.EDU
  4458. X-Vms-To: icon-group@Arizona.edu
  4459.  
  4460. Norman Azadian had correctly criticized me privately for not offering
  4461. a version of itlib.icn which is common to MS-DOS and UNIX.  He has also
  4462. offered me a revised version of itlib.  I've looked over his revised
  4463. version, taken out the portions which seemed to me to be overly spe-
  4464. cific to his environment, and come up with a new library.
  4465.  
  4466. This file is general enough that I believe, with a little tweaking, it
  4467. could be made to work on virtually any system for which a termcap file
  4468. can be found.  Anyone have a termcap file for VMS?  I think the nethack
  4469. distribution has one.  One for the Amiga as well.
  4470.  
  4471. Anyway, here is a preliminary posting.  Norman Azadian may well change
  4472. some things somewhere down the line.
  4473.  
  4474. ########################################################################
  4475. #    
  4476. #    Name:    iolib.icn
  4477. #    
  4478. #    Title:    Icon termlib-type tools for MS-DOS and UNIX
  4479. #    
  4480. #    Author:    Richard Goerwitz and Norman Azadian
  4481. #
  4482. #    Version: 1.1
  4483. #
  4484. #########################################################################
  4485. #
  4486. #  The following library represents a series of rough functional
  4487. #  equivalents to the standard Unix low-level termcap routines.  It is
  4488. #  not meant as an exact termlib clone.  Nor is it enhanced to take
  4489. #  care of magic cookie terminals, terminals that use \D in their
  4490. #  termcap entries, or archaic terminals that require padding.  These
  4491. #  routines are geared mainly for use with ANSI and VT-100 devices.
  4492. #  Note that this file may, in many instances, be used in place of the
  4493. #  older UNIX-only itlib.icn or DOS-only itlibdos.icn files.  The sole
  4494. #  problems that might be encountered would come with certain archaic
  4495. #  or arcane UNIX terminals and/or system file arrangements.  Note that
  4496. #  because these routines ignore padding, they can (unlike itlib.icn)
  4497. #  be run on the NeXT and other systems which fail to implement the -g
  4498. #  option of the stty command.
  4499. #
  4500. #########################################################################
  4501. #
  4502. #  Contents:
  4503. #
  4504. #  setname(term)
  4505. #    Use only if you wish to initialize itermlib for a terminal
  4506. #  other than what your current environment specifies.  "Term" is the
  4507. #  name of the termcap entry to use.  Normally this initialization is
  4508. #  done automatically, and need not concern the user.
  4509. #
  4510. #  getval(id)
  4511. #    Works something like tgetnum, tgetflag, and tgetstr.  In the
  4512. #  spirit of Icon, all three have been collapsed into one routine.
  4513. #  Integer valued caps are returned as integers, strings as strings,
  4514. #  and flags as records (if a flag is set, then type(flag) will return
  4515. #  "true").  Absence of a given capability is signalled by procedure
  4516. #  failure.
  4517. #
  4518. #  igoto(cm,destcol,destline) - NB:  default 1 offset (*not* zero)!
  4519. #    Analogous to tgoto.  "Cm" is the cursor movement command for
  4520. #  the current terminal, as obtained via getval("cm").  Igoto()
  4521. #  returns a string which, when output via iputs, will cause the
  4522. #  cursor to move to column "destcol" and line "destline."  Column and
  4523. #  line are always calculated using a *one* offset.  This is far more
  4524. #  Iconish than the normal zero offset used by tgoto.  If you want to
  4525. #  go to the first square on your screen, then include in your program
  4526. #  "iputs(igoto(getval("cm"),1,1))."
  4527. #
  4528. #  iputs(cp,affcnt)
  4529. #    Equivalent to tputs.  "Cp" is a string obtained via getval(),
  4530. #  or, in the case of "cm," via igoto(getval("cm"),x,y).  Affcnt is a
  4531. #  count of affected lines.  It is completely irrelevant for most
  4532. #  modern terminals, and is supplied here merely for the sake of
  4533. #  backward compatibility with itlib, a UNIX-only version of these
  4534. #  routines (one which handles padding on archaic terminals).
  4535. #
  4536. ##########################################################################
  4537. #
  4538. #  Notes for MS-DOS users:
  4539. #
  4540. #    There are two basic reasons for using the I/O routines
  4541. #  contained in this package.  First, by using a set of generalized
  4542. #  routines, your code will become much more readable.  Secondly, by
  4543. #  using a high level interface, you can avoid the cardinal
  4544. #  programming error of hard coding things like screen length and
  4545. #  escape codes into your programs.
  4546. #
  4547. #    To use this collection of programs, you must do two things.
  4548. #  First, you must add the line "device=ansi.sys" (or the name of some
  4549. #  other driver, like zansi.sys, nansi.sys, or nnansi.sys [=new
  4550. #  nansi.sys]) to your config.sys file.  Secondly, you must add two
  4551. #  lines to your autoexec.bat file: 1) "set TERM=ansi-mono" and 2)
  4552. #  "set TERMCAP=\location\termcap."  The purpose of setting the TERM
  4553. #  variable is to tell this program what driver you are using.  If you
  4554. #  have a color system, you could use "ansi-color" instead of
  4555. #  "ansi-mono," although for compatibility with a broader range of
  4556. #  users, it would perhaps be better to stick with mono.  The purpose
  4557. #  of setting TERMCAP is to make it possible to determine where the
  4558. #  termcap database file is located.  The termcap file (which should
  4559. #  have been packed with this library as termcap.dos) is a short
  4560. #  database of all the escape sequences used by the various terminal
  4561. #  drivers.  Set TERMCAP so that it reflects the location of this file
  4562. #  (which should be renamed as termcap, for the sake of consistency
  4563. #  across UNIX and MS-DOS spectra).  If desired, you can also try
  4564. #  using termcap2.dos.  Certain games work a lot better using this
  4565. #  alternate file.  To try it out, rename it to termcap, and set
  4566. #  the environment variable TERMCAP to its location.
  4567. #
  4568. #    Although the authors make no pretense of providing here a
  4569. #  complete introduction to the format of the termcap database file,
  4570. #  it will be useful, we believe, to explain a few basic facts about
  4571. #  how to use this program in conjunction with it.  If, say, you want
  4572. #  to clear the screen, add the line,
  4573. #
  4574. #    iputs(getval("cl"))
  4575. #
  4576. #  to your program.  The function iputs() outputs screen control
  4577. #  sequences.  Getval retrieves a specific sequence from the termcap
  4578. #  file.  The string "cl" is the symbol used in the termcap file to
  4579. #  mark the code used to clear the screen.  By executing the
  4580. #  expression "iputs(getval("cl"))," you are 1) looking up the "cl"
  4581. #  (clear) code in the termcap database entry for your terminal, and
  4582. #  the 2) outputting that sequence to the screen.
  4583. #
  4584. #    Some other useful termcap symbols are "ce" (clear to end of
  4585. #  line), "ho" (go to the top left square on the screen), "so" (begin
  4586. #  standout mode), and "se" (end standout mode).  To output a
  4587. #  boldfaced string, str, to the screen, you would write -
  4588. #
  4589. #    iputs(getval("so"))
  4590. #    writes(str)
  4591. #    iputs(getval("se"))
  4592. #
  4593. #  You can also write "writes(getval("so") || str || getval("se")),
  4594. #  but this would make reimplementation for UNIX terminals that
  4595. #  require padding rather difficult.
  4596. #
  4597. #    It is also heartily to be recommended that MS-DOS programmers
  4598. #  try not to assume that everyone will be using a 25-line screen.
  4599. #  Most terminals are 24-line.  Some 43.  Some have variable window
  4600. #  sizes.  If you want to put a status line on, say, the 2nd-to-last
  4601. #  line of the screen, then determine what that line is by executing
  4602. #  "getval("li")."  The termcap database holds not only string-valued
  4603. #  sequences, but numeric ones as well.  The value of "li" tells you
  4604. #  how many lines the terminal has (compare "co," which will tell you
  4605. #  how many columns).  To go to the beginning of the second-to-last
  4606. #  line on the screen, type in:
  4607. #
  4608. #    iputs(igoto(getval("cm"), 1, getval("li")-1))
  4609. #
  4610. #  The "cm" capability is a special capability, and needs to be output
  4611. #  via igoto(cm,x,y), where cm is the sequence telling your computer
  4612. #  to move the cursor to a specified spot, x is the column, and y is
  4613. #  the row.  The expression "getval("li")-1" will return the number of
  4614. #  the second-to-last line on your screen.
  4615. #
  4616. ##########################################################################
  4617. #
  4618. #  Requires: UNIX or MS-DOS, co-expressions
  4619. #
  4620. #  See also: itlib.icn, itlibdos.icn, iscreen.icn
  4621. #
  4622. ##########################################################################
  4623.  
  4624.  
  4625. global tc_table, isDOS
  4626. record true()
  4627.  
  4628.  
  4629. procedure check_features()
  4630.  
  4631.     initial {
  4632.  
  4633.     if find("UNIX",&features) then
  4634.         isDOS := &null
  4635.     else if find("MS-DOS", &features) then
  4636.         isDOS := 1
  4637.     else stop("check_features:  OS not (yet?) supported.")
  4638.  
  4639.     find("expressi",&features) |
  4640.         er("check_features","co-expressions not implemented - &$#!",1)
  4641.     }
  4642.  
  4643.     return
  4644.  
  4645. end
  4646.  
  4647.  
  4648.  
  4649. procedure setname(name)
  4650.  
  4651.     # Sets current terminal type to "name" and builds a new termcap
  4652.     # capability database (residing in tc_table).  Fails if unable to
  4653.     # find a termcap entry for terminal type "name."  If you want it
  4654.     # to terminate with an error message under these circumstances,
  4655.     # comment out "| fail" below, and uncomment the er() line.
  4656.  
  4657.     #tc_table is global
  4658.     
  4659.     check_features()
  4660.  
  4661.     tc_table := table()
  4662.     tc_table := maketc_table(getentry(name)) | fail
  4663.     # er("setname","no termcap entry found for "||name,3)
  4664.     return "successfully reset for terminal " || name
  4665.  
  4666. end
  4667.  
  4668.  
  4669.  
  4670. procedure getname()
  4671.  
  4672.     # Getname() first checks to be sure we're running under DOS or
  4673.     # UNIX, and, if so, tries to figure out what the current terminal
  4674.     # type is, checking successively the value of the environment
  4675.     # variable TERM, and then (under UNIX) the output of "tset -".
  4676.     # Terminates with an error message if the terminal type cannot be
  4677.     # ascertained.  DOS defaults to "mono."
  4678.  
  4679.     local term, tset_output
  4680.  
  4681.     check_features()
  4682.  
  4683.     if \isDOS then {
  4684.         term := getenv("TERM") | "mono"
  4685.     }
  4686.     else {
  4687.     if not (term := getenv("TERM")) then {
  4688.         tset_output := open("/bin/tset -","pr") |
  4689.         er("getname","can't find tset command",1)
  4690.         term := !tset_output
  4691.         close(tset_output)
  4692.     }
  4693.     }
  4694.  
  4695.     return \term |
  4696.     er("getname","can't seem to determine your terminal type",1)
  4697.  
  4698. end
  4699.  
  4700.  
  4701.  
  4702. procedure er(func,msg,errnum)
  4703.  
  4704.     # short error processing utility
  4705.     write(&errout,func,":  ",msg)
  4706.     exit(errnum)
  4707.  
  4708. end
  4709.  
  4710.  
  4711.  
  4712. procedure getentry(name, termcap_string)
  4713.  
  4714.     # "Name" designates the current terminal type.  Getentry() scans
  4715.     # the current environment for the variable TERMCAP.  If the
  4716.     # TERMCAP string represents a termcap entry for a terminal of type
  4717.     # "name," then getentry() returns the TERMCAP string.  Otherwise,
  4718.     # getentry() will check to see if TERMCAP is a file name.  If so,
  4719.     # getentry() will scan that file for an entry corresponding to
  4720.     # "name."  If the TERMCAP string does not designate a filename,
  4721.     # getentry() will scan the termcap file for the correct entry.
  4722.     # Whatever the input file, if an entry for terminal "name" is
  4723.     # found, getentry() returns that entry.  Otherwise, getentry()
  4724.     # fails.
  4725.  
  4726.     local f, getline, line, nm, ent1, ent2
  4727.     static slash, dirinits, termcap_name
  4728.     initial {
  4729.     if \isDOS then {
  4730.         slash := "\\"
  4731.         dirinits := create (tab(any(&letters)), =":") | match(slash)
  4732.         termcap_name := "termcap"
  4733.     }
  4734.     else {
  4735.         slash := "/"
  4736.         dirinits := create match(slash)
  4737.         termcap_name := "/etc/termcap"
  4738.     }
  4739.     }
  4740.  
  4741.  
  4742.     # You can force getentry() to use a specific termcap file by cal-
  4743.     # ling it with a second argument - the name of the termcap file
  4744.     # to use instead of the regular one, or the one specified in the
  4745.     # termcap environment variable.
  4746.     /termcap_string := getenv("TERMCAP")
  4747.  
  4748.     dirinits := ^dirinits
  4749.     if \termcap_string ? (not @dirinits, pos(1) | tab(find("|")+1), =name)
  4750.     then return termcap_string
  4751.     else {
  4752.  
  4753.     # The logic here probably isn't clear.  The idea is to try to use
  4754.     # the termcap environment variable successively as 1) a termcap en-
  4755.     # try and then 2) as a termcap file.  If neither works, 3) go to
  4756.     # the /etc/termcap file.  The else clause here does 2 and, if ne-
  4757.     # cessary, 3.  The "\termcap_string ? (not match..." expression
  4758.     # handles 1.
  4759.  
  4760.     if find(slash, \termcap_string)
  4761.     then f := open(termcap_string)
  4762.     /f := open(termcap_name) |
  4763.         er("getentry","I can't access your /etc/termcap file",1)
  4764.  
  4765.     getline := create read_file(f)
  4766.     
  4767.     while line := @getline do {
  4768.         if line ? (pos(1) | tab(find("|")+1), =name, any(':|')) then {
  4769.         entry := ""
  4770.         while (\line | @getline) ? {
  4771.             if entry ||:= 1(tab(find(":")+1), pos(0))
  4772.             then {
  4773.             close(f)
  4774.             # if entry ends in tc= then add in the named tc entry
  4775.             entry ?:= tab(find("tc=")) ||
  4776.                 # recursively fetch the new termcap entry
  4777.                 (move(3), getentry(tab(find(":"))) ?
  4778.                     # remove the name field from the new entry
  4779.                      (tab(find(":")+1), tab(0)))
  4780.             return entry
  4781.             }
  4782.             else {
  4783.             \line := &null # must precede the next line
  4784.             entry ||:= trim(trim(tab(0),'\\'),':')
  4785.             }
  4786.         }
  4787.         }
  4788.     }
  4789.     }
  4790.  
  4791.     close(f)
  4792.     er("getentry","can't find and/or process your termcap entry",3)
  4793.  
  4794. end
  4795.  
  4796.  
  4797.  
  4798. procedure read_file(f)
  4799.  
  4800.     # Suspends all non #-initial lines in the file f.
  4801.     # Removes leading tabs and spaces from lines before suspending
  4802.     # them.
  4803.  
  4804.     local line
  4805.  
  4806.     \f | er("read_tcap_file","no valid termcap file found",3)
  4807.     while line := read(f) do {
  4808.     match("#",line) & next
  4809.     line ?:= (tab(many('\t ')) | &null, tab(0))
  4810.     suspend line
  4811.     }
  4812.  
  4813.     fail
  4814.  
  4815. end
  4816.  
  4817.  
  4818.  
  4819. procedure maketc_table(entry)
  4820.  
  4821.     # Maketc_table(s) (where s is a valid termcap entry for some
  4822.     # terminal-type): Returns a table in which the keys are termcap
  4823.     # capability designators, and the values are the entries in
  4824.     # "entry" for those designators.
  4825.  
  4826.     local k, v
  4827.  
  4828.     /entry & er("maketc_table","no entry given",8)
  4829.     if entry[-1] ~== ":" then entry ||:= ":"
  4830.     
  4831.     /tc_table := table()
  4832.  
  4833.     entry ? {
  4834.  
  4835.     tab(find(":")+1)    # tab past initial (name) field
  4836.  
  4837.     while tab((find(":")+1) \ 1) ? {
  4838.         &subject == "" & next
  4839.         if k := 1(move(2), ="=")
  4840.         then tc_table[k] := Decode(tab(find(":")))
  4841.         else if k := 1(move(2), ="#")
  4842.         then tc_table[k] := integer(tab(find(":")))
  4843.         else if k := 1(tab(find(":")), pos(-1))
  4844.         then tc_table[k] := true()
  4845.         else er("maketc_table", "your termcap file has a bad entry",3)
  4846.     }
  4847.     }
  4848.  
  4849.     return tc_table
  4850.  
  4851. end
  4852.  
  4853.  
  4854.  
  4855. procedure getval(id)
  4856.  
  4857.     /tc_table := maketc_table(getentry(getname())) |
  4858.     er("getval","can't make a table for your terminal",4)
  4859.  
  4860.     return \tc_table[id] | fail
  4861.     # er("getval","the current terminal doesn't support "||id,7)
  4862.  
  4863. end
  4864.  
  4865.  
  4866.  
  4867. procedure Decode(s)
  4868.  
  4869.     # Does things like turn ^ plus a letter into a genuine control
  4870.     # character.
  4871.  
  4872.     new_s := ""
  4873.  
  4874.     s ? {
  4875.  
  4876.     while new_s ||:= tab(upto('\\^')) do {
  4877.         chr := move(1)
  4878.         if chr == "\\" then {
  4879.         new_s ||:= {
  4880.             case chr2 := move(1) of {
  4881.             "\\" : "\\"
  4882.             "^"  : "^"
  4883.             "E"  : "\e"
  4884.             "b"  : "\b"
  4885.             "f"  : "\f"
  4886.             "n"  : "\n"
  4887.             "r"  : "\r"
  4888.             "t"  : "\t"
  4889.             default : {
  4890.                 if any(&digits,chr2) then {
  4891.                 char(integer("8r"||chr2||move(2 to 0 by -1))) |
  4892.                     er("Decode","bad termcap entry",3)
  4893.                 }
  4894.                else chr2
  4895.             }
  4896.             }
  4897.         }
  4898.         }
  4899.         else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
  4900.     }
  4901.     new_s ||:= tab(0)
  4902.     }
  4903.  
  4904.     return new_s
  4905.  
  4906. end
  4907.  
  4908.  
  4909.  
  4910. procedure igoto(cm,col,line)
  4911.  
  4912.     local colline, range, increment, str, outstr, chr, x, y
  4913.  
  4914.     if col > (tc_table["co"]) | line > (tc_table["li"]) then {
  4915.     colline := string(\col) || "," || string(\line) | string(\col|line)
  4916.     range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
  4917.     er("igoto",colline || " out of range " || (\range|""),9)
  4918.     } 
  4919.  
  4920.     # Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
  4921.     increment := -1
  4922.     outstr := ""
  4923.     
  4924.     cm ? {
  4925.     while outstr ||:= tab(find("%")) do {
  4926.         tab(match("%"))
  4927.         chr := move(1)
  4928.         if case chr of {
  4929.         "." :  outstr ||:= char(line + increment)
  4930.         "+" :  outstr ||:= char(line + ord(move(1)) + increment)
  4931.         "d" :  {
  4932.             str := string(line + increment)
  4933.             outstr ||:= right(str, integer(tab(any('23'))), "0") | str
  4934.         }
  4935.         }
  4936.         then line :=: col
  4937.         else {
  4938.         case chr of {
  4939.             "n" :  line := ixor(line,96) & col := ixor(col,96)
  4940.             "i" :  increment := 0
  4941.             "r" :  line :=: col
  4942.             "%" :  outstr ||:= "%"
  4943.             "B" :  line := ior(ishift(line / 10, 4), line % 10)
  4944.             ">" :  {
  4945.             x := move(1); y := move(1)
  4946.             line > ord(x) & line +:= ord(y)
  4947.             &null
  4948.             }
  4949.         } | er("goto","bad termcap entry",5)
  4950.         }
  4951.     }
  4952.     return outstr || tab(0)
  4953.     }
  4954.  
  4955. end
  4956.  
  4957.  
  4958.  
  4959. procedure iputs(cp, affcnt)
  4960.  
  4961.     # Writes cp to the screen.  Use this instead of writes() for
  4962.     # compatibility with itlib (a UNIX-only version which can handle
  4963.     # albeit inelegantly) terminals that need padding.
  4964.  
  4965.     static num_chars
  4966.     initial num_chars := &digits ++ '.'
  4967.  
  4968.     type(cp) == "string" |
  4969.     er("iputs","you can't iputs() a non-string value!",10)
  4970.  
  4971.     cp ? {
  4972.     if tab(many(num_chars)) & ="*" then
  4973.         stop("iputs:  iolib can't use terminals that require padding.")
  4974.     writes(tab(0))
  4975.     }
  4976.  
  4977.     return
  4978.  
  4979. end
  4980.  
  4981. From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu  Thu Jan 17 10:40:29 1991
  4982. Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  4983.     id AA11762; Thu, 17 Jan 91 10:40:29 -0700
  4984. Received: by uwm.edu; id AA15663; Thu, 17 Jan 91 11:40:19 -0600
  4985. Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
  4986.           Thu, 17 Jan 91 10:54:55 CDT
  4987. Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
  4988.           Thu, 17 Jan 1991 10:10 CST
  4989. Date: Thu, 17 Jan 1991 10:09 CST
  4990. From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
  4991. Subject: sh.icn : Shell Archive
  4992. To: icon-group@cs.arizona.edu
  4993. Message-Id: <6BDCE31FC0A0013F@mis.mcw.edu>
  4994. X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
  4995. X-Envelope-To: icon-group@cs.arizona.edu
  4996. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  4997.  
  4998.  
  4999. Here's the icon shell archive utility. It's in shell archive format. I
  5000. would like comments and bug reports from unix sites. It tests out fairly
  5001. well under DOS and VMS.
  5002.  
  5003. Thanx,
  5004.  
  5005. Chris Tenaglia (System Manager) | Medical College of Wisconsin
  5006. 8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  5007. (414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  5008.  
  5009. #!/bin/sh
  5010. # This is shar.sh, a shell archive (sh.icn 1.1)
  5011. # made Thursday, January 17, 1991  9:55 am by tenaglia@mis.mcw.edu
  5012. # Source directory /usr53/tenaglia/i/
  5013. #
  5014. # This shar contains:
  5015. # length  mode       name
  5016. # ------ ---------- ------------------------------------------
  5017. #    928 -rw-r--r-- sh.txt
  5018. #   7866 -rw-r--r-- sh.icn
  5019. #
  5020. # This is the icon Shell Archive Utility
  5021. #   *** The Next Generation ***
  5022. # Needs testing on unix systems.
  5023. # It seems to work fine on VMS and MS-DOS.
  5024. # Interested in your comments and/or bug reports.
  5025. # Thank you.
  5026. #
  5027. # ============== sh.txt ==============
  5028. if test X"$1" != X"-c" -a -f 'sh.txt'; then
  5029.     echo "File already exists: skipping 'sh.txt'"
  5030. else
  5031. echo "x - extracting sh.txt (Text)"
  5032. sed 's/^X//' << 'SHEOF' > sh.txt &&
  5033. X
  5034. XThis is a shell archive utility for non-unix hosts. It can extract from
  5035. Xshell archives (no overwrite checking done). It can list archives. And
  5036. Xit can create archives. No actual shell script interpretation is done.
  5037. XFor extraction it reads the important stuff and extracts the files. For
  5038. Xbuilding, it runs through an interactive dialog.
  5039. X
  5040. XExamples : sh termlib1.sh             Extracts by default
  5041. X           sh mystuff build           Builds mystuff.sh archive
  5042. X           sh mgale.sh list           Lists modules of mgale archive
  5043. X
  5044. XI've written it primarily for VMS and MS-DOS. I haven't tested the MS-DOS
  5045. Xpart yet. Also since I don't have unix out there, someone out there in
  5046. Xunixland can test it to make sure that what it builds is extractable.
  5047. X
  5048. XYours truly,
  5049. X
  5050. XChris Tenaglia (System Manager) | Medical College of Wisconsin
  5051. X8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  5052. X(414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  5053. X
  5054. SHEOF
  5055. true || echo "Restore of sh.txt failed."
  5056. set `wc -c sh.txt`;Wc_c=$1
  5057. if test "$Wc_c" != "928"; then
  5058.   echo original size 928, current size $Wc_c
  5059. fi
  5060. fi
  5061. # ============== sh.icn ==============
  5062. if test X"$1" != X"-c" -a -f 'sh.icn'; then
  5063.     echo "File already exists: skipping 'sh.icn'"
  5064. else
  5065. echo "x - extracting sh.icn (Text)"
  5066. sed 's/^X//' << 'SHEOF' > sh.icn &&
  5067. X##################################################################
  5068. X#                                                                #
  5069. X# SH.ICN  V1.1           01/14/91          BY TENAGLIA           #
  5070. X#                                                                #
  5071. X# PROGRAM HANDLES  UNIX SHELL ARCHIVES                           #
  5072. X# USAGE : sh archive [action] [target]                           #
  5073. X#         Where action is extract(default) list or build         #
  5074. X#         If action is list, target is ignored.                  #
  5075. X#         If action is extract (""), target is ignored           #
  5076. X#         If action id build, target is filespec to archive      #
  5077. X# NOTE :  Does not make split archives yet.                      #
  5078. X# NOTE :  Extraction doesn't check for overwrite, just does it.  #
  5079. X# NOTE :  shar 3.xx lengths include the leading X, and don't     #
  5080. X#         match here. This uses their real lengths.              #
  5081. X#                                                                #
  5082. X##################################################################
  5083. Xglobal os, files
  5084. Xprocedure main(param)
  5085. X  source := param[1]          | input("_Source:")
  5086. X  option := param[2]          | "extract"
  5087. X  target := param[3]          | "!nill"
  5088. X  work   := case option of
  5089. X    {
  5090. X    "list" : " Lister\n"
  5091. X    "build": " Builder\n"
  5092. X    default: " Extractor\n"
  5093. X    }
  5094. X  write("sh v1.1 : (Icon) Unix Shell Archive",work)
  5095. X  os     := getsys()
  5096. X  sum    := 0
  5097. X  find(".",source) | (os ~== "VMS") | (source ||:= ".sh")
  5098. X  if option == "build" then build(source)
  5099. X  (in    := open(source)) | stop(&line," : Can't open ",source)
  5100. X  while line := read(in) do
  5101. X    {
  5102. X    stuff := parse(line,'\"\'\t ')
  5103. X    if stuff[1] == "sed" & stuff[2] == "s/^X//" then
  5104. X      {
  5105. X      every i := 1 to *stuff do
  5106. X        {
  5107. X        if stuff[i] == "<<" then     { eof  := stuff[i+1] ; next }
  5108. X        if match("<<",stuff[i]) then { eof  := stuff[i][3:0] ; next }
  5109. X        if stuff[i] == ">>" then
  5110. X          {
  5111. X          name   := stuff[i+1]
  5112. X          method := "a"                # append
  5113. X          what   := "appended."
  5114. X          next
  5115. X          }
  5116. X        if match(">>",stuff[i]) then
  5117. X          {
  5118. X          name   := stuff[i][2:0]
  5119. X          method := "a"                # append
  5120. X          what   := "appended."
  5121. X          next
  5122. X          }
  5123. X        if stuff[i] == ">"  then
  5124. X          {
  5125. X          name   := stuff[i+1]
  5126. X          method := "w"                # create
  5127. X          what   := "written."
  5128. X          next
  5129. X          }
  5130. X        if match(">",stuff[i]) then
  5131. X          {
  5132. X          name   := stuff[i][2:0]
  5133. X          method := "w"                # create
  5134. X          what   := "written."
  5135. X          next
  5136. X          }
  5137. X        }
  5138. X      prog := extract(in,eof)
  5139. X      } else next
  5140. X    directory := if target == "!nill" then "" else target
  5141. X    (option == "list") |
  5142. X      (out := open(directory||name,method)) |
  5143. X        stop(&line," : Can't write ",name)
  5144. X    every stmt := !prog do
  5145. X      {
  5146. X      if option == "extract" then write(out,stmt)
  5147. X      sum +:= *stmt
  5148. X      }
  5149. X    if option == "extract"
  5150. X      then write(name," : ",sum," bytes ",what)
  5151. X      else write(name," : contains ",sum," bytes.")
  5152. X    sum := 0
  5153. X    (option == "list") | close(out)
  5154. X    }
  5155. X  close(in)
  5156. X  end
  5157. X
  5158. X#
  5159. X# This routine extracts the shell archive for a module. It returns
  5160. X# the module in a list structure.
  5161. X#
  5162. Xprocedure extract(file,eofstr)
  5163. X  lst := []
  5164. X  until match(eofstr,(str := read(file))) do
  5165. X    put(lst,str[2:0])
  5166. X  return lst
  5167. X  end
  5168. X
  5169. X#
  5170. X# This routine builds a shell archive. archive is the archive to be made.
  5171. X# The rest of this is interactive.
  5172. X#
  5173. Xprocedure build(archive)
  5174. X  username  := input("Username  :")
  5175. X  directory := input("Directory :")
  5176. X  if (os=="MS-DOS") then
  5177. X    (directory[-1] == "\\") | (directory ||:= "\\")
  5178. X  modules   := table([])
  5179. X  find(".",archive) | (archive ||:= ".sh")
  5180. X  (output   := open(archive,"w")) | stop(&line," : Can't write to ",archive)
  5181. X  comments  := ["#"] ; write("Enter Comments (blank line when done)")
  5182. X  repeat {
  5183. X  comment := input("Comment :")
  5184. X  if trim(comment) == "" then break
  5185. X  put(comments,"# " || comment) }
  5186. X  put(comments,"#")
  5187. X  begin := list()
  5188. X  put(begin,"#!/bin/sh")
  5189. X  put(begin,"# This is " || archive || ", a shell archive (sh.icn 1.1)")
  5190. X  put(begin,"# made " || &dateline  || " by " || username)
  5191. X  put(begin,"# Source directory "   || fsmap(directory))
  5192. X  put(begin,"#", "# existing files will Not be overwritten, hopefully","#")
  5193. X  put(begin,"# This shar contains:")
  5194. X  put(begin,"# length  mode       name")
  5195. X  put(begin,"# ------ ---------- ------------------------------------------")
  5196. X  namelist := []
  5197. X  repeat {
  5198. X  name := input("File (blank when done) :")
  5199. X  if trim(name) == "" then break
  5200. X  (infile := open(directory||name)) | { write("Can't open ",directory,name) ; next }
  5201. X  code := [ "# ============== " || name || " ==============",
  5202. X            "if test X\"$1\" != X\"-c\" -a -f '" || name || "'; then",
  5203. X            "    echo \"File already exists: skipping '"  || name || "'\"",
  5204. X            "else",
  5205. X            "echo \"x - extracting " || name || " (Text)\"",
  5206. X            "sed 's/^X//' << 'SHEOF' > " || name || " &&" ]
  5207. X  measure := 0
  5208. X  while text := read(infile) do
  5209. X    {
  5210. X    measure +:= *text
  5211. X    put(code,"X" || text)
  5212. X    }
  5213. X  put(code,"SHEOF")
  5214. X  put(code,"true || echo \"Restore of " || name || " failed.\"")
  5215. X  put(code,"set `wc -c " || name || "`;Wc_c=$1")
  5216. X  put(code,"if test \"$Wc_c\" != \"" || measure || "\"; then")
  5217. X  put(code,"  echo original size " || measure || ", current size $Wc_c")
  5218. X  put(code,"fi")
  5219. X  put(code,"fi")
  5220. X  close(infile)
  5221. X  put(begin,"# " || right(measure,6) || " -rw-r--r-- " || name)
  5222. X  insert(modules,name,copy(code)) ; put(namelist,name) }
  5223. X  output := open(archive,"a")
  5224. X  every write(output,!begin)
  5225. X  every write(output,!comments)
  5226. X  every file := !namelist do every write(output,!(modules[file]))
  5227. X  write(output,"#")
  5228. X  write(output,"# End of sh archive.")
  5229. X  close(output)
  5230. X  stop("sh archive written to ",archive)
  5231. X  end
  5232. X
  5233. X#
  5234. X# This routine parses a string with respect to some delimiter.
  5235. X# It returns the tokens in a list structure.
  5236. X#
  5237. Xprocedure parse(line,delims)
  5238. X  static chars
  5239. X  chars  := &cset -- delims
  5240. X  tokens := []
  5241. X  line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
  5242. X  return tokens
  5243. X  end
  5244. X
  5245. X#
  5246. X# This routine prompts for a string input. The entered string is returned.
  5247. X#
  5248. Xprocedure input(prompt)
  5249. X  writes(prompt)
  5250. X  return read()
  5251. X  end
  5252. X
  5253. X#
  5254. X# This procedure determines the os by examining &features.
  5255. X#
  5256. Xprocedure getsys()
  5257. X  files := "DIR "             # most logical initially
  5258. X  if &host == "MS-DOS" then
  5259. X    return &host
  5260. X  tmp := []
  5261. X  every feature := &features do
  5262. X    put(tmp,feature)
  5263. X  if tmp[1] ~== "VMS" then files := "ls "
  5264. X  return tmp[1]
  5265. X  end
  5266. X
  5267. X#
  5268. X# This routine maps the directory spec to unix style notation
  5269. X#
  5270. Xprocedure fsmap(spec)
  5271. X  if spec == "" then return spec
  5272. X  case os of
  5273. X    {
  5274. X    "VMS"    : { if (i := find(":",spec)) then
  5275. X                   {
  5276. X                   path := "/usr" || ord(spec[i-1]) || "/"
  5277. X                   if (x := find("[",spec)) then
  5278. X                     {
  5279. X                     y := find("]",spec)
  5280. X                     path ||:= map(spec[x+1:y],".","/") || "/"
  5281. X                     } else path ||:= spec[i+1:0] || "/"
  5282. X                   } else {
  5283. X                   if (x := find("[",spec)) then
  5284. X                     {
  5285. X                     y := find("]",spec)
  5286. X                     path := map(spec[x+1:y],".","/") || "/"
  5287. X                     } else path ||:= spec || "/"
  5288. X                   }
  5289. X                 return path
  5290. X               }
  5291. X    "MS-DOS" : { if find(":",spec) then
  5292. X                   {
  5293. X                   path := "/usr" || ord(map(spec[1])) - 96 ||
  5294. X                           (map(spec[3:0],"\\","/") | "")
  5295. X                   } else {
  5296. X                   path := map(spec,"\\","/")
  5297. X                   }
  5298. X                 (path[-1] == "/") | (path ||:= "/")
  5299. X                 return path || " (MS-DOS " || spec || ")"
  5300. X               }
  5301. X    default  : { return spec }
  5302. X    }
  5303. X  end
  5304. X
  5305. SHEOF
  5306. true || echo "Restore of sh.icn failed."
  5307. set `wc -c sh.icn`;Wc_c=$1
  5308. if test "$Wc_c" != "7866"; then
  5309.   echo original size 7866, current size $Wc_c
  5310. fi
  5311. fi
  5312. #
  5313. # End of sh archive.
  5314.  
  5315. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Thu Jan 17 14:25:41 1991
  5316. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  5317.     id AA21736; Thu, 17 Jan 91 14:25:41 -0700
  5318. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  5319.     id AA07748; Thu, 17 Jan 91 16:25:36 -0500
  5320. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Thu, 17 Jan 91 16:15:09 EST
  5321. Date: Thu, 17 Jan 91 16:09:48 EST
  5322. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5323. To: icon-group@cs.arizona.edu
  5324. Message-Id: <286296@Wayne-MTS>
  5325. Subject: Ignoring failure
  5326.  
  5327. One way to evaluate an expression e solely for its side effects, ignoring
  5328. whether or not it fails, is to write:
  5329.   {e;}
  5330. Does anyone know of a better (more elegant or even shorter) way?
  5331.  
  5332. Paul Abrahams
  5333. abrahams%wayne-mts@um.cc.umich.edu
  5334.  
  5335.  
  5336. From ralph  Thu Jan 17 14:43:18 1991
  5337. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  5338.     id AA22699; Thu, 17 Jan 91 14:43:18 -0700
  5339. Date: Thu, 17 Jan 91 14:43:13 MST
  5340. From: "Ralph Griswold" <ralph>
  5341. Message-Id: <9101172143.AA16309@cheltenham.cs.arizona.edu>
  5342. Received: by cheltenham.cs.arizona.edu; Thu, 17 Jan 91 14:43:13 MST
  5343. To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5344. Subject: Re:  Ignoring failure
  5345. Cc: icon-group
  5346.  
  5347. You get the effect of {e;} by putting just e on a separate line, provided
  5348. it's not inside another expression.  There are lots of ways to get the
  5349. effect if e is inside another expression, such as (e | &null).  I think
  5350. that's clearer than {e;}.
  5351.  
  5352. From cjeffery  Thu Jan 17 17:08:51 1991
  5353. Resent-From: "Clinton Jeffery" <cjeffery>
  5354. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  5355.     id AA00611; Thu, 17 Jan 91 17:08:51 -0700
  5356. Received: from megaron.cs.Arizona.EDU by Arizona.edu with PMDF#10282; Thu, 17
  5357.  Jan 1991 17:08 MST
  5358. Received: from caslon.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via
  5359.  SMTP id AA00595; Thu, 17 Jan 91 17:08:07 -0700
  5360. Received: by caslon.cs.arizona.edu; Thu, 17 Jan 91 17:08:06 -0700
  5361. Resent-Date: Thu, 17 Jan 1991 17:08 MST
  5362. Date: Thu, 17 Jan 91 17:08:06 -0700
  5363. From: Clinton Jeffery <cjeffery@cs.arizona.edu>
  5364. Subject: gripe
  5365. In-Reply-To: Norman Azadian's message of 14 Jan 91 19:16:50 GMT
  5366.  <1724@hslrswi.hasler.ascom.ch>
  5367. Resent-To: icon-group@cs.arizona.edu
  5368. To: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net
  5369. Cc: icon-group@arizona.edu
  5370. Resent-Message-Id: <A660E4DE00802514@Arizona.edu>
  5371. Message-Id: <9101180008.AA21515@caslon.cs.arizona.edu>
  5372. X-Envelope-To: icon-group@CS.Arizona.EDU
  5373. X-Vms-To: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net
  5374. X-Vms-Cc: icon-group@Arizona.edu
  5375.  
  5376. The question of modules and Icon's single global name space is discussed
  5377. about once every six months or so.  I can't speak for Icon's designers,
  5378. but the module deficiency is no longer relevant to me because of two
  5379. factors:
  5380.  
  5381.   (a) Icon programs tend to be way shorter than other language's programs.
  5382.       Short programs are not the problem.
  5383.   (b) For larger Icon programs I use Idol, the object-oriented Icon
  5384.       preprocessor.  Idol classes can vastly reduce the problem of the
  5385.       global name space, especially the problem of having procedures
  5386.       with the same name in different libraries.
  5387.  
  5388. Sorry, I couldn't resist the chance to advertise.
  5389.  
  5390. Clint
  5391.  
  5392. From nowlin@iwtqg.att.com  Fri Jan 18 08:44:17 1991
  5393. Message-Id: <9101181544.AA01662@megaron.cs.arizona.edu>
  5394. Received: from att.att.com by megaron.cs.arizona.edu (5.61/15) via SMTP
  5395.     id AA01662; Fri, 18 Jan 91 08:44:17 -0700
  5396. From: nowlin@iwtqg.att.com
  5397. Date: Fri, 18 Jan 91 07:42 CST
  5398. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  5399. To: icon-group@cs.arizona.edu
  5400. Subject: Re: overcoming inelegance
  5401.  
  5402. > Subject: Overcoming inelegance?
  5403. >  
  5404. > Many times I've encountered the following problem: I have a procedure *p*
  5405. > that each time it's called writes some material to a file *f*.  I want to
  5406. > pass *f* as a command-line parameter and close *f* when I'm done.  There
  5407. > are two inelegant ways to do this:
  5408. > (1) Make the file name a global variable; open and close it outside of *p*.
  5409. > (2) Jigger the parameters passed to *p* so that a special form of argument
  5410. > indicates file opening or closing rather than data to be written.
  5411. > Is there an elegant way?  (A similar problem exists for input.)
  5412. > Paul Abrahams
  5413. > abrahams%wayne-mts@um.cc.umich.edu
  5414.  
  5415. A compromise to the global variable is to pass an opened file pointer into
  5416. the procedure p().  Just open the file outside the procedure and close it
  5417. after the last time the procedure is called.  The ability to have the
  5418. entire open(), write(), close() suite of calls contained in the procedure
  5419. is tricky.  The procedure then has to know the file name somehow.
  5420.  
  5421. The real problem I see with the self-contained approach is the same one
  5422. that was batted around when the discussion of a "final" clause was going
  5423. on.  How do you know when it's the last time you're calling a procedure?
  5424. In this special case you should be able to rely on the language itself or
  5425. the underlying operating system to flush all buffers and close all opened
  5426. files as a program terminates.  Then you only need to worry about opening
  5427. the file.  Is the following the kind of idea you had?  The comment explains
  5428. the concept:
  5429.  
  5430. procedure main(args)
  5431.     p("first output")
  5432.     every f := !args do every p(1 to 10,f)
  5433.     p("last output")
  5434. end
  5435.  
  5436. # This procedure writes the data 'd' to an output stream.  'f' is optional
  5437. # but if passed it's assumed to be a file name and is checked against the
  5438. # currently open file.  If they're the same continue writing to the open
  5439. # file.  If they're different close the current file and open the new one. 
  5440. # If no file is ever passed all writing is to standard output.  NOTE: It is
  5441. # assumed that the system itself will flush and close the final file opened.
  5442.  
  5443. procedure p(d,f)
  5444.  
  5445.     static    o
  5446.     initial    o := &null
  5447.  
  5448.     if \f & not (image(o) ? (="file(" & f == tab(upto(')')))) then {
  5449.         if image(o) ? ="file(" then close(o)
  5450.         o := open(f,"w") | stop("can't open: ",f)
  5451.     }
  5452.  
  5453.     write(o,d)
  5454.  
  5455.     return
  5456. end
  5457.  
  5458. Realize, I don't like the idea of relying on the system to close files for
  5459. me.  That's sloppy not elegant.  Maybe someone will come up with a better
  5460. idea.
  5461.  
  5462. Jerry Nowlin
  5463. att!iwtqg!nowlin
  5464.  
  5465. From R.J.Hare@edinburgh.ac.uk  Fri Jan 18 09:29:27 1991
  5466. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  5467.     id AA03452; Fri, 18 Jan 91 09:29:27 -0700
  5468. Received: from UKACRL.BITNET (MAILER@UKACRL) by Arizona.edu with PMDF#10282;
  5469.  Fri, 18 Jan 1991 09:29 MST
  5470. Received: from RL.IB by UKACRL.BITNET (Mailer R2.07) with BSMTP id 9190; Fri,
  5471.  18 Jan 91 15:19:24 GMT
  5472. Received: from RL.IB by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 3179; Fri, 18
  5473.  Jan 91 15:19:24 GMT
  5474. Date: 18 Jan 91  15:19:22 gmt
  5475. From: R.J.Hare@edinburgh.ac.uk
  5476. Subject: non-echoed input
  5477. To: icon-group@cs.arizona.edu
  5478. Message-Id: <18 Jan 91  15:19:22 gmt  060607@EMAS-A>
  5479. X-Envelope-To: icon-group@cs.arizona.edu
  5480. Via:        UK.AC.ED.EMAS-A; 18 JAN 91 15:19:21 GMT
  5481.  
  5482. I am trying to enter a parameter to an Icon program which I don't want echoing
  5483. (it's a password). I'm sure I should be able to do this either with getch() or
  5484. reads(,1) and then writes(\b*) or something similar, but I can't get it to go.
  5485. Has anyone got a solution to this oroblem?
  5486.  
  5487. Thanks.
  5488.  
  5489. Roger Hare.
  5490.  
  5491. PS: I am running on a Unix machine.
  5492.  
  5493. From goer%sophist@gargoyle.uchicago.edu  Fri Jan 18 09:57:17 1991
  5494. Received: from gargoyle.uchicago.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  5495.     id AA04415; Fri, 18 Jan 91 09:57:17 -0700
  5496. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu) (4.0/1.14)
  5497.     id AA11530; Fri, 18 Jan 91 10:57:13 CST
  5498. Return-Path: <goer@sophist.uchicago.edu>
  5499. Received:  by sophist (4.1/UofC3.1X)
  5500.     id AA11351; Fri, 18 Jan 91 10:59:57 CST
  5501. Date: Fri, 18 Jan 91 10:59:57 CST
  5502. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  5503. Message-Id: <9101181659.AA11351@sophist>
  5504. To: R.J.Hare@edinburgh.ac.uk, icon-group@cs.arizona.edu
  5505. Subject: Re:  non-echoed input
  5506.  
  5507. > I am trying to enter a parameter to an Icon program which I don't want echoing
  5508. > (it's a password). I'm sure I should be able to do this either with getch() or
  5509. > reads(,1) and then writes(\b*) or something similar, but I can't get it to go.
  5510. > Has anyone got a solution to this problem?
  5511.      
  5512. If you are using Unix, you won't be able to access getch().  It can't be done
  5513. portably.  You'll have to do a system() of some kind.  E.g.:
  5514.  
  5515.     system("stty -echo")
  5516.     read(&input)
  5517.     system("stty echo")
  5518.  
  5519. Difficulty:  What if, for some reason the system() fails?  Oh no!  Your
  5520. password gets echoed!  There's no way to test whether system() forked
  5521. a shell, and that shell couldn't execute the command.  You can't tell
  5522. whether the command worked or not using pipes, for the same reason.  All
  5523. you get is a diagnostic written to stderr by the shell, I believe.  Hmmm.
  5524. Maybe you can do this:
  5525.  
  5526.         instty := open("stty -echo 2>&1","pr")
  5527.         if ("" ~== !instty) then
  5528.         stop("Can't seem to reset your tty to no echo mode.")
  5529.         close(instty)
  5530.         read(&input)
  5531.  
  5532. Then do the same sort of thing to reset to echo mode.
  5533.  
  5534. I have an implementation of getch() for UNIX around, but it's not per-
  5535. fect.  And it suffers from the same problem as above.
  5536.  
  5537. Anyone have any bright ideas, short of hacking a stub that will do an
  5538. extcall to stty, and then recompiling an idiosyncratic interpreter?
  5539.  
  5540. -Richard
  5541.  
  5542. From nowlin@iwtqg.att.com  Fri Jan 18 12:36:41 1991
  5543. Message-Id: <9101181936.AA10542@megaron.cs.arizona.edu>
  5544. Received: from att.att.com by megaron.cs.arizona.edu (5.61/15) via SMTP
  5545.     id AA10542; Fri, 18 Jan 91 12:36:41 -0700
  5546. From: nowlin@iwtqg.att.com
  5547. Date: Fri, 18 Jan 91 12:59 CST
  5548. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  5549. To: icon-group@cs.arizona.edu
  5550. Subject: Re non-echoed input
  5551.  
  5552. > > I am trying to enter a parameter to an Icon program which I don't want
  5553. > > echoing (it's a password). I'm sure I should be able to do this either
  5554. > > with getch() or reads(,1) and then writes(\b*) or something similar, but
  5555. > > I can't get it to go.  Has anyone got a solution to this problem?
  5556. >      
  5557. > If you are using Unix, you won't be able to access getch().  It can't be
  5558. > done portably.  You'll have to do a system() of some kind.  E.g.:
  5559. >     system("stty -echo")
  5560. >     read(&input)
  5561. >     system("stty echo")
  5562. > Difficulty: What if, for some reason the system() fails?  Oh no!  Your
  5563. > password gets echoed!  There's no way to test whether system() forked a
  5564. > shell, and that shell couldn't execute the command.  You can't tell whether
  5565. > the command worked or not using pipes, for the same reason.  All you get is
  5566. > a diagnostic written to stderr by the shell, I believe.  Hmmm.
  5567.  
  5568. This seems like the best way for now to turn off the echoing of typed
  5569. input.
  5570.  
  5571. I've been using the return code from system() calls on UNIX for some time
  5572. and they always seem to return the exit code of the command spawned with
  5573. them.  The Icon book (2nd edition) says they do.  If you use the open(,"p")
  5574. call in UNIX the exit code of the command piped is returned from the
  5575. close() call of the file pointer returned by the open.  That seems to work
  5576. just fine too.  You have to look at the iconx source to see that that's
  5577. what's happening though.  I couldn't find a reference to it in the book.
  5578.  
  5579. Jerry Nowlin
  5580. att!iwtqg!nowlin
  5581.  
  5582. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Fri Jan 18 14:13:22 1991
  5583. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  5584.     id AA14348; Fri, 18 Jan 91 14:13:22 -0700
  5585. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  5586.     id AA04712; Fri, 18 Jan 91 16:13:16 -0500
  5587. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Fri, 18 Jan 91 16:09:04 EST
  5588. Date: Fri, 18 Jan 91 16:01:26 EST
  5589. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5590. To: icon-group@cs.arizona.edu
  5591. Message-Id: <286624@Wayne-MTS>
  5592. Subject: Ignoring failure
  5593.  
  5594. Ralph has suggested some other ways of ignoring failure than {e;}.  The
  5595. specific context I was interested in is (...,e,...) where the sequential
  5596. expression is part of a pattern match.  In this case putting e on a
  5597. separate line won't work.  But perhaps, in the spirit of Ralph's
  5598. suggestion, a good solution is to write (...,e|0,...), which takes two
  5599. characters rather than the three required by the solution I proposed.  But
  5600. of course e|0 doesn't work if there are other operators in the vicinity.
  5601.  
  5602. Paul Abrahams 
  5603.  
  5604. From goer%sophist@gargoyle.uchicago.edu  Fri Jan 18 14:43:16 1991
  5605. Resent-From: goer%sophist@gargoyle.uchicago.edu
  5606. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  5607.     id AA15416; Fri, 18 Jan 91 14:43:16 -0700
  5608. Return-Path: goer@sophist.uchicago.edu
  5609. Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Fri, 18
  5610.  Jan 1991 14:42 MST
  5611. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  5612.  (4.0/1.14) id AA19303; Fri, 18 Jan 91 15:41:53 CST
  5613. Received: by sophist (4.1/UofC3.1X) id AA11619; Fri, 18 Jan 91 15:44:37 CST
  5614. Resent-Date: Fri, 18 Jan 1991 14:42 MST
  5615. Date: Fri, 18 Jan 91 15:44:37 CST
  5616. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  5617. Subject: RE:  Re non-echoed input
  5618. Resent-To: icon-group@cs.arizona.edu
  5619. To: nowlin@iwtqg.att.com
  5620. Cc: icon-group@arizona.edu
  5621. Resent-Message-Id: <5B3082624080292A@Arizona.edu>
  5622. Message-Id: <9101182144.AA11619@sophist>
  5623. X-Envelope-To: icon-group@CS.Arizona.EDU
  5624. X-Vms-To: nowlin@iwtqg.att.com
  5625. X-Vms-Cc: icon-group@Arizona.edu
  5626.  
  5627. >>     system("stty -echo")
  5628. >>     read(&input)
  5629. >>     system("stty echo")
  5630. >> 
  5631. >> Difficulty: What if, for some reason the system() fails?  Oh no!  Your
  5632. >> password gets echoed!  There's no way to test whether system() forked a
  5633. >> shell, and that shell couldn't execute the command.  You can't tell whether
  5634. >> the command worked or not using pipes, for the same reason.
  5635.  
  5636.  > I've been using the return code from system() calls on UNIX for some time
  5637.  > and they always seem to return the exit code of the command spawned with
  5638.  > them.  The Icon book (2nd edition) says they do.
  5639.  
  5640. I looked at the first ed., and it does, too.  I remember writing
  5641.  
  5642.      system("something") | fail
  5643.  
  5644. a long time ago, and finding out that it didn't work.  It never occurred
  5645. to me to do something that I saw as very un-Iconish:  Test for an exit
  5646. status.
  5647.  
  5648. I suppose, though, that if we are going to interface on this level with
  5649. the operating system, it makes sense to do it on the operating system's
  5650. terms, especially when important information might be lost.
  5651.  
  5652. Just the other day, Ralph Griswold pointed out to me that &subject is
  5653. never null.  It's always at least going to dereference to an empty
  5654. string.  Funny, but I'd never had any reason since starting to program
  5655. in Icon to question my (mis)conception that, outside of a scanning
  5656. expression, type(&subject) yielded "null."  The bit on system() was
  5657. of the same order.
  5658.  
  5659. Oh well.
  5660.  
  5661. -Richard
  5662.  
  5663. From goer%sophist@gargoyle.uchicago.edu  Fri Jan 18 14:57:31 1991
  5664. Resent-From: goer%sophist@gargoyle.uchicago.edu
  5665. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  5666.     id AA16131; Fri, 18 Jan 91 14:57:31 -0700
  5667. Return-Path: goer@sophist.uchicago.edu
  5668. Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Fri, 18
  5669.  Jan 1991 14:56 MST
  5670. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  5671.  (4.0/1.14) id AA19923; Fri, 18 Jan 91 15:56:53 CST
  5672. Received: by sophist (4.1/UofC3.1X) id AA11629; Fri, 18 Jan 91 15:59:37 CST
  5673. Resent-Date: Fri, 18 Jan 1991 14:57 MST
  5674. Date: Fri, 18 Jan 91 15:59:37 CST
  5675. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  5676. Subject: Ignoring failure (idiomatic Icon)
  5677. Resent-To: icon-group@cs.arizona.edu
  5678. To: icon-group@arizona.edu
  5679. Resent-Message-Id: <5D33944B4080233D@Arizona.edu>
  5680. Message-Id: <9101182159.AA11629@sophist>
  5681. X-Envelope-To: icon-group@CS.Arizona.EDU
  5682. X-Vms-To: icon-group@Arizona.edu
  5683.  
  5684. > Ralph has suggested some other ways of ignoring failure than {e;}.  The
  5685. > specific context I was interested in is (...,e,...) where the sequential
  5686. > expression is part of a pattern match.  In this case putting e on a
  5687. > separate line won't work.  But perhaps, in the spirit of Ralph's
  5688. > suggestion, a good solution is to write (...,e|0,...), which takes two
  5689. > characters rather than the three required by the solution I proposed.  But
  5690. > of course e|0 doesn't work if there are other operators in the vicinity.
  5691.  
  5692. It's just personal opinion, but I find
  5693.  
  5694.         tab(find(this)+that) &
  5695.         =something_else | &null &
  5696.         do-some-other-things
  5697.  
  5698. a lot clearer than
  5699.  
  5700.         (tab(find(this)+that), =something_else | 0, do-some-other-things)
  5701.  
  5702. It looks like you need to use the zero for something other than to pro-
  5703. vide a dummy result.  From an Iconish standpoint, the zero looks a lot
  5704. more "interesting" than &null.
  5705.  
  5706. Of course, if you are planning on using matched substrings, you'll have
  5707. to use the empty string:
  5708.  
  5709.         tab(find(this)+that) ||
  5710.         (=something_else | "") ||
  5711.         do-some-other-things
  5712.  
  5713. -Richard
  5714.  
  5715. From ralph  Fri Jan 18 15:13:12 1991
  5716. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  5717.     id AA16939; Fri, 18 Jan 91 15:13:12 -0700
  5718. Date: Fri, 18 Jan 91 15:13:08 MST
  5719. From: "Ralph Griswold" <ralph>
  5720. Message-Id: <9101182213.AA16103@cheltenham.cs.arizona.edu>
  5721. Received: by cheltenham.cs.arizona.edu; Fri, 18 Jan 91 15:13:08 MST
  5722. To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  5723. Subject: Re:  Ignoring failure
  5724. Cc: icon-group
  5725.  
  5726. If you're seeking elegance, I'd argue against (e | 0), since it looks
  5727. like the zero is meaningful, while &null is less likely to be
  5728. interpreted that way.  Of course, if you're just concerned about
  5729. keystrokes, your method is briefer.
  5730.  
  5731.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  5732.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  5733.  
  5734. From ralph  Fri Jan 18 15:33:55 1991
  5735. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  5736.     id AA17772; Fri, 18 Jan 91 15:33:55 -0700
  5737. Date: Fri, 18 Jan 91 15:33:54 MST
  5738. From: "Ralph Griswold" <ralph>
  5739. Message-Id: <9101182233.AA16796@cheltenham.cs.arizona.edu>
  5740. Received: by cheltenham.cs.arizona.edu; Fri, 18 Jan 91 15:33:54 MST
  5741. To: icon-group
  5742. Subject: system()
  5743.  
  5744.  
  5745. I suspect the intention of the earlier comment "What if ... system() fails"
  5746. didn't mean failure in the Icon sense, but that the specified action
  5747. didn't take place.
  5748.  
  5749. The reason that system() in Icon returns the exit code of the process
  5750. is that there are many possible values, not just "error exit" and
  5751. "normal exit".  Some programs terminate with a variety of different
  5752. error codes to signal different situations.  Icon has to have a way
  5753. to capture this.
  5754.  
  5755. I suppose system() could fail on "error exit" and return a value on
  5756. other exits, but since it just reflects a capability of the C
  5757. runtime library in Icon, it seems unnecessarily confusing to have
  5758. it behave in a different way, since no real functionality would be
  5759. gained.
  5760.  
  5761.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  5762.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  5763.  
  5764. From icon-group-request@arizona.edu  Fri Jan 18 18:44:56 1991
  5765. Resent-From: icon-group-request@arizona.edu
  5766. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  5767.     id AA24178; Fri, 18 Jan 91 18:44:56 -0700
  5768. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 18 Jan
  5769.  1991 18:44 MST
  5770. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA24738; Fri, 18 Jan 91
  5771.  17:39:15 -0800
  5772. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  5773.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  5774.  usenet@ucbvax.Berkeley.EDU if you have questions)
  5775. Resent-Date: Fri, 18 Jan 1991 18:44 MST
  5776. Date: 18 Jan 91 23:47:53 GMT
  5777. From: midway!quads.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
  5778. Subject: blackjack
  5779. Sender: icon-group-request@arizona.edu
  5780. Resent-To: icon-group@cs.arizona.edu
  5781. To: icon-group@arizona.edu
  5782. Resent-Message-Id: <7CF50958A0802917@Arizona.edu>
  5783. Message-Id: <1991Jan18.234753.13506@midway.uchicago.edu>
  5784. X-Envelope-To: icon-group@CS.Arizona.EDU
  5785. X-Vms-To: icon-group@Arizona.edu
  5786. Organization: University of Chicago
  5787.  
  5788. I posted a Unix port of Chris Tenaglia's  bj game some time ago.
  5789. My son has found several bugs in it since then.  If any Unixoids
  5790. want an update, please drop me a line.  I'll be glad to mail them
  5791. out.
  5792.  
  5793. -Richard (goer@sophist.uchicago.edu)
  5794.  
  5795. From goer%sophist@gargoyle.uchicago.edu  Fri Jan 18 23:14:14 1991
  5796. Resent-From: goer%sophist@gargoyle.uchicago.edu
  5797. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  5798.     id AA01446; Fri, 18 Jan 91 23:14:14 -0700
  5799. Return-Path: goer@sophist.uchicago.edu
  5800. Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Fri, 18
  5801.  Jan 1991 23:13 MST
  5802. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  5803.  (4.0/1.14) id AA01710; Sat, 19 Jan 91 00:13:35 CST
  5804. Received: by sophist (4.1/UofC3.1X) id AA11802; Sat, 19 Jan 91 00:16:19 CST
  5805. Resent-Date: Fri, 18 Jan 1991 23:14 MST
  5806. Date: Sat, 19 Jan 91 00:16:19 CST
  5807. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  5808. Subject: DOS->Unix/Unix->DOS
  5809. Resent-To: icon-group@cs.arizona.edu
  5810. To: icon-group@arizona.edu
  5811. Resent-Message-Id: <A2984956D0802F8B@Arizona.edu>
  5812. Message-Id: <9101190616.AA11802@sophist>
  5813. X-Envelope-To: icon-group@CS.Arizona.EDU
  5814. X-Vms-To: icon-group@Arizona.edu
  5815.  
  5816. Here's a set of short UNIX->DOS and DOS->UNIX text file translators.
  5817. They are pretty fresh, and I wouldn't mind hearing suggestions from
  5818. anyone who happens to try them out.
  5819.  
  5820. Now that you all have Chris Tenaglia's shell archiver, I don't have
  5821. to worry that people won't be able to unpack this.
  5822.  
  5823. -Richard (goer@sophist.uchicago.edu)
  5824.  
  5825.  
  5826.  
  5827. ---- Cut Here and feed the following to sh ----
  5828. #!/bin/sh
  5829. # This is a shell archive (produced by shar 3.49)
  5830. # To extract the files from this archive, save it to a file, remove
  5831. # everything above the "!/bin/sh" line above, and type "sh file_name".
  5832. #
  5833. # made 01/19/1991 06:02 UTC by goer@sophist.uchicago.edu
  5834. # Source directory /u/richard/Nocr
  5835. #
  5836. # existing files will NOT be overwritten unless -c is specified
  5837. # This format requires very little intelligence at unshar time.
  5838. # "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
  5839. #
  5840. #                                                                          
  5841. #                                                                          
  5842. #
  5843. # This shar contains:
  5844. # length  mode       name
  5845. # ------ ---------- ------------------------------------------
  5846. #   3401 -r--r--r-- yescr.icn
  5847. #   3177 -r--r--r-- nocr.icn
  5848. #   1024 -rw-r--r-- README
  5849. #    728 -rw-r--r-- Makefile.dist
  5850. #
  5851. if test -r _shar_seq_.tmp; then
  5852.     echo 'Must unpack archives in sequence!'
  5853.     echo Please unpack part `cat _shar_seq_.tmp` next
  5854.     exit 1
  5855. fi
  5856. # ============= yescr.icn ==============
  5857. if test -f 'yescr.icn' -a X"$1" != X"-c"; then
  5858.     echo 'x - skipping yescr.icn (File already exists)'
  5859.     rm -f _shar_wnt_.tmp
  5860. else
  5861. > _shar_wnt_.tmp
  5862. echo 'x - extracting yescr.icn (Text)'
  5863. sed 's/^X//' << 'SHAR_EOF' > 'yescr.icn' &&
  5864. X############################################################################
  5865. X#
  5866. X#    Name:     yescr.icn
  5867. X#
  5868. X#    Title:     yescr (convert UNIX text files to DOS format)
  5869. X#
  5870. X#    Author:     Richard L. Goerwitz
  5871. X#
  5872. X#    Version: 1.2
  5873. X#
  5874. X############################################################################
  5875. X#  
  5876. X#  usage:  yescr file1 [file2 [etc.]]
  5877. X#
  5878. X#  PURPOSE:  Yescr simply inserts MS-DOS carriage-return+linefeed
  5879. X#  sequences in place of UNIX newlines.  Effects conversion from the
  5880. X#  native UNIX text file format to its DOS correspondent.
  5881. X#
  5882. X#  BUGS:  Doesn't check to see whether the input files are in fact
  5883. X#  text files.
  5884. X#
  5885. X############################################################################
  5886. X#
  5887. X#  Links: none
  5888. X#
  5889. X#  Requires:  UNIX or MS-DOS
  5890. X#
  5891. X#  See also: nocr.icn
  5892. X#
  5893. X############################################################################
  5894. X
  5895. X
  5896. Xprocedure main(a)
  5897. X
  5898. X    local fname, infile, outfile, line
  5899. X
  5900. X    # Static variables, initial clause not really necessary in main().
  5901. X    static slash, l, ms, DOSos, nok, ok
  5902. X    initial {
  5903. X    nok := string(~&letters)
  5904. X    ok := repl("X",*nok)
  5905. X    # Find us a place to put temporary files.
  5906. X    if find("UNIX",&features) then {
  5907. X        slash := "/"
  5908. X        l := 10
  5909. X        ms := ""
  5910. X    }
  5911. X    else if find("MS-DOS", &features) then {
  5912. X        slash := "\\"
  5913. X        l := 8
  5914. X        ms := "u"
  5915. X        DOSos := 1
  5916. X    }
  5917. X    # Don't take this out unless you're sure of what you're doing.
  5918. X    else stop("yescr:  tested only under UNIX and MS-DOS")
  5919. X    }
  5920. X
  5921. X    # Check to see if we have any arguments.
  5922. X    *a = 0 & stop("usage:  yescr file1 [file2...]")
  5923. X
  5924. X    # Start popping filenames off of the argument list.
  5925. X    while fname := pop(a) do {
  5926. X
  5927. X    # Open input file.
  5928. X    infile := open(fname,"r"||ms) | (er_out(fname), next)
  5929. X    # Get temporary file name.
  5930. X    every temp_name :=
  5931. X        pathname(fname, slash) ||
  5932. X        map(left(basename(fname,slash),l,"X"), nok, ok) ||
  5933. X        "." || right(0 to 999,3,"0")
  5934. X    do close(open(temp_name)) | break
  5935. X    # Open temporary file.
  5936. X    outfile := open(temp_name,"w"||ms) | (er_out(temp_name), next)
  5937. X
  5938. X    if \DOSos then {
  5939. X        # Read in blocks of 80 chars.
  5940. X        while line := reads(infile,80) do {
  5941. X        line ? {
  5942. X            # Replace ASCII LF with CR+LF, effecting a translation
  5943. X            # from UNIX to DOS format.
  5944. X            while writes(outfile, tab(find("\x0A")), "\x0D", move(1))
  5945. X            writes(outfile, tab(0))
  5946. X        }
  5947. X        }
  5948. X    }
  5949. X    else {
  5950. X        # I presume I'm running under UNIX (unless I've been hacked).
  5951. X        # Convert lines into DOS format by appending a carriage return,
  5952. X        # and then write()'ing (which automatically adds a newline).
  5953. X        every line := !infile do {
  5954. X        if line[-1] == "\x0D"
  5955. X        then write(outfile, line)
  5956. X        else write(outfile, line || "\x0D")
  5957. X        }
  5958. X    }
  5959. X
  5960. X    # Close opened input and output files.
  5961. X    close(infile)  | stop("yescr:  cannot close, ",fname,"; aborting")
  5962. X    close(outfile) | stop("yescr:  cannot close, ",temp_name,"; aborting")
  5963. X
  5964. X    # Remove physical input file.
  5965. X    remove(fname) | stop("yescr:  cannot remove ",fname,"; aborting")
  5966. X
  5967. X    # Give temp name the same name as the input file, completing the
  5968. X    # conversion process.
  5969. X    rename(temp_name,fname) |
  5970. X        stop("yescr:  Can't find temp file ",temp_name,"; aborting")
  5971. X    }
  5972. X
  5973. Xend
  5974. X
  5975. X
  5976. Xprocedure er_out(s)
  5977. X    write(&errout,"yescr:  cannot open ",s," for reading")
  5978. X    return
  5979. Xend
  5980. X
  5981. X
  5982. Xprocedure basename(s,slash)
  5983. X    s ? {
  5984. X    while tab(find(slash)+1)
  5985. X    return tab(0)
  5986. X    }
  5987. Xend
  5988. X
  5989. X
  5990. Xprocedure pathname(s,slash)
  5991. X    s2 := ""
  5992. X    s ? {
  5993. X    while s2 ||:= tab(find(slash)+1)
  5994. X    return s2
  5995. X    }
  5996. Xend
  5997. SHAR_EOF
  5998. true || echo 'restore of yescr.icn failed'
  5999. rm -f _shar_wnt_.tmp
  6000. fi
  6001. # ============= nocr.icn ==============
  6002. if test -f 'nocr.icn' -a X"$1" != X"-c"; then
  6003.     echo 'x - skipping nocr.icn (File already exists)'
  6004.     rm -f _shar_wnt_.tmp
  6005. else
  6006. > _shar_wnt_.tmp
  6007. echo 'x - extracting nocr.icn (Text)'
  6008. sed 's/^X//' << 'SHAR_EOF' > 'nocr.icn' &&
  6009. X############################################################################
  6010. X#
  6011. X#    Name:     nocr.icn
  6012. X#
  6013. X#    Title:     nocr (convert MS-DOS text files to UNIX format)
  6014. X#
  6015. X#    Author:     Richard L. Goerwitz
  6016. X#
  6017. X#    Version: 1.2
  6018. X#
  6019. X############################################################################
  6020. X#  
  6021. X#  usage:  nocr file1 [file2 [etc.]]
  6022. X#
  6023. X#  PURPOSE:  Nocr simply converts \r\n to \n in each line of each of the
  6024. X#  files supplied as command-line arguments, thereby effecting conversion
  6025. X#  of MS-DOS format text files to the corresponding UNIX format.
  6026. X#
  6027. X#  BUGS:  No check done to see whether the file is in fact a text file.
  6028. X#
  6029. X############################################################################
  6030. X#
  6031. X#  Links: none
  6032. X#
  6033. X#  Requires:  UNIX or MS-DOS
  6034. X#
  6035. X#  See also: yescr.icn
  6036. X#
  6037. X############################################################################
  6038. X
  6039. X
  6040. Xprocedure main(a)
  6041. X
  6042. X    local fname, infile, outfile, line
  6043. X
  6044. X    # Static variables, initial clause not really necessary in main().
  6045. X    static slash, l, ms, DOSos, nok, ok
  6046. X    initial {
  6047. X
  6048. X    nok := string(~&letters)
  6049. X    ok := repl("X",*nok)
  6050. X
  6051. X    # Find us a place to put temporary files.
  6052. X    if find("UNIX",&features) then {
  6053. X        slash := "/"
  6054. X        l := 10
  6055. X        ms := ""
  6056. X    }
  6057. X    else if find("MS-DOS", &features) then {
  6058. X        slash := "\\"
  6059. X        l := 8
  6060. X        ms := "u"
  6061. X        DOSos := 1
  6062. X    }
  6063. X    # Don't take this out unless you're sure of what you're doing.
  6064. X    else stop("nocr:  tested only under UNIX and MS-DOS")
  6065. X    }
  6066. X
  6067. X    # Check to see if we have any arguments.
  6068. X    *a = 0 & stop("usage:  nocr file1 [file2...]")
  6069. X
  6070. X    # Start popping filenames off of the argument list.
  6071. X    while fname := pop(a) do {
  6072. X
  6073. X    # Open input file.
  6074. X    infile := open(fname,"r") | (er_out(fname), next)
  6075. X    # Get temporary file name.
  6076. X    every temp_name :=
  6077. X        pathname(fname, slash) ||
  6078. X        map(left(basename(fname,slash),l,"X"), nok, ok) ||
  6079. X        "." || right(0 to 999,3,"0")
  6080. X    do close(open(temp_name)) | break
  6081. X    # Open temporary file.
  6082. X    outfile := open(\temp_name,"w"||ms) | (er_out(fname), next)
  6083. X
  6084. X    if \DOSos then {
  6085. X        # Infile above was opened in translate mode (removing the CR),
  6086. X        # while outfile was opened in untranslate mode (automatically
  6087. X            # writing the line in UNIX format).
  6088. X        while write(outfile,read(infile))
  6089. X    }
  6090. X    else {
  6091. X        # If not running under DOS, then we're under UNIX (unless
  6092. X        # we've been hacked).  Trim CR manually, then write.
  6093. X        while write(outfile, read(infile) ? tab(-1|0))
  6094. X    }
  6095. X
  6096. X    # Close opened input and output files.
  6097. X    close(infile)  | stop("nocr:  cannot close, ",fname,"; aborting")
  6098. X    close(outfile) | stop("nocr:  cannot close, ",temp_name,"; aborting")
  6099. X
  6100. X    # Remove physical input file.
  6101. X    remove(fname) | stop("nocr:  cannot remove ",fname,"; aborting")
  6102. X
  6103. X    # Give temp name the same name as the input file, completing the
  6104. X    # conversion process.
  6105. X    rename(temp_name,fname) |
  6106. X        stop("nocr:  Can't find temp file ",temp_name,"; aborting")
  6107. X    }
  6108. X
  6109. Xend
  6110. X
  6111. X
  6112. Xprocedure er_out(s)
  6113. X    write(&errout,"nocr:  cannot open ",s," for reading")
  6114. X    return
  6115. Xend
  6116. X
  6117. X
  6118. Xprocedure basename(s,slash)
  6119. X    s ? {
  6120. X    while tab(find(slash)+1)
  6121. X    return tab(0)
  6122. X    }
  6123. Xend
  6124. X
  6125. X
  6126. Xprocedure pathname(s,slash)
  6127. X    s2 := ""
  6128. X    s ? {
  6129. X    while s2 ||:= tab(find(slash)+1)
  6130. X    return s2
  6131. X    }
  6132. Xend
  6133. SHAR_EOF
  6134. true || echo 'restore of nocr.icn failed'
  6135. rm -f _shar_wnt_.tmp
  6136. fi
  6137. # ============= README ==============
  6138. if test -f 'README' -a X"$1" != X"-c"; then
  6139.     echo 'x - skipping README (File already exists)'
  6140.     rm -f _shar_wnt_.tmp
  6141. else
  6142. > _shar_wnt_.tmp
  6143. echo 'x - extracting README (Text)'
  6144. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  6145. X
  6146. XContained in this distribution are two Icon programs, the one (yescr)
  6147. Xused to translate UNIX into MS-DOS text-files, the other (nocr) used
  6148. Xto perform the opposite conversion.
  6149. X
  6150. XTo make these programs under UNIX, just type "cp Makefile.dist
  6151. XMakefile" and make.  If you are satisfied that the programs work fine
  6152. Xedit the Makefile, su root, and "make -f Makefile.dist install."
  6153. X
  6154. XThose without a makefile facility will have to translate manually:
  6155. X
  6156. X        icont yescr.icn
  6157. X        icont nocr.icn
  6158. X
  6159. XPlease send me bug reports and modifications.  These programs should
  6160. Xwork okay under UNIX and DOS.  Haven't really tested anything else.
  6161. XNote that you must have an Icon interpreter or compiler installed.  If
  6162. Xyou don't, then I'd suggest ftping the files from cs.arizona.edu.  The
  6163. Xsource is public domain, and is as bugless and easy to install as any
  6164. Xacademic distribution I've ever seen.  DOS users need not bother with
  6165. Xthe source, as there are optimized and tested executables online.
  6166. X
  6167. X-Richard Goerwitz (goer@sophist.uchicago.edu)
  6168. SHAR_EOF
  6169. true || echo 'restore of README failed'
  6170. rm -f _shar_wnt_.tmp
  6171. fi
  6172. # ============= Makefile.dist ==============
  6173. if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
  6174.     echo 'x - skipping Makefile.dist (File already exists)'
  6175.     rm -f _shar_wnt_.tmp
  6176. else
  6177. > _shar_wnt_.tmp
  6178. echo 'x - extracting Makefile.dist (Text)'
  6179. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
  6180. X# Please edit these to reflect your local file structure & conventions.
  6181. XDESTDIR = /usr/local/bin
  6182. XOWNER = bin
  6183. XGROUP = bin
  6184. X
  6185. X# I hope you won't have to use this.
  6186. XDEBUGFLAG = #-t
  6187. X
  6188. Xall: nocr yescr
  6189. X
  6190. Xnocr:
  6191. X    icont $(DEBUGFLAG) nocr.icn
  6192. Xyescr:
  6193. X    icont $(DEBUGFLAG) yescr.icn
  6194. X
  6195. X# Pessimistic assumptions regarding the environment (in particular,
  6196. X# I don't assume you have the BSD "install" shell script).
  6197. Xinstall: all
  6198. X    @sh -c "test -d $(DESTDIR) || (mkdir $(DESTDIR) && chmod 755 $(DESTDIR))"
  6199. X    cp yescr $(DESTDIR)/
  6200. X    chgrp $(GROUP) $(DESTDIR)/yescr
  6201. X    chown $(OWNER) $(DESTDIR)/yescr
  6202. X    cp nocr $(DESTDIR)/
  6203. X    chgrp $(GROUP) $(DESTDIR)/nocr
  6204. X    chown $(OWNER) $(DESTDIR)/nocr
  6205. X    @echo "\nInstallation done.\n"
  6206. X
  6207. Xclean:
  6208. X    -rm -f *.u *~
  6209. X    -rm -f yescr nocr
  6210. SHAR_EOF
  6211. true || echo 'restore of Makefile.dist failed'
  6212. rm -f _shar_wnt_.tmp
  6213. fi
  6214. exit 0
  6215.  
  6216. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Sat Jan 19 10:09:54 1991
  6217. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  6218.     id AA19906; Sat, 19 Jan 91 10:09:54 -0700
  6219. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  6220.     id AA15526; Sat, 19 Jan 91 12:08:34 -0500
  6221. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 19 Jan 91 12:03:25 EST
  6222. Date: Sat, 19 Jan 91 11:34:02 EST
  6223. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  6224. To: icon-group@cs.arizona.edu
  6225. Message-Id: <286791@Wayne-MTS>
  6226. Subject: Error in Icon Analyst #4
  6227.  
  6228. Icon Analyst 4 (Feb 1991) has an error in the example that runs from the
  6229. end of page 3 to the beginning of page 4.  In two places, the first
  6230. tab(many(&letters)) should be replaced by tab(upto(&letters)) (as it is in
  6231. the preceding parts of the example).
  6232.  
  6233. Paul Abrahams 
  6234.  
  6235. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Sat Jan 19 10:10:06 1991
  6236. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  6237.     id AA19927; Sat, 19 Jan 91 10:10:06 -0700
  6238. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  6239.     id AA15551; Sat, 19 Jan 91 12:08:46 -0500
  6240. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 19 Jan 91 12:03:46 EST
  6241. Date: Sat, 19 Jan 91 11:34:52 EST
  6242. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  6243. To: icon-group@cs.arizona.edu
  6244. Message-Id: <286792@Wayne-MTS>
  6245. Subject: How to write string scanning operations
  6246.  
  6247.  
  6248. Version 4 of the Icon Analyst suggests, as an example of good style, the
  6249. string scanning expression:
  6250.  
  6251. expression ? {
  6252.    ="(" &
  6253.    tab(bal()) &
  6254.    =")" &
  6255.    pos(0)
  6256.    }
  6257.  
  6258. I'd argue for the superiority of:
  6259.  
  6260. expression ? (
  6261.    ="(" ,
  6262.    tab(bal()) ,
  6263.    =")" ,
  6264.    pos(0)
  6265.    )
  6266.  
  6267. This version is less vulnerable to confusions about precedence.  It also
  6268. makes explicit the circumstances under which the match fails, and follows
  6269. the general suggestion in the Icon book that (..., ... , ...) should be
  6270. used in preference to a long sequence of conjunctions.
  6271.  
  6272. Paul Abrahams 
  6273.  
  6274. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Sat Jan 19 10:10:20 1991
  6275. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  6276.     id AA19958; Sat, 19 Jan 91 10:10:20 -0700
  6277. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  6278.     id AA15558; Sat, 19 Jan 91 12:08:59 -0500
  6279. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 19 Jan 91 12:04:07 EST
  6280. Date: Sat, 19 Jan 91 11:35:46 EST
  6281. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  6282. To: icon-group@cs.arizona.edu
  6283. Message-Id: <286793@Wayne-MTS>
  6284. Subject: Efficiency of search
  6285.  
  6286.  
  6287. I'm sure this has come up a hundred times, but I don't remember the answer. 
  6288. Assume that c is a single character.  Which is more efficient,
  6289.   find("c",s)
  6290. or
  6291.   upto('c', s)  ?
  6292. I think they are semantically equivalent.
  6293.  
  6294. Paul Abrahams 
  6295.  
  6296. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Sat Jan 19 10:10:33 1991
  6297. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  6298.     id AA19989; Sat, 19 Jan 91 10:10:33 -0700
  6299. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  6300.     id AA15563; Sat, 19 Jan 91 12:09:12 -0500
  6301. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 19 Jan 91 12:04:28 EST
  6302. Date: Sat, 19 Jan 91 11:36:24 EST
  6303. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  6304. To: icon-group@cs.arizona.edu
  6305. Message-Id: <286794@Wayne-MTS>
  6306. Subject: Typesetting Icon
  6307.  
  6308.  
  6309. The usual style for typesetting Icon seems to be to use a Helvetica
  6310. (sans-serif) font.  The problem with such a font is that uppercase I and
  6311. lowercase l are indistinguishable.  Has anybody thought about that problem
  6312. and how to overcome it, e.g., by somehow jiggering the font to put tiny
  6313. serifs on the uppercase I?   Am I the only one bothered by this ambiguity? 
  6314. (Consider typesetting the identifier `SmallInteger'.)
  6315.  
  6316. This problem arises in typesetting other programming languages also, of
  6317. course.
  6318.  
  6319. Paul Abrahams 
  6320.  
  6321. From ralph  Sat Jan 19 10:30:56 1991
  6322. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  6323.     id AA20549; Sat, 19 Jan 91 10:30:56 -0700
  6324. Date: Sat, 19 Jan 91 10:30:53 MST
  6325. From: "Ralph Griswold" <ralph>
  6326. Message-Id: <9101191730.AA04912@cheltenham.cs.arizona.edu>
  6327. Received: by cheltenham.cs.arizona.edu; Sat, 19 Jan 91 10:30:53 MST
  6328. To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  6329. Subject: Re:  Efficiency of search
  6330. Cc: icon-group
  6331.  
  6332. find("c",s) is faster than upto('c',s).  The reason is the extra time
  6333. needed to set up the character table for upto().
  6334.  
  6335. The difference is small, however.
  6336.  
  6337.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  6338.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  6339.  
  6340. From ralph  Sat Jan 19 10:35:21 1991
  6341. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  6342.     id AA20647; Sat, 19 Jan 91 10:35:21 -0700
  6343. Date: Sat, 19 Jan 91 10:35:16 MST
  6344. From: "Ralph Griswold" <ralph>
  6345. Message-Id: <9101191735.AA05044@cheltenham.cs.arizona.edu>
  6346. Received: by cheltenham.cs.arizona.edu; Sat, 19 Jan 91 10:35:16 MST
  6347. To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  6348. Subject: Re:  Typesetting Icon
  6349. Cc: icon-group
  6350.  
  6351. The style used in typesetting the second edition of the Icon book is
  6352. the one specified by the publisher.
  6353.  
  6354. We're aware, of course, of the visual ambiguity of "el" and "one".  That
  6355. ambiguity occurs not just in sans-serif faces; for many line-printer and
  6356. screen faces it is easy to confuse the two characters.
  6357.  
  6358. We try to avoid program text where this ambiguity is serious.
  6359.  
  6360.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  6361.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  6362.  
  6363. From goer%sophist@gargoyle.uchicago.edu  Sun Jan 20 09:01:14 1991
  6364. Resent-From: goer%sophist@gargoyle.uchicago.edu
  6365. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  6366.     id AA24067; Sun, 20 Jan 91 09:01:14 -0700
  6367. Return-Path: goer@sophist.uchicago.edu
  6368. Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Sun, 20
  6369.  Jan 1991 09:00 MST
  6370. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  6371.  (4.0/1.14) id AA07213; Sun, 20 Jan 91 10:00:36 CST
  6372. Received: by sophist (4.1/UofC3.1X) id AA12219; Sun, 20 Jan 91 10:03:18 CST
  6373. Resent-Date: Sun, 20 Jan 1991 09:00 MST
  6374. Date: Sun, 20 Jan 91 10:03:18 CST
  6375. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  6376. Subject: Icon compression
  6377. Resent-To: icon-group@cs.arizona.edu
  6378. To: icon-group@arizona.edu
  6379. Resent-Message-Id: <BDC156E8F080292C@Arizona.edu>
  6380. Message-Id: <9101201603.AA12219@sophist>
  6381. X-Envelope-To: icon-group@CS.Arizona.EDU
  6382. X-Vms-To: icon-group@Arizona.edu
  6383.  
  6384. Has anyone created any compression routines in Icon?  I know of
  6385. Robert Alexander's LZW compression utility, but, as he notes, it
  6386. contains a lot of tracing and tests, and it much too slow for
  6387. practical use.  If anyone has written, say, a Huffmon encoding
  6388. routine in Icon, I'd love to have it and not have to write it my-
  6389. self....
  6390.  
  6391. -Richard
  6392.  
  6393. From icon-group-request@arizona.edu  Sun Jan 20 11:16:58 1991
  6394. Resent-From: icon-group-request@arizona.edu
  6395. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  6396.     id AA27043; Sun, 20 Jan 91 11:16:58 -0700
  6397. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sun, 20 Jan
  6398.  1991 11:16 MST
  6399. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA04469; Sun, 20 Jan 91
  6400.  10:12:12 -0800
  6401. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6402.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6403.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6404. Resent-Date: Sun, 20 Jan 1991 11:16 MST
  6405. Date: 20 Jan 91 16:26:07 GMT
  6406. From: tron!beser@uunet.uu.net (Eric Beser)
  6407. Subject: icon program to shorten file names
  6408. Sender: icon-group-request@arizona.edu
  6409. Resent-To: icon-group@cs.arizona.edu
  6410. To: icon-group@arizona.edu
  6411. Resent-Message-Id: <D0B9736E208029BF@Arizona.edu>
  6412. Message-Id: <692@tron.UUCP>
  6413. X-Envelope-To: icon-group@CS.Arizona.EDU
  6414. X-Vms-To: icon-group@Arizona.edu
  6415. Organization: Westinghouse Electronic Systems Group, Baltimore, MD, USA
  6416.  
  6417. I read in one of the technical reports that there was a program
  6418. written in icon that read a tar file, checked if the names were
  6419. longer than 15 characters, if so, shortened them. 
  6420.  
  6421. Is there such a critter? If so, and someone has it, could they
  6422. email it ? 
  6423.  
  6424. thanks
  6425.  
  6426. Eric Beser
  6427. Westinghouse Aerospace Software Engineering
  6428.  
  6429. From goer%sophist@gargoyle.uchicago.edu  Sun Jan 20 15:00:01 1991
  6430. Resent-From: goer%sophist@gargoyle.uchicago.edu
  6431. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  6432.     id AA02569; Sun, 20 Jan 91 15:00:01 -0700
  6433. Return-Path: goer@sophist.uchicago.edu
  6434. Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Sun, 20
  6435.  Jan 1991 14:59 MST
  6436. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  6437.  (4.0/1.14) id AA12555; Sun, 20 Jan 91 15:59:25 CST
  6438. Received: by sophist (4.1/UofC3.1X) id AA12295; Sun, 20 Jan 91 16:02:08 CST
  6439. Resent-Date: Sun, 20 Jan 1991 14:59 MST
  6440. Date: Sun, 20 Jan 91 16:02:08 CST
  6441. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  6442. Subject: shortening long filenames
  6443. Resent-To: icon-group@cs.arizona.edu
  6444. To: icon-group@arizona.edu
  6445. Resent-Message-Id: <EFE15461A0803144@Arizona.edu>
  6446. Message-Id: <9101202202.AA12295@sophist>
  6447. X-Envelope-To: icon-group@CS.Arizona.EDU
  6448. X-Vms-To: icon-group@Arizona.edu
  6449.  
  6450.     I read in one of the technical reports that there was a program
  6451.     written in icon that read a tar file, checked if the names were
  6452.     longer than 15 characters, if so, shortened them. 
  6453.  
  6454. I wrote such a utility nearly a year ago, and have posted several
  6455. versions of it to this newsgroup.  I have been getting enough sporadic
  6456. requests for it that I've decided to post it to alt.sources.  Anyone
  6457. who is unable to look it up there can write to me directly, and I'll
  6458. happily send them a copy.
  6459.  
  6460. Gotta send me bug reports and comments, though!
  6461.  
  6462. -Richard
  6463.  
  6464. From icon-group-request@arizona.edu  Sun Jan 20 23:49:16 1991
  6465. Resent-From: icon-group-request@arizona.edu
  6466. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  6467.     id AA19217; Sun, 20 Jan 91 23:49:16 -0700
  6468. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sun, 20 Jan
  6469.  1991 23:48 MST
  6470. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA18892; Sun, 20 Jan 91
  6471.  22:42:07 -0800
  6472. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6473.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6474.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6475. Resent-Date: Sun, 20 Jan 1991 23:49 MST
  6476. Date: 21 Jan 91 05:02:59 GMT
  6477. From: midway!quads.uchicago.edu!goer@uunet.uu.net (Richard L. Goerwitz)
  6478. Subject: DOS->UNIX conversion, patch
  6479. Sender: icon-group-request@arizona.edu
  6480. Resent-To: icon-group@cs.arizona.edu
  6481. To: icon-group@arizona.edu
  6482. Resent-Message-Id: <39D179D9A0802B02@Arizona.edu>
  6483. Message-Id: <1991Jan21.050259.9512@midway.uchicago.edu>
  6484. X-Envelope-To: icon-group@CS.Arizona.EDU
  6485. X-Vms-To: icon-group@Arizona.edu
  6486. Organization: University of Chicago
  6487.  
  6488. Eeek!  A bug!
  6489.  
  6490. Please apply the following patch to nocr.icn.  If anyone is unable
  6491. to apply patches, send me a note, and I'll mail you the whole thing
  6492. in toto.
  6493.  
  6494. -Richard
  6495.  
  6496.  
  6497. *** nocr.icn    Sun Jan 20 23:00:00 1991
  6498. --- nocr.icn.old    Sun Jan 20 22:59:52 1991
  6499. ***************
  6500. *** 6,12 ****
  6501.   #
  6502.   #    Author:     Richard L. Goerwitz
  6503.   #
  6504. ! #    Version: 1.4
  6505.   #
  6506.   ############################################################################
  6507.   #  
  6508. --- 6,12 ----
  6509.   #
  6510.   #    Author:     Richard L. Goerwitz
  6511.   #
  6512. ! #    Version: 1.2
  6513.   #
  6514.   ############################################################################
  6515.   #  
  6516. ***************
  6517. *** 82,92 ****
  6518.       else {
  6519.           # If not running under DOS, then we're under UNIX (unless
  6520.           # we've been hacked).  Trim CR manually, then write.
  6521. !         while line := read(infile) do {
  6522. !                 if line[-1] == "\x0D" then
  6523. !             line[-1] := ""
  6524. !             write(outfile, line)
  6525. !             }
  6526.       }
  6527.   
  6528.       # Close opened input and output files.
  6529. --- 82,88 ----
  6530.       else {
  6531.           # If not running under DOS, then we're under UNIX (unless
  6532.           # we've been hacked).  Trim CR manually, then write.
  6533. !         while write(outfile, read(infile) ? tab(-1|0))
  6534.       }
  6535.   
  6536.       # Close opened input and output files.
  6537.  
  6538. From icon-group-request@arizona.edu  Wed Jan 23 12:08:06 1991
  6539. Resent-From: icon-group-request@arizona.edu
  6540. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  6541.     id AA06797; Wed, 23 Jan 91 12:08:06 -0700
  6542. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 23 Jan
  6543.  1991 12:07 MST
  6544. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA10871; Wed, 23 Jan 91
  6545.  11:02:56 -0800
  6546. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6547.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6548.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6549. Resent-Date: Wed, 23 Jan 1991 12:07 MST
  6550. Date: 23 Jan 91 17:16:55 GMT
  6551. From: midway!quads.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
  6552. Subject: simple text-base utility
  6553. Sender: icon-group-request@arizona.edu
  6554. Resent-To: icon-group@cs.arizona.edu
  6555. To: icon-group@arizona.edu
  6556. Resent-Message-Id: <3359802B60804218@Arizona.edu>
  6557. Message-Id: <1991Jan23.171655.14402@midway.uchicago.edu>
  6558. X-Envelope-To: icon-group@CS.Arizona.EDU
  6559. X-Vms-To: icon-group@Arizona.edu
  6560. Organization: University of Chicago
  6561.  
  6562. Ever want to work with tables, in order to retrieve entries on the
  6563. basis of a key, but yet have entries that are so big that the whole
  6564. process gets terribly unweildy?  If you have, here's a little util-
  6565. ity that lets you dump all your text into a file, but yet still be
  6566. able to access it as if it were in a table.
  6567.  
  6568. I wrote this for a project I was doing the other day, but I think
  6569. it would be of general interest.  Note that it's *not* been extensively
  6570. tested.
  6571.  
  6572. -Richard
  6573.  
  6574.  
  6575. ---- Cut Here and feed the following to sh ----
  6576. #!/bin/sh
  6577. # This is a shell archive (produced by shar 3.49)
  6578. # To extract the files from this archive, save it to a file, remove
  6579. # everything above the "!/bin/sh" line above, and type "sh file_name".
  6580. #
  6581. # made 01/22/1991 16:13 UTC by goer@sophist.uchicago.edu
  6582. # Source directory /u/richard/Gettext
  6583. #
  6584. # existing files will NOT be overwritten unless -c is specified
  6585. # This format requires very little intelligence at unshar time.
  6586. # "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
  6587. #
  6588. #                                                                          
  6589. #                                                                          
  6590. #
  6591. # This shar contains:
  6592. # length  mode       name
  6593. # ------ ---------- ------------------------------------------
  6594. #   1943 -r--r--r-- idxtext.icn
  6595. #   4681 -r--r--r-- gettext.icn
  6596. #   1310 -r--r--r-- adjuncts.icn
  6597. #   2222 -rw-r--r-- README
  6598. #    611 -rw-r--r-- Makefile.dist
  6599. #
  6600. if test -r _shar_seq_.tmp; then
  6601.     echo 'Must unpack archives in sequence!'
  6602.     echo Please unpack part `cat _shar_seq_.tmp` next
  6603.     exit 1
  6604. fi
  6605. # ============= idxtext.icn ==============
  6606. if test -f 'idxtext.icn' -a X"$1" != X"-c"; then
  6607.     echo 'x - skipping idxtext.icn (File already exists)'
  6608.     rm -f _shar_wnt_.tmp
  6609. else
  6610. > _shar_wnt_.tmp
  6611. echo 'x - extracting idxtext.icn (Text)'
  6612. sed 's/^X//' << 'SHAR_EOF' > 'idxtext.icn' &&
  6613. X############################################################################
  6614. X#
  6615. X#    Name:     idxtext.icn
  6616. X#
  6617. X#    Title:     idxtext (index text-base for gettext() routine)
  6618. X#
  6619. X#    Author:     Richard L. Goerwitz
  6620. X#
  6621. X#    Version: 1.2
  6622. X#
  6623. X############################################################################
  6624. X#  
  6625. X#  Turns a file associated with gettext() routine into an indexed text-
  6626. X#  base.  Though gettext() will work fine with files that haven't been
  6627. X#  indexed via idxtext(), access is much faster if the indexing is done.
  6628. X#
  6629. X#  Usage is simply:
  6630. X#
  6631. X#      idxtext file1 [file2 [...]]
  6632. X#
  6633. X#  where file1, file2, etc are the names of gettext-format files that
  6634. X#  are to be (re-)indexed.
  6635. X#
  6636. X############################################################################
  6637. X#
  6638. X#  Links: ./adjuncts.icn
  6639. X#
  6640. X#  Requires: UNIX or MS-DOS
  6641. X#
  6642. X#  See also: gettext.icn
  6643. X#
  6644. X############################################################################
  6645. X
  6646. X
  6647. Xglobal _slash, _baselen
  6648. X
  6649. Xprocedure main(a)
  6650. X
  6651. X    local temp_name, fname, infile, outfile
  6652. X    initial {
  6653. X    if find("UNIX", &features) then {
  6654. X        _slash := "/"
  6655. X        _baselen := 10
  6656. X    }
  6657. X    else if find("MS-DOS", &features) then {
  6658. X        _slash := "\\"
  6659. X        _baselen := 8
  6660. X    }
  6661. X    else stop("idxtext:  OS not supported")
  6662. X    }
  6663. X
  6664. X    # Check to see if we have any arguments.
  6665. X    *a = 0 & stop("usage:  idxtext file1 [file2 [...]]")
  6666. X
  6667. X    # Start popping filenames off of the argument list.
  6668. X    while fname := pop(a) do {
  6669. X
  6670. X    # Open input file.
  6671. X    infile := open(fname) | stop("idxtext:  ",fname," not found")
  6672. X    # Get index file name.
  6673. X    outfile := open(temp_name := Pathname(fname)||getidxname(fname),"w") |
  6674. X        stop("idxtext:  ",temp_name," not found")
  6675. X
  6676. X    # Write index to temporary file.
  6677. X    write_index(infile, outfile)
  6678. X
  6679. X    every close(infile | outfile)
  6680. X
  6681. X    }
  6682. X
  6683. Xend
  6684. X
  6685. X
  6686. Xprocedure write_index(in, out)
  6687. X
  6688. X    local w, line
  6689. X    while (w := where(in), line := read(in)) do {
  6690. X    line ? {
  6691. X        if ="::" then
  6692. X        write(out, trim(tab(0)), "\t", w)
  6693. X    }
  6694. X    }
  6695. X
  6696. X    return
  6697. X
  6698. Xend
  6699. SHAR_EOF
  6700. true || echo 'restore of idxtext.icn failed'
  6701. rm -f _shar_wnt_.tmp
  6702. fi
  6703. # ============= gettext.icn ==============
  6704. if test -f 'gettext.icn' -a X"$1" != X"-c"; then
  6705.     echo 'x - skipping gettext.icn (File already exists)'
  6706.     rm -f _shar_wnt_.tmp
  6707. else
  6708. > _shar_wnt_.tmp
  6709. echo 'x - extracting gettext.icn (Text)'
  6710. sed 's/^X//' << 'SHAR_EOF' > 'gettext.icn' &&
  6711. X############################################################################
  6712. X#
  6713. X#    Name:     gettext.icn
  6714. X#
  6715. X#    Title:     gettext (simple text-base routines)
  6716. X#
  6717. X#    Author:     Richard L. Goerwitz
  6718. X#
  6719. X#    Version: 1.4
  6720. X#
  6721. X############################################################################
  6722. X#
  6723. X#  Gettext() and associated routines allow the user to maintain a file
  6724. X#  of KEY/value combinations such that a call to gettext(KEY, FNAME)
  6725. X#  will produce value.  Fails if no such KEY exists.  Returns an empty
  6726. X#  string if the key exists, but has no associated value in the file,
  6727. X#  FNAME.
  6728. X#
  6729. X#  The file format is simple.  Keys belong on separate lines, marked
  6730. X#  as such by an initial colon+colon (::).  Values begin on the line
  6731. X#  following their respective keys, and extend up to the next
  6732. X#  colon+colon-initial line or EOF.  E.g.
  6733. X#
  6734. X#    ::sample.1
  6735. X#    Notice how the key above, sample.1, has :: prepended to mark it
  6736. X#    out as a key.  The text you are now reading represents that key's
  6737. X#    value.  To retrieve this text, you would call gettext() with the
  6738. X#    name of the key passed as its first argument, and the name of the
  6739. X#    file in which this text is stored as its second argument (as in
  6740. X#    gettext("sample.1","tmp.idx")).
  6741. X#    ::next.key
  6742. X#    etc...
  6743. X#
  6744. X#  For faster access, an indexing utility is included, idxtext.  Idxtext
  6745. X#  creates a separate index for a given text-base file.  If an index file
  6746. X#  exists in the same directory as FNAME
  6747. X#
  6748. X#  Donts:
  6749. X#      1) Don't nest gettext text-base files.
  6750. X#      2) Don't use spaces and/or tabs in key names.
  6751. X#      3) Don't modify indexed files in any way other than to append
  6752. X#         additional keys/values (unless you want to re-index).
  6753. X#
  6754. X#  This program is intended for situations where keys tend to have
  6755. X#  very large values, and use of an Icon table structure would be
  6756. X#  unweildy.
  6757. X#
  6758. X#  BUGS:  Fairly slow.  Could be modified to use the library routine
  6759. X#  findre.icn, and do regexp pattern matches on keys.  Wouldn't that
  6760. X#  be nice?  Should be modified to alphabetize indices, and then do a
  6761. X#  real binary search of the index.  This would preclude easy regexp
  6762. X#  pattern matches, but would be worth it for larger databases.
  6763. X#
  6764. X#  Note:  This program is NOT YET TESTED UNDER DOS.  In particular,
  6765. X#  I have no idea whether the indexing mechanism will work, due to
  6766. X#  translation that has to be done on MS-DOS text files.
  6767. X#
  6768. X############################################################################
  6769. X#
  6770. X#  Links: ./adjuncts.icn
  6771. X#
  6772. X#  Requires: UNIX (maybe MS-DOS; untested)
  6773. X#
  6774. X############################################################################
  6775. X
  6776. X
  6777. Xglobal _slash, _baselen
  6778. X
  6779. Xprocedure gettext(KEY,FNAME)
  6780. X
  6781. X    local line, value
  6782. X    static last_FNAME, intext, inidx
  6783. X    initial {
  6784. X    if find("UNIX", &features) then {
  6785. X        _slash := "/"
  6786. X        _baselen := 10
  6787. X    }
  6788. X    else if find("MS-DOS", &features) then {
  6789. X        _slash := "\\"
  6790. X        _baselen := 8
  6791. X    }
  6792. X    else stop("gettext:  OS not supported")
  6793. X    }
  6794. X
  6795. X    (/KEY | /FNAME) & stop("error (gettext):  null argument")
  6796. X
  6797. X    if FNAME ~== \last_FNAME then {
  6798. X    seek(intext, 1)
  6799. X    seek(inidx, 1)
  6800. X    }
  6801. X    else {
  6802. X    # We've got a new text-base file.  Close the old one.
  6803. X    every close(\intext | \inidx)
  6804. X        # Try to open named text-base file.
  6805. X    intext := open(FNAME) | stop("gettext:  ",FNAME," not found")
  6806. X        # Try to open index file.
  6807. X    inidx := open(Pathname(FNAME) || getidxname(FNAME))
  6808. X    }
  6809. X    last_FNAME := FNAME
  6810. X
  6811. X    # Find offsets for key KEY in index file.  Defaults to 1.
  6812. X    every seek(intext, get_offsets(KEY, inidx)) do {
  6813. X
  6814. X    # Find key.  Should be right there, unless the user has
  6815. X    # appended key/value pairs to the end without re-indexing, or
  6816. X    # else has not bothered to index in the first place.
  6817. X    while line := (read(intext) | fail) do {
  6818. X        line ? {
  6819. X        if (="::", =KEY, pos(0))
  6820. X        then break
  6821. X        }
  6822. X    }
  6823. X
  6824. X        # Collect all text upto the next colon+colon-initial line (::)
  6825. X    # or EOF.
  6826. X    value := ""
  6827. X    while line := read(intext) do {
  6828. X        match("::",line) & break
  6829. X        value ||:= line || "\n"
  6830. X    }
  6831. X
  6832. X        # Note that a key with an empty value returns an empty string.
  6833. X    suspend value
  6834. X
  6835. X    }
  6836. X
  6837. Xend
  6838. X
  6839. X
  6840. Xprocedure get_offsets(KEY, inidx)
  6841. X
  6842. X    # If there's no index file, then just return an offset of 1.
  6843. X    if /inidx then
  6844. X    return 1
  6845. X
  6846. X    # I guess we could insert some sort of binary search routine
  6847. X    # here, but I'm feeling lazy.
  6848. X
  6849. X    # Find every instance of this key, KEY, in the index file.
  6850. X    while line := read(inidx) do {
  6851. X    line ? {
  6852. X        # Tab separates key from offset.
  6853. X        (=KEY, ="\t") | next
  6854. X        # Rest of the line contains the offset.
  6855. X        suspend integer(tab(0))
  6856. X    }
  6857. X    }
  6858. X
  6859. X    # Last line of the index file contains offset of last indexed
  6860. X    # byte + 1.
  6861. X    return integer(line)
  6862. X
  6863. Xend
  6864. SHAR_EOF
  6865. true || echo 'restore of gettext.icn failed'
  6866. rm -f _shar_wnt_.tmp
  6867. fi
  6868. # ============= adjuncts.icn ==============
  6869. if test -f 'adjuncts.icn' -a X"$1" != X"-c"; then
  6870.     echo 'x - skipping adjuncts.icn (File already exists)'
  6871.     rm -f _shar_wnt_.tmp
  6872. else
  6873. > _shar_wnt_.tmp
  6874. echo 'x - extracting adjuncts.icn (Text)'
  6875. sed 's/^X//' << 'SHAR_EOF' > 'adjuncts.icn' &&
  6876. X############################################################################
  6877. X#
  6878. X#    Name:     adjuncts.icn
  6879. X#
  6880. X#    Title:     adjuncts (adjunct utilities for gettext and idxtext)
  6881. X#
  6882. X#    Author:     Richard L. Goerwitz
  6883. X#
  6884. X#    Version: 1.1
  6885. X#
  6886. X############################################################################
  6887. X#  
  6888. X#  Pretty mundane stuff.  Basename(), Pathname(), Strip(), and a utility
  6889. X#  for creating index filenames.
  6890. X#
  6891. X############################################################################
  6892. X#
  6893. X#  Links: none
  6894. X#
  6895. X#  See also: gettext.icn, idxtext,icn
  6896. X#
  6897. X############################################################################
  6898. X
  6899. X
  6900. Xprocedure Basename(s)
  6901. X
  6902. X    # global _slash
  6903. X    s ? {
  6904. X    while tab(find(_slash)+1)
  6905. X    return tab(0)
  6906. X    }
  6907. X
  6908. Xend
  6909. X
  6910. X
  6911. Xprocedure Pathname(s)
  6912. X
  6913. X    # global _slash
  6914. X    s2 := ""
  6915. X    s ? {
  6916. X    while s2 ||:= tab(find(_slash)+1)
  6917. X    return s2
  6918. X    }
  6919. X
  6920. Xend
  6921. X
  6922. X
  6923. Xprocedure getidxname(FNAME)
  6924. X
  6925. X    #
  6926. X    # Discard path component.  Cut basename down to a small enough
  6927. X    # size that the OS will be able to handle addition of the ex-
  6928. X    # tension ".IDX"
  6929. X    #
  6930. X
  6931. X    # global _slash, _baselen
  6932. X    return right(Strip(Basename(FNAME,_slash),'.'), _baselen, "x") || ".IDX"
  6933. X
  6934. Xend
  6935. X
  6936. X
  6937. Xprocedure Strip(s,c)
  6938. X
  6939. X    local s2
  6940. X
  6941. X    s2 := ""
  6942. X    s ? {
  6943. X    while s2 ||:= tab(upto(c))
  6944. X    do tab(many(c))
  6945. X    s2 ||:= tab(0)
  6946. X    }
  6947. X    return s2
  6948. X
  6949. Xend
  6950. SHAR_EOF
  6951. true || echo 'restore of adjuncts.icn failed'
  6952. rm -f _shar_wnt_.tmp
  6953. fi
  6954. # ============= README ==============
  6955. if test -f 'README' -a X"$1" != X"-c"; then
  6956.     echo 'x - skipping README (File already exists)'
  6957.     rm -f _shar_wnt_.tmp
  6958. else
  6959. > _shar_wnt_.tmp
  6960. echo 'x - extracting README (Text)'
  6961. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  6962. X
  6963. XThis archive contains gettext() and associated routines.  These allow
  6964. Xthe user to maintain a file of key/value combinations such that a call
  6965. Xto gettext(key, FNAME) will produce value.  Fails if no such key
  6966. Xexists.  Returns an empty string if the key exists, but has no
  6967. Xassociated value in the file named in arg 2 (FNAME).  Gettext() is
  6968. Xintended for use in situations where keys need to be associated with
  6969. Xvery large strings (i.e. where hand-inserting these values into hash
  6970. Xtables would be unweildy, and would take up a sizable chunk of
  6971. Xmemory).
  6972. X
  6973. XThe file format is simple.  Keys belong on separate lines, marked
  6974. Xas such by an initial colon+colon (::).  Values begin on the line
  6975. Xfollowing their respective keys, and extend up to the next
  6976. Xcolon+colon-initial line or EOF.  E.g.
  6977. X
  6978. X   ::sample.1
  6979. X   Notice how the key above, sample.1, has :: prepended to mark it
  6980. X   out as a key.  The text you are now reading represents that key's
  6981. X   value.  To retrieve this text, you would call gettext() with the
  6982. X   name of the key passed as its first argument, and the name of the
  6983. X   file in which this text is stored as its second argument (as in
  6984. X   gettext("sample.1","tmp.idx")).
  6985. X   ::next.key
  6986. X   etc...
  6987. X
  6988. XFor faster access, an indexing utility is included, idxtext.  Idxtext
  6989. Xcreates a separate index for a given text-base file.  If an index file
  6990. Xexists in the same directory as FNAME.
  6991. X
  6992. XBoth idxtext.icn and gettext.icn need to be linked with a common set
  6993. Xof utilities, ./adjuncts.icn.
  6994. X
  6995. XThere are lots of things that might be done to gettext/idxtext, such
  6996. Xas implement a binary search mechanism in the routine get_offsets(),
  6997. Xand compress or pack portions or the index file.  Might also be sen-
  6998. Xsible to offer regex patterns as an option for key/value retrievals.
  6999. XThis is a pretty rough version, as it stands, and I hope someone will
  7000. Xsee fit to modify it some time.  Note that it's untested under MS-DOS,
  7001. Xbut I suppose it could be made to work there.  The only big problem
  7002. XI foresee is with translation of CR+LF sequences and the consequent
  7003. Xdisruption of where() and seek().
  7004. X
  7005. XFor a list of do's/dont's, see the comments prepended to gettext.icn.
  7006. XSend bug reports/fixes, comments, etc. to -
  7007. X
  7008. XRichard Goerwitz (goer@sophist.uchicago.edu)
  7009. SHAR_EOF
  7010. true || echo 'restore of README failed'
  7011. rm -f _shar_wnt_.tmp
  7012. fi
  7013. # ============= Makefile.dist ==============
  7014. if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
  7015.     echo 'x - skipping Makefile.dist (File already exists)'
  7016.     rm -f _shar_wnt_.tmp
  7017. else
  7018. > _shar_wnt_.tmp
  7019. echo 'x - extracting Makefile.dist (Text)'
  7020. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
  7021. X# Please edit these to reflect your local file structure & conventions.
  7022. XDESTDIR = /usr/local/bin
  7023. XOWNER = bin
  7024. XGROUP = bin
  7025. X
  7026. Xidxtext: idxtext.icn
  7027. X    icont idxtext.icn adjunct.icn
  7028. X
  7029. X# Pessimistic assumptions regarding the environment (in particular,
  7030. X# I don't assume you have the BSD "install" shell script).
  7031. Xinstall: idxtext
  7032. X    @echo "\nInstalling idxtext in $(DESTDIR).\n"
  7033. X    @sh -c "test -d $(DESTDIR) || (mkdir $(DESTDIR) && chmod 755 $(DESTDIR))"
  7034. X    cp idxtext $(DESTDIR)/
  7035. X    chgrp $(GROUP) $(DESTDIR)/idxtext
  7036. X    chown $(OWNER) $(DESTDIR)/idxtext
  7037. X    @echo "\nInstallation done.\n"
  7038. X
  7039. Xclean:
  7040. X    -rm -f *u? *~
  7041. X    -rm -f idxtext test
  7042. SHAR_EOF
  7043. true || echo 'restore of Makefile.dist failed'
  7044. rm -f _shar_wnt_.tmp
  7045. fi
  7046. exit 0
  7047.  
  7048. From icon-group-request@arizona.edu  Thu Jan 31 00:21:35 1991
  7049. Resent-From: icon-group-request@arizona.edu
  7050. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  7051.     id AA23580; Thu, 31 Jan 91 00:21:35 -0700
  7052. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 31 Jan
  7053.  1991 00:21 MST
  7054. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA13991; Wed, 30 Jan 91
  7055.  23:17:36 -0800
  7056. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  7057.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  7058.  usenet@ucbvax.Berkeley.EDU if you have questions)
  7059. Resent-Date: Thu, 31 Jan 1991 00:21 MST
  7060. Date: 31 Jan 91 02:47:32 GMT
  7061. From: hsi!mlfarm!ron@uunet.uu.net (Ronald Florence)
  7062. Subject: Postscript two-up filter
  7063. Sender: icon-group-request@arizona.edu
  7064. Resent-To: icon-group@cs.arizona.edu
  7065. To: icon-group@arizona.edu
  7066. Resent-Message-Id: <19FD7CCE80805A29@Arizona.edu>
  7067. Message-Id: <735@mlfarm.com>
  7068. X-Envelope-To: icon-group@CS.Arizona.EDU
  7069. X-Vms-To: icon-group@Arizona.edu
  7070. Organization: Maple Lawn Farm, Stonington, CT
  7071.  
  7072. Before I reinvent the wheel, has anyone written an Icon filter to
  7073. print Postscript pages two-up, e.g., side-by-side in landscape mode?
  7074. I've seen filters to do this written in perl.  Icon seems perfect for
  7075. the task.
  7076. --
  7077.  
  7078. Ronald Florence            ron@mlfarm.com
  7079.  
  7080. From S.P.Q.Rahtz@ecs.southampton.ac.uk  Thu Jan 31 02:52:23 1991
  7081. Resent-From: S.P.Q.Rahtz@ecs.southampton.ac.uk
  7082. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  7083.     id AA29202; Thu, 31 Jan 91 02:52:23 -0700
  7084. Received: from sun2.nsfnet-relay.ac.uk by Arizona.edu with PMDF#10282; Thu, 31
  7085.  Jan 1991 02:51 MST
  7086. Received: from vax.nsfnet-relay.ac.uk by sun2.nsfnet-relay.ac.uk with SMTP
  7087.  inbound id <2568-5@sun2.nsfnet-relay.ac.uk>; Thu, 31 Jan 1991 09:46:52 +0000
  7088. Received: from sun2.nsfnet-relay.ac.uk by vax.NSFnet-Relay.AC.UK via Janet with
  7089.  NIFTP id aa02812; 31 Jan 91 9:26 GMT
  7090. Received: from bright.ecs.soton.ac.uk by hilliard.ecs.soton.ac.uk; Thu, 31 Jan
  7091.  91 09:42:41 GMT
  7092. Received: from vicky.ecs.soton.ac.uk by bright.ecs.soton.ac.uk; Thu, 31 Jan 91
  7093.  09:39:28 GMT
  7094. Resent-Date: Thu, 31 Jan 1991 02:52 MST
  7095. Date: Thu, 31 Jan 91 14:40:46 gmt
  7096. From: Sebastian Rahtz <S.P.Q.Rahtz@ecs.southampton.ac.uk>
  7097. Subject: RE: Postscript two-up filter
  7098. In-Reply-To: <735@mlfarm.com>
  7099. Resent-To: icon-group@cs.arizona.edu
  7100. To: ron <@uunet.uu.net,@hsi:ron@mlfarm>
  7101. Cc: icon-group@arizona.edu
  7102. Resent-Message-Id: <2F0DE92A10805C97@Arizona.edu>
  7103. Message-Id: <15130.9101311440@manutius.ecs.soton.ac.uk>
  7104. X-Envelope-To: icon-group@CS.Arizona.EDU
  7105. X-Vms-To: ron <@uunet.uu.net,@hsi:ron@mlfarm>
  7106. X-Vms-Cc: icon-group@Arizona.edu
  7107.  
  7108. Ronald Florence writes:
  7109.  > Before I reinvent the wheel, has anyone written an Icon filter to
  7110.  > print Postscript pages two-up, e.g., side-by-side in landscape mode?
  7111.  > I've seen filters to do this written in perl.  Icon seems perfect for
  7112.  > the task.
  7113. there is an even simpler solution, which is to write it in PostScript
  7114. itself... thats what I use, an excellent offering by Ross Cartlidge
  7115. which does everything you need in the way of n-up.
  7116.  
  7117. much as I dote on Icon, I can't help feeling that a) having to have
  7118. Icon on every machine from which I print PS, and b) having to load in
  7119. the Icon interpreter each time I print is mild overkill.
  7120.  
  7121. if anyone wants Ross Cartlidge's code (you just prepend it to your
  7122. normal output), I can mail it
  7123.  
  7124. sebastian
  7125.  
  7126.  
  7127. From ralph  Thu Jan 31 10:12:10 1991
  7128. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  7129.     id AA15341; Thu, 31 Jan 91 10:12:10 -0700
  7130. Date: Thu, 31 Jan 91 10:12:08 MST
  7131. From: "Ralph Griswold" <ralph>
  7132. Message-Id: <9101311712.AA25007@cheltenham.cs.arizona.edu>
  7133. Received: by cheltenham.cs.arizona.edu; Thu, 31 Jan 91 10:12:08 MST
  7134. To: icon-group
  7135. Subject: UNIX configurations for Version 8 of Icon
  7136.  
  7137. Since Version 8 of Icon was released, we've received several new and
  7138. improved configurations for UNIX platforms.
  7139.  
  7140. We do not plan to update the complete Version 8 distribution for Icon
  7141. in the near future, but we've put an updated version of the configuration
  7142. subdirectory on our FTP area.  This update is available in cpio and
  7143. tar format, and replaces the config/unix subdirectory in the original
  7144. distribution.
  7145.  
  7146. To get this update, do an anonymous FTP to cs.arizona.edu and
  7147. cd /icon/v8.  The files are named unixconf.cpi and unixconf.tar.
  7148.  
  7149. If you have any questions, please send mail to me, not to icon-group.
  7150.  
  7151.         Ralph Griswold
  7152.  
  7153.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  7154.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  7155.  
  7156. From icon-group-request@arizona.edu  Fri Feb  1 08:23:13 1991
  7157. Resent-From: icon-group-request@arizona.edu
  7158. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  7159.     id AA25356; Fri, 1 Feb 91 08:23:13 -0700
  7160. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 1 Feb
  7161.  1991 08:22 MST
  7162. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA25963; Fri, 1 Feb 91 07:08:16
  7163.  -0800
  7164. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  7165.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  7166.  usenet@ucbvax.Berkeley.EDU if you have questions)
  7167. Resent-Date: Fri, 1 Feb 1991 08:22 MST
  7168. Date: 1 Feb 91 14:55:11 GMT
  7169. From: att!linac!midway!ellis.uchicago.edu!goer@ucbvax.Berkeley.EDU (Richard L.
  7170.  Goerwitz)
  7171. Subject: shooting yourself in the foot
  7172. Sender: icon-group-request@arizona.edu
  7173. Resent-To: icon-group@cs.arizona.edu
  7174. To: icon-group@arizona.edu
  7175. Resent-Message-Id: <26702A2D808067B7@Arizona.edu>
  7176. Message-Id: <1991Feb1.145511.9592@midway.uchicago.edu>
  7177. X-Envelope-To: icon-group@CS.Arizona.EDU
  7178. X-Vms-To: icon-group@Arizona.edu
  7179. Organization: University of Chicago
  7180.  
  7181. Howd'ya shoot yourself in the foot in Icon?
  7182.  
  7183.     You think your are going to shoot your foot, but automatic type
  7184.     conversion suddenly kicks in, and you find yourself aiming at a
  7185.     bull's eye.  You shoot the bull's eye until the it completely
  7186.     disintegrates.  Backtracking then kicks in, finds the other foot,
  7187.     shoots it, and then reports your efforts as a failure.
  7188.  
  7189. -Richard
  7190.  
  7191. From ralph  Sat Feb  2 14:31:50 1991
  7192. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  7193.     id AA24576; Sat, 2 Feb 91 14:31:50 -0700
  7194. Date: Sat, 2 Feb 91 14:31:47 MST
  7195. From: "Ralph Griswold" <ralph>
  7196. Message-Id: <9102022131.AA18227@cheltenham.cs.arizona.edu>
  7197. Received: by cheltenham.cs.arizona.edu; Sat, 2 Feb 91 14:31:47 MST
  7198. To: icon-group
  7199. Subject: New Company Formed to Provide Commercial Support for Icon
  7200.  
  7201.  
  7202.    Iconic Software, Inc. (ISI), is a new company founded by a
  7203. core group of computer scientists, together with professionals in
  7204. computer marketing and technical customer service.
  7205.  
  7206.    ISI's goal is to become a major supplier of software develop-
  7207. ment tools, languages, and high-value applications for the UNIX
  7208. system environment.  ISI founders have considerable expertise and
  7209. experience with Icon and with UNIX-based systems, much of it
  7210. gained while working at AT&T Bell Laboratories.
  7211.  
  7212.    The company will initially focus on high-quality voice pro-
  7213. cessing systems.  "Voice response systems are applications in
  7214. which persons interact with a computer over their touch-tone
  7215. phones to access and update databases, hear prerecorded informa-
  7216. tion and leave recorded messages, and perform other transactions"
  7217. said ISI founder, Jerry Nowlin.  "We've already developed special
  7218. Icon utilities that will allow us to deliver thoroughly tested
  7219. systems in a fraction of the time that would be required if C
  7220. were used."
  7221.  
  7222.    An exciting prospect for ISI is commercial support for the
  7223. Icon compiler, which is currently under development at the
  7224. University of Arizona.  Although the initial UNIX version of the
  7225. compiler will be available to the public, ISI will extend and
  7226. support a commercial UNIX version.  Ken Walker, who designed and
  7227. implemented the compiler and is presently completing his PhD, is
  7228. joining ISI to work on this project.  ISI is also investigating
  7229. the feasibility of an MS-DOS implementation.  ISI hopes to become
  7230. known as the "Icon Compiler Company" and sees a significant
  7231. opportunity in bringing Icon to professional developers of com-
  7232. mercial software products.
  7233.  
  7234.    ISI's administrative and marketing offices are currently
  7235. located in West Lafayette, Indiana.  Development facilities are
  7236. located in Plano, Illinois.  For more information about ISI's pro-
  7237. ducts and services contact Roger Fonorow: (317) 463-9269.
  7238.  
  7239.    Electronic mail can be sent to ISI at:
  7240.  
  7241.     isi@isidev.att.com    Internet
  7242.  
  7243.     att!isidev!isi        uucp
  7244.  
  7245. From icon-group-request@arizona.edu  Sat Feb  2 17:20:39 1991
  7246. Resent-From: icon-group-request@arizona.edu
  7247. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  7248.     id AA28782; Sat, 2 Feb 91 17:20:39 -0700
  7249. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 2 Feb
  7250.  1991 17:19 MST
  7251. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA08172; Sat, 2 Feb 91 16:12:25
  7252.  -0800
  7253. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  7254.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  7255.  usenet@ucbvax.Berkeley.EDU if you have questions)
  7256. Resent-Date: Sat, 2 Feb 1991 17:20 MST
  7257. Date: 2 Feb 91 18:02:11 GMT
  7258. From: hsi!mlfarm!ron@uunet.uu.net (Ronald Florence)
  7259. Subject: reply.icn & post.icn
  7260. Sender: icon-group-request@arizona.edu
  7261. Resent-To: icon-group@cs.arizona.edu
  7262. To: icon-group@arizona.edu
  7263. Resent-Message-Id: <3AAC7B8EEAE00504@Arizona.edu>
  7264. Message-Id: <741@mlfarm.com>
  7265. X-Envelope-To: icon-group@CS.Arizona.EDU
  7266. X-Vms-To: icon-group@Arizona.edu
  7267. Organization: Maple Lawn Farm, Stonington, CT
  7268.  
  7269. To my surprise, these programs are actually used for mail replies and
  7270. news posting at a few Unix and ms-dos sites.  I've added some modest
  7271. revisions: case-insensitive header parsing, parsing for follow-ups to
  7272. newsgroups or "poster", prompts for news distribution, and slightly
  7273. more robust syntax in the Icon code.  Let me know if you want the
  7274. current version of either program by email.
  7275. --
  7276.  
  7277. Ronald Florence            ron@mlfarm.com
  7278.  
  7279. From icon-group-request@arizona.edu  Mon Feb  4 19:08:15 1991
  7280. Resent-From: icon-group-request@arizona.edu
  7281. Received: from Arizona.edu (Osprey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  7282.     id AA03902; Mon, 4 Feb 91 19:08:15 -0700
  7283. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 4 Feb
  7284.  1991 19:07 MST
  7285. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA09578; Mon, 4 Feb 91 17:59:04
  7286.  -0800
  7287. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  7288.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  7289.  usenet@ucbvax.Berkeley.EDU if you have questions)
  7290. Resent-Date: Mon, 4 Feb 1991 19:08 MST
  7291. Date: 4 Feb 91 12:54:55 GMT
  7292. From: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net (Norman H. Azadian)
  7293. Subject: IPATH under MKS Toolkit
  7294. Sender: icon-group-request@arizona.edu
  7295. Resent-To: icon-group@cs.arizona.edu
  7296. To: icon-group@arizona.edu
  7297. Resent-Message-Id: <DC0B3BCECAE0113D@Arizona.edu>
  7298. Message-Id: <1808@hslrswi.hasler.ascom.ch>
  7299. X-Envelope-To: icon-group@CS.Arizona.EDU
  7300. X-Vms-To: icon-group@Arizona.edu
  7301. Organization: Hasler AG
  7302.  
  7303. Well, I sure screwed up royal when I posted that last gripe about the
  7304. Icon linker not being able to use IPATH under the MKS Toolkit.  It works
  7305. like a champ when one remembers to export the environment variable.
  7306. I swear I gotta stop this late night hacking.
  7307.  
  7308. NHA
  7309. -- 
  7310. PAPER:  Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
  7311. INTERNET:  naz%hslrswi.uucp@uunet.uu.net
  7312. UUCP:   ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
  7313. VOICE:  +41 31 63 2178            BITNET: naz%hslrswi.UUCP@cernvax.BITNET
  7314.  
  7315. From goer%sophist@gargoyle.uchicago.edu  Thu Feb  7 23:17:23 1991
  7316. Resent-From: goer%sophist@gargoyle.uchicago.edu
  7317. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  7318.     id AA27075; Thu, 7 Feb 91 23:17:23 -0700
  7319. Return-Path: goer@sophist.uchicago.edu
  7320. Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Thu, 7 Feb
  7321.  1991 23:16 MST
  7322. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  7323.  (4.0/1.14) id AA04989; Fri, 8 Feb 91 00:16:30 CST
  7324. Received: by sophist (4.1/UofC3.1X) id AA25266; Fri, 8 Feb 91 00:19:02 CST
  7325. Resent-Date: Thu, 7 Feb 1991 23:17 MST
  7326. Date: Fri, 8 Feb 91 00:19:02 CST
  7327. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  7328. Subject: gettext text-base routines
  7329. Resent-To: icon-group@cs.arizona.edu
  7330. To: icon-group@arizona.edu
  7331. Resent-Message-Id: <5A558FBFBAE01E14@Arizona.edu>
  7332. Message-Id: <9102080619.AA25266@sophist>
  7333. X-Envelope-To: icon-group@CS.Arizona.EDU
  7334. X-Vms-To: icon-group@Arizona.edu
  7335.  
  7336. I posted a set of text-base utilities a while back.  They have
  7337. been somewhat improved since then, and although I really haven't
  7338. had as much feedback as I'd like since the initial posting, I
  7339. believe the changes are enough to warrant a repost.
  7340.  
  7341. Please, if you use these programs - and especially if you find
  7342. bugs - drop me a line.
  7343.  
  7344. -Richard (goer@sophist.uchicago.edu)
  7345.  
  7346. ---- Cut Here and feed the following to sh ----
  7347. #!/bin/sh
  7348. # This is a shell archive (produced by shar 3.49)
  7349. # To extract the files from this archive, save it to a file, remove
  7350. # everything above the "!/bin/sh" line above, and type "sh file_name".
  7351. #
  7352. # made 02/08/1991 06:07 UTC by goer@sophist.uchicago.edu
  7353. # Source directory /u/richard/Gettext
  7354. #
  7355. # existing files will NOT be overwritten unless -c is specified
  7356. # This format requires very little intelligence at unshar time.
  7357. # "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
  7358. #
  7359. #                                                                          
  7360. #                                                                          
  7361. #
  7362. # This shar contains:
  7363. # length  mode       name
  7364. # ------ ---------- ------------------------------------------
  7365. #   2799 -r--r--r-- idxtext.icn
  7366. #   6225 -r--r--r-- gettext.icn
  7367. #   1310 -r--r--r-- adjuncts.icn
  7368. #   2230 -rw-r--r-- README
  7369. #    600 -rw-r--r-- Makefile.dist
  7370. #
  7371. if test -r _shar_seq_.tmp; then
  7372.     echo 'Must unpack archives in sequence!'
  7373.     echo Please unpack part `cat _shar_seq_.tmp` next
  7374.     exit 1
  7375. fi
  7376. # ============= idxtext.icn ==============
  7377. if test -f 'idxtext.icn' -a X"$1" != X"-c"; then
  7378.     echo 'x - skipping idxtext.icn (File already exists)'
  7379.     rm -f _shar_wnt_.tmp
  7380. else
  7381. > _shar_wnt_.tmp
  7382. echo 'x - extracting idxtext.icn (Text)'
  7383. sed 's/^X//' << 'SHAR_EOF' > 'idxtext.icn' &&
  7384. X############################################################################
  7385. X#
  7386. X#    Name:     idxtext.icn
  7387. X#
  7388. X#    Title:     idxtext (index text-base for gettext() routine)
  7389. X#
  7390. X#    Author:     Richard L. Goerwitz
  7391. X#
  7392. X#    Version: 1.9
  7393. X#
  7394. X############################################################################
  7395. X#
  7396. X#      Idxtext turns a file associated with gettext() routine into an
  7397. X#  indexed text- base.  Though gettext() will work fine with files
  7398. X#  that haven't been indexed via idxtext(), access is faster if the
  7399. X#  indexing is done if the file is, say, over 10k (on my system the
  7400. X#  crossover point is actually about 5k).
  7401. X#
  7402. X#      Usage is simply "idxtext file1 [file2 [...]]," where file1,
  7403. X#  file2, etc are the names of gettext-format files that are to be
  7404. X#  (re-)indexed.
  7405. X#
  7406. X#      Indexed files have a very simple format: keyname tab offset
  7407. X#  [tab offset [etc.]]\n.  The first line of the index file is a
  7408. X#  pointer to the last indexed byte of the text-base file it indexes.
  7409. X#
  7410. X#  BUGS:  Index files are too large.
  7411. X#
  7412. X############################################################################
  7413. X#
  7414. X#  Links: ./adjuncts.icn
  7415. X#
  7416. X#  Requires: UNIX or MS-DOS
  7417. X#
  7418. X#  See also: gettext.icn
  7419. X#
  7420. X############################################################################
  7421. X
  7422. X
  7423. Xglobal _slash, _baselen
  7424. X
  7425. Xprocedure main(a)
  7426. X
  7427. X    local temp_name, fname, infile, outfile
  7428. X    initial {
  7429. X    if find("UNIX", &features) then {
  7430. X        _slash := "/"
  7431. X        _baselen := 10
  7432. X    }
  7433. X    else if find("MS-DOS", &features) then {
  7434. X        _slash := "\\"
  7435. X        _baselen := 8
  7436. X    }
  7437. X    else stop("idxtext:  OS not supported")
  7438. X    }
  7439. X
  7440. X    # Check to see if we have any arguments.
  7441. X    *a = 0 & stop("usage:  idxtext file1 [file2 [...]]")
  7442. X
  7443. X    # Start popping filenames off of the argument list.
  7444. X    while fname := pop(a) do {
  7445. X
  7446. X    # Open input file.
  7447. X    infile := open(fname) | stop("idxtext:  ",fname," not found")
  7448. X    # Get index file name.
  7449. X    outfile := open(temp_name := Pathname(fname)||getidxname(fname),"w") |
  7450. X        stop("idxtext:  ",temp_name," not found")
  7451. X
  7452. X    # Write index to index.IDX file.
  7453. X    write_index(infile, outfile)
  7454. X
  7455. X    every close(infile | outfile)
  7456. X
  7457. X    }
  7458. X
  7459. Xend
  7460. X
  7461. X
  7462. Xprocedure write_index(in, out)
  7463. X
  7464. X    local key_offset_table, w, line, KEY
  7465. X
  7466. X    # Write to out all keys in file "in," with their byte
  7467. X    # offsets.
  7468. X
  7469. X    key_offset_table := table()
  7470. X
  7471. X    while (w := where(in), line := read(in)) do {
  7472. X    line ? {
  7473. X        if ="::" then {
  7474. X        KEY := trim(tab(0))
  7475. X        if not (/key_offset_table[KEY] := KEY || "\t" || w)
  7476. X        then stop("idxtext:  duplicate key, ",KEY)
  7477. X        }
  7478. X    }
  7479. X    }
  7480. X
  7481. X    # First line of index contains the offset of the last
  7482. X    # indexed byte in write_index, so that we can still
  7483. X    # search unindexed parts of in.
  7484. X    write(out, where(in))
  7485. X
  7486. X    # Write sorted KEY\toffset lines.
  7487. X    if *key_offset_table > 0 then
  7488. X    every write(out, (!sort(key_offset_table))[2])
  7489. X
  7490. X    return
  7491. X
  7492. Xend
  7493. SHAR_EOF
  7494. true || echo 'restore of idxtext.icn failed'
  7495. rm -f _shar_wnt_.tmp
  7496. fi
  7497. # ============= gettext.icn ==============
  7498. if test -f 'gettext.icn' -a X"$1" != X"-c"; then
  7499.     echo 'x - skipping gettext.icn (File already exists)'
  7500.     rm -f _shar_wnt_.tmp
  7501. else
  7502. > _shar_wnt_.tmp
  7503. echo 'x - extracting gettext.icn (Text)'
  7504. sed 's/^X//' << 'SHAR_EOF' > 'gettext.icn' &&
  7505. X############################################################################
  7506. X#
  7507. X#    Name:     gettext.icn
  7508. X#
  7509. X#    Title:     gettext (simple text-base routines)
  7510. X#
  7511. X#    Author:     Richard L. Goerwitz
  7512. X#
  7513. X#    Version: 1.14
  7514. X#
  7515. X############################################################################
  7516. X#
  7517. X#  Gettext() and associated routines allow the user to maintain a file
  7518. X#  of KEY/value combinations such that a call to gettext(KEY, FNAME)
  7519. X#  will produce value.  Gettext() fails if no such KEY exists.
  7520. X#  Returns an empty string if the key exists, but has no associated
  7521. X#  value in the file, FNAME.
  7522. X#
  7523. X#  The file format is simple.  Keys belong on separate lines, marked
  7524. X#  as such by an initial colon+colon (::).  Values begin on the line
  7525. X#  following their respective keys, and extend up to the next
  7526. X#  colon+colon-initial line or EOF.  E.g.
  7527. X#
  7528. X#    ::sample.1
  7529. X#    Notice how the key above, sample.1, has :: prepended to mark it
  7530. X#    out as a key.  The text you are now reading represents that key's
  7531. X#    value.  To retrieve this text, you would call gettext() with the
  7532. X#    name of the key passed as its first argument, and the name of the
  7533. X#    file in which this text is stored as its second argument (as in
  7534. X#    gettext("sample.1","tmp.idx")).
  7535. X#    ::next.key
  7536. X#    etc...
  7537. X#
  7538. X#  For faster access, an indexing utility is included, idxtext.  Idxtext
  7539. X#  creates a separate index for a given text-base file.  If an index file
  7540. X#  exists in the same directory as FNAME, gettext() will make use of it.
  7541. X#  The index becomes worthwhile (at least on my system) after the text-
  7542. X#  base file becomes longer than 5 kilobytes.
  7543. X#
  7544. X#  Donts:
  7545. X#      1) Don't nest gettext text-base files.
  7546. X#      2) Don't use spaces and/or tabs in key names.
  7547. X#      3) Don't modify indexed files in any way other than to append
  7548. X#         additional keys/values (unless you want to re-index).
  7549. X#
  7550. X#  This program is intended for situations where keys tend to have
  7551. X#  very large values, and use of an Icon table structure would be
  7552. X#  unweildy.
  7553. X#
  7554. X#  BUGS:  Gettext() relies on the Icon runtime system and the OS to
  7555. X#  make sure the last text/index file it opens gets closed.
  7556. X#
  7557. X#  Note:  This program is NOT YET TESTED UNDER DOS.  In particular,
  7558. X#  I have no idea whether the indexing mechanism will work, due to
  7559. X#  translation that has to be done on MS-DOS text files.
  7560. X#
  7561. X############################################################################
  7562. X#
  7563. X#  Links: ./adjuncts.icn
  7564. X#
  7565. X#  Requires: UNIX (maybe MS-DOS; untested)
  7566. X#
  7567. X############################################################################
  7568. X
  7569. X
  7570. Xglobal _slash, _baselen
  7571. X
  7572. Xprocedure gettext(KEY,FNAME)
  7573. X
  7574. X    local line, value
  7575. X    static last_FNAME, intext, inidx
  7576. X    initial {
  7577. X    if find("UNIX", &features) then {
  7578. X        _slash := "/"
  7579. X        _baselen := 10
  7580. X    }
  7581. X    else if find("MS-DOS", &features) then {
  7582. X        _slash := "\\"
  7583. X        _baselen := 8
  7584. X    }
  7585. X    else stop("gettext:  OS not supported")
  7586. X    }
  7587. X
  7588. X    (/KEY | /FNAME) & stop("error (gettext):  null argument")
  7589. X
  7590. X    if FNAME ~== \last_FNAME then {
  7591. X    seek(intext, 1)
  7592. X    seek(\inidx, 1)
  7593. X    }
  7594. X    else {
  7595. X    # We've got a new text-base file.  Close the old one.
  7596. X    every close(\intext | \inidx)
  7597. X        # Try to open named text-base file.
  7598. X    intext := open(FNAME) | stop("gettext:  ",FNAME," not found")
  7599. X        # Try to open index file.
  7600. X    inidx := open(Pathname(FNAME) || getidxname(FNAME))
  7601. X    }
  7602. X    last_FNAME := FNAME
  7603. X
  7604. X    # Find offsets for key KEY in index file.  If inidx (the index
  7605. X    # file) is null (which happens when none was found), get_offsets()
  7606. X    # defaults to 1.  Otherwise it returns the offset for KEY in the
  7607. X    # index file, and then returns the last indexed byte of the file.
  7608. X    # Returning the last indexed byte lets us seek to the end and do a
  7609. X    # sequential search of any key/value entries that have been added
  7610. X    # since the last time idxtext was run.
  7611. X
  7612. X    seek(intext, get_offsets(KEY, inidx))
  7613. X
  7614. X    # Find key.  Should be right there, unless the user has appended
  7615. X    # key/value pairs to the end without re-indexing, or else has not
  7616. X    # bothered to index in the first place.  In this case we're
  7617. X    # supposed to start a sequential search for KEY upto EOF.
  7618. X
  7619. X    while line := (read(intext) | fail) do {
  7620. X    line ? {
  7621. X        if (="::", =KEY, pos(0))
  7622. X        then break
  7623. X    }
  7624. X    }
  7625. X
  7626. X    # Collect all text upto the next colon+colon-initial line (::)
  7627. X    # or EOF.
  7628. X    value := ""
  7629. X    while line := read(intext) do {
  7630. X    match("::",line) & break
  7631. X    value ||:= line || "\n"
  7632. X    }
  7633. X
  7634. X    # Note that a key with an empty value returns an empty string.
  7635. X    return trim(value, '\n')
  7636. X
  7637. Xend
  7638. X
  7639. X
  7640. X
  7641. Xprocedure get_offsets(KEY, inidx)
  7642. X
  7643. X    local bottom, top, loc, firstpart, offset
  7644. X    # Use these to store values likely to be reused.
  7645. X    static old_inidx, firstline, SOF, EOF
  7646. X
  7647. X    # If there's no index file, then just return an offset of 1.
  7648. X    if /inidx then
  7649. X    return 1
  7650. X
  7651. X    # First line contains offset of last indexed byte in the main
  7652. X    # text file.  We need this later.  Save it.  Start the binary
  7653. X    # search routine at the next byte after this line.
  7654. X    seek(inidx, 1)
  7655. X    if not (inidx === \old_inidx) then {
  7656. X
  7657. X    # Get first line.
  7658. X    firstline := !inidx
  7659. X    # Set "bottom."
  7660. X    1 = (SOF := where(inidx)-1) &
  7661. X        stop("get_offsets:  corrupt .IDX file; reindex")
  7662. X    # How big is this file?
  7663. X    seek(inidx, 0)
  7664. X    EOF := where(inidx)
  7665. X
  7666. X    old_inidx := inidx
  7667. X    }
  7668. X    # SOF, EOF constant for a given inidx file.
  7669. X    bottom := SOF; top := EOF
  7670. X
  7671. X    # If bottom gets bigger than top, there's no such key.
  7672. X    until bottom > top do {
  7673. X
  7674. X    loc := (top+bottom) / 2
  7675. X    seek(inidx, loc)
  7676. X
  7677. X    # Move past next newline.  If at EOF, break.
  7678. X    incr := 1
  7679. X    until reads(inidx) == "\n" do
  7680. X        incr +:= 1
  7681. X    if loc+incr = EOF then {
  7682. X        top := loc-1
  7683. X        next
  7684. X    }
  7685. X
  7686. X    # Check to see if the current line contains KEY.
  7687. X    read(inidx) ? {
  7688. X
  7689. X        # .IDX file line format is KEY\toffset
  7690. X        firstpart := tab(find("\t"))
  7691. X        if KEY == firstpart then {
  7692. X        # return offset
  7693. X        return (move(1), tab(0))
  7694. X        }
  7695. X        # Ah, this is what all binary searches do.
  7696. X        else {
  7697. X        if KEY << firstpart
  7698. X        then top := loc-1
  7699. X        else bottom := loc + incr + *&subject
  7700. X        }
  7701. X    }
  7702. X    }
  7703. X
  7704. X    # First line of the index file contains offset of last indexed
  7705. X    # byte + 1.  Might be the only line in the file (if it had no
  7706. X    # keys when it was indexed).
  7707. X    return firstline
  7708. X
  7709. Xend
  7710. SHAR_EOF
  7711. true || echo 'restore of gettext.icn failed'
  7712. rm -f _shar_wnt_.tmp
  7713. fi
  7714. # ============= adjuncts.icn ==============
  7715. if test -f 'adjuncts.icn' -a X"$1" != X"-c"; then
  7716.     echo 'x - skipping adjuncts.icn (File already exists)'
  7717.     rm -f _shar_wnt_.tmp
  7718. else
  7719. > _shar_wnt_.tmp
  7720. echo 'x - extracting adjuncts.icn (Text)'
  7721. sed 's/^X//' << 'SHAR_EOF' > 'adjuncts.icn' &&
  7722. X############################################################################
  7723. X#
  7724. X#    Name:     adjuncts.icn
  7725. X#
  7726. X#    Title:     adjuncts (adjunct utilities for gettext and idxtext)
  7727. X#
  7728. X#    Author:     Richard L. Goerwitz
  7729. X#
  7730. X#    Version: 1.1
  7731. X#
  7732. X############################################################################
  7733. X#  
  7734. X#  Pretty mundane stuff.  Basename(), Pathname(), Strip(), and a utility
  7735. X#  for creating index filenames.
  7736. X#
  7737. X############################################################################
  7738. X#
  7739. X#  Links: none
  7740. X#
  7741. X#  See also: gettext.icn, idxtext,icn
  7742. X#
  7743. X############################################################################
  7744. X
  7745. X
  7746. Xprocedure Basename(s)
  7747. X
  7748. X    # global _slash
  7749. X    s ? {
  7750. X    while tab(find(_slash)+1)
  7751. X    return tab(0)
  7752. X    }
  7753. X
  7754. Xend
  7755. X
  7756. X
  7757. Xprocedure Pathname(s)
  7758. X
  7759. X    # global _slash
  7760. X    s2 := ""
  7761. X    s ? {
  7762. X    while s2 ||:= tab(find(_slash)+1)
  7763. X    return s2
  7764. X    }
  7765. X
  7766. Xend
  7767. X
  7768. X
  7769. Xprocedure getidxname(FNAME)
  7770. X
  7771. X    #
  7772. X    # Discard path component.  Cut basename down to a small enough
  7773. X    # size that the OS will be able to handle addition of the ex-
  7774. X    # tension ".IDX"
  7775. X    #
  7776. X
  7777. X    # global _slash, _baselen
  7778. X    return right(Strip(Basename(FNAME,_slash),'.'), _baselen, "x") || ".IDX"
  7779. X
  7780. Xend
  7781. X
  7782. X
  7783. Xprocedure Strip(s,c)
  7784. X
  7785. X    local s2
  7786. X
  7787. X    s2 := ""
  7788. X    s ? {
  7789. X    while s2 ||:= tab(upto(c))
  7790. X    do tab(many(c))
  7791. X    s2 ||:= tab(0)
  7792. X    }
  7793. X    return s2
  7794. X
  7795. Xend
  7796. SHAR_EOF
  7797. true || echo 'restore of adjuncts.icn failed'
  7798. rm -f _shar_wnt_.tmp
  7799. fi
  7800. # ============= README ==============
  7801. if test -f 'README' -a X"$1" != X"-c"; then
  7802.     echo 'x - skipping README (File already exists)'
  7803.     rm -f _shar_wnt_.tmp
  7804. else
  7805. > _shar_wnt_.tmp
  7806. echo 'x - extracting README (Text)'
  7807. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  7808. X
  7809. XThis archive contains gettext() and associated routines.  These allow
  7810. Xthe user to maintain a file of key/value combinations such that a call
  7811. Xto gettext(key, FNAME) will produce value.  Fails if no such key
  7812. Xexists.  Returns an empty string if the key exists, but has no
  7813. Xassociated value in the file named in arg 2 (FNAME).  Gettext() is
  7814. Xintended for use in situations where keys need to be associated with
  7815. Xvery large strings (i.e. where hand-inserting these values into hash
  7816. Xtables would be unweildy, and would take up a sizable chunk of
  7817. Xmemory).
  7818. X
  7819. XThe file format is simple.  Keys belong on separate lines, marked
  7820. Xas such by an initial colon+colon (::).  Values begin on the line
  7821. Xfollowing their respective keys, and extend up to the next
  7822. Xcolon+colon-initial line or EOF.  E.g.
  7823. X
  7824. X   ::sample.1
  7825. X   Notice how the key above, sample.1, has :: prepended to mark it
  7826. X   out as a key.  The text you are now reading represents that key's
  7827. X   value.  To retrieve this text, you would call gettext() with the
  7828. X   name of the key passed as its first argument, and the name of the
  7829. X   file in which this text is stored as its second argument (as in
  7830. X   gettext("sample.1","tmp.idx")).
  7831. X   ::next.key
  7832. X   etc...
  7833. X
  7834. XFor faster access, an indexing utility is included, idxtext.  Idxtext
  7835. Xcreates a separate index for a given text-base file.  If an index file
  7836. Xexists in the same directory as FNAME, gettext() will make use of it.
  7837. XOtherwise, it just does a sequential search of the entire file (this
  7838. Xworks fine for smaller files).  Please don't change a file, once you've
  7839. Xrun idxtext on it, except to append key/value entries to it.  If you
  7840. Xalter the indexed portion of the file in any way, you must reindex.
  7841. X
  7842. XBoth idxtext.icn and gettext.icn need to be linked with a common set
  7843. Xof utilities, ./adjuncts.icn.
  7844. X
  7845. XFor a list of do/dont's, see the comments prepended to gettext.icn.
  7846. XNote that these routines are, thus far, tested only under UNIX, and
  7847. Xhave not yet been used on a system for which seek() gets skewed by
  7848. Xline-end translations done on text files (e.g. MS-DOS).  I would ex-
  7849. Xpect them to work under DOS, though I cannot say how robust they
  7850. Xwould prove to be.
  7851. X
  7852. XSend bug reports/fixes, comments, etc. to -
  7853. X
  7854. XRichard Goerwitz (goer@sophist.uchicago.edu)
  7855. SHAR_EOF
  7856. true || echo 'restore of README failed'
  7857. rm -f _shar_wnt_.tmp
  7858. fi
  7859. # ============= Makefile.dist ==============
  7860. if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
  7861.     echo 'x - skipping Makefile.dist (File already exists)'
  7862.     rm -f _shar_wnt_.tmp
  7863. else
  7864. > _shar_wnt_.tmp
  7865. echo 'x - extracting Makefile.dist (Text)'
  7866. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
  7867. X# Please edit these to reflect your local file structure & conventions.
  7868. XDESTDIR = /usr/local/bin
  7869. XOWNER = bin
  7870. XGROUP = bin
  7871. X
  7872. Xidxtext:
  7873. X    icont idxtext.icn adjuncts.icn
  7874. X
  7875. X# Pessimistic assumptions regarding the environment (in particular,
  7876. X# I don't assume you have the BSD "install" shell script).
  7877. Xinstall: idxtext
  7878. X    @echo "\nInstalling idxtext in $(DESTDIR).\n"
  7879. X    @sh -c "test -d $(DESTDIR) || (mkdir $(DESTDIR) && chmod 755 $(DESTDIR))"
  7880. X    cp idxtext $(DESTDIR)/
  7881. X    chgrp $(GROUP) $(DESTDIR)/idxtext
  7882. X    chown $(OWNER) $(DESTDIR)/idxtext
  7883. X    @echo "\nInstallation done.\n"
  7884. X
  7885. Xclean:
  7886. X    -rm -f *u? *~
  7887. X    -rm -f idxtext test
  7888. SHAR_EOF
  7889. true || echo 'restore of Makefile.dist failed'
  7890. rm -f _shar_wnt_.tmp
  7891. fi
  7892. exit 0
  7893.  
  7894. From ralph  Thu Feb 14 14:03:03 1991
  7895. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  7896.     id AA25824; Thu, 14 Feb 91 14:03:03 -0700
  7897. Date: Thu, 14 Feb 91 14:03:01 MST
  7898. From: "Ralph Griswold" <ralph>
  7899. Message-Id: <9102142103.AA03800@cheltenham.cs.arizona.edu>
  7900. Received: by cheltenham.cs.arizona.edu; Thu, 14 Feb 91 14:03:01 MST
  7901. To: icon-group
  7902. Subject: Icon compiler status report
  7903.  
  7904. We've successfully installed the Icon compiler at our site
  7905. on the following UNIX platforms, using the default C compiler in
  7906. each case:
  7907.  
  7908.     DECstation 3100        Ultrix
  7909.     HP 9000/300        HP/UX
  7910.     Intel 386        System V
  7911.     Iris 4d            System V + BSD extensions
  7912.     NeXT            Mach
  7913.     Sequent Symmetry    Dynix
  7914.     Sun 3            SunOS
  7915.     Sun 4            SunOS
  7916.     VAX 8650        4.3BSD
  7917.     
  7918. We've started beta testing on other platforms at other sites.
  7919.  
  7920. We hope to have a preliminary version of the Icon compiler in
  7921. executable form for these platforms in a few weeks.  We'll
  7922. make source code available later.
  7923.  
  7924. Please direct any questions to me, not icon-group.
  7925.  
  7926.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  7927.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  7928.  
  7929. From ralph  Thu Feb 14 15:21:49 1991
  7930. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  7931.     id AA28553; Thu, 14 Feb 91 15:21:49 -0700
  7932. Date: Thu, 14 Feb 91 15:21:47 MST
  7933. From: "Ralph Griswold" <ralph>
  7934. Message-Id: <9102142221.AA07054@cheltenham.cs.arizona.edu>
  7935. Received: by cheltenham.cs.arizona.edu; Thu, 14 Feb 91 15:21:47 MST
  7936. To: icon-group
  7937. Subject: Icon compiler clarification
  7938.  
  7939. When we use the term "Icon compiler", we're referring to the new
  7940. optimizing compiler for Icon, done by Ken Walker, not the Icon
  7941. interpreter, which has been around for many years.
  7942.  
  7943.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  7944.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  7945.  
  7946. From ralph  Thu Feb 14 15:44:49 1991
  7947. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  7948.     id AA29346; Thu, 14 Feb 91 15:44:49 -0700
  7949. Date: Thu, 14 Feb 91 15:44:47 MST
  7950. From: "Ralph Griswold" <ralph>
  7951. Message-Id: <9102142244.AA07798@cheltenham.cs.arizona.edu>
  7952. Received: by cheltenham.cs.arizona.edu; Thu, 14 Feb 91 15:44:47 MST
  7953. To: icon-group
  7954. Subject: Beta testing for the Icon compiler
  7955.  
  7956. As noted in a recent posting, we're in the process of beta testing for
  7957. the Icon compiler.
  7958.  
  7959. We're looking for individuals to do beta testing on the following UNIX
  7960. platforms:
  7961.  
  7962.     AT&T 3B4000
  7963.     AViiON workstation
  7964.     Convex
  7965.     Cray 2
  7966.     Apollo workstation
  7967.     Elxsi
  7968.     Macintosh under A/UX
  7969.     Encore
  7970.     PS/2 under AIX
  7971.     Pyramid
  7972.     IBM RS6000 workstation
  7973.     VAX-11 under System V
  7974.     VAX-11 under Ultrix
  7975.  
  7976. If you're interested, send me e-mail and I'll tell you what's involved
  7977. and what the conditions are.
  7978.  
  7979. We only have the resources to support one beta-test site for each of the
  7980. above platforms, so we'll accept qualified persons on a first-come,
  7981. first served basis.
  7982.  
  7983. For the same reason, we won't be able to handle beta testing for other
  7984. platforms at present, but if you're interested in beta testing for a system
  7985. that's different from the ones above and the ones listed in the previous
  7986. message, let us know and we'll get back to you later.
  7987.  
  7988. Please send mail to me, not icon-group.
  7989.  
  7990.  
  7991.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  7992.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  7993.  
  7994. From jeff@aiai.edinburgh.ac.uk  Fri Feb 15 10:34:10 1991
  7995. Received: from sun2.nsfnet-relay.ac.uk by megaron.cs.arizona.edu (5.61/15) via SMTP
  7996.     id AA03641; Fri, 15 Feb 91 10:34:10 -0700
  7997. Received: from aiai.edinburgh.ac.uk by sun2.nsfnet-relay.ac.uk via JANET 
  7998.           with NIFTP id <18129-0@sun2.nsfnet-relay.ac.uk>;
  7999.           Fri, 15 Feb 1991 17:20:14 +0000
  8000. Date: Fri, 15 Feb 91 17:19:32 GMT
  8001. Message-Id: <6367.9102151719@subnode.aiai.ed.ac.uk>
  8002. From: Jeff Dalton <jeff@aiai.edinburgh.ac.uk>
  8003. Subject: Re: Icon compiler status report
  8004. To: Ralph Griswold <ralph@cs.arizona.edu>, icon-group@cs.arizona.edu
  8005. In-Reply-To: Ralph Griswold's message of Thu, 14 Feb 91 14:03:01 MST
  8006.  
  8007. > We hope to have a preliminary version of the Icon compiler in
  8008. > executable form for these platforms in a few weeks.  We'll
  8009. > make source code available later.
  8010.  
  8011. One reason I have seldom used Icon is that it is (was?) not interactive
  8012. like Lisp or ML.  Any hope of this changing (or has it already)?
  8013.  
  8014. -- jeff
  8015.  
  8016. From mlfarm!ron@hsi.hsi.com  Tue Feb 19 05:48:49 1991
  8017. Received: from hsi.hsi.com by megaron.cs.arizona.edu (5.61/15) via SMTP
  8018.     id AA02698; Tue, 19 Feb 91 05:48:49 -0700
  8019. Received: by hsi.hsi.com (5.61+++/1.34)
  8020.     id AA25930; Tue, 19 Feb 91 07:46:25 -0500
  8021. Received: by mlfarm.com (smail2.5)
  8022.     id AA11809; 19 Feb 91 06:46:53 EST (Tue)
  8023. To: icon-group@cs.arizona.edu
  8024. Subject: getopt 
  8025. Message-Id: <9102190646.AA11809@mlfarm.com>
  8026. Date: 19 Feb 91 06:46:53 EST (Tue)
  8027. From: mlfarm!ron@hsi.hsi.com (Ronald Florence)
  8028.  
  8029. Has anyone written a getopt-style command-line parser in Icon?  
  8030. --
  8031.  
  8032. Ronald Florence            ron@mlfarm.com
  8033.  
  8034. From ralph  Tue Feb 19 06:11:46 1991
  8035. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  8036.     id AA03313; Tue, 19 Feb 91 06:11:46 -0700
  8037. Date: Tue, 19 Feb 91 06:11:44 MST
  8038. From: "Ralph Griswold" <ralph>
  8039. Message-Id: <9102191311.AA19001@cheltenham.cs.arizona.edu>
  8040. Received: by cheltenham.cs.arizona.edu; Tue, 19 Feb 91 06:11:44 MST
  8041. To: mlfarm!ron@hsi.hsi.com
  8042. Subject: Re:  getopt
  8043. Cc: icon-group
  8044.  
  8045. There's one in the Icon program library (called "options", since it's
  8046. slightly different from getopt).
  8047.  
  8048.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  8049.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  8050.  
  8051. From THEODORE@UAFSYSB.UARK.EDU  Tue Feb 19 13:55:47 1991
  8052. Message-Id: <9102192055.AA21742@megaron.cs.arizona.edu>
  8053. Received: from UAFSYSB.UARK.EDU by megaron.cs.arizona.edu (5.61/15) via SMTP
  8054.     id AA21742; Tue, 19 Feb 91 13:55:47 -0700
  8055. Received: from UAFSYSB.UARK.EDU by UAFSYSB.UARK.EDU (IBM VM SMTP R1.2.2MX) with BSMTP id 4508; Tue, 19 Feb 91 14:54:16 CST
  8056. Received: from UAFSYSB (THEODORE) by UAFSYSB.UARK.EDU (Mailer R2.07) with BSMTP
  8057.  id 7979; Tue, 19 Feb 91 14:54:14 CST
  8058. Date:         Tue, 19 Feb 91 14:34:54 CST
  8059. From: TED PEDERSEN <THEODORE@UAFSYSB.UARK.EDU>
  8060. Subject:      MACHINE TRANSLATION
  8061. To: ICON-GROUP@cs.arizona.edu
  8062. X-Acknowledge-To: <THEODORE@UAFSYSB>
  8063.  
  8064. Is anyone doing any work with machine translation of "human" languages using
  8065. ICON?  (By machine translation I mean taking text and translating it
  8066. into another language. English to Arabic or Russian to German would be
  8067. examples.)
  8068.  
  8069. I am considering embarking on this sort of project and any experiences that
  8070. others have had would be of great value to me. If your experiences are only
  8071. loosely connected with either machine translation or ICON (maybe some
  8072. more general work in natural language processing etc) I would still like
  8073. to establish contact.
  8074.  
  8075. Thanks,
  8076.  
  8077. Ted Pedersen
  8078. Univ. of Arkansas
  8079.  
  8080. From icon-group-request@arizona.edu  Thu Feb 21 04:45:28 1991
  8081. Resent-From: icon-group-request@arizona.edu
  8082. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8083.     id AA06818; Thu, 21 Feb 91 04:45:28 -0700
  8084. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 21 Feb
  8085.  1991 04:44 MST
  8086. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12782; Thu, 21 Feb 91
  8087.  03:42:52 -0800
  8088. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8089.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8090.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8091. Resent-Date: Thu, 21 Feb 1991 04:45 MST
  8092. Date: 20 Feb 91 22:56:22 GMT
  8093. From: mintaka!think.com!zaphod.mps.ohio-state.edu!usc!isi.edu!ata.isi.edu!paulp@bloom-beacon.mit.edu
  8094.  (Paul Postel)
  8095. Subject: support for UDFs in compiler?
  8096. Sender: icon-group-request@arizona.edu
  8097. Resent-To: icon-group@cs.arizona.edu
  8098. To: icon-group@arizona.edu
  8099. Resent-Message-Id: <BF542B75E6600D0F@Arizona.edu>
  8100. Message-Id: <16842@venera.isi.edu>
  8101. X-Envelope-To: icon-group@CS.Arizona.EDU
  8102. X-Vms-To: icon-group@Arizona.edu
  8103. Organization: USC-Information Sciences Institute
  8104.  
  8105.  
  8106.  
  8107. The icon compiler sounds like just what I need to avoid
  8108. optimizing some slow icon software I've written.  However
  8109. my software depends on some functions added to a personalized
  8110. interpreter.  Will the compiler support user defined functions?
  8111.  
  8112. Paul Postel     paulp@isi.edu
  8113. USC/Information Sciences Institute
  8114.  
  8115. From kwalker  Thu Feb 21 13:02:25 1991
  8116. Received: from gacham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  8117.     id AA24903; Thu, 21 Feb 91 13:02:25 -0700
  8118. Date: Thu, 21 Feb 91 13:02:22 MST
  8119. From: "Kenneth Walker" <kwalker>
  8120. Message-Id: <9102212002.AA08638@gacham.cs.arizona.edu>
  8121. Received: by gacham.cs.arizona.edu; Thu, 21 Feb 91 13:02:22 MST
  8122. In-Reply-To: <16842@venera.isi.edu>
  8123. To: icon-group
  8124. Subject: Re:  support for UDFs in compiler?
  8125.  
  8126. > Date: 20 Feb 91 22:56:22 GMT
  8127. > Paul Postel     paulp@isi.edu:
  8128. >   The icon compiler sounds like just what I need to avoid
  8129. >   optimizing some slow icon software I've written.  However
  8130. >   my software depends on some functions added to a personalized
  8131. >   interpreter.  Will the compiler support user defined functions?
  8132.  
  8133. The compiler supports user defined functions. However, interpereter
  8134. functions must be rewritten for use with the compiler.
  8135.  
  8136.   Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  8137.   +1 602 621-4252  kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker
  8138.  
  8139. From R.J.Hare@edinburgh.ac.uk  Mon Feb 25 10:08:11 1991
  8140. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8141.     id AA17831; Mon, 25 Feb 91 10:08:11 -0700
  8142. Received: from UKACRL.BITNET (MAILER@UKACRL) by Arizona.edu with PMDF#10282;
  8143.  Mon, 25 Feb 1991 10:07 MST
  8144. Received: from RL.IB by UKACRL.BITNET (Mailer R2.07) with BSMTP id 8633; Mon,
  8145.  25 Feb 91 16:56:42 GMT
  8146. Received: from RL.IB by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 6247; Mon, 25
  8147.  Feb 91 16:55:47 GMT
  8148. Date: 25 Feb 91  16:53:26 gmt
  8149. From: R.J.Hare@edinburgh.ac.uk
  8150. Subject: Case statement and string scanning
  8151. To: icon-group@cs.arizona.edu
  8152. Message-Id: <25 Feb 91  16:53:26 gmt  060303@EMAS-A>
  8153. X-Envelope-To: icon-group@cs.arizona.edu
  8154. Via:        UK.AC.ED.EMAS-A; 25 FEB 91 16:53:18 GMT
  8155.  
  8156.  
  8157. I have a program in which I repetitively read in a string. According to what
  8158. the string contains, I do a variety of things - set up an option, display a
  8159. file, execute a system command, etc.
  8160.  
  8161. I would like to do this (fairly obviously) in a case statement, but the test I
  8162. am carrying out are so varied that I can't quite see how to fit them into a
  8163. case statement, for example, I will be doing:
  8164.  
  8165. if match("!",string) then...
  8166. if match(";",string) then...
  8167. if find("*",string) then...
  8168. if type(string) == "integer" then...
  8169. ...some default action...
  8170.  
  8171. Any ideas on how I may set this up in a case statement please? Note that
  8172. because a string starts with "!", this does not preclude the possibility of it
  8173. also including a "*" elsewhere, so I guess a series of simple if statements
  8174. won't do the job as in such a circumstance, 2 of the blocks of code would be
  8175. executed...
  8176.  
  8177. I guess that there is a ridiculously simple answer, but I don't see it yet!
  8178.  
  8179. Thanks.
  8180.  
  8181. Roger Hare.
  8182.  
  8183. From wgg@cs.washington.edu  Mon Feb 25 10:52:05 1991
  8184. Received: from june.cs.washington.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  8185.     id AA19206; Mon, 25 Feb 91 10:52:05 -0700
  8186. Received: by june.cs.washington.edu (5.64/7.0jh)
  8187.     id AA08120; Mon, 25 Feb 91 09:46:17 -0800
  8188. Date: Mon, 25 Feb 91 09:46:17 -0800
  8189. From: wgg@cs.washington.edu (William Griswold)
  8190. Return-Path: <wgg@cs.washington.edu>
  8191. Message-Id: <9102251746.AA08120@june.cs.washington.edu>
  8192. To: R.J.Hare@edinburgh.ac.uk, icon-group@cs.arizona.edu
  8193. Subject: Re:  Case statement and string scanning
  8194.  
  8195. To handle more general test/action alternatives, I would put the tests and
  8196. actions in procedures, store them in pairs in a list, and then iterate over
  8197. the tests in the list until success:
  8198.  
  8199. record pair(test,action)
  8200.  
  8201. ...
  8202.  
  8203. procedure bangmatch(str)
  8204.     return match("!",str)
  8205. end
  8206.     
  8207. ...
  8208.  
  8209. procedure main(arglist)
  8210.  
  8211.     case_list := [pair(bangmatch,bangaction),....]
  8212.  
  8213.     ...
  8214.  
  8215.     if (pr := !case_list).test(string) then 
  8216.     pr.action(string)
  8217.  
  8218.     ...
  8219. end
  8220.  
  8221.  
  8222. I'm sure there are more elegant solutions, but you get the idea.
  8223.  
  8224.                     bill
  8225.  
  8226. From icon-group-request@arizona.edu  Tue Feb 26 05:14:48 1991
  8227. Resent-From: icon-group-request@arizona.edu
  8228. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8229.     id AA22594; Tue, 26 Feb 91 05:14:48 -0700
  8230. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Tue, 26 Feb
  8231.  1991 05:14 MST
  8232. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA18264; Tue, 26 Feb 91
  8233.  04:12:23 -0800
  8234. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8235.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8236.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8237. Resent-Date: Tue, 26 Feb 1991 05:14 MST
  8238. Date: 26 Feb 91 08:26:10 GMT
  8239. From: mcsun!cernvax!chx400!chx400!hslrswi!naz@uunet.uu.net (Norman H. Azadian)
  8240. Subject: string indexing peculiarity
  8241. Sender: icon-group-request@arizona.edu
  8242. Resent-To: icon-group@cs.arizona.edu
  8243. To: icon-group@arizona.edu
  8244. Resent-Message-Id: <B14113B45A6018B2@Arizona.edu>
  8245. Message-Id: <1871@hslrswi.hasler.ascom.ch>
  8246. X-Envelope-To: icon-group@CS.Arizona.EDU
  8247. X-Vms-To: icon-group@Arizona.edu
  8248. Organization: Hasler AG
  8249.  
  8250. Recently I found out the hard way about something I consider to be
  8251. an anomaly in string indexing.  I consider it an anomaly  because
  8252. it was, at least for me, totally unexpected.  To wit:
  8253.  
  8254.     s := "-D"
  8255.     x := (s[3:0] | "default")
  8256.  
  8257. "Obviously" accessing the 3rd character in a 2-character string
  8258. should fail and x would get the string "default".  It turns out,
  8259. non-intuitively enough, that I get an empty string, exactly as
  8260. if I had tried s[1:1].
  8261.  
  8262. Thinking about it, I have to admit that it makes a certain amount
  8263. of sense.  In fact, it makes a lot of sense when I think about it.
  8264. However it was totally unexpected and so I thought I'd mention it
  8265. to perhaps help some other hapless soul from falling into the same
  8266. pit.
  8267.  
  8268. NHA
  8269. -- 
  8270. PAPER:  Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
  8271. INTERNET:  naz%hslrswi.uucp@uunet.uu.net
  8272. UUCP:   ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
  8273. VOICE:  +41 31 63 2178            BITNET: naz%hslrswi.UUCP@cernvax.BITNET
  8274.  
  8275. From goer%sophist@gargoyle.uchicago.edu  Tue Feb 26 08:49:36 1991
  8276. Resent-From: goer%sophist@gargoyle.uchicago.edu
  8277. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8278.     id AA06727; Tue, 26 Feb 91 08:49:36 -0700
  8279. Return-Path: goer@sophist.uchicago.edu
  8280. Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Tue, 26
  8281.  Feb 1991 08:47 MST
  8282. Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
  8283.  (4.0/1.14) id AA14715; Tue, 26 Feb 91 09:47:44 CST
  8284. Received: by sophist (4.1/UofC3.1X) id AA09774; Tue, 26 Feb 91 09:50:05 CST
  8285. Resent-Date: Tue, 26 Feb 1991 08:48 MST
  8286. Date: Tue, 26 Feb 91 09:50:05 CST
  8287. From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
  8288. Subject: RE:  string indexing peculiarity
  8289. Resent-To: icon-group@cs.arizona.edu
  8290. To: icon-group@arizona.edu
  8291. Resent-Message-Id: <CF1714D62A601ABC@Arizona.edu>
  8292. Message-Id: <9102261550.AA09774@sophist>
  8293. X-Envelope-To: icon-group@CS.Arizona.EDU
  8294. X-Vms-To: icon-group@Arizona.edu
  8295.  
  8296.     Recently I found out the hard way about something I consider to be
  8297.     an anomaly in string indexing.  I consider it an anomaly  because
  8298.     it was, at least for me, totally unexpected.  To wit:
  8299.  
  8300.         s := "-D"
  8301.         x := (s[3:0] | "default")
  8302.  
  8303.     "Obviously" accessing the 3rd character in a 2-character string
  8304.     should fail and x would get the string "default".  It turns out,
  8305.     non-intuitively enough, that I get an empty string, exactly as
  8306.     if I had tried s[1:1].
  8307.  
  8308. Icon's string indexing methods are definitely non-intuitive for people
  8309. who acquire it as a second, third, etc. language (which means virtually
  8310. everyone).  I guess the idea that people need to catch on to is that
  8311. subscripts deal with string positions, and not the index of characters
  8312. within strings.  What throws people off is that s[3] would work as in
  8313. some other languages (producing the third character in s).  In reality,
  8314. though, this is shorthand in Icon for s[3+:1], i.e. s[3:4].
  8315.  
  8316. Of course, if we want to talk about unintuitive schemes, let's not for-
  8317. get languages where s[0] indexes the _first_ array element in s.
  8318.  
  8319.         s := "-D"
  8320.     s ? { x := move(3) | "default" }
  8321.  
  8322.         s := "-D"
  8323.         s ? { x := (tab(-3), tab(0)) | "default" }
  8324.  
  8325.         s := "-D"
  8326.         x := ("" ~== s[3:0]) | "default"
  8327.  
  8328.  
  8329. -Richard (goer@sophist.uchicago.edu)
  8330.  
  8331. From R.J.Hare@edinburgh.ac.uk  Tue Feb 26 11:39:03 1991
  8332. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8333.     id AA12783; Tue, 26 Feb 91 11:39:03 -0700
  8334. Received: from UKACRL.BITNET (MAILER@UKACRL) by Arizona.edu with PMDF#10282;
  8335.  Tue, 26 Feb 1991 11:37 MST
  8336. Received: from RL.IB by UKACRL.BITNET (Mailer R2.07) with BSMTP id 6819; Tue,
  8337.  26 Feb 91 12:24:31 GMT
  8338. Received: from RL.IB by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 2731; Tue, 26
  8339.  Feb 91 12:24:31 GMT
  8340. Date: 26 Feb 91  12:24:40 gmt
  8341. From: R.J.Hare@edinburgh.ac.uk
  8342. Subject: Case statements and string scanning
  8343. To: icon-group@cs.arizona.edu
  8344. Message-Id: <26 Feb 91  12:24:40 gmt  060488@EMAS-A>
  8345. X-Envelope-To: icon-group@cs.arizona.edu
  8346. Via:        UK.AC.ED.EMAS-A; 26 FEB 91 12:24:28 GMT
  8347.  
  8348.  
  8349. Thanks to those who replied.
  8350.  
  8351. The method involving paired tests and operations seems an intersting idea, I
  8352. shall certainly try it out when I get a chance.
  8353.  
  8354. RGs comments on the use of if statements highlight the 'problem'. If I do
  8355.  
  8356. if expr1 then ...
  8357. if expr2 then ...
  8358. if expr3 then ...
  8359.  
  8360. obviously with varied 'expr's, I could have more than one block of code being
  8361. executed when I only want one. The alternative:
  8362.  
  8363. if expr1
  8364. then ...
  8365. else if expr2
  8366.      then ...
  8367.      else if expr3
  8368.           then ...
  8369.           else ...
  8370.  
  8371. is fine but awful hard to read (which is the part I am unhappy about). What is
  8372. really needed is something like the Fortran ELSEIF construct:
  8373.  
  8374. IF (test1) THEN
  8375.   .
  8376. ELSEIF (test2) THEN
  8377.   .
  8378. ELSEIF (test3) THEN
  8379.   .
  8380. ELSE
  8381.   .
  8382. ENDIF
  8383.  
  8384. which is only a case statement with a different hat on.
  8385.  
  8386. Is there such a thing in Icon (ie: have I missed it?). Should there be?
  8387.  
  8388. Roger Hare.
  8389.  
  8390. From wgg@cs.washington.edu  Tue Feb 26 12:14:07 1991
  8391. Received: from june.cs.washington.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  8392.     id AA14080; Tue, 26 Feb 91 12:14:07 -0700
  8393. Received: by june.cs.washington.edu (5.64/7.0jh)
  8394.     id AA04472; Tue, 26 Feb 91 11:11:27 -0800
  8395. Date: Tue, 26 Feb 91 11:11:27 -0800
  8396. From: wgg@cs.washington.edu (William Griswold)
  8397. Return-Path: <wgg@cs.washington.edu>
  8398. Message-Id: <9102261911.AA04472@june.cs.washington.edu>
  8399. To: R.J.Hare@edinburgh.ac.uk, icon-group@cs.arizona.edu
  8400. Subject: Re:  Case statements and string scanning
  8401.  
  8402. No, there is no ELSEIF in Icon.  However, I indent my IF THEN ELSE's
  8403. differently to allow a more tabular appearance:
  8404.  
  8405. if t1 then
  8406.    e1
  8407. else if t2 then
  8408.    e2
  8409. else if t3 then
  8410.    e3
  8411. else
  8412.    e4
  8413.  
  8414. I don't find this confusing to interpret at all.
  8415.  
  8416.                     bill
  8417.  
  8418. From @um.cc.umich.edu:Paul_Abrahams@MTS.cc.Wayne.edu  Tue Feb 26 13:41:31 1991
  8419. Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  8420.     id AA16808; Tue, 26 Feb 91 13:41:31 -0700
  8421. Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
  8422.     id AA15072; Tue, 26 Feb 91 15:40:08 -0500
  8423. Received: from MTS.cc.Wayne.edu by um.cc.umich.edu via MTS-Net; Tue, 26 Feb 91 15:37:36 EST
  8424. Date: Tue, 26 Feb 91 15:37:36 EST
  8425. From: Paul_Abrahams@MTS.cc.Wayne.edu
  8426. To: icon-group@cs.arizona.edu
  8427. Message-Id: <301677@MTS.cc.Wayne.edu>
  8428. Subject: String indexing
  8429.  
  8430. In my design of SPLASH I've used the Icon approach to string indexing
  8431. virtually unchanged.  Imitation is the sincerest form of flattery.
  8432.  
  8433. Paul Abrahams
  8434.  
  8435. From icon-group-request@arizona.edu  Fri Mar  1 16:07:52 1991
  8436. Resent-From: icon-group-request@arizona.edu
  8437. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8438.     id AA08978; Fri, 1 Mar 91 16:07:52 -0700
  8439. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 1 Mar
  8440.  1991 16:07 MST
  8441. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA26804; Fri, 1 Mar 91 14:57:01
  8442.  -0800
  8443. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8444.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8445.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8446. Resent-Date: Fri, 1 Mar 1991 16:07 MST
  8447. Date: 1 Mar 91 21:56:12 GMT
  8448. From: meaddata!pulse@uunet.uu.net (Tom Hesley)
  8449. Subject: Computer Language Books  FOR SALE ! ! !
  8450. Sender: icon-group-request@arizona.edu
  8451. Resent-To: icon-group@cs.arizona.edu
  8452. To: icon-group@arizona.edu
  8453. Resent-Message-Id: <67FB79C6D2603215@Arizona.edu>
  8454. Message-Id: <3118@meaddata.meaddata.com>
  8455. X-Envelope-To: icon-group@CS.Arizona.EDU
  8456. X-Vms-To: icon-group@Arizona.edu
  8457. Organization: Mead Data Central, Dayton OH
  8458.  
  8459. Got some computer language books for sale.  They are:
  8460.  
  8461. SCRIBE Pocket Reference        UnuLogic        $1
  8462.  
  8463. Programming in Prolog        W. F. Clocksin
  8464.                 C. S. Mellish        $15
  8465.  
  8466. PostScript Language Reference    Adobe Systems Inc.    $15
  8467.     Manual
  8468. (Includes detailed programming information on the Laserwriter)
  8469.  
  8470.  
  8471. PostScript Language Tutorial and Cookbook        $15
  8472.                 Adobe Systems Inc.
  8473.  
  8474. PostScript Language Program Design            $15
  8475.                 Adobe Systems Inc.
  8476.  
  8477. Modula 2 Discipline and Design    Arthur Sale        $10
  8478.  
  8479. Icon Programming Language    Ralph Griswold        $10
  8480.                 Madge T. Griswold
  8481.  
  8482. Ada -- An Advanced Introduction    Narain Gehani        $10
  8483.  
  8484. Structured FORTRAN 77 for Engineers and Scientists    $10
  8485.                 D. M. Etter
  8486.  
  8487. FORTRAN 77            Loren P. Meissner    $5
  8488.                 Elliot I. Organick
  8489.  
  8490. Computer Organization and Programming for the VAX-11    $10
  8491.     (VAX Assembler)        Souhail El-Asfouri
  8492.                 Olin Johnson
  8493.                 Willis K. King
  8494.  
  8495. VAX-11 Assembly Language Programming            $10
  8496.                 Sarah Baase
  8497.  
  8498. An Introduction to Numerical Methods with Pascal    $10
  8499.                 L. V. Atkinson
  8500.                 P. J. Harley
  8501.  
  8502. Will listen to package deals.  You pay shipping and COD charges.
  8503. Will only ship COD.
  8504. --
  8505. Tom Hesley                Opinions expressed within              (513) 865-7053 
  8506. Mead Data Central            are my own and not             Systems Development
  8507. P.O. Box 933                necessarily those of             pulse@meaddata.com
  8508. Dayton, Ohio  45401          Mead Data Central         ...!uunet!meaddata!pulse
  8509.  
  8510. From uunet!men2a!aquin!luvthang!talmage  Fri Mar  1 16:39:50 1991
  8511. Received: from univers.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  8512.     id AA09912; Fri, 1 Mar 91 16:39:50 -0700
  8513. Received: from uunet.UUCP by univers.cs.arizona.edu; Fri, 1 Mar 91 16:39:48 MST
  8514. Received: from men2a.UUCP by uunet.UU.NET with UUCP 
  8515.     (5.61/UUNET-primary-gateway) id AA29953; Wed, 27 Feb 91 13:06:09 -0500
  8516. Received: by men2a.ori-cal.com (smail2.5)
  8517.     id AA01645; 27 Feb 91 12:09:53 EST (Wed)
  8518. Received: by aquin.uucp (smail2.5)
  8519.     id AA18151; 27 Feb 91 13:01:54 EST (Wed)
  8520. Received: by luvthang.aquin.ori-cal.com (1.05D/Amiga)
  8521.     id AA01743; Wed, 27 Feb 91 07:47:12 EST
  8522. Date: Wed, 27 Feb 91 07:47:12 EST
  8523. Message-Id: <9102271247.AA01743@luvthang.aquin.ori-cal.com>
  8524. From: uunet!luvthang.aquin.ori-cal.com!talmage (David W. Talmage)
  8525. To: arizona!icon-group
  8526. Subject: Re: Case statements and string scanning
  8527.  
  8528.  
  8529. :is fine but awful hard to read (which is the part I am unhappy about). What is
  8530. :really needed is something like the Fortran ELSEIF construct:
  8531. :IF (test1) THEN
  8532. :  .
  8533. :ELSEIF (test2) THEN
  8534. :  .
  8535. :ELSEIF (test3) THEN
  8536. :  .
  8537. :ELSE
  8538. :  .
  8539. :ENDIF
  8540. :which is only a case statement with a different hat on.
  8541.  
  8542. How about using ipp, the Icon Pre-Processor that comes with the Icon
  8543. Program Library?  You could do something like this:
  8544.  
  8545. $define IF(x) if x
  8546. $define THEN {
  8547. $define ELSEIF(x) } else if (x) {
  8548. $define ELSE } {
  8549. $define ENDIF }
  8550.  
  8551. IF (test1) THEN
  8552.     .
  8553. ELSEIF (test2) THEN
  8554.     .
  8555. ELSEIF (test3) THEN
  8556.     .
  8557. ELSE
  8558.     .
  8559. ENDIF
  8560. -----------------------------------------------------------------------------
  8561. David W. Talmage (talmage@luvthang.aquin.ori-cal.com)
  8562. "I need fifty dollars to make you hollar.  I get paid to run this luvthang."
  8563.  
  8564. From icon-group-request@arizona.edu  Sat Mar  2 17:02:42 1991
  8565. Resent-From: icon-group-request@arizona.edu
  8566. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8567.     id AA24724; Sat, 2 Mar 91 17:02:42 -0700
  8568. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 2 Mar
  8569.  1991 17:02 MST
  8570. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA07046; Sat, 2 Mar 91 15:55:42
  8571.  -0800
  8572. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8573.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8574.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8575. Resent-Date: Sat, 2 Mar 1991 17:02 MST
  8576. Date: 2 Mar 91 17:50:36 GMT
  8577. From: pyramid!tekbspa!yost@hplabs.hpl.hp.com (Dave Yost)
  8578. Subject: ideas from the icon language applied to scheme
  8579. Sender: icon-group-request@arizona.edu
  8580. Resent-To: icon-group@cs.arizona.edu
  8581. To: icon-group@arizona.edu
  8582. Resent-Message-Id: <38CDC78D4260351A@Arizona.edu>
  8583. Message-Id: <1991Mar2.175036.24463@tss.com>
  8584. X-Envelope-To: icon-group@CS.Arizona.EDU
  8585. X-Vms-To: icon-group@Arizona.edu
  8586. Organization: Teknekron Software Systems, Inc.
  8587.  
  8588. Has anyone implemented any of icon's great features in scheme?
  8589. Seems to me to be a reasonable idea.
  8590.  
  8591.  --dave yost
  8592.  
  8593. From icon-group-request@arizona.edu  Sat Mar  2 21:02:37 1991
  8594. Resent-From: icon-group-request@arizona.edu
  8595. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8596.     id AA00236; Sat, 2 Mar 91 21:02:37 -0700
  8597. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 2 Mar
  8598.  1991 21:02 MST
  8599. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA16467; Sat, 2 Mar 91 19:51:22
  8600.  -0800
  8601. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8602.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8603.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8604. Resent-Date: Sat, 2 Mar 1991 21:02 MST
  8605. Date: 3 Mar 91 01:39:12 GMT
  8606. From: midway!ellis.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
  8607. Subject: RE: ideas from the icon language applied to scheme
  8608. Sender: icon-group-request@arizona.edu
  8609. Resent-To: icon-group@cs.arizona.edu
  8610. To: icon-group@arizona.edu
  8611. Resent-Message-Id: <5A5413453260272C@Arizona.edu>
  8612. Message-Id: <1991Mar3.013912.14857@midway.uchicago.edu>
  8613. X-Envelope-To: icon-group@CS.Arizona.EDU
  8614. X-Vms-To: icon-group@Arizona.edu
  8615. Organization: University of Chicago
  8616. References: <1991Mar2.175036.24463@tss.com>
  8617.  
  8618. Regarding Dave Yost's question about implementing Iconish features in
  8619. Scheme:
  8620.  
  8621. It's hard to respond to such a question without knowing what you have
  8622. in mind.  For instance, if you are interested in backtracking,
  8623. then I doubt you could move the Icon mechanisms to Scheme, with all
  8624. its limitation expressions, goal-directed evaluation, and what not.
  8625. String scanning is a bit less difficult.  At some point, though, I'd
  8626. begin to wonder whether it was easier just to cut Icon code.
  8627.  
  8628. What is it about Scheme in particular that make it a more attractive
  8629. basis for your intended application?  Just curious.
  8630.  
  8631. -Richard
  8632.  
  8633. From icon-group-request@arizona.edu  Sat Mar  2 22:18:04 1991
  8634. Resent-From: icon-group-request@arizona.edu
  8635. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8636.     id AA02027; Sat, 2 Mar 91 22:18:04 -0700
  8637. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 2 Mar
  8638.  1991 22:17 MST
  8639. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA17819; Sat, 2 Mar 91 21:05:25
  8640.  -0800
  8641. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8642.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8643.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8644. Resent-Date: Sat, 2 Mar 1991 22:17 MST
  8645. Date: 3 Mar 91 04:44:47 GMT
  8646. From: magnus.ircc.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!ut-emx!ccwf.cc.utexas.edu@tut.cis.ohio-state.edu (David Boles)
  8647. Subject: MIT scheme on Silicon Graphics
  8648. Sender: icon-group-request@arizona.edu
  8649. Resent-To: icon-group@cs.arizona.edu
  8650. To: icon-group@arizona.edu
  8651. Resent-Message-Id: <64DAB9228260343D@Arizona.edu>
  8652. Message-Id: <44998@ut-emx.uucp>
  8653. X-Envelope-To: icon-group@CS.Arizona.EDU
  8654. X-Vms-To: icon-group@Arizona.edu
  8655. Organization: The University of Texas at Austin
  8656. References: <1991Mar2.175036.24463@tss.com>,
  8657.  <1991Mar3.013912.14857@midway.uchicago.edu>
  8658.  
  8659. Has anyone out there put MIT Scheme on a Silicon Graphics machine (4D)?
  8660. I just got a 4D/310 and it will be my prime computing resource for
  8661. the next year or so; I'm interested in putting the environment on it.
  8662.  
  8663. Any help is welcome.
  8664.  
  8665. Note: I haven't tried it yet, but the distribution doesn't mention
  8666. SGI machines at all.
  8667.  
  8668. David Boles
  8669. apas611@hermes.chpc.utexas.edu
  8670.  
  8671. -- 
  8672. -------------------------------------------------------------------------------
  8673. David Boles                                       Applied Research Laboratories
  8674. dboles@ccwf.cc.utexas.edu                        DOS is severely brain-damaged,
  8675. apas611@chpc.utexas.edu                   so just pull the plug and let it DIE.
  8676. -------------------------------------------------------------------------------
  8677.  
  8678. From icon-group-request@arizona.edu  Mon Mar  4 15:07:04 1991
  8679. Resent-From: icon-group-request@arizona.edu
  8680. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8681.     id AA18662; Mon, 4 Mar 91 15:07:04 -0700
  8682. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 4 Mar
  8683.  1991 15:06 MST
  8684. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA10200; Mon, 4 Mar 91 13:58:57
  8685.  -0800
  8686. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8687.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8688.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8689. Resent-Date: Mon, 4 Mar 1991 15:06 MST
  8690. Date: 4 Mar 91 18:58:19 GMT
  8691. From: tekbspa!tss.com!yost@uunet.uu.net (Dave Yost)
  8692. Subject: RE: ideas from the icon language applied to scheme
  8693. Sender: icon-group-request@arizona.edu
  8694. Resent-To: icon-group@cs.arizona.edu
  8695. To: icon-group@arizona.edu
  8696. Resent-Message-Id: <BAFC46AF6260372E@Arizona.edu>
  8697. Message-Id: <1991Mar4.185819.19587@tss.com>
  8698. X-Envelope-To: icon-group@CS.Arizona.EDU
  8699. X-Vms-To: icon-group@Arizona.edu
  8700. Organization: Teknekron Software Systems, Inc.
  8701. References: <1991Mar2.175036.24463@tss.com>,
  8702.  <1991Mar3.013912.14857@midway.uchicago.edu>
  8703.  
  8704. In article <1991Mar3.013912.14857@midway.uchicago.edu>, goer@ellis.uchicago.edu (Richard L. Goerwitz) writes:
  8705. |> What is it about Scheme in particular that make it a more attractive
  8706. |> basis for your intended application?  Just curious.
  8707.  
  8708. * The fact that it can execute a string containing source code.
  8709. * The fact there are scheme implementations that seem to be more
  8710.   easily assimilated into a C environment.
  8711.  
  8712. Also, I'm learning scheme partly just because I'm interested in it
  8713. and because I'm reading the Abelson & Sussman(s) book.
  8714. I'd rather use Icon-style expression evaluation, and it seemed
  8715. that scheme could easily accomodate that.
  8716.  
  8717.  --dave yost
  8718.  
  8719. From icon-group-request@arizona.edu  Mon Mar  4 16:40:21 1991
  8720. Resent-From: icon-group-request@arizona.edu
  8721. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8722.     id AA22239; Mon, 4 Mar 91 16:40:21 -0700
  8723. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 4 Mar
  8724.  1991 16:39 MST
  8725. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12920; Mon, 4 Mar 91 15:31:51
  8726.  -0800
  8727. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8728.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8729.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8730. Resent-Date: Mon, 4 Mar 1991 16:40 MST
  8731. Date: 4 Mar 91 22:57:07 GMT
  8732. From: sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!ellis.uchicago.edu!goer@ucsd.edu (Richard
  8733.  L. Goerwitz)
  8734. Subject: RE: ideas from the icon language applied to scheme
  8735. Sender: icon-group-request@arizona.edu
  8736. Resent-To: icon-group@cs.arizona.edu
  8737. To: icon-group@arizona.edu
  8738. Resent-Message-Id: <C8057EFE426035C3@Arizona.edu>
  8739. Message-Id: <1991Mar4.225707.12864@midway.uchicago.edu>
  8740. X-Envelope-To: icon-group@CS.Arizona.EDU
  8741. X-Vms-To: icon-group@Arizona.edu
  8742. Organization: University of Chicago
  8743. References: <1991Mar2.175036.24463@tss.com>,
  8744.  <1991Mar3.013912.14857@midway.uchicago.edu>, <1991Mar4.185819.19587@tss.com>
  8745.  
  8746. In article <1991Mar4.185819.19587@tss.com> yost@tss.COM writes:
  8747. >|> What is it about Scheme in particular that make it a more attractive
  8748. >|> basis for your intended application?  Just curious.
  8749. >
  8750. >* The fact that it can execute a string containing source code.
  8751. >* The fact there are scheme implementations that seem to be more
  8752. >  easily assimilated into a C environment.
  8753.  
  8754. The fact that Icon isn't interpreted per se does get in the way of
  8755. Icon code executing code.  Everything has to be compiled, either
  8756. into an icode file (geared for a virtual machine implemented by an
  8757. interpreter) or else into C code (as with Ken Walker's compiler).
  8758. As if the Icon Project didn't have enough to do already, it might
  8759. be nice to have an Icon interpreter (in the interactive, rather
  8760. than "virtual machine" sense).
  8761.  
  8762. I guess, though, that the fundamental code/data unity of Lisp and
  8763. Prolog really isn't part of the Icon paradigm (although you can
  8764. get some of the same functionality by judicious application of the
  8765. IPL codeobj procedure).
  8766.  
  8767. The C <-> Icon interoperability issue is interesting.  You can create
  8768. personalized interpreters and translators, if you simply want addi-
  8769. tional built-in functions.  If it's access to C functions that you
  8770. want, you can use the callout() function, which lets you call C
  8771. functions from Icon.  With the compiler, it's even easier to call
  8772. C code, although I don't think the technical document explaining
  8773. precisely how has been put online yet.
  8774.  
  8775. I'd say that the major disadvantage to using Icon code is that the
  8776. programmer is completely hamstrung when it comes to low-level inter-
  8777. action with the operating system.  Icon is meant to be very, very
  8778. portable, and it's counter to the spirit of its implementation to,
  8779. say, give you, a fork(), wait(), and exec().  You can get these
  8780. via callout(), I guess.  But it would not be elegant.  The compiler
  8781. should rectify this, though, since it allows you to add C code in-
  8782. line.
  8783.  
  8784. If you knew about all of this callout() (interpreter) and inline
  8785. (compiler) stuff, then I apologize.  I figure there are others out
  8786. there asking the same sorts of questions, though, and that it is
  8787. worth posting a reply.  It's also worth reminding people about some
  8788. of the many gems included in the IPL (the adjunct library that
  8789. comes with the full Icon distribution).  Codeobj is one of them.
  8790.  
  8791. -Richard
  8792.  
  8793. From cjeffery  Mon Mar  4 17:16:35 1991
  8794. Resent-From: "Clinton Jeffery" <cjeffery>
  8795. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8796.     id AA23771; Mon, 4 Mar 91 17:16:35 -0700
  8797. Received: from megaron.cs.arizona.edu (128.196.128.118) by Arizona.edu with
  8798.  PMDF#10282; Mon, 4 Mar 1991 17:16 MST
  8799. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15)
  8800.  via SMTP id AA23750; Mon, 4 Mar 91 17:16:01 -0700
  8801. Received: by cheltenham.cs.arizona.edu; Mon, 4 Mar 91 17:15:59 MST
  8802. Resent-Date: Mon, 4 Mar 1991 17:16 MST
  8803. Date: Mon, 4 Mar 91 17:15:59 MST
  8804. From: Clinton Jeffery <cjeffery@cs.arizona.edu>
  8805. Subject: ideas from the icon language applied to scheme
  8806. In-Reply-To: Richard L. Goerwitz's message of 4 Mar 91 22:57:07 GMT
  8807.  <1991Mar4.225707.12864@midway.uchicago.edu>
  8808. Resent-To: icon-group@cs.arizona.edu
  8809. To: icon-group@arizona.edu
  8810. Resent-Message-Id: <CD1617DB526035A9@Arizona.edu>
  8811. Message-Id: <9103050015.AA21315@cheltenham.cs.arizona.edu>
  8812. X-Envelope-To: icon-group@CS.Arizona.EDU
  8813. X-Vms-To: icon-group@Arizona.edu
  8814.  
  8815. >In response to people comparing Scheme and Icon, Richard notes that:
  8816. >The fact that Icon isn't interpreted per se does get in the way of
  8817. >Icon code executing code.
  8818.  
  8819. Icon's virtual machine architecture does not rule out a true
  8820. interpreter.  For instance, most implementations of the SmallTalk
  8821. language use a virtual machine, but the SmallTalk environment comes
  8822. with an interpreter.  A SmallTalk guru could provide some useful
  8823. suggestions in this discussion, I think.
  8824.  
  8825. A by-product of my own research this year is a "multi-program interpreter",
  8826. a version of iconx that allows mulitple icon programs to be loaded into a
  8827. single execution of the virtual machine.  This would allow further
  8828. improvements to the kind of "Icon interpreter written in Icon" programs
  8829. that were posted last year by various members of this group.
  8830.  
  8831. From DSMOLARSKI@SCUACC.SCU.EDU  Mon Mar  4 18:05:02 1991
  8832. Received: from SCUACC.SCU.EDU by megaron.cs.arizona.edu (5.61/15) via SMTP
  8833.     id AA25361; Mon, 4 Mar 91 18:05:02 -0700
  8834. Date: Mon, 4 Mar 1991 17:02 PST
  8835. From: "Dennis C. Smolarski, S.J." <DSMOLARSKI@SCUACC.SCU.EDU>
  8836. Subject: icon on VMS 5.4
  8837. To: icon-group@cs.arizona.edu
  8838. Message-Id: <CB30F5C080004161@SCU.BITNET>
  8839. X-Envelope-To: icon-group@cs.arizona.edu
  8840. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  8841.  
  8842. Has anyone installed the VMS backup version of ICON on a VAX running
  8843. VMS 5.4?
  8844.  
  8845. The scripts for correcting an FTP'd file don't quite work with VMS 5.4.
  8846.  
  8847. Thanks for any suggestions.
  8848.  
  8849. Dennis Smolarski
  8850. Santa Clara University
  8851. Dept. of Mathematics
  8852. Santa Clara CA
  8853.  
  8854. DSMOLARSKI@SCU.BITNET
  8855.  
  8856. From gmt  Mon Mar  4 18:55:09 1991
  8857. Received: from owl.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  8858.     id AA26889; Mon, 4 Mar 91 18:55:09 -0700
  8859. Date: Mon, 4 Mar 91 18:55:05 MST
  8860. From: "Gregg Townsend" <gmt>
  8861. Message-Id: <9103050155.AA14246@owl.cs.arizona.edu>
  8862. Received: by owl.cs.arizona.edu; Mon, 4 Mar 91 18:55:05 MST
  8863. To: icon-group
  8864. Subject: Re: icon on VMS 5.4
  8865.  
  8866. As far as I know the VMSFIX script works under VMS 5.4, though until very
  8867. recently the comments were misleading and implied that it wouldn't.
  8868. Did you actually try it, or did you just believe what it told you :-) ?
  8869.  
  8870. It does need a big file quota, bigger than I have at the moment, so when I
  8871. retested it just now (VMS V5.4-1) I had to test with a different BACKUP file.
  8872.  
  8873.     Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  8874.     +1 602 621 4325     gmt@cs.arizona.edu     110 57 16 W / 32 13 45 N / +758m
  8875.  
  8876. From TENAGLIA@mis3.mis.mcw.edu  Tue Mar  5 17:51:42 1991
  8877. Received: from mis3.mis.mcw.edu ([141.106.64.13]) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8878.     id AA21376; Tue, 5 Mar 91 17:51:42 -0700
  8879. Date: Tue, 5 Mar 1991 18:51 CST
  8880. From: Chris Tenaglia - 257-8765 <TENAGLIA@mis3.mis.mcw.edu>
  8881. Subject: Re: icon on VMS 5.4
  8882. To: DSMOLARSKI@SCUACC.SCU.EDU
  8883. Cc: icon-group@cs.arizona.edu
  8884. Message-Id: <A39A02D1C0602DC2@mis3.mis.mcw.edu>
  8885. X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
  8886. X-Vms-To: IN%"DSMOLARSKI@SCUACC.SCU.EDU"
  8887. X-Vms-Cc: IN%"icon-group@cs.arizona.edu"
  8888.  
  8889. Regarding:    icon on VMS 5.4
  8890.  
  8891.  
  8892. > Has anyone installed the VMS backup version of ICON on a VAX running
  8893. > VMS 5.4?
  8894.  
  8895. > The scripts for correcting an FTP'd file don't quite work with VMS 5.4.
  8896.  
  8897. > Thanks for any suggestions.
  8898.  
  8899. > Dennis Smolarski
  8900. > Santa Clara University
  8901. > Dept. of Mathematics
  8902. > Santa Clara CA
  8903.  
  8904. > DSMOLARSKI@SCU.BITNET
  8905.  
  8906. I have icon running quite well under VMS 5.4 on a microvax 3100. I happen
  8907. to have it on mag tape. For FTPing the saveset, a lot depends on the TCP/IP
  8908. package running under VMS. We have CMU/TEK and TGV MULTINET and the FTP
  8909. has a file type command used to pass VMS specific information. I believe
  8910. the command is TYPE IMAGE (MULTINET) or SET TYPE IMAGE (CMU/TEK) will work
  8911. from the FTP> prompt. I haven't actually tried the ICON saveset, but I've
  8912. used it successfully between my hosts.
  8913.  
  8914. Chris Tenaglia (System Manager) | Medical College of Wisconsin
  8915. 8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  8916. (414)257-8765                   | tenaglia@mis.mcw.edu, mcwmis!tenaglia
  8917.  
  8918.  
  8919. From icon-group-request@arizona.edu  Wed Mar  6 08:22:33 1991
  8920. Resent-From: icon-group-request@arizona.edu
  8921. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8922.     id AA17602; Wed, 6 Mar 91 08:22:33 -0700
  8923. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 6 Mar
  8924.  1991 08:21 MST
  8925. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA28369; Wed, 6 Mar 91 07:12:05
  8926.  -0800
  8927. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8928.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8929.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8930. Resent-Date: Wed, 6 Mar 1991 08:22 MST
  8931. Date: 5 Mar 91 12:32:24 GMT
  8932. From: mcsun!ukc!mucs!m1!bevan@uunet.uu.net (Stephen J Bevan)
  8933. Subject: Which to use :- Perl, Python, Icon, ... ?
  8934. Sender: icon-group-request@arizona.edu
  8935. Resent-To: icon-group@cs.arizona.edu
  8936. To: icon-group@arizona.edu
  8937. Resent-Message-Id: <14CCAB6C4260463E@Arizona.edu>
  8938. Message-Id: <BEVAN.91Mar5123224@tiger.cs.man.ac.uk>
  8939. X-Envelope-To: icon-group@CS.Arizona.EDU
  8940. X-Vms-To: icon-group@Arizona.edu
  8941. Organization: Department of Computer Science, University of Manchester
  8942.  
  8943. In the past I've written various programs to extract information from
  8944. files.  To do this I've used :- Common Lisp, Emacs Lisp, awk, sh, ksh
  8945. and csh.  As this is a bit of nightmare as regards maintenance, I'd
  8946. like to move to a single language for doing these sort of tasks.  The
  8947. likely contenders for this seem to be Perl, Python and Icon.
  8948.  
  8949. Rather than FTP all of them and wade through the documentation, I was
  8950. wondering if anybody has experiences with them that they'd like to
  8951. share?
  8952. I'm particularly interested in comments from people who have used (or
  8953. at least looked at) more than one of them.
  8954.  
  8955. As a guide to the sort of things I'm interested in :-
  8956.  
  8957.   + Does the language have any arbitrary limits? e.g. the length of a
  8958.     line ... etc.
  8959.  
  8960.   + How fast is it?  This can be compared to whatever you like, but each
  8961.     other preferably.  I'm not really interested if XXX is only, X%
  8962.     quicker than YYY on average (whatever that maybe).
  8963.  
  8964.   + Does it give `reasonable' error messages?  i.e. something better
  8965.     than the equivalent of `awk bailing out on line X'.
  8966.  
  8967.   + Does it have a debugger?  If not, are there any extra facilities
  8968.     for debuggging above and beyond simply inserting `printf' (change
  8969.     as appropriate) statements.
  8970.  
  8971.   + Does it allow conditional interpretation/compilation? i.e.
  8972.     anything like +FEATURE in Lisp or #ifdef FEATURE/#endif in C.
  8973.  
  8974. Some other points to note :-
  8975.  
  8976.   + The scripts won't be distributed, so arguments about XXX is
  8977.     installed on more machines than YYY aren't relevant.
  8978.  
  8979.   + The fact that Perl has a C like syntax is NOT an advantage in my
  8980.     book.  (I'm not saying its a disadvantage either, I just don't
  8981.     think it's important either way).
  8982.  
  8983. email/post as you think is appropriate (note the followup to
  8984. comp.lang.misc).  I will summarize email replies after a suitable period. 
  8985.  
  8986. Thanks in advance,
  8987.  
  8988. Stephen J. Bevan        bevan@cs.man.ac.uk
  8989.  
  8990. From icon-group-request@arizona.edu  Thu Mar  7 09:31:55 1991
  8991. Resent-From: icon-group-request@arizona.edu
  8992. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  8993.     id AA00600; Thu, 7 Mar 91 09:31:55 -0700
  8994. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 7 Mar
  8995.  1991 09:31 MST
  8996. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA08815; Thu, 7 Mar 91 08:24:18
  8997.  -0800
  8998. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8999.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9000.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9001. Resent-Date: Thu, 7 Mar 1991 09:31 MST
  9002. Date: 7 Mar 91 15:47:13 GMT
  9003. From: acf5!mitsolid@nyu.edu (Thanasis Mitsolides)
  9004. Subject: A
  9005. Sender: icon-group-request@arizona.edu
  9006. Resent-To: icon-group@cs.arizona.edu
  9007. To: icon-group@arizona.edu
  9008. Resent-Message-Id: <E7A8EB5CB2604B3E@Arizona.edu>
  9009. Message-Id: <1532@acf5.NYU.EDU>
  9010. X-Envelope-To: icon-group@CS.Arizona.EDU
  9011. X-Vms-To: icon-group@Arizona.edu
  9012. Organization: New York University
  9013.  
  9014. A
  9015.  
  9016.  
  9017.  
  9018. -- 
  9019. -------------------------------------------------------------------------------
  9020. Internet: mitsolid@cs.nyu.edu                 (mitsolid%cs.nyu.edu@relay.cs.net)
  9021. UUCP    : ...!uunet!cmcl2!cs!mitsolid
  9022. -------------------------------------------------------------------------------
  9023.  
  9024. From icon-group-request@arizona.edu  Thu Mar  7 09:32:10 1991
  9025. Resent-From: icon-group-request@arizona.edu
  9026. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9027.     id AA00619; Thu, 7 Mar 91 09:32:10 -0700
  9028. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 7 Mar
  9029.  1991 09:31 MST
  9030. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA08826; Thu, 7 Mar 91 08:24:33
  9031.  -0800
  9032. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9033.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9034.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9035. Resent-Date: Thu, 7 Mar 1991 09:31 MST
  9036. Date: 7 Mar 91 15:54:45 GMT
  9037. From: acf5!mitsolid@nyu.edu (Thanasis Mitsolides)
  9038. Subject: A
  9039. Sender: icon-group-request@arizona.edu
  9040. Resent-To: icon-group@cs.arizona.edu
  9041. To: icon-group@arizona.edu
  9042. Resent-Message-Id: <E7B2742872603B3F@Arizona.edu>
  9043. Message-Id: <1535@acf5.NYU.EDU>
  9044. X-Envelope-To: icon-group@CS.Arizona.EDU
  9045. X-Vms-To: icon-group@Arizona.edu
  9046. Organization: New York University
  9047.  
  9048. cd
  9049.  
  9050. -- 
  9051. -------------------------------------------------------------------------------
  9052. Internet: mitsolid@cs.nyu.edu                 (mitsolid%cs.nyu.edu@relay.cs.net)
  9053. UUCP    : ...!uunet!cmcl2!cs!mitsolid
  9054. -------------------------------------------------------------------------------
  9055.  
  9056. From icon-group-request@arizona.edu  Thu Mar  7 18:18:18 1991
  9057. Resent-From: icon-group-request@arizona.edu
  9058. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9059.     id AA28844; Thu, 7 Mar 91 18:18:18 -0700
  9060. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 7 Mar
  9061.  1991 18:16 MST
  9062. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA25123; Thu, 7 Mar 91 17:04:40
  9063.  -0800
  9064. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9065.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9066.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9067. Resent-Date: Thu, 7 Mar 1991 18:17 MST
  9068. Date: 8 Mar 91 00:58:52 GMT
  9069. From: iris!williamh@ucdavis.ucdavis.edu (Heather Blanchard)
  9070. Subject: RE: ideas from the icon language applied to scheme
  9071. Sender: icon-group-request@arizona.edu
  9072. Resent-To: icon-group@cs.arizona.edu
  9073. To: icon-group@arizona.edu
  9074. Resent-Message-Id: <3127F7E392604513@Arizona.edu>
  9075. Message-Id: <8507@ucdavis.ucdavis.edu>
  9076. X-Envelope-To: icon-group@CS.Arizona.EDU
  9077. X-Vms-To: icon-group@Arizona.edu
  9078. Organization: U.C. Davis - Dept. of Electrical Engineering and Computer Science
  9079.  
  9080. In article <1991Mar4.225707.12864@midway.uchicago.edu> goer@ellis.uchicago.edu 
  9081. (Richard L. Goerwitz) writes:
  9082.  
  9083. >As if the Icon Project didn't have enough to do already, it might
  9084. >be nice to have an Icon interpreter (in the interactive, rather
  9085. >than "virtual machine" sense).
  9086.  
  9087. Just thought I would let you know:
  9088.  
  9089. An interactive Icon interpreter is what I am currently working on for
  9090. my Master's Thesis.  I am merging the source code for the translator
  9091. and executor, icont & iconx, into a single program, iconi, which will
  9092. translate, link, and execute single Icon expressions interactively.  I
  9093. have already done some of the work, but have quite a bit left.
  9094.  
  9095. If anyone is interested in the interpreter, please let me know and I
  9096. will let you know when I have finished my work.  
  9097.  
  9098. Heather
  9099.  
  9100. From icon-group-request@arizona.edu  Fri Mar  8 19:51:03 1991
  9101. Resent-From: icon-group-request@arizona.edu
  9102. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9103.     id AA20689; Fri, 8 Mar 91 19:51:03 -0700
  9104. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 8 Mar
  9105.  1991 19:50 MST
  9106. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA02473; Fri, 8 Mar 91 18:40:29
  9107.  -0800
  9108. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9109.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9110.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9111. Resent-Date: Fri, 8 Mar 1991 19:50 MST
  9112. Date: 7 Mar 91 15:24:55 GMT
  9113. From: mvb.saic.com!ncr-sd!ncrcae!hubcap!fpst@ucsd.edu (Thanasis Mitsolides)
  9114. Subject: ALLOY: parallel and higher level.
  9115. Sender: icon-group-request@arizona.edu
  9116. Resent-To: icon-group@cs.arizona.edu
  9117. To: icon-group@arizona.edu
  9118. Resent-Message-Id: <0753B90A52604910@Arizona.edu>
  9119. Message-Id: <1991Mar7.202850.27650@hubcap.clemson.edu>
  9120. X-Envelope-To: icon-group@CS.Arizona.EDU
  9121. X-Vms-To: icon-group@Arizona.edu
  9122. Organization: New York University
  9123.  
  9124.  
  9125.  
  9126. This is to announce the availability of
  9127.  the interpreter, manual and examples for the programming language ALLOY.
  9128. ALLOY is high level, parallel, flexible and more than reasonably efficient.
  9129. ALLOY combines serial/parallel ev., eager/lazy ev., single/multiple solutions
  9130.  and parallel object oriented programming in a remarkably simple framework.
  9131.  
  9132. Example programs ready for execution include:
  9133.  1) factorial, partition sort, FP             (highly parallel)
  9134.  2) fibonacci sequence, prime numbers             (eager or lazy)
  9135.  3) systolic sort, hamming network            (clear flow of data)
  9136.  4) list member, tree leave, list permutation, n queens (multiple solutions)
  9137.  5) queue, stack, faa, semaphores, dinning philosophers    (objects)
  9138.  6) prolog package, prolog/parlog programming styles     (flexibility)
  9139.  
  9140. Part of ALLOY is explained in:
  9141. [MH90]    Thanasis  Mitsolides  and  Malcolm  Harrison.   Generators  and  the
  9142.           replicator control  structure in the parallel  environment of ALLOY.
  9143.           In ACM  SIGPLAN '90  Conference on  Programming Language  Design and
  9144.           Implementation, pages 189--196, White Plains, New York, June 1990.
  9145.  
  9146. The abstract of the ALLOY manual is appended at the end of this message.
  9147. The sources, manual, example programs and benchmarks of ALLOY are available
  9148. for anonymous FTP from cs.nyu.edu (128.122.140.24)
  9149.  
  9150. I hope you will find ALLOY interesting.
  9151. I will be glad to answer your comments!
  9152. Thank you,
  9153.  
  9154. Thanasis
  9155.  
  9156.  
  9157. ===============================================================================
  9158.                 ABSTRACT
  9159.  
  9160.        ALLOY is a higher level parallel  programming language appropriate
  9161.      for programming  massively parallel computing systems.   It is based
  9162.      on  a combination  of  ideas from  functional,  object oriented  and
  9163.      logic programming languages.
  9164.        The result being a language that can  directly support functional,
  9165.      object  oriented  and logic  programming  styles  in a  unified  and
  9166.      controlled framework.   Evaluating modes support serial  or parallel
  9167.      execution,  eager or  lazy evaluation,  non-determinism or  multiple
  9168.      solutions etc.   ALLOY is  simple as it only requires  31 primitives
  9169.      in all (half of which for Object Oriented Programming support).
  9170.        This article, starts with  a formal definition of the  small ALLOY
  9171.      kernel  proceeds with the  definition of  some useful libraries  and
  9172.      concludes  with examples  which demonstrate  its expressiveness  and
  9173.      clarity.
  9174.        Programming language ALLOY is located  on system spunky.cs.nyu.edu
  9175.      directory  ~mitsolid/alloy.   This article can  be found in dvi  and
  9176.      ascii  form  on subdirectory  doc,  The  examples presented  can  be
  9177.      found  in subdirectory progs.   The  interpreter is executable  file
  9178.      alloy.   All the above and the sources of the  ALLOY interpreter are
  9179.      available   for   anonymous  ftp  on  system  cs.nyu.edu   directory 
  9180.      pub/local/alloy.
  9181.  
  9182. -------------------------------------------------------------------------------
  9183. Internet: mitsolid@cs.nyu.edu                 (mitsolid%cs.nyu.edu@relay.cs.net)
  9184. UUCP    : ...!uunet!cmcl2!cs!mitsolid
  9185. -------------------------------------------------------------------------------
  9186. -------------------------------------------------------------------------------
  9187. Internet: mitsolid@cs.nyu.edu                 (mitsolid%cs.nyu.edu@relay.cs.net)
  9188. UUCP    : ...!uunet!cmcl2!cs!mitsolid
  9189. -------------------------------------------------------------------------------
  9190.  
  9191.  
  9192. -- 
  9193. -------------------------------------------------------------------------------
  9194. Internet: mitsolid@cs.nyu.edu                 (mitsolid%cs.nyu.edu@relay.cs.net)
  9195. UUCP    : ...!uunet!cmcl2!cs!mitsolid
  9196. -------------------------------------------------------------------------------
  9197.  
  9198. -- 
  9199. =========================== MODERATOR ==============================
  9200. Steve Stevenson                            {steve,fpst}@hubcap.clemson.edu
  9201. Department of Computer Science,            comp.parallel
  9202. Clemson University, Clemson, SC 29634-1906 (803)656-5880.mabell
  9203.  
  9204. From jyelon@cs.uiuc.edu  Sun Mar 10 13:52:16 1991
  9205. Received: from herodotus.cs.uiuc.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  9206.     id AA28436; Sun, 10 Mar 91 13:52:16 -0700
  9207. Received: by herodotus.cs.uiuc.edu
  9208.     (5.62+/IDA-1.2.8) id AA14599; Sun, 10 Mar 91 14:51:46 -0600
  9209. Date: Sun, 10 Mar 91 14:51:46 -0600
  9210. From: Josh Yelon <jyelon@cs.uiuc.edu>
  9211. Message-Id: <9103102051.AA14599@herodotus.cs.uiuc.edu>
  9212. To: icon-group@cs.arizona.edu
  9213. Subject: C-Icon interface
  9214.  
  9215.  
  9216. I'm using the new Icon compiler, but 'callout' doesn't seem to be
  9217. present. I need to be able to call the unix system libraries (to do
  9218. some hairy network protocol stuff). I'm willing to learn the format
  9219. of "rt.db" and add my own code to "rt.a", if necessary.
  9220.  
  9221. Any ideas? - Josh
  9222.  
  9223.  
  9224. From icon-group-request@arizona.edu  Thu Mar 14 09:57:10 1991
  9225. Resent-From: icon-group-request@arizona.edu
  9226. Received: from Arizona.edu ([128.196.128.231]) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9227.     id AA07815; Thu, 14 Mar 91 09:57:10 -0700
  9228. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
  9229.  1991 09:56 MST
  9230. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA01573; Thu, 14 Mar 91
  9231.  08:43:14 -0800
  9232. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9233.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9234.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9235. Resent-Date: Thu, 14 Mar 1991 09:56 MST
  9236. Date: 12 Mar 91 14:25:47 GMT
  9237. From: mcsun!cernvax!chx400!chx400!hslrswi!naz@uunet.uu.net (Norman H. Azadian)
  9238. Subject: alternation surprise
  9239. Sender: icon-group-request@arizona.edu
  9240. Resent-To: icon-group@cs.arizona.edu
  9241. To: icon-group@arizona.edu
  9242. Resent-Message-Id: <6B58F583FC6013A9@Arizona.edu>
  9243. Message-Id: <1899@hslrswi.hasler.ascom.ch>
  9244. X-Envelope-To: icon-group@CS.Arizona.EDU
  9245. X-Vms-To: icon-group@Arizona.edu
  9246. Organization: Hasler AG
  9247.  
  9248. I know my postings are starting to sound like an idiot's tour
  9249. of Icon.  Anyway, here's another "gotcha" I stumbled over.
  9250.  
  9251.     procedure main()
  9252.     local flag, x
  9253.         flag := 1
  9254.         (\flag)  |  (x := runerr(500))
  9255.         (\flag)  |  x := runerr(500)
  9256.     end
  9257.  
  9258. This dies on line 5, which I did not expect.  I guess alternation
  9259. has lower priority than assignment.  Pardon me while I go out and
  9260. stock up on parenthesis.
  9261.  
  9262. NHA
  9263. -- 
  9264. PAPER:  Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
  9265. INTERNET:  naz%hslrswi.uucp@uunet.uu.net
  9266. UUCP:   ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
  9267. VOICE:  +41 31 63 2178            BITNET: naz%hslrswi.UUCP@cernvax.BITNET
  9268.  
  9269. From icon-group-request@arizona.edu  Thu Mar 14 10:44:58 1991
  9270. Resent-From: icon-group-request@arizona.edu
  9271. Received: from Arizona.edu ([128.196.128.231]) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9272.     id AA09033; Thu, 14 Mar 91 10:44:58 -0700
  9273. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
  9274.  1991 10:44 MST
  9275. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA04220; Thu, 14 Mar 91
  9276.  09:34:25 -0800
  9277. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9278.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9279.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9280. Resent-Date: Thu, 14 Mar 1991 10:44 MST
  9281. Date: 12 Mar 91 23:55:58 GMT
  9282. From: midway!quads.uchicago.edu!goer@uunet.uu.net (Richard L. Goerwitz)
  9283. Subject: RE: alternation surprise
  9284. Sender: icon-group-request@arizona.edu
  9285. Resent-To: icon-group@cs.arizona.edu
  9286. To: icon-group@arizona.edu
  9287. Resent-Message-Id: <7207D251EC60151A@Arizona.edu>
  9288. Message-Id: <1991Mar12.235558.1542@midway.uchicago.edu>
  9289. X-Envelope-To: icon-group@CS.Arizona.EDU
  9290. X-Vms-To: icon-group@Arizona.edu
  9291. Organization: University of Chicago
  9292. References: <1899@hslrswi.hasler.ascom.ch>
  9293.  
  9294. Na@hslrswi.hasler.ascom.ch (Norman H. Azadian) writes:
  9295.  
  9296. >I know my postings are starting to sound like an idiot's tour
  9297. >of Icon.
  9298.  
  9299. If you want a real laugh, try taking a look at icon-group traffic
  9300. from, say, three years or so ago (when I was still just learning the
  9301. language).  The archives are on cs.arizona.edu (much to my chagrin
  9302. :-).
  9303.  
  9304. >
  9305. >    procedure main()
  9306. >    local flag, x
  9307. >        flag := 1
  9308. >        (\flag)  |  (x := runerr(500))
  9309. >        (\flag)  |  x := runerr(500)
  9310. >    end
  9311. >
  9312. >This dies on line 5, which I did not expect.  I guess alternation
  9313. >has lower priority than assignment.  Pardon me while I go out and
  9314. >stock up on parenthesis.
  9315.  
  9316. My golden rule, for a long time , was "conjunction has the lowest prece-
  9317. of any infix operation."  Everything else I parenthesized.
  9318.  
  9319. You may find that the precedence of alternation makes more sense if you
  9320. think of the very common idiom -
  9321.  
  9322.     intext :=open(\filename) | &input
  9323.  
  9324. -Richard
  9325.  
  9326. From icon-group-request@arizona.edu  Thu Mar 14 13:42:32 1991
  9327. Resent-From: icon-group-request@arizona.edu
  9328. Received: from Arizona.edu ([128.196.128.231]) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9329.     id AA12449; Thu, 14 Mar 91 13:42:32 -0700
  9330. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
  9331.  1991 13:41 MST
  9332. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12230; Thu, 14 Mar 91
  9333.  12:26:47 -0800
  9334. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9335.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9336.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9337. Resent-Date: Thu, 14 Mar 1991 13:42 MST
  9338. Date: 12 Mar 91 20:04:03 GMT
  9339. From: hsi!mlfarm!ron@uunet.uu.net (Ronald Florence)
  9340. Subject: pipe opens
  9341. Sender: icon-group-request@arizona.edu
  9342. Resent-To: icon-group@cs.arizona.edu
  9343. To: icon-group@arizona.edu
  9344. Resent-Message-Id: <8ACF86F7AC600E35@Arizona.edu>
  9345. Message-Id: <772@mlfarm.com>
  9346. X-Envelope-To: icon-group@CS.Arizona.EDU
  9347. X-Vms-To: icon-group@Arizona.edu
  9348. Organization: Maple Lawn Farm, Stonington, CT
  9349.  
  9350. I can't get this bit of code to work:
  9351.  
  9352.      procedure main()
  9353.  
  9354.        write(pipe("bogus-command", "nonsense", "logname"))
  9355.      end
  9356.  
  9357.      procedure pipe(cmd[])
  9358.  
  9359.        until inf := open(pop(cmd), "pr") 
  9360.        got := !inf
  9361.        close(inf)
  9362.        return got
  9363.      end
  9364.  
  9365. The idea is to try opening a pipe to a series of commands until one
  9366. succeeds.  It doesn't work (at least here), because instead of the
  9367. open() failing on "bogus-command" and "nonsense", the shell reports
  9368. that the command wasn't found.
  9369.  
  9370. Any idea how to do what I want to do?
  9371. --
  9372.  
  9373. Ronald Florence            ron@mlfarm.com
  9374.  
  9375. From icon-group-request@arizona.edu  Thu Mar 14 19:30:15 1991
  9376. Resent-From: icon-group-request@arizona.edu
  9377. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9378.     id AA19629; Thu, 14 Mar 91 19:30:15 -0700
  9379. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
  9380.  1991 19:29 MST
  9381. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA28569; Thu, 14 Mar 91
  9382.  18:22:32 -0800
  9383. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9384.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9385.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9386. Resent-Date: Thu, 14 Mar 1991 19:29 MST
  9387. Date: 13 Mar 91 14:44:00 GMT
  9388. From: sam.cs.olemiss.edu!hcc@cs.duke.edu (Conrad Cunningham)
  9389. Subject: Use of Icon in Support of Coursework??
  9390. Sender: icon-group-request@arizona.edu
  9391. Resent-To: icon-group@cs.arizona.edu
  9392. To: icon-group@arizona.edu
  9393. Resent-Message-Id: <BB681B05DC601810@Arizona.edu>
  9394. Message-Id: <1991Mar13.144400.20767@cs.olemiss.edu>
  9395. X-Envelope-To: icon-group@CS.Arizona.EDU
  9396. X-Vms-To: icon-group@Arizona.edu
  9397. Organization: University of Mississippi, Dept. of Computer Science
  9398.  
  9399. A question for academics who use Icon in support of undergraduate- or
  9400. graduate-level courses:  In what kinds of courses, at what levels, and
  9401. in what ways is Icon used in support of teaching--particularly in
  9402. computing science?  What are the advantages/disadvantages to use of
  9403. Icon in comparison to other languages?  What are the available
  9404. textbooks?
  9405.  
  9406. Motivation for question:  most of the coursework in my department uses
  9407. Pascal, C, or Ada for laboratory exercises.  Since joining this
  9408. department two years ago I have been looking for appropriate ways to
  9409. broaden our students "exposure" to different styles, paradigms, and
  9410. approaches to programming.  For example, I've developed or am
  9411. developing elective courses in program derivation, functional
  9412. programming (lazy), and concurrent programming.  I was just wondering
  9413. what place Icon has in existing or potentially new courses.
  9414.  
  9415. Thanks,
  9416. -------------------------------------------------------------------------------
  9417. H. Conrad Cunningham  | Dept. of Computer & Info. Sci., Univ. of Mississippi
  9418. Tel:  (601) 232-5358  | 302 Weir Hall, University, MS 38677  U.S.A.
  9419. Fax:  (601) 232-7010  | Email:  cunningham@cs.olemiss.edu 
  9420. -------------------------------------------------------------------------------
  9421.  
  9422. From icon-group-request@arizona.edu  Thu Mar 14 22:51:54 1991
  9423. Resent-From: icon-group-request@arizona.edu
  9424. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9425.     id AA26733; Thu, 14 Mar 91 22:51:54 -0700
  9426. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
  9427.  1991 22:51 MST
  9428. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA07825; Thu, 14 Mar 91
  9429.  21:36:13 -0800
  9430. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9431.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9432.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9433. Resent-Date: Thu, 14 Mar 1991 22:51 MST
  9434. Date: 13 Mar 91 19:53:53 GMT
  9435. From: csus.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!quads.uchicago.edu!goer@ucdavis.ucdavis.edu (Richard
  9436.  L. Goerwitz)
  9437. Subject: RE: Use of Icon in Support of Coursework??
  9438. Sender: icon-group-request@arizona.edu
  9439. Resent-To: icon-group@cs.arizona.edu
  9440. To: icon-group@arizona.edu
  9441. Resent-Message-Id: <D794C129EC601405@Arizona.edu>
  9442. Message-Id: <1991Mar13.195353.15075@midway.uchicago.edu>
  9443. X-Envelope-To: icon-group@CS.Arizona.EDU
  9444. X-Vms-To: icon-group@Arizona.edu
  9445. Organization: University of Chicago
  9446. References: <1991Mar13.144400.20767@cs.olemiss.edu>
  9447.  
  9448. Hcc@cs.olemiss.edu (Conrad Cunningham) writes:
  9449. >A question for academics who use Icon in support of undergraduate- or
  9450. >graduate-level courses:  In what kinds of courses, at what levels, and
  9451. >in what ways is Icon used in support of teaching--particularly in
  9452. >computing science?  What are the advantages/disadvantages to use of
  9453. >Icon in comparison to other languages?  What are the available
  9454. >textbooks?
  9455. >
  9456. >Motivation for question:  most of the coursework in my department uses
  9457. >Pascal, C, or Ada for laboratory exercises.  Since joining this
  9458. >department two years ago I have been looking for appropriate ways to
  9459. >broaden our students "exposure" to different styles, paradigms, and
  9460. >approaches to programming.
  9461.  
  9462. The problem with Icon - and it's only a problem under certain cir-
  9463. comstances - is that people who've learned an Algol-family language
  9464. before learning Icon have a very hard time thinking of Icon in its
  9465. own terms.  They'll tend to pick up things like string scanning and
  9466. goal-directed evaluation very late in the game - when in fact they
  9467. are some of Icon's major advantages, and ought to be picked up right
  9468. away.
  9469.  
  9470. Icon is a totally different paradigm in a familiar guise.  This
  9471. can be very useful, but also very deceptive.
  9472.  
  9473. I'd think Icon would be a nice steppingstone to a lecture or two
  9474. on Prolog, which has similar backtracking mechanisms (not to say
  9475. that the languages in other respects are much the same).  Icon's
  9476. string scanning would also serve as a good introduction to the
  9477. grand old Snobol tradition - which students at this stage would
  9478. probably not want to invest a lot of time in (but which they
  9479. ought to know exists).
  9480.  
  9481. For people doing nonnumeric computing, I'd think it would be
  9482. an ideal first language.  For those in more traditional com-
  9483. puting courses (I'm just guessing here, since I've never taken
  9484. a programming course), I'd think it would be an instructive
  9485. paradigm shift which might, if done with care, provide a nice
  9486. bridge between Algol-family languages and the rest of the
  9487. programming languages that are out there.
  9488.  
  9489. Actually, I wonder (now that I'm thinking about it) why any-
  9490. one would bother with Pascal.  Pascal is annoying in that
  9491. the core language definition was originally so sparse that
  9492. everyone extended it in all kinds of ways just to get it
  9493. to work.
  9494.  
  9495. -Richard
  9496.  
  9497. From icon-group-request@arizona.edu  Fri Mar 15 08:29:49 1991
  9498. Resent-From: icon-group-request@arizona.edu
  9499. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9500.     id AA17555; Fri, 15 Mar 91 08:29:49 -0700
  9501. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 15 Mar
  9502.  1991 08:29 MST
  9503. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA05989; Fri, 15 Mar 91
  9504.  07:26:10 -0800
  9505. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9506.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9507.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9508. Resent-Date: Fri, 15 Mar 1991 08:29 MST
  9509. Date: 13 Mar 91 18:05:36 GMT
  9510. From: mcsun!ukc!cam-cl!news@uunet.uu.net (Brian Brunswick)
  9511. Subject: Multiple value assignment in icon???
  9512. Sender: icon-group-request@arizona.edu
  9513. Resent-To: icon-group@cs.arizona.edu
  9514. To: icon-group@arizona.edu
  9515. Resent-Message-Id: <284FC6751C60153A@Arizona.edu>
  9516. Message-Id: <1991Mar13.180536.22613@cl.cam.ac.uk>
  9517. X-Envelope-To: icon-group@CS.Arizona.EDU
  9518. X-Vms-To: icon-group@Arizona.edu
  9519. Organization: U of Cambridge Comp Lab, UK
  9520.  
  9521. I am fairly new to icon, but am considering thr pros and cons of
  9522. writing a medium size project using it.  I came up with a language feature
  9523. that I have found useful in the past, namely returning a fixed small
  9524. number of distinct values from a procedure and assigning them to separate
  9525. variables, and wondered what the particular idiom might be.
  9526.  
  9527. That was where the trouble began.
  9528.  
  9529. Something like every (x|y):=f() is no good, of course.
  9530.  
  9531. I fiddled about, and eventually came up with using this:
  9532.  
  9533.     every z:=:y:=:x:=:r123()
  9534.  
  9535. where r123 would do
  9536.  
  9537.     suspend ![1|2|3]
  9538.  
  9539. and ends up with x=1, y=2, z=3
  9540.  
  9541. Note the reversed order of xyz.
  9542.  
  9543. Now this is a horrible cludge, it seems to me. Am I missing something,
  9544. or does this irritation spoil an otherwise pretty language?
  9545. Brian.Brunswick@uk.ac.cam.cl  Disclaimer.  Short sig rules!
  9546.  
  9547. From isidev!nowlin@uunet.UU.NET  Fri Mar 15 09:56:25 1991
  9548. Received: from uunet.UU.NET by megaron.cs.arizona.edu (5.61/15) via SMTP
  9549.     id AA19923; Fri, 15 Mar 91 09:56:25 -0700
  9550. Received: from isidev.UUCP by uunet.UU.NET with UUCP 
  9551.     (5.61/UUNET-primary-gateway) id AA02775; Fri, 15 Mar 91 11:56:20 -0500
  9552. Date: Fri, 15 Mar 91 11:56:20 -0500
  9553. From: isidev!nowlin@uunet.uu.net
  9554. Message-Id: <9103151656.AA02775@uunet.UU.NET>
  9555. To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
  9556. Subject: Re: pipe opens
  9557.  
  9558. > I can't get this bit of code to work:
  9559. >      procedure main()
  9560. >        write(pipe("bogus-command", "nonsense", "logname"))
  9561. >      end
  9562. >      procedure pipe(cmd[])
  9563. >        until inf := open(pop(cmd), "pr") 
  9564. >        got := !inf
  9565. >        close(inf)
  9566. >        return got
  9567. >      end
  9568. > The idea is to try opening a pipe to a series of commands until one
  9569. > succeeds.  It doesn't work (at least here), because instead of the
  9570. > open() failing on "bogus-command" and "nonsense", the shell reports
  9571. > that the command wasn't found.
  9572. > Any idea how to do what I want to do?
  9573. > --
  9574. > Ronald Florence            ron@mlfarm.com
  9575.  
  9576. The problem is that the pipe-read in Icon invokes the command in a
  9577. sub-shell and the open of the sub-shell almost never fails.  That's why the
  9578. first bogus command in your list terminates the program.  The main reason
  9579. to test the success or failure of the open in this program is in case the
  9580. pop() fails.
  9581.  
  9582. The real way to test the success or failure of a command invoked with the
  9583. pipe-read is to check the return value from the close of the pipe.  This is
  9584. where the exit code of the command is returned.  For standard UNIX this
  9585. exit code should be zero if the command succeeded.
  9586.  
  9587. The second problem is that the "not found" error comes from the sub-shell
  9588. instead of the command being tested.  There's no (easy) way to redirect
  9589. that error output without invoking the command in a separate sub-shell.
  9590. The following program works that way.  I included three sets of test data
  9591. since the possibility of an infinite loop, if there's no command that
  9592. succeeds, should be tested:
  9593.  
  9594.     procedure main()
  9595.  
  9596.         write(pipe("bogus-command","nonsense","logname","more-junk"))
  9597.         write(pipe("bogus-command","nonsense","lognothing","more-junk"))
  9598.         write(pipe("logname","bogus-command","nonsense","more-junk"))
  9599.  
  9600.     end
  9601.  
  9602.     procedure pipe(cmd[])
  9603.  
  9604.         repeat {
  9605.             inf := open("(" || pop(cmd) || ") 2>&1","pr") | fail
  9606.             got := !inf
  9607.             if close(inf) = 0 then return got
  9608.         }
  9609.  
  9610.     end
  9611.  
  9612. This version of pipe() follows the basic algorithm you used.  I know the
  9613. order of precedence of the expression containing the open() is not obvious
  9614. here but once a procedure fails it fails.  It doesn't make any difference
  9615. if it's trying to assign the result of failure to a variable.
  9616.  
  9617. The following version of the pipe() procedure uses goal directed evaluation
  9618. instead of iteration.  I like this one better:
  9619.  
  9620.     procedure pipe(cmd[])
  9621.  
  9622.         if inf := open("(" || !cmd || ") 2>&1","pr") &
  9623.            got := !inf &
  9624.            close(inf) = 0 then
  9625.                return got
  9626.  
  9627.         else   fail
  9628.  
  9629.     end
  9630.  
  9631. +-------------------------------------------------------------------------+
  9632. |  --- ---                                                                |
  9633. |   | S |  Iconic Software, Inc.  -  Jerry Nowlin  - uunet!isidev!nowlin  |
  9634. |  --- ---                                                                |
  9635. +-------------------------------------------------------------------------+
  9636.  
  9637.  
  9638. From wunder@hpsdel.sde.hp.com  Fri Mar 15 14:35:14 1991
  9639. Resent-From: wunder@hpsdel.sde.hp.com
  9640. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9641.     id AA27094; Fri, 15 Mar 91 14:35:14 -0700
  9642. Received: from relay.hp.com by Arizona.edu with PMDF#10282; Fri, 15 Mar 1991
  9643.  14:34 MST
  9644. Received: from orac.sde.hp.com by relay.hp.com with SMTP (16.5/15.5+IOS 3.13)
  9645.  id AA22435; Fri, 15 Mar 91 13:34:26 -0800
  9646. Received: by hpsdel.sde.hp.com (15.7/SES42.42) id AA06684; Fri, 15 Mar 91
  9647.  13:34:12 pst
  9648. Resent-Date: Fri, 15 Mar 1991 14:34 MST
  9649. Date: Fri, 15 Mar 91 13:34:12 pst
  9650. From: Walter Underwood <wunder@hpsdel.sde.hp.com>
  9651. Subject: Use of Icon in Support of Coursework??
  9652. Resent-To: icon-group@cs.arizona.edu
  9653. To: icon-group@arizona.edu
  9654. Resent-Message-Id: <5B5AFDFA1C601A3E@Arizona.edu>
  9655. Message-Id: <9103152134.AA06684@hpsdel.sde.hp.com>
  9656. X-Envelope-To: icon-group@CS.Arizona.EDU
  9657. X-Vms-To: icon-group@Arizona.edu
  9658.  
  9659.    For those in more traditional computing courses (I'm just guessing
  9660.    here, since I've never taken a programming course), I'd think it would
  9661.    be an instructive paradigm shift which might, ...
  9662.  
  9663. My intro to programming course taught apl and PL/C (a cut-down PL/1).
  9664. Learning two very different paradigms was not that hard, and was very
  9665. valuable.  It fostered a "right tool for the job" attitude, and
  9666. steered people away from language bigotry.  We also learned how to
  9667. change typeballs on Selectric terminals.
  9668.  
  9669. Rice now uses Pascal on Macs, which eliminates most of the
  9670. edit-compile-debug hassle (a big plus), but I think there was also
  9671. something lost in the switch.
  9672.  
  9673. wunder
  9674.  
  9675. From icon-group-request@arizona.edu  Sun Mar 17 22:19:12 1991
  9676. Resent-From: icon-group-request@arizona.edu
  9677. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9678.     id AA10694; Sun, 17 Mar 91 22:19:12 -0700
  9679. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sun, 17 Mar
  9680.  1991 22:18 MST
  9681. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA18137; Sun, 17 Mar 91
  9682.  21:10:16 -0800
  9683. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9684.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9685.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9686. Resent-Date: Sun, 17 Mar 1991 22:18 MST
  9687. Date: 18 Mar 91 04:39:48 GMT
  9688. From: zaphod.mps.ohio-state.edu!ceres.physics.uiowa.edu!news.iastate.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@tut.cis.ohio-state.edu
  9689.  (Richard L. Goerwitz)
  9690. Subject: terrible code
  9691. Sender: icon-group-request@arizona.edu
  9692. Resent-To: icon-group@cs.arizona.edu
  9693. To: icon-group@arizona.edu
  9694. Resent-Message-Id: <2E839197AC6020A5@Arizona.edu>
  9695. Message-Id: <1991Mar18.043948.11527@midway.uchicago.edu>
  9696. X-Envelope-To: icon-group@CS.Arizona.EDU
  9697. X-Vms-To: icon-group@Arizona.edu
  9698. Organization: University of Chicago
  9699.  
  9700.  
  9701. I wrote the following code because I figured that using sets or
  9702. lists alone to accomplish what it does would be inefficient.  It
  9703. turns out that, even though the code below produces a determinis-
  9704. tic automaton (with some small cheating in one spot), it's about
  9705. a third as fast as just using a set or list all by itself to do
  9706. the same thing.
  9707.  
  9708. If there are any wizards online, who feel like bending their minds
  9709. over some obscure code, I wouldn't mind a bit if they'd comment
  9710. on how this might be done more efficiently.  Non-wizards beware
  9711. :-).
  9712.  
  9713. -Richard
  9714.  
  9715.  
  9716. ------------------------------------------------------------------
  9717.  
  9718. procedure anystr(l,s,i,j)
  9719.  
  9720.     static done_tbl
  9721.     initial done_tbl := table()
  9722.  
  9723.     #
  9724.     # Make defaults work like those for built-in string-handling
  9725.     # functions.
  9726.     #
  9727.     /s := &subject
  9728.     if \i then {
  9729.     if i < 1 then
  9730.         i := *s + (i+1)
  9731.     }
  9732.     else i := \&pos | 1
  9733.     if \j then {
  9734.     if j < 1 then
  9735.         j := *s + (j+1)
  9736.     }
  9737.     else j := *s+1
  9738.  
  9739.     #
  9740.     # Create table to sort and hold characters for list l (if it
  9741.     # does not already exist.  Then return the position in s of
  9742.     # the longest string in l that matches at position i.
  9743.     #
  9744.     /done_tbl[l] := table(sort(set(l)))
  9745.     return (i-1) + (s[i:j] ? walk_table(done_tbl[l]))
  9746.  
  9747.     # NB:  longest possible match approach!
  9748.  
  9749. end
  9750.  
  9751.  
  9752. procedure walk_table(t)
  9753.  
  9754.     local val, chr, ntbl, nlst, empty_string_present
  9755.  
  9756.     while val := t[move(1)] do {
  9757.  
  9758.     case type(val) of {
  9759.         "table" : {
  9760.         if "" == key(val) then {
  9761.             POS := &pos
  9762.             return (walk_table(val) | POS)
  9763.         }
  9764.         else return walk_table(val)
  9765.         }
  9766.         "list"  : {
  9767.         case *val of {
  9768.             0      : fail
  9769.             1      : if (move(-1),=val[1]) then return .&pos else fail
  9770.             default: {
  9771.             nkey := "impossible key"
  9772.             while pop(val) ? {
  9773.                 empty_string_present := pos(0)
  9774.                 chr := move(1) | ""
  9775.                 if nkey ~==:= chr then {
  9776.                 nlst := list()
  9777.                 ntbl := table(nlst)
  9778.                 insert(t, nkey, ntbl)
  9779.                 }
  9780.                 put(nlst, tab(0))
  9781.             }
  9782.             move(-1)
  9783.             if \empty_string_present then {
  9784.                 POS := &pos
  9785.                 return (walk_table(t) | POS)
  9786.             }
  9787.             else return walk_table(t)
  9788.             }
  9789.         }
  9790.         }
  9791.     }
  9792.     }
  9793.  
  9794. end
  9795.  
  9796. From icon-group-request@arizona.edu  Mon Mar 18 00:50:38 1991
  9797. Resent-From: icon-group-request@arizona.edu
  9798. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  9799.     id AA12908; Mon, 18 Mar 91 00:50:38 -0700
  9800. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 18 Mar
  9801.  1991 00:49 MST
  9802. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA21142; Sun, 17 Mar 91
  9803.  23:45:10 -0800
  9804. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9805.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9806.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9807. Resent-Date: Mon, 18 Mar 1991 00:50 MST
  9808. Date: 16 Mar 91 14:27:26 GMT
  9809. From: mcsun!ukc!cam-cl!news@uunet.uu.net (Brian Brunswick)
  9810. Subject: RE: Multiple value assignment in icon???
  9811. Sender: icon-group-request@arizona.edu
  9812. Resent-To: icon-group@cs.arizona.edu
  9813. To: icon-group@arizona.edu
  9814. Resent-Message-Id: <43A76328FC601EB3@Arizona.edu>
  9815. Message-Id: <1991Mar16.142726.5947@cl.cam.ac.uk>
  9816. X-Envelope-To: icon-group@CS.Arizona.EDU
  9817. X-Vms-To: icon-group@Arizona.edu
  9818. Organization: U of Cambridge Comp Lab, UK
  9819. References: <1991Mar13.180536.22613@cl.cam.ac.uk>,
  9820.  <1991Mar15.013415.1499@midway.uchicago.edu>
  9821.  
  9822. In article <1991Mar15.013415.1499@midway.uchicago.edu> goer@quads.uchicago.edu (Richard L. Goerwitz) writes:
  9823. >Bdb@cl.cam.ac.uk (Brian Brunswick) writes (with regard to the problem
  9824. >of assigning a series of results to a series of variables):
  9825. >>
  9826. >>Something like every (x|y):=f() is no good, of course.
  9827. >>
  9828. >
  9829. >This is sooo close to working.... [explanation of what goes wrong]
  9830. >
  9831. >Aha!  We've suddenly run into one very good use for coexpressions.
  9832. >Here's what to do:
  9833. >
  9834. >    val := create f()
  9835. >    every (x|y) := @val
  9836.  
  9837. Yup, I'd spotted that this was possible, but was put off by the extra
  9838. temporary variable needed - I'd really like something on one line.
  9839. One can't even do things like ...@(val := create f()), since rhs
  9840. evaluated multiple times when lhs is resumed. I did experiment with
  9841. putting inteligence in a wrapper function, but it doesn't have enough
  9842. information to work safely enough to withstand mistakes.
  9843.  
  9844. >Now here's an excercize to see if you fully grasp how Icon de-
  9845. >references variables.  Why will the following NOT work the way you
  9846. >want it to?
  9847. >
  9848. >    var := create (x|y)
  9849. >    every val := f() do
  9850. >        var := val
  9851.  
  9852. Urble ... create makes its own copy of local variables ... but would
  9853. they even survive undereferenced (ug!) to be (pointlessly) used?  I
  9854. suppose globals would work.
  9855.  
  9856. >Referring to a solution offered (but not quoted here):
  9857.  
  9858. Which was using a wrapper of ![...] around the procedure return values
  9859. to turn them into anonymous variables, which enables the calling line
  9860. to use a multiple swapping assignment to do rotation amongst several
  9861. variables and accumulate results that way. ( every z:=:y:=:x:=:f() )
  9862.  
  9863. >
  9864. >> Am I missing something, or does this irritation spoil an otherwise
  9865. >> pretty language?
  9866. >
  9867. >Your solution isn't particularly idiomatic.  You clearly sensed this.
  9868. >Hence your posting.  Your question was really very good, though, be-
  9869. >cause you've clearly grasped precisely the sort of situation that makes
  9870. >coexpressions useful and elegant additions to the language.  You aren't
  9871. >missing a thing, but rather demonstrating an understanding of the sort
  9872. >of logic that led to the implementation of coexpressions....
  9873. >
  9874. >I hope this helps.
  9875. >
  9876. >-Richard Goerwitz (goer@sophist.uchicago.edu)
  9877.  
  9878. Hmm... I'm not so sure that I don't prefer my cludge to having to
  9879. introduce an extra intermediate variable. Of course, its only good so
  9880. long as its clearly recognised as an idiom by the reader, otherwise
  9881. its needless obfuscation.
  9882.  
  9883. Also, I hesitated somewhat at creating a co expression just to do
  9884. something that short that I'm likely to use quite a lot. Isn't that
  9885. likely to be quite expensive in terms of garbage produced? Or would
  9886. reusing the same temporary to hold it mean that reference counting or
  9887. something rescues things?
  9888. Brian.Brunswick@uk.ac.cam.cl  Disclaimer.  Short sig rules!
  9889.  
  9890. From isidev!nowlin@uunet.UU.NET  Mon Mar 18 08:58:28 1991
  9891. Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
  9892.     id AA25661; Mon, 18 Mar 91 08:58:28 -0700
  9893. Received: from isidev.UUCP by uunet.uu.net with UUCP 
  9894.     (5.61/UUNET-primary-gateway) id AA20381; Mon, 18 Mar 91 10:58:24 -0500
  9895. Date: Mon, 18 Mar 91 10:58:24 -0500
  9896. From: isidev!nowlin@uunet.uu.net
  9897. Message-Id: <9103181558.AA20381@uunet.uu.net>
  9898. To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
  9899. Subject: Re: terrible code
  9900.  
  9901. You're right.  Terrible code :-)  I'm not a wizard so could you please
  9902. stick an illustrative main procedure on there so we non-wizards can figure
  9903. out what this program is supposed to do in the first place?  It looks like
  9904. it scans a string for the longest match on any one of a list of strings but
  9905. I got nowhere trying to make that work.  If that's really what is going on
  9906. I have some ideas.
  9907.  
  9908. Thanks.
  9909.  
  9910. +-------------------------------------------------------------------------+
  9911. |  --- ---                                                                |
  9912. |   | S |  Iconic Software, Inc.  -  Jerry Nowlin  - uunet!isidev!nowlin  |
  9913. |  --- ---                                                                |
  9914. +-------------------------------------------------------------------------+
  9915.  
  9916.  
  9917. From isidev!nowlin@uunet.UU.NET  Mon Mar 18 08:58:29 1991
  9918. Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
  9919.     id AA25664; Mon, 18 Mar 91 08:58:29 -0700
  9920. Received: from isidev.UUCP by uunet.uu.net with UUCP 
  9921.     (5.61/UUNET-primary-gateway) id AA20389; Mon, 18 Mar 91 10:58:25 -0500
  9922. Date: Mon, 18 Mar 91 10:58:25 -0500
  9923. From: isidev!nowlin@uunet.uu.net
  9924. Message-Id: <9103181558.AA20389@uunet.uu.net>
  9925. To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
  9926. Subject: Re: terrible code (2)
  9927.  
  9928. I figured out what I was doing wrong and got the program originally posted
  9929. to work.  I came up with a solution that got the same answer for my test
  9930. data.  Is this a possible solution to what you were trying to do?  Notice I
  9931. just borrowed the argument processing code from the original anystr()
  9932. procedure for my longstr() procedure:
  9933.  
  9934. procedure main(args)
  9935.  
  9936.     l := ["th","that ","not close","tha","that b","t"]
  9937.     s := "that begins this string"
  9938.  
  9939.     #write(anystr(l,s))
  9940.     write(longstr(l,s))
  9941.  
  9942. end
  9943.  
  9944. procedure longstr(l,s,i,j)
  9945.  
  9946.     ##### borrowed #####
  9947.     /s := &subject
  9948.     if \i then {
  9949.     if i < 1 then
  9950.         i := *s + (i+1)
  9951.     }
  9952.     else i := \&pos | 1
  9953.     if \j then {
  9954.     if j < 1 then
  9955.         j := *s + (j+1)
  9956.     }
  9957.     else j := *s+1
  9958.     ##### borrowed #####
  9959.  
  9960.     m := 0
  9961.     while *(p := (s ? =!l)) > m do m := *p
  9962.     return m + 1
  9963. end
  9964.  
  9965. I didn't include the original posted code here but you can add it to this
  9966. program and test the two solutions together.  I haven't a clue which is
  9967. faster but this one is somewhat shorter.
  9968.  
  9969. +-------------------------------------------------------------------------+
  9970. |  --- ---                                                                |
  9971. |   | S |  Iconic Software, Inc.  -  Jerry Nowlin  - uunet!isidev!nowlin  |
  9972. |  --- ---                                                                |
  9973. +-------------------------------------------------------------------------+
  9974.  
  9975.  
  9976. From isidev!nowlin@uunet.UU.NET  Mon Mar 18 09:58:13 1991
  9977. Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
  9978.     id AA27135; Mon, 18 Mar 91 09:58:13 -0700
  9979. Received: from isidev.UUCP by uunet.uu.net with UUCP 
  9980.     (5.61/UUNET-primary-gateway) id AA05469; Mon, 18 Mar 91 11:58:07 -0500
  9981. Date: Mon, 18 Mar 91 11:58:07 -0500
  9982. From: isidev!nowlin@uunet.uu.net
  9983. Message-Id: <9103181658.AA05469@uunet.uu.net>
  9984. To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
  9985. Subject: Re: terrible code (3)
  9986.  
  9987. Last time...promise.  I just forgot to use the 'i' and 'j' arguments in my
  9988. solution and thought as long as I'm posting it again why not comment it
  9989. some since it is a little cryptic:
  9990.  
  9991. procedure main(args)
  9992.  
  9993.     s := "that begins this string"
  9994.  
  9995.     l := ["th","that beg","not close","","tha","begins t","that b","t"]
  9996.  
  9997.     write(longstr(l,s)) | write("nomatch")
  9998.     write(longstr(l,s,6)) | write("nomatch")
  9999.     write(longstr(l,s,6,12)) | write("nomatch")
  10000.  
  10001.     l := ["th","that beg","not close","tha","begins t","that b","t"]
  10002.  
  10003.     write(longstr(l,s)) | write("nomatch")
  10004.     write(longstr(l,s,6)) | write("nomatch")
  10005.     write(longstr(l,s,6,12)) | write("nomatch")
  10006.  
  10007. end
  10008.  
  10009. procedure longstr(l,s,i,j)
  10010.     ##### borrowed #####
  10011.     /s := &subject
  10012.     if \i then {
  10013.     if i < 1 then
  10014.         i := *s + (i+1)
  10015.     }
  10016.     else i := \&pos | 1
  10017.     if \j then {
  10018.     if j < 1 then
  10019.         j := *s + (j+1)
  10020.     }
  10021.     else j := *s+1
  10022.     ##### borrowed #####
  10023.  
  10024.     # initialize the match length
  10025.     m := 0
  10026.  
  10027.     # while there is a pattern 'p' in list 'l' that matches string 's[i:j]'
  10028.     # and that pattern 'p' is longer than the current match length 'm' reset
  10029.     # the match length 'm' to the length of pattern 'p' -- goal directed
  10030.     # evaluation in the 'while' expression is the key here
  10031.     while *(p := (s[i:j] ? =!l)) > m do m := *p
  10032.  
  10033.     # if no pattern matched fail
  10034.     if /p then fail
  10035.  
  10036.     # if a pattern matched return the position in 's' past the pattern
  10037.     else return i + m
  10038.  
  10039. end
  10040.  
  10041. +-------------------------------------------------------------------------+
  10042. |  --- ---                                                                |
  10043. |   | S |  Iconic Software, Inc.  -  Jerry Nowlin  - uunet!isidev!nowlin  |
  10044. |  --- ---                                                                |
  10045. +-------------------------------------------------------------------------+
  10046.  
  10047.  
  10048. From icon-group-request@arizona.edu  Mon Mar 18 10:07:13 1991
  10049. Resent-From: icon-group-request@arizona.edu
  10050. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  10051.     id AA27362; Mon, 18 Mar 91 10:07:13 -0700
  10052. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 18 Mar
  10053.  1991 10:06 MST
  10054. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA29542; Mon, 18 Mar 91
  10055.  09:02:57 -0800
  10056. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  10057.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  10058.  usenet@ucbvax.Berkeley.EDU if you have questions)
  10059. Resent-Date: Mon, 18 Mar 1991 10:06 MST
  10060. Date: 18 Mar 91 15:08:38 GMT
  10061. From: agate!bionet!uwm.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@ucbvax.Berkeley.EDU (Richard
  10062.  L. Goerwitz)
  10063. Subject: RE: Multiple value assignment in icon???
  10064. Sender: icon-group-request@arizona.edu
  10065. Resent-To: icon-group@cs.arizona.edu
  10066. To: icon-group@arizona.edu
  10067. Resent-Message-Id: <916B68B65C602198@Arizona.edu>
  10068. Message-Id: <1991Mar18.150838.24597@midway.uchicago.edu>
  10069. X-Envelope-To: icon-group@CS.Arizona.EDU
  10070. X-Vms-To: icon-group@Arizona.edu
  10071. Organization: University of Chicago
  10072. References: <1991Mar13.180536.22613@cl.cam.ac.uk>,
  10073.  <1991Mar15.013415.1499@midway.uchicago.edu>,
  10074.  <1991Mar16.142726.5947@cl.cam.ac.uk>
  10075.  
  10076. Bdb@cl.cam.ac.uk (Brian Brunswick) writes:
  10077. >>
  10078. >>    val := create f()
  10079. >>    every (x|y) := @val
  10080. >
  10081. >Yup, I'd spotted that this was possible, but was put off by the extra
  10082. >temporary variable needed - I'd really like something on one line....
  10083.  
  10084. You know, I've never understood peoples' resistence to side-effects of
  10085. this kind in Icon.  All your garbage gets collected for you, and you are
  10086. not going to have any problems with pointers.  The variables, if declared
  10087. explicitly local, aren't going to conflict with anything else.  If they
  10088. make the code clear and idiomatic, then my own vote is to use them!
  10089.  
  10090. >Hmm... I'm not so sure that I don't prefer my cludge to having to
  10091. >introduce an extra intermediate variable. Of course, its only good so
  10092. >long as its clearly recognised as an idiom by the reader, otherwise
  10093. >its needless obfuscation.
  10094.  
  10095. I guess that's what I was trying to say.
  10096.  
  10097. >Also, I hesitated somewhat at creating a co-expression just to do
  10098. >something that short that I'm likely to use quite a lot. Isn't that
  10099. >likely to be quite expensive in terms of garbage produced? Or would
  10100. >reusing the same temporary to hold it mean that reference counting or
  10101. >something rescues things?
  10102.  
  10103. You know, I really don't know.  Co-expressions involve less overhead
  10104. than a procedure call, as I understand them, and are a bit faster.  If
  10105. storage and garbage collection is a problem, you could try writing two
  10106. versions of the program, and then check out the IPL program empg.icn.
  10107. It's a tool that's ideal for just this kind of profiling.
  10108.  
  10109. You could also write a little shell script to turn on memory monitoring,
  10110. and then use the IPL routine memsum to get a summary of the results.
  10111. I'm thinking of, say,
  10112.  
  10113.  
  10114. #!/bin/sh
  10115. if
  10116.     test $# = 0
  10117. then
  10118.     echo 'usage:  memmon icon-program [arguments]'
  10119.     exit 1
  10120. else
  10121.     export MEMMON
  10122.     MEMMON=tablc.mon
  10123.     $*
  10124. #   unset MEMMON
  10125.     /usr/local/bin/memsum < tablc.mon > tablc.sum
  10126.     /bin/cat tablc.sum | egrep -v '0.000$' 1>&2
  10127.     /bin/rm tablc.mon tablc.sum
  10128. fi
  10129.  
  10130.  
  10131. I'll be curious to hear what you eventually settle on.
  10132.  
  10133. -Richard (goer@sophist.uchicago.edu)
  10134.  
  10135. From icon-group-request@arizona.edu  Mon Mar 18 12:26:15 1991
  10136. Resent-From: icon-group-request@arizona.edu
  10137. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  10138.     id AA01036; Mon, 18 Mar 91 12:26:15 -0700
  10139. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 18 Mar
  10140.  1991 12:25 MST
  10141. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA03997; Mon, 18 Mar 91
  10142.  11:07:22 -0800
  10143. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  10144.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  10145.  usenet@ucbvax.Berkeley.EDU if you have questions)
  10146. Resent-Date: Mon, 18 Mar 1991 12:26 MST
  10147. Date: 18 Mar 91 17:19:46 GMT
  10148. From: sdd.hp.com!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@ucsd.edu
  10149.  (Richard L. Goerwitz)
  10150. Subject: RE: terrible code (2)
  10151. Sender: icon-group-request@arizona.edu
  10152. Resent-To: icon-group@cs.arizona.edu
  10153. To: icon-group@arizona.edu
  10154. Resent-Message-Id: <A4D7B6DE5C601CBC@Arizona.edu>
  10155. Message-Id: <1991Mar18.171946.28280@midway.uchicago.edu>
  10156. X-Envelope-To: icon-group@CS.Arizona.EDU
  10157. X-Vms-To: icon-group@Arizona.edu
  10158. Organization: University of Chicago
  10159. References: <9103181558.AA20389@uunet.uu.net>
  10160.  
  10161. In article <9103181558.AA20389@uunet.uu.net> nowlin@isidev.UUCP writes:
  10162. >    m := 0
  10163. >    while *(p := (s ? =!l)) > m do m := *p
  10164. >    return m + 1
  10165.  
  10166. Very clever.  Try matching each member of l, keeping a record of the
  10167. length of the match.  The longest match wins.
  10168.  
  10169. This sort of code does exactly what my code does.  Here's the problem.
  10170. Solution of the type exemplified above involve mindless interation
  10171. through the entire list, l.  I decided that it would be sensible to
  10172. write a little program that made this process deterministic.  I used
  10173. tables of tables to accomplish this.  Read a char, then see if the
  10174. char is in the lookup table.  Whatever strings begin with that char
  10175. become possible matches.  Then read another char.  Of the strings con-
  10176. sidered possible matches before, only those whose 2nd character matches
  10177. the one just read are possible matches, etc.
  10178.  
  10179. I added a cheat.  If at any time we run into "" (some string runs out
  10180. of chars), we remember that spot, and continue with the remaining
  10181. strings.  If nothing else matches beyond this point, we backtrack to
  10182. it and return the position we were at when we ran out of characters in
  10183. on of the strings.
  10184.  
  10185. Anyway, this is pretty much a deterministic process (with that one
  10186. cheat described immediately above).  It's slow as mud, though.  And
  10187. so your code, Jerry, while seemingly "dumb but elegant" turns out
  10188. better than mine!
  10189.  
  10190. There must be a way to do the kinds of things we're talking about here
  10191. in Icon, and do it with somewhat greater speed than the =!l approach.
  10192.  
  10193. -Richard
  10194.  
  10195. From isidev!nowlin@uunet.UU.NET  Mon Mar 18 19:45:19 1991
  10196. Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
  10197.     id AA14218; Mon, 18 Mar 91 19:45:19 -0700
  10198. Received: from isidev.UUCP by uunet.uu.net with UUCP 
  10199.     (5.61/UUNET-primary-gateway) id AA11982; Mon, 18 Mar 91 21:45:15 -0500
  10200. Date: Mon, 18 Mar 91 21:45:15 -0500
  10201. From: isidev!nowlin@uunet.uu.net
  10202. Message-Id: <9103190245.AA11982@uunet.uu.net>
  10203. To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
  10204. Subject: Re: RE: terrible code
  10205.  
  10206. >From article <1991Mar18.171946.28280@midway.uchicago.edu> (Richard L. Goerwitz)
  10207. > In article <9103181558.AA20389@uunet.uu.net> nowlin@isidev.UUCP writes:
  10208. > >
  10209. > >    m := 0
  10210. > >    while *(p := (s ? =!l)) > m do m := *p
  10211. > >    return m + 1
  10212. >
  10213. > Very clever.  Try matching each member of l, keeping a record of the
  10214. > length of the match.  The longest match wins.
  10215. > This sort of code does exactly what my code does.  Here's the problem.
  10216. > Solution of the type exemplified above involve mindless interation
  10217. > through the entire list, l.  I decided that it would be sensible to
  10218. > ...
  10219. > There must be a way to do the kinds of things we're talking about here
  10220. > in Icon, and do it with somewhat greater speed than the =!l approach.
  10221.  
  10222. I've included the source from a subsequent reposting of the piece of code
  10223. being discussed since it was modified to follow the original program more
  10224. closely:
  10225.  
  10226.    m := 0
  10227.    while *(p := (s[i:j] ?  =!l)) > m do m := *p
  10228.    if /p then fail
  10229.    else return i + m
  10230.  
  10231. The key to this is that it's not a "mindless iteration through the entire
  10232. list".  It's an iteration, but in any language but Icon you'd have to
  10233. explicitly do a lot more to control this iteration than in the simple
  10234. expression above.  Simple is in the eyes of the beholder :-)
  10235.  
  10236. Any expression that follows the 'while' control structure must try to
  10237. succeed due to goal directed evaluation.  That means if the expression
  10238. contains a generator, in this case the !l, results are generated until the
  10239. generator is exhausted or the expression succeeds in the context of one of
  10240. the results.  If the expression succeeds the result is used to modify the
  10241. expression.  Eventually none of the generator's results will cause the
  10242. expression to succeed and the loop is exited.
  10243.  
  10244. This Icon stuff is pretty slick.  I fail to see why a few of dozen lines of
  10245. admittedly "terrible" code make a better solution than these four lines.
  10246. I could do a matching table in C that would blow this away in terms of
  10247. speed but this is Icon.  It should be done Iconishly.
  10248.  
  10249. +-------------------------------------------------------------------------+
  10250. |  --- ---                                                                |
  10251. |   | S |  Iconic Software, Inc.  -  Jerry Nowlin  - uunet!isidev!nowlin  |
  10252. |  --- ---                                                                |
  10253. +-------------------------------------------------------------------------+
  10254.  
  10255.  
  10256. From sbw@turing.cse.nau.edu  Mon Mar 18 19:57:16 1991
  10257. Received: from turing.cse.nau.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  10258.     id AA14513; Mon, 18 Mar 91 19:57:16 -0700
  10259. Received: by turing.cse.nau.edu (5.64/1.34)
  10260.     id AA10874; Mon, 18 Mar 91 19:57:02 -0700
  10261. Message-Id: <9103190257.AA10874@turing.cse.nau.edu>
  10262. From: sbw@turing.cse.nau.edu (Steve Wampler)
  10263. Date: Mon, 18 Mar 1991 19:57:02 MST
  10264. In-Reply-To: isidev!nowlin@uunet.uu.net's mail message of Mar 18, 19:47.
  10265. X-Mailer: Mail User's Shell (7.2.0 10/31/90)
  10266. To: icon-group@cs.arizona.edu
  10267. Subject: Re: RE: terrible code
  10268.  
  10269. On Mar 18 at 19:47, isidev!nowlin@uunet.uu.net writes:
  10270. }    m := 0
  10271. }    while *(p := (s[i:j] ?  =!l)) > m do m := *p
  10272. }    if /p then fail
  10273. }    else return i + m
  10274.  
  10275. Out of curiousity (and because I like bizarre code), couldn't
  10276. the above be written:
  10277.  
  10278.     m := 0
  10279.     while m >:= *(s[i:j] ? =!l)
  10280.     return i + (0 ~= m)
  10281.  
  10282. instead?  (No, I haven't tried it, but it seems the same to me...)
  10283.  
  10284. -- 
  10285.     Steve Wampler
  10286.     {....!arizona!naucse!sbw}
  10287.     {sbw@turing.cse.nau.edu}
  10288.  
  10289. From sbw@turing.cse.nau.edu  Mon Mar 18 20:01:05 1991
  10290. Received: from turing.cse.nau.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  10291.     id AA14645; Mon, 18 Mar 91 20:01:05 -0700
  10292. Received: by turing.cse.nau.edu (5.64/1.34)
  10293.     id AA10894; Mon, 18 Mar 91 20:00:46 -0700
  10294. Message-Id: <9103190300.AA10894@turing.cse.nau.edu>
  10295. From: sbw@turing.cse.nau.edu (Steve Wampler)
  10296. Date: Mon, 18 Mar 1991 20:00:46 MST
  10297. In-Reply-To: Steve Wampler's mail message of Mar 18, 19:58.
  10298. X-Mailer: Mail User's Shell (7.2.0 10/31/90)
  10299. To: icon-group@cs.arizona.edu
  10300. Subject: Re: RE: terrible code
  10301.  
  10302. On Mar 18 at 19:58, Steve Wampler writes:
  10303. } On Mar 18 at 19:47, isidev!nowlin@uunet.uu.net writes:
  10304. } } 
  10305. } }    m := 0
  10306. } }    while *(p := (s[i:j] ?  =!l)) > m do m := *p
  10307. } }    if /p then fail
  10308. } }    else return i + m
  10309. } } 
  10310. } Out of curiousity (and because I like bizarre code), couldn't
  10311. } the above be written:
  10312. }     m := 0
  10313. }     while m >:= *(s[i:j] ? =!l)
  10314. }     return i + (0 ~= m)
  10315. } instead?  (No, I haven't tried it, but it seems the same to me...)
  10316.  
  10317. Sigh.  Make that a <:=, not >:=.
  10318.  
  10319.  
  10320. -- 
  10321.     Steve Wampler
  10322.     {....!arizona!naucse!sbw}
  10323.     {sbw@turing.cse.nau.edu}
  10324.  
  10325. From icon-group-request@arizona.edu  Mon Mar 18 22:09:23 1991
  10326. Resent-From: icon-group-request@arizona.edu
  10327. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  10328.     id AA17558; Mon, 18 Mar 91 22:09:23 -0700
  10329. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 18 Mar
  10330.  1991 22:08 MST
  10331. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA22191; Mon, 18 Mar 91
  10332.  20:59:10 -0800
  10333. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  10334.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  10335.  usenet@ucbvax.Berkeley.EDU if you have questions)
  10336. Resent-Date: Mon, 18 Mar 1991 22:09 MST
  10337. Date: 19 Mar 91 04:26:11 GMT
  10338. From: magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@tut.cis.ohio-state.edu (Richard L.
  10339.  Goerwitz)
  10340. Subject: RE: RE: terrible code
  10341. Sender: icon-group-request@arizona.edu
  10342. Resent-To: icon-group@cs.arizona.edu
  10343. To: icon-group@arizona.edu
  10344. Resent-Message-Id: <F64F2F1CDC6025C0@Arizona.edu>
  10345. Message-Id: <1991Mar19.042611.18718@midway.uchicago.edu>
  10346. X-Envelope-To: icon-group@CS.Arizona.EDU
  10347. X-Vms-To: icon-group@Arizona.edu
  10348. Organization: University of Chicago
  10349. References: <9103190245.AA11982@uunet.uu.net>
  10350.  
  10351. In article <9103190245.AA11982@uunet.uu.net> nowlin@isidev.UUCP writes:
  10352. >
  10353. >   m := 0
  10354. >   while *(p := (s[i:j] ?  =!l)) > m do m := *p
  10355. >   if /p then fail
  10356. >   else return i + m
  10357. >
  10358. >The key to this is that it's not a "mindless iteration through the entire
  10359. >list".  It's an iteration, but in any language but Icon you'd have to
  10360. >explicitly do a lot more to control this iteration than in the simple
  10361. >expression above.  Simple is in the eyes of the beholder :-)
  10362.  
  10363. You know, reading over my last posting, you could take the word "mindless"
  10364. to refer to the programmer, and not to the =!l method of looking for mat-
  10365. ches.  That's not what I indended, of course.  I should really try to be
  10366. a bit more gracious.  The overall solution was really very clean.
  10367.  
  10368. Anyway, elegance of expression is certainly a plus with Icon.  So it its
  10369. economy.  The question is whether this economy doesn't sometimes involve
  10370. some serious, serious performance penalties.  In the case of my "terrible
  10371. code" (self-admitted), I was trying to use two Icon features (hash tables
  10372. and sets) to coax more performance out of a routine than the backtrack-
  10373. ing mechanisms, unhindered, allowed.
  10374.  
  10375. >This Icon stuff is pretty slick.  I fail to see why a few of dozen lines of
  10376. >admittedly "terrible" code make a better solution than these four lines.
  10377. >I could do a matching table in C that would blow this away in terms of
  10378. >speed but this is Icon.  It should be done Iconishly.
  10379.  
  10380. Well, that again is in the eyes of the beholder.  Does "Iconishly" mean
  10381. "in an extremely compact and elegant, but computationally clumsy and inef-
  10382. ficient, manner"?  Perhaps in many cases, yes.  In this case, I had hoped
  10383. no.  My attempt at doing things more deterministically, though, failed.
  10384. So in the end I was left with something both slow and inelegant.
  10385.  
  10386. I guess one could argue that this sort of thing should be done in C, and
  10387. that the easiest way to do things would be just to use the regexp rou-
  10388. tines.  Often, though, I work on larger-scale projects mainly in Icon,
  10389. and am very, very reluctant to hack in C code, either through extcall/
  10390. callout, or, worse yet, via shell scripts and pipes.  Unix isn't the only
  10391. platform I operate on, and there is something esthetically displeasing
  10392. about having to hack every interpreter I want to run software on.
  10393.  
  10394. I guess the big question is this:  How easy will inline C code be able
  10395. to be incorporated into compiled Icon code??
  10396.  
  10397. (Jerry, thanks for responding; I'll probably end up using your code, a
  10398. la Steve Wampler's modifications.)
  10399.  
  10400. -Richard (goer@sophist.uchicago.edu)
  10401.  
  10402. From cjeffery  Mon Mar 18 23:05:42 1991
  10403. Resent-From: "Clinton Jeffery" <cjeffery>
  10404. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  10405.     id AA18690; Mon, 18 Mar 91 23:05:42 -0700
  10406. Received: from megaron.cs.arizona.edu (128.196.128.118) by Arizona.edu with
  10407.  PMDF#10282; Mon, 18 Mar 1991 23:05 MST
  10408. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15)
  10409.  via SMTP id AA18679; Mon, 18 Mar 91 23:05:11 -0700
  10410. Received: by cheltenham.cs.arizona.edu; Mon, 18 Mar 91 23:05:09 MST
  10411. Resent-Date: Mon, 18 Mar 1991 23:05 MST
  10412. Date: Mon, 18 Mar 91 23:05:09 MST
  10413. From: Clinton Jeffery <cjeffery@cs.arizona.edu>
  10414. Subject: Multiple value assignment in icon???
  10415. In-Reply-To: Richard L. Goerwitz's message of 18 Mar 91 15:08:38 GMT
  10416.  <1991Mar18.150838.24597@midway.uchicago.edu>
  10417. Resent-To: icon-group@cs.arizona.edu
  10418. To: icon-group@arizona.edu
  10419. Resent-Message-Id: <FE2DEB351C60220B@Arizona.edu>
  10420. Message-Id: <9103190605.AA25040@cheltenham.cs.arizona.edu>
  10421. X-Envelope-To: icon-group@CS.Arizona.EDU
  10422. X-Vms-To: icon-group@Arizona.edu
  10423.  
  10424. >>Also, I hesitated somewhat at creating a co-expression just to do
  10425. >>something that short that I'm likely to use quite a lot. Isn't that
  10426. >>likely to be quite expensive in terms of garbage produced? Or would
  10427. >>reusing the same temporary to hold it mean that reference counting or
  10428. >>something rescues things?
  10429.  
  10430. >You know, I really don't know.  Co-expressions involve less overhead
  10431. >than a procedure call, as I understand them, and are a bit faster.
  10432.  
  10433. Basically everyone is right.
  10434. Co-expression >activation< involves less overhead and is a bit faster
  10435. than procedure call.  Co-expression >creation< does involve some work
  10436. setting up stacks and copying variables.  In many of these situations
  10437. there is some magic "average number of results" beyond which co-expressions
  10438. are cost-effective.  But of course, Icon is focused on programmer
  10439. time more than on execution time.  If you are a busy person and you
  10440. are in the habit of avoiding co-expressions for performance reasons,
  10441. not only will you miss out on a lot of fun, you will spend a lot more
  10442. time writing and debugging, and often you will not gain enough to
  10443. have justified it.
  10444.  
  10445. Clint
  10446.  
  10447. P.S. I have been guilty of avoiding co-expressions before!  Its very
  10448. understandable and really is justified, AFTER the program is finished
  10449. and you are tuning it.  Why not write it in two lines with a co-expression
  10450. first, and write yourself a comment to look at it again later...
  10451.  
  10452. From isidev!nowlin@uunet.UU.NET  Tue Mar 19 04:56:13 1991
  10453. Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
  10454.     id AA28474; Tue, 19 Mar 91 04:56:13 -0700
  10455. Received: from isidev.UUCP by uunet.uu.net with UUCP 
  10456.     (5.61/UUNET-primary-gateway) id AA24294; Tue, 19 Mar 91 06:56:08 -0500
  10457. Date: Tue, 19 Mar 91 06:56:08 -0500
  10458. From: isidev!nowlin@uunet.uu.net
  10459. Message-Id: <9103191156.AA24294@uunet.uu.net>
  10460. To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
  10461. Subject: Re: RE: terrible code
  10462.  
  10463. In message <9103190300.AA10894@turing.cse.nau.edu> From: (Steve Wampler)
  10464. > } Out of curiousity (and because I like bizarre code), couldn't
  10465. > } the above be written:
  10466. > } 
  10467. > }     m := 0
  10468. > }     while m >:= *(s[i:j] ? =!l)
  10469. > }     return i + (0 ~= m)
  10470. > } 
  10471. > } instead?  (No, I haven't tried it, but it seems the same to me...)
  10472. > Sigh.  Make that a <:=, not >:=.
  10473.  
  10474. Good reduction.  The only problem with this is that if someone were to
  10475. include an empty string in the list they're matching this solution would
  10476. fail even if it matched the empty string.  (I know...who cares!)  A simple
  10477. modification fixes that though.  I added enough to test this.  Look at an
  10478. earlier posting to see comments:
  10479.  
  10480. procedure main(args)
  10481.     s := "that begins this string"
  10482.     l := ["th","that beg","not close","","tha","begins t","that b","t"]
  10483.     write(longstr(l,s,6,12)) | write("nomatch")
  10484.     l := ["th","that beg","not close","tha","begins t","that b","t"]
  10485.     write(longstr(l,s,6,12)) | write("nomatch")
  10486. end
  10487.  
  10488. procedure longstr(l,s,i,j)
  10489.     ##### borrowed #####
  10490.     /s := &subject
  10491.     if \i then {
  10492.     if i < 1 then
  10493.         i := *s + (i+1)
  10494.     }
  10495.     else i := \&pos | 1
  10496.     if \j then {
  10497.     if j < 1 then
  10498.         j := *s + (j+1)
  10499.     }
  10500.     else j := *s+1
  10501.     ##### borrowed #####
  10502.  
  10503.     m := 0
  10504.     while m <:= *(p := (s[i:j] ? =!l))
  10505.     if /p then fail
  10506.     else return i + m
  10507. end
  10508.  
  10509. +-------------------------------------------------------------------------+
  10510. |  --- ---                                                                |
  10511. |   | S |  Iconic Software, Inc.  -  Jerry Nowlin  - uunet!isidev!nowlin  |
  10512. |  --- ---                                                                |
  10513. +-------------------------------------------------------------------------+
  10514.  
  10515.  
  10516. From sbw@turing.cse.nau.edu  Tue Mar 19 06:44:24 1991
  10517. Received: from turing.cse.nau.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  10518.     id AA01804; Tue, 19 Mar 91 06:44:24 -0700
  10519. Received: by turing.cse.nau.edu (5.64/1.34)
  10520.     id AA11777; Tue, 19 Mar 91 06:44:09 -0700
  10521. Message-Id: <9103191344.AA11777@turing.cse.nau.edu>
  10522. From: sbw@turing.cse.nau.edu (Steve Wampler)
  10523. Date: Tue, 19 Mar 1991 06:44:08 MST
  10524. X-Mailer: Mail User's Shell (7.2.0 10/31/90)
  10525. To: icon-group@cs.arizona.edu
  10526. Subject: Re: RE: terible code
  10527.  
  10528. Oh right, empty strings.  I think I would care about that - I'm pretty
  10529. fond of empty strings.  Just for grins, here's yam (yet another
  10530. modification:
  10531.  
  10532.    m := -1
  10533.    while m <:= *(s[i:j] ? =!l)
  10534.    return i+(-1 ~= m)
  10535.  
  10536.  
  10537.  
  10538. -- 
  10539.     Steve Wampler
  10540.     {....!arizona!naucse!sbw}
  10541.     {sbw@turing.cse.nau.edu}
  10542.  
  10543. From icon-group-request@arizona.edu  Tue Mar 19 10:58:56 1991
  10544. Resent-From: icon-group-request@arizona.edu
  10545. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  10546.     id AA08037; Tue, 19 Mar 91 10:58:56 -0700
  10547. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Tue, 19 Mar
  10548.  1991 10:57 MST
  10549. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA09157; Tue, 19 Mar 91
  10550.  09:43:39 -0800
  10551. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  10552.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  10553.  usenet@ucbvax.Berkeley.EDU if you have questions)
  10554. Resent-Date: Tue, 19 Mar 1991 10:58 MST
  10555. Date: 19 Mar 91 16:05:29 GMT
  10556. From: midway!ellis.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
  10557. Subject: longstr.icn
  10558. Sender: icon-group-request@arizona.edu
  10559. Resent-To: icon-group@cs.arizona.edu
  10560. To: icon-group@arizona.edu
  10561. Resent-Message-Id: <61CD2EA81C6023C2@Arizona.edu>
  10562. Message-Id: <1991Mar19.160529.4734@midway.uchicago.edu>
  10563. X-Envelope-To: icon-group@CS.Arizona.EDU
  10564. X-Vms-To: icon-group@Arizona.edu
  10565. Organization: University of Chicago
  10566.  
  10567. Here's what I finally settled on.  Thanks, everyone.
  10568. -Richard
  10569.  
  10570.  
  10571. ############################################################################
  10572. #
  10573. #    Name:     longstr.icn
  10574. #
  10575. #    Title:     match longest string in a list or set of strings
  10576. #
  10577. #    Author:     Jerry Nowlin, Steve Wampler, and Richard Goerwitz
  10578. #
  10579. #    Version: 1.1
  10580. #
  10581. ############################################################################
  10582. #
  10583. #  Anystr(l,s,i,j) works like any(), except that instead of taking a
  10584. #  cset as its first argument, it takes instead a list or set of
  10585. #  strings (l).  Returns i + *x, where x is the longest string in l
  10586. #  for which match(x,s,i,j) succeeds.  Fails if no match occurs.
  10587. #
  10588. #  Defaults:
  10589. #      s     &subject
  10590. #      i     &pos if s is defaulted, otherwise 1
  10591. #      j     0
  10592. #
  10593. #  Errors:
  10594. #      The only manual error-checking that is done is to test l to
  10595. #      be sure it is, in fact, a list or set.  Errors such as non-
  10596. #      string members in l, and non-integer i/j parameters, are
  10597. #      caught by the normal Icon built-in string processing and sub-
  10598. #      scripting mechanisms.
  10599. #
  10600. ############################################################################
  10601. #
  10602. #  Links: none
  10603. #
  10604. ############################################################################
  10605.  
  10606.  
  10607. procedure longstr(l,s,i,j)
  10608.  
  10609.     local m
  10610.  
  10611.     #
  10612.     # Is l a list or set?
  10613.     #
  10614.     type(l) == ("list"|"set") |
  10615.     stop("longstr:  list or set expected (arg 1)")
  10616.  
  10617.     #
  10618.     # Set up s and i variables just as in built-in string-handling
  10619.     # functions.
  10620.     #
  10621.     if /s := &subject then {
  10622.     if \i then {
  10623.         if i < 1 then
  10624.         i := *s + (i+1)
  10625.     }
  10626.     else i := &pos
  10627.     }
  10628.     else i := 1
  10629.  
  10630.     #
  10631.     # Set up j.
  10632.     #
  10633.     if \j then {
  10634.     if j < 1 then
  10635.         j := *s + (j+1)
  10636.     }
  10637.     else j := *s+1
  10638.  
  10639.  
  10640.     #
  10641.     # Find longest match()-ing string in l.  Initialize m to -1 so
  10642.     # as to detect cases where "" is the only match that succeeds.
  10643.     #
  10644.     m := -1            # Attempt to match() each member in l (=!l).
  10645.     while m <:= *(s[i:j] ? =!l)    # Produce the length of each match that suc-
  10646.                                    # ceeds, and store its value in m iff it is
  10647.                 # greater than m's current value.
  10648.     #
  10649.     # Return i + the length of the longest match.  Fail if there was
  10650.     # no match (i.e. m still has its original value).
  10651.     #
  10652.     return i + (-1 ~= m)
  10653.  
  10654. end
  10655.  
  10656. From icon-group-request@arizona.edu  Tue Mar 19 15:29:18 1991
  10657. Resent-From: icon-group-request@arizona.edu
  10658. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  10659.     id AA16012; Tue, 19 Mar 91 15:29:18 -0700
  10660. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Tue, 19 Mar
  10661.  1991 15:28 MST
  10662. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA18189; Tue, 19 Mar 91
  10663.  14:19:26 -0800
  10664. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  10665.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  10666.  usenet@ucbvax.Berkeley.EDU if you have questions)
  10667. Resent-Date: Tue, 19 Mar 1991 15:28 MST
  10668. Date: 19 Mar 91 21:31:34 GMT
  10669. From: agate!bionet!uwm.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@ucbvax.Berkeley.EDU (Richard
  10670.  L. Goerwitz)
  10671. Subject: longstr; naturally an oops
  10672. Sender: icon-group-request@arizona.edu
  10673. Resent-To: icon-group@cs.arizona.edu
  10674. To: icon-group@arizona.edu
  10675. Resent-Message-Id: <8786208B2C6027B2@Arizona.edu>
  10676. Message-Id: <1991Mar19.213134.15017@midway.uchicago.edu>
  10677. X-Envelope-To: icon-group@CS.Arizona.EDU
  10678. X-Vms-To: icon-group@Arizona.edu
  10679. Organization: University of Chicago
  10680.  
  10681. So you say I should actually test programs before posting them?
  10682. Looks like the while/every mistake eluded more people than just
  10683. me,though.  It took a confused (or rather not-so-confused) note
  10684. from Ken Walker.
  10685.  
  10686. -Richard
  10687.  
  10688. -------
  10689.  
  10690. ############################################################################
  10691. #
  10692. #    Name:     longstr.icn
  10693. #
  10694. #    Title:     match longest string in a list or set of strings
  10695. #
  10696. #    Author:     Jerry Nowlin, Steve Wampler, and Richard Goerwitz
  10697. #
  10698. #    Version: 1.3
  10699. #
  10700. ############################################################################
  10701. #
  10702. #  longstr(l,s,i,j) works like any(), except that instead of taking a
  10703. #  cset as its first argument, it takes instead a list or set of
  10704. #  strings (l).  Returns i + *x, where x is the longest string in l
  10705. #  for which match(x,s,i,j) succeeds.  Fails if no match occurs.
  10706. #
  10707. #  Defaults:
  10708. #      s     &subject
  10709. #      i     &pos if s is defaulted, otherwise 1
  10710. #      j     0
  10711. #
  10712. #  Errors:
  10713. #      The only manual error-checking that is done is to test l to
  10714. #      be sure it is, in fact, a list or set.  Errors such as non-
  10715. #      string members in l, and non-integer i/j parameters, are
  10716. #      caught by the normal Icon built-in string processing and sub-
  10717. #      scripting mechanisms.
  10718. #
  10719. ############################################################################
  10720. #
  10721. #  Links: none
  10722. #
  10723. ############################################################################
  10724.  
  10725.  
  10726. procedure longstr(l,s,i,j)
  10727.  
  10728.     local m
  10729.  
  10730.     #
  10731.     # Is l a list or set?
  10732.     #
  10733.     type(l) == ("list"|"set") |
  10734.     stop("longstr:  list or set expected (arg 1)")
  10735.  
  10736.     #
  10737.     # Set up s and i variables just as in built-in string-handling
  10738.     # functions.
  10739.     #
  10740.     if /s := &subject then
  10741.     /i := &pos
  10742.     if \i then {
  10743.     if i < 1 then
  10744.         i := *s + (i+1)
  10745.     }
  10746.     else i := 1
  10747.  
  10748.     #
  10749.     # Set up j.
  10750.     #
  10751.     if \j then {
  10752.     if j < 1 then
  10753.         j := *s + (j+1)
  10754.     }
  10755.     else j := *s+1
  10756.  
  10757.     #
  10758.     # Find longest match()-ing string in l.  Initialize m to -1 so
  10759.     # as to detect cases where "" is the only match that succeeds.
  10760.     #
  10761.     m := -1            # Attempt to match() each member in l (=!l).
  10762.     every m <:= *(s[i:j] ? =!l)    # Produce the length of each match that suc-
  10763.                                    # ceeds, and store its value in m iff it is
  10764.                 # greater than m's current value.
  10765.     #
  10766.     # Return i + the length of the longest match.  Fail if there was
  10767.     # no match (i.e. m still has its original value).
  10768.     #
  10769.     return i + (-1 ~= m)
  10770.  
  10771. end
  10772.  
  10773. From alex@laguna.Metaphor.COM  Tue Mar 19 17:28:53 1991
  10774. Received: from relay.metaphor.com by megaron.cs.arizona.edu (5.61/15) via SMTP
  10775.     id AA20897; Tue, 19 Mar 91 17:28:53 -0700
  10776. Received: from laguna.Metaphor.COM by relay.metaphor.com (4.1/SMI-4.1)
  10777.     id AA05155; Tue, 19 Mar 91 16:24:19 PST
  10778. Received: by laguna.Metaphor.COM (4.0/SMI-4.0)
  10779.     id AA02704; Tue, 19 Mar 91 16:28:02 PST
  10780. Date: Tue, 19 Mar 91 16:28:02 PST
  10781. From: alex@laguna.Metaphor.COM (Bob Alexander)
  10782. Message-Id: <9103200028.AA02704@laguna.Metaphor.COM>
  10783. To: icon-group@cs.arizona.edu
  10784. Subject: Comment on longstr.icn
  10785.  
  10786. Gee, this is fun.  I have a couple of comments to throw into the frey.
  10787.  
  10788. 1)  Perhaps instead of the stop() if there is a problem with the
  10789. arguments, a runerr() would be more consistent with the builtin
  10790. string-analysis procedures -- "115: list, set, or table expected" would
  10791. be reasonably appropriate, since the algorithm could work with tables
  10792. too (records, too, for that matter, but that's probably a bit much).
  10793.  
  10794. 2)  Things could be simplified quite a bit by not messing with defaults
  10795. for s, i, and j and letting Icon do the work by eliminating the string
  10796. scanning.  In this version, the m := -1 initial value can revert back
  10797. to 0, since matching an empty string returns 1.
  10798.  
  10799. So here's my entry in the series of suggestions.  Somehow I can't help
  10800. but wonder if I've missed something obvious -- but if not, do I get my
  10801. name in the growing list of credits? :-)
  10802.  
  10803.  
  10804. procedure longstr(l,s,i,j)
  10805.  
  10806.     local m
  10807.  
  10808.     #
  10809.     # Is l a list, set, table?
  10810.     #
  10811.     type(l) == ("list" | "set" | "table") |
  10812.         runerr(115,l)
  10813.  
  10814.     #
  10815.     # Find longest match()-ing string in l.
  10816.     #
  10817.     m := 0                      # Attempt to match() each member in l (=!l).
  10818.     every m <:= match(!l,s,i,j) # Produce the length of each match that suc-
  10819.                                 # ceeds, and store its value in m iff it is
  10820.                                 # greater than m's current value.
  10821.     #
  10822.     # Return i + the length of the longest match.  Fail if there was
  10823.     # no match (i.e. m still has its original value).
  10824.     #
  10825.     return 0 ~= m
  10826.  
  10827. end
  10828.  
  10829.  
  10830. -- Bob Alexander
  10831.  
  10832. Metaphor Computer Systems   (415) 961-3600 x751   alex@metaphor.com
  10833. ====^=== Mountain View, CA  ...{uunet}!{decwrl,apple}!metaphor!alex
  10834.  
  10835. From isidev!nowlin@uunet.UU.NET  Tue Mar 19 19:33:10 1991
  10836. Received: from uunet.UU.NET by megaron.cs.arizona.edu (5.61/15) via SMTP
  10837.     id AA26567; Tue, 19 Mar 91 19:33:10 -0700
  10838. Received: from isidev.UUCP by uunet.UU.NET with UUCP 
  10839.     (5.61/UUNET-primary-gateway) id AA07937; Tue, 19 Mar 91 21:33:06 -0500
  10840. Date: Tue, 19 Mar 91 21:33:06 -0500
  10841. From: isidev!nowlin@uunet.uu.net
  10842. Message-Id: <9103200233.AA07937@uunet.UU.NET>
  10843. To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
  10844. Subject: Re: longstr oops
  10845.  
  10846. From-Id: <1991Mar19.213134.15017@midway.uchicago.edu>
  10847.  
  10848. > So you say I should actually test programs before posting them?
  10849. > Looks like the while/every mistake eluded more people than just
  10850. > me, though.  It took a confused (or rather not-so-confused) note
  10851. > from Ken Walker.
  10852. >   # Find longest match()-ing string in l.  Initialize m to -1 so
  10853. >   # as to detect cases where "" is the only match that succeeds.
  10854. >   #
  10855. >   m := -1            # Attempt to match() each member in l (=!l).
  10856. >   every m <:= *(s[i:j] ? =!l)    # Produce the length of each match that suc-
  10857. >                                  # ceeds, and store its value in m if it is
  10858. >                # greater than m's current value.
  10859. >   #
  10860. >   # Return i + the length of the longest match.  Fail if there was
  10861. >   # no match (i.e. m still has its original value).
  10862. >   #
  10863. >   return i + (-1 ~= m)
  10864.  
  10865. The 'while' was not a mistake.  The program I posted with test data and a
  10866. main procedure in it worked just fine with a 'while' instead of an
  10867. 'every'.  I wasn't looking for iteration here.  I was looking for GOAL
  10868. DIRECTED EVALUATION.  The 'while' forces the expression:
  10869.  
  10870.         m <:= *(s[i:j] ?  =!l)
  10871.  
  10872. to do everything it can to succeed.  Since there's a generator in this
  10873. expression (!l) all the strings in 'l' are generated every time through the
  10874. loop until one of the strings is matched and it's longer than the last
  10875. string that was matched.  GOAL DIRECTED EVALUATION forces the generator to
  10876. generate so you don't need an 'every'.  When there are no more strings in
  10877. 'l' that will match and that are longer than the last match the loop
  10878. terminates.
  10879.  
  10880. The 'every' works, but for a different reason.  The 'every' is probably
  10881. faster since it only iterates through the list once.  It's important to
  10882. understand why both work for different reasons.  They both work though.
  10883.  
  10884. +-------------------------------------------------------------------------+
  10885. |  --- ---                                                                |
  10886. |   | S | Iconic Software, Inc.  -  Jerry Nowlin  -  uunet!isidev!nowlin  |
  10887. |  --- ---                                                                |
  10888. +-------------------------------------------------------------------------+
  10889.  
  10890.  
  10891. From sbw@turing.cse.nau.edu  Tue Mar 19 19:44:16 1991
  10892. Received: from turing.cse.nau.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  10893.     id AA26810; Tue, 19 Mar 91 19:44:16 -0700
  10894. Received: by turing.cse.nau.edu (5.64/1.34)
  10895.     id AA15863; Tue, 19 Mar 91 19:44:01 -0700
  10896. Message-Id: <9103200244.AA15863@turing.cse.nau.edu>
  10897. From: sbw@turing.cse.nau.edu (Steve Wampler)
  10898. Date: Tue, 19 Mar 1991 19:44:00 MST
  10899. In-Reply-To: isidev!nowlin@uunet.uu.net's mail message of Mar 19, 19:35.
  10900. X-Mailer: Mail User's Shell (7.2.0 10/31/90)
  10901. To: icon-group@cs.arizona.edu
  10902. Subject: Re: longstr oops
  10903.  
  10904. On Mar 19 at 19:35, isidev!nowlin@uunet.uu.net writes:
  10905. } The 'while' was not a mistake.  The program I posted with test data and a
  10906. } main procedure in it worked just fine with a 'while' instead of an
  10907. } 'every'.  I wasn't looking for iteration here.  I was looking for GOAL
  10908. } DIRECTED EVALUATION.  The 'while' forces the expression:
  10909. }         m <:= *(s[i:j] ?  =!l)
  10910. } to do everything it can to succeed.  Since there's a generator in this
  10911. } expression (!l) all the strings in 'l' are generated every time through the
  10912. } loop until one of the strings is matched and it's longer than the last
  10913. } string that was matched.  GOAL DIRECTED EVALUATION forces the generator to
  10914. } generate so you don't need an 'every'.  When there are no more strings in
  10915. } 'l' that will match and that are longer than the last match the loop
  10916. } terminates.
  10917. } The 'every' works, but for a different reason.  The 'every' is probably
  10918. } faster since it only iterates through the list once.  It's important to
  10919. } understand why both work for different reasons.  They both work though.
  10920.  
  10921. Along the same lines, if the list were sorted by length of strings
  10922. (longest first), you can eliminate the 'while' and the 'every' and
  10923. let's GDE do it's thing.  It just doesn't seem worth it do so...
  10924.  
  10925. And anyway, I definitely like Bob Alexander's solution more.
  10926.  
  10927. -- 
  10928.     Steve Wampler
  10929.     {....!arizona!naucse!sbw}
  10930.     {sbw@turing.cse.nau.edu}
  10931.  
  10932. From kwalker  Tue Mar 19 21:22:43 1991
  10933. Received: from gacham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  10934.     id AA29427; Tue, 19 Mar 91 21:22:43 -0700
  10935. Date: Tue, 19 Mar 91 21:22:41 MST
  10936. From: "Kenneth Walker" <kwalker>
  10937. Message-Id: <9103200422.AA03634@gacham.cs.arizona.edu>
  10938. Received: by gacham.cs.arizona.edu; Tue, 19 Mar 91 21:22:41 MST
  10939. In-Reply-To: <9103200233.AA07937@uunet.UU.NET>
  10940. To: icon-group
  10941. Subject: Re: longstr oops
  10942.  
  10943. > Date: Tue, 19 Mar 91 21:33:06 -0500
  10944. > From: isidev!nowlin@uunet.uu.net
  10945. > The 'while' was not a mistake.  The program I posted with test data and a
  10946. > main procedure in it worked just fine with a 'while' instead of an
  10947. > 'every'.  I wasn't looking for iteration here.  I was looking for GOAL
  10948. > DIRECTED EVALUATION.  The 'while' forces the expression:
  10949. >         m <:= *(s[i:j] ?  =!l)
  10950. > to do everything it can to succeed.  Since there's a generator in this
  10951. > expression (!l) all the strings in 'l' are generated every time through the
  10952. > loop until one of the strings is matched and it's longer than the last
  10953. > string that was matched.  GOAL DIRECTED EVALUATION forces the generator to
  10954. > generate so you don't need an 'every'.  When there are no more strings in
  10955. > 'l' that will match and that are longer than the last match the loop
  10956. > terminates.
  10957. > The 'every' works, but for a different reason.  The 'every' is probably
  10958. > faster since it only iterates through the list once.  It's important to
  10959. > understand why both work for different reasons.  They both work though.
  10960.  
  10961. I agree that both work. However, I don't feel the reason is that much
  10962. different. In both cases, goal directed evaluation occurs within
  10963. the expression to satisefy the <:= operator. When it succeeds within
  10964. the while expression, evaluation starts over from the begining of the
  10965. list and continues till it finds the next value that satisefies the
  10966. operator. The process is potentially quadratic in the size of the list
  10967. [1 + 2 + 3 + ... + n = n*(n+1)/2]. When the expression succeeds in the
  10968. every expression it is resumed and goal-directed evaluation continues
  10969. the search where it left off - a linear process.
  10970.  
  10971. I suspect there are some properties of a list that cannot be computed
  10972. with one linear pass but can be computed with the "while" approach
  10973. though I haven't come up with one after a few minutes of thought.
  10974.  
  10975.   Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  10976.   +1 602 621-4252  kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker
  10977.  
  10978. From icon-group-request@arizona.edu  Wed Mar 20 12:53:41 1991
  10979. Resent-From: icon-group-request@arizona.edu
  10980. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  10981.     id AA27344; Wed, 20 Mar 91 12:53:41 -0700
  10982. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 20 Mar
  10983.  1991 12:53 MST
  10984. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA28187; Wed, 20 Mar 91
  10985.  11:37:30 -0800
  10986. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  10987.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  10988.  usenet@ucbvax.Berkeley.EDU if you have questions)
  10989. Resent-Date: Wed, 20 Mar 1991 12:53 MST
  10990. Date: 20 Mar 91 17:10:35 GMT
  10991. From: usc!sdd.hp.com!news.cs.indiana.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@ucsd.edu
  10992.  (Richard L. Goerwitz)
  10993. Subject: RE: Comment on longstr.icn (will this thread die?)
  10994. Sender: icon-group-request@arizona.edu
  10995. Resent-To: icon-group@cs.arizona.edu
  10996. To: icon-group@arizona.edu
  10997. Resent-Message-Id: <3AFF72310C6028A5@Arizona.edu>
  10998. Message-Id: <1991Mar20.171035.14579@midway.uchicago.edu>
  10999. X-Envelope-To: icon-group@CS.Arizona.EDU
  11000. X-Vms-To: icon-group@Arizona.edu
  11001. Organization: University of Chicago
  11002. References: <9103200028.AA02704@laguna.Metaphor.COM>
  11003.  
  11004. alex@LAGUNA.METAPHOR.COM (Bob Alexander) writes:
  11005.  
  11006. >Gee, this is fun.
  11007.  
  11008. Sure is.
  11009.  
  11010. >So here's my entry in the series of suggestions.  Somehow I can't help
  11011. >but wonder if I've missed something obvious -- but if not, do I get my
  11012. >name in the growing list of credits? :-)
  11013.  
  11014. The credits don't fit onto one line anymore :-).
  11015.  
  11016. Jerry Nowlin gave this procedure its name, and started the whole dis-
  11017. cussion of whether backtracking though a list was not better than my
  11018. original (terrible) solution.  Steve Wampler made the code somewhat
  11019. terser and more elegant.  Ken Walker suggested turning while into
  11020. every, to make it possible to go through the list only once.  Bob
  11021. Alexander pointed out that explicit handling of offsets i/j was not
  11022. necessary, as long as we were using match().
  11023.  
  11024. In this most recent post, I've created a static structure to hold re-
  11025. verse-sorted versions of arg 1 (l).  Under normal circumstances, each in-
  11026. vocation will not contain a completely different first argument.  In
  11027. most cases, the same l will be used at least two or three times.  On
  11028. my machine, the magic number of re-uses for a five or six-element l,
  11029. with strings of 3-8 characters, is about 3.  With three or more invo-
  11030. cations of longstr(l, s, i, j) with the same first arg, it becomes
  11031. worthwhile to sort l in reverse order, and store this list for later
  11032. use.
  11033.  
  11034. The worst-case scenario for this version would be if it were called
  11035. repeatedly, with different first arguments, each of which was a list
  11036. with elements of the same length.  The performance, even in this case,
  11037. however, is close enough to Bob Alexander's version that it's worth
  11038. using it.
  11039.  
  11040. -Richard
  11041.  
  11042.  
  11043. ############################################################################
  11044. #
  11045. #    Name:     longstr.icn
  11046. #
  11047. #    Title:     match longest string in a list or set of strings
  11048. #
  11049. #    Authors: Jerry Nowlin, Steve Wampler, Kenneth Walker, Bob
  11050. #                Alexander, and Richard Goerwitz
  11051. #
  11052. #    Version: 1.8
  11053. #
  11054. ############################################################################
  11055. #
  11056. #  longstr(l,s,i,j) works like any(), except that instead of taking a
  11057. #  cset as its first argument, it takes instead a list or set of
  11058. #  strings (l).  Returns i + *x, where x is the longest string in l
  11059. #  for which match(x,s,i,j) succeeds.  Fails if no match occurs.
  11060. #
  11061. #  Defaults:
  11062. #      s     &subject
  11063. #      i     &pos if s is defaulted, otherwise 1
  11064. #      j     0
  11065. #
  11066. #  Errors:
  11067. #      The only manual error-checking that is done is to test l to
  11068. #      be sure it is, in fact, a list or set.  Errors such as non-
  11069. #      string members in l, and non-integer i/j parameters, are
  11070. #      caught by the normal Icon built-in string processing and sub-
  11071. #      scripting mechanisms.
  11072. #
  11073. ############################################################################
  11074. #
  11075. #  Links: none
  11076. #
  11077. ############################################################################
  11078.  
  11079.  
  11080. procedure longstr(l,s,i,j)
  11081.  
  11082.     local elem, tmp_table
  11083.     static l_table
  11084.     initial l_table := table()
  11085.  
  11086.     #
  11087.     # No-arg invocation wipes out all static structures, and forces an
  11088.     # immediate garbage collection.
  11089.     #
  11090.     if (/l, /s) then {
  11091.     l_table := table()
  11092.     collect()        # do it NOW
  11093.     return            # return &null
  11094.     }
  11095.  
  11096.     #
  11097.     # Is l a list, set, or table?
  11098.     #
  11099.     type(l) == ("list"|"set"|"table") |
  11100.     stop("longstr:  list, table, or set expected (arg 1)")
  11101.  
  11102.     #
  11103.     # Sort l longest-to-shortest, and keep a copy of the resulting
  11104.     # structure in l_table[l] for later use.
  11105.     #
  11106.     if /l_table[l] := [] then {
  11107.  
  11108.     tmp_table := table()
  11109.     # keys = lengths of elements, values = elements
  11110.     every elem := !l do {
  11111.         /tmp_table[*elem] := []
  11112.         put(tmp_table[*elem], elem)
  11113.     }
  11114.     # sort by key; stuff values, in reverse order, into a list
  11115.     every put(l_table[l], !sort(tmp_table,3)[*tmp_table*2 to 2 by -2])
  11116.  
  11117.     }
  11118.  
  11119.     #
  11120.     # First element in l_table[l] to match is the longest match (it's
  11121.     # sorted longest-to-shortest, remember?).
  11122.     #
  11123.     return match(!l_table[l],s,i,j)
  11124.  
  11125. end
  11126.  
  11127. From ralph  Thu Mar 21 14:30:32 1991
  11128. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  11129.     id AA07095; Thu, 21 Mar 91 14:30:32 -0700
  11130. Date: Thu, 21 Mar 91 14:30:30 MST
  11131. From: "Ralph Griswold" <ralph>
  11132. Message-Id: <9103212130.AA13645@cheltenham.cs.arizona.edu>
  11133. Received: by cheltenham.cs.arizona.edu; Thu, 21 Mar 91 14:30:30 MST
  11134. To: icon-group
  11135. Subject: An Optimizing Compiler for Icon
  11136.  
  11137.         Icon Compiler for UNIX Platforms
  11138.  
  11139. A preliminary release of the optimizing compiler for the Icon programming
  11140. language is now available. This compiler generates stand-alone executable
  11141. files unlike the Icon interpreter. The compilation process itself is slow
  11142. compared with the interpreter, but the resulting executable files run
  11143. much faster than interpreted ones.
  11144.  
  11145. The Icon compiler produces C code, so you'll need a C compiler to use it.
  11146.  
  11147. The preliminary release corresponds approximately to Version 7.6 of Icon
  11148. and does not have all Version 8 features. Version 8 of the compiler will
  11149. be released later.
  11150.  
  11151. The preliminary release is now available via FTP for several UNIX platforms.
  11152. The presently available platforms are:
  11153.  
  11154.     DECstation 3100 running Ultrix
  11155.     HP 9000/330 running HP/UX
  11156.     Iris 4D running IRIX
  11157.     NeXT running Mach
  11158.     Sequent Symmetry running DYNIX
  11159.     Sun 3 Workstation running SunOS
  11160.     Sun 4 Workstation running SunOS
  11161.     VAX running 4.3 BSD
  11162.  
  11163. Implementations for other platforms will be added as they are completed.
  11164.  
  11165. The present release is in object format. Complete source code for the
  11166. compiler will be released later.
  11167.  
  11168. To get a copy of the Icon compiler, do an anonymous FTP to cs.arizona.edu.
  11169. Then cd to /icon/v8/Compiler. There are two subdirectories, Docs and
  11170. Packages.
  11171.  
  11172. The subdirectory Docs contains PostScript for an installation manual (IPD165)
  11173. and a user's guide (IPD157). You should print and read these documents before
  11174. getting a copy of the compiler.
  11175.  
  11176. The subdirectory Packages contains several additional subdirectories,
  11177. one for each presently supported platform. The subdirectory names identify
  11178. the platforms.
  11179.  
  11180. See the READ.ME files in the various directories for additional information.
  11181.  
  11182. Please direct any questions to me, not icon-group.
  11183.  
  11184.  
  11185.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  11186.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  11187.     
  11188.  
  11189. From ralph  Thu Mar 21 17:20:12 1991
  11190. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  11191.     id AA11895; Thu, 21 Mar 91 17:20:12 -0700
  11192. Date: Thu, 21 Mar 91 17:20:11 MST
  11193. From: "Ralph Griswold" <ralph>
  11194. Message-Id: <9103220020.AA20593@cheltenham.cs.arizona.edu>
  11195. Received: by cheltenham.cs.arizona.edu; Thu, 21 Mar 91 17:20:11 MST
  11196. To: icon-group
  11197. Subject: Icon compiler
  11198.  
  11199. If you have troubles running the Icon compiler on your system, first
  11200. check the information in the READ.ME file in our FTP area for your
  11201. platform.  If, for example, you're running a different version of
  11202. the operating system and related software from the one on which the
  11203. object files of the compiler are based, you may have difficulties.
  11204.  
  11205. We can't hope to provide variants for different versions of software.
  11206. If you can't run our object distribution, please be patient -- we'll
  11207. have source code available later.
  11208.  
  11209.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  11210.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  11211.  
  11212. From mailrus.cc.umich.edu!ames!amdcad!netcom!pbewig@hellgate.utah.edu  Fri Mar 22 10:15:54 1991
  11213. Received: from univers.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  11214.     id AA08183; Fri, 22 Mar 91 10:15:54 -0700
  11215. Received: from hellgate.utah.edu by univers.cs.arizona.edu; Fri, 22 Mar 91 10:15:52 MST
  11216. Received: from mailrus.cc.umich.edu by hellgate.utah.edu (5.65/utah-2.16s-cs)
  11217.     id AA12951; Fri, 22 Mar 91 10:15:38 -0700
  11218. Received: from ames.arc.nasa.gov by mailrus.cc.umich.edu (5.61/1123-1.0)
  11219.     id AA11495; Fri, 22 Mar 91 12:13:19 -0500
  11220. Received: by ames.arc.nasa.gov (5.64/1.2); Fri, 22 Mar 91 09:15:31 -0800
  11221. Received: from netcom.UUCP by AMD.COM (4.1/SMI-4.1-AMD-90.12.27)
  11222.     id AA08351; Fri, 22 Mar 91 08:53:25 PST
  11223. Received: by netcom.netcom.com (/\==/\ Smail3.1.20.1 #20.4)
  11224.     id <m0jJpFY-000CQyC@netcom.netcom.com>; Fri, 22 Mar 91 08:46 PST
  11225. Message-Id: <m0jJpFY-000CQyC@netcom.netcom.com>
  11226. Date: Fri, 22 Mar 91 08:46 PST
  11227. From: mailrus.cc.umich.edu!ames!amdcad!netcom.com!pbewig@hellgate.utah.edu (Phil Bewig)
  11228. X-Mailer: Mail User's Shell (7.2.0 10/31/90)
  11229. To: icon-group@cs.arizona.edu
  11230. Subject: dBASE procedures
  11231.  
  11232. Does anyone have available a library of procedures for maintaining
  11233. a dBASE database?
  11234.  
  11235. Thanks for any help.
  11236.  
  11237. Phil Bewig .. pbewig@netcom.com
  11238.  
  11239. From icon-group-request@arizona.edu  Fri Mar 22 10:37:22 1991
  11240. Resent-From: icon-group-request@arizona.edu
  11241. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  11242.     id AA08650; Fri, 22 Mar 91 10:37:22 -0700
  11243. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 22 Mar
  11244.  1991 10:36 MST
  11245. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA07723; Fri, 22 Mar 91
  11246.  09:34:20 -0800
  11247. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  11248.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  11249.  usenet@ucbvax.Berkeley.EDU if you have questions)
  11250. Resent-Date: Fri, 22 Mar 1991 10:37 MST
  11251. Date: 22 Mar 91 16:39:13 GMT
  11252. From: pacific.mps.ohio-state.edu!linac!midway!ellis.uchicago.edu!goer@tut.cis.ohio-state.edu (Richard L.
  11253.  Goerwitz)
  11254. Subject: snapshot; readability
  11255. Sender: icon-group-request@arizona.edu
  11256. Resent-To: icon-group@cs.arizona.edu
  11257. To: icon-group@arizona.edu
  11258. Resent-Message-Id: <BA4AE0466C602F1C@Arizona.edu>
  11259. Message-Id: <1991Mar22.163913.27902@midway.uchicago.edu>
  11260. X-Envelope-To: icon-group@CS.Arizona.EDU
  11261. X-Vms-To: icon-group@Arizona.edu
  11262. Organization: University of Chicago
  11263.  
  11264.  
  11265. I'm not claiming that this is particularly elegant, or even correct.
  11266. I just hacked it together this morning because I have a doc in which
  11267. 90% of the strings don't fit on my terminal, and which snapshot(),
  11268. as it is in the IPL, produces an unreadable display.
  11269.  
  11270. Does anyone, in principle, have any objection to snapshot having a
  11271. notion of display length?
  11272.  
  11273. -Richard
  11274.  
  11275.  
  11276. ----------
  11277.  
  11278. procedure snapshot(title,len)
  11279.  
  11280.    local bar1, bar2, bar3, is, is0, prefix, titlel, placement, POS
  11281.  
  11282.    /title := ""
  11283.    prefix := "&subject = "
  11284.    is := image(&subject)
  11285.    is0 := *image(&subject[1:&pos]) | fail # quick exit if bogus
  11286.  
  11287.    #
  11288.    # Set up top and bottom bars (not exceeding len width, if
  11289.    # len is nonnull).  Fit title into top bar (bar1).
  11290.    #
  11291.    bar1 := bar3 := repl("-", *is + *prefix + 4)[1:\len-4|0]
  11292.    # in *is + *prefix + 4, the 4 is for two vbars/two spaces
  11293.    titlel := (*title > *bar3-4) | *title[1:\len-4|0]
  11294.    bar1[3+:titlel] := title[1+:titlel]
  11295.  
  11296.  
  11297.    #
  11298.    # Write bar1, then a spacer (bar2).  Then write out len-size chunks
  11299.    # of &subject, with the | pointer-line, where appropriate. Finally,
  11300.    # write out bar3.
  11301.    #
  11302.    write(bar1)
  11303.    write(bar2 := ("|" || repl(" ", *bar1 - 2) || "|"),"\n",bar2)
  11304.    placement := *prefix + is0
  11305.    (prefix || is) ? {
  11306.        until pos(0) do {
  11307.        POS := &pos - 1
  11308.        write("| ", move(*bar3-4) | left(tab(0), *bar3-4), " |")
  11309.        if POS < placement <= &pos then {
  11310.            writes("| ")
  11311.            writes(left(repl(" ", placement - POS) || "|", *bar3-4))
  11312.            write(" |\n",bar2)
  11313.        }
  11314.        else write(bar2,"\n",bar2)
  11315.        }
  11316.    }
  11317.    write(bar3)
  11318.    return            # nothing to return
  11319.  
  11320. end
  11321.  
  11322. From icon-group-request@arizona.edu  Tue Mar 26 18:21:53 1991
  11323. Resent-From: icon-group-request@arizona.edu
  11324. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  11325.     id AA27321; Tue, 26 Mar 91 18:21:53 -0700
  11326. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Tue, 26 Mar
  11327.  1991 18:21 MST
  11328. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA25268; Tue, 26 Mar 91
  11329.  17:00:08 -0800
  11330. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  11331.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  11332.  usenet@ucbvax.Berkeley.EDU if you have questions)
  11333. Resent-Date: Tue, 26 Mar 1991 18:21 MST
  11334. Date: 26 Mar 91 23:46:39 GMT
  11335. From: midway!ellis.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
  11336. Subject: text-base utility
  11337. Sender: icon-group-request@arizona.edu
  11338. Resent-To: icon-group@cs.arizona.edu
  11339. To: icon-group@arizona.edu
  11340. Resent-Message-Id: <1FD63D74EC6039BC@Arizona.edu>
  11341. Message-Id: <1991Mar26.234639.27285@midway.uchicago.edu>
  11342. X-Envelope-To: icon-group@CS.Arizona.EDU
  11343. X-Vms-To: icon-group@Arizona.edu
  11344. Organization: University of Chicago
  11345.  
  11346. Sometimes it's not convenient to insert numerous and/or large blocks
  11347. of text into hash tables at run-time.  Some time ago I posted some
  11348. simple routines which make it possible to perform table-like operations
  11349. on files containing key/value combinations.  I've updated these rou-
  11350. tines a bit, and expanded them slightly.  Instead of reposting, I've
  11351. decided to mail them out individually to anyone who asks.
  11352.  
  11353. -Richard
  11354.  
  11355. ------------
  11356.  
  11357. From the README file:
  11358.  
  11359. This archive contains gettext() and associated routines.  Gettext()
  11360. allows the user to maintain a file of key/value combinations such that
  11361. a call to gettext(key, FNAME) will produce value.  Fails if no such
  11362. key exists.  Returns an empty string if the key exists, but has no
  11363. associated value in the file named in arg 2 (FNAME).  Gettext() is
  11364. intended for use in situations where keys need to be associated with
  11365. very large strings (i.e. where hand-inserting these values into hash
  11366. tables would be unwieldy, and would take up a sizable chunk of
  11367. memory).
  11368.  
  11369. The file format is simple.  Keys belong on separate lines, marked as
  11370. such by an initial colon+colon (::).  Values begin on the line
  11371. following their respective keys, and extend up to the next
  11372. colon+colon-initial line or EOF.  E.g.
  11373.  
  11374.    ::sample.1
  11375.    Notice how the key above, sample.1, has :: prepended to mark it
  11376.    out as a key.  The text you are now reading represents that key's
  11377.    value.  To retrieve this text, you would call gettext() with the
  11378.    name of the key passed as its first argument, and the name of the
  11379.    file in which this text is stored as its second argument (as in
  11380.    gettext("sample.1","tmp.idx")).
  11381.    ::next.key
  11382.    etc...
  11383.  
  11384. For faster access, an indexing utility is included, idxtext.  Idxtext
  11385. creates a separate index for a given text-base file.  If an index file
  11386. exists in the same directory as FNAME, gettext() will make use of it.
  11387. Otherwise, it just does a sequential search of the entire file (this
  11388. works fine for smaller files).  Please don't change a file, once
  11389. you've run idxtext on it, except to append key/value entries to it.
  11390. If you alter the indexed portion of the file in any way, you must
  11391. reindex.
  11392.  
  11393. If you want a list of all the keys in FNAME, call getkeys(FNAME).
  11394. Getkeys (as one might expect) resides in the file getkeys.icn.  I
  11395. guess an in-core regexp pattern search could be implemented by
  11396. stuffing all keys for a given text-base file into a list, and then
  11397. using findre.icn to match patterns agains the keys (hits could 
  11398. then be retrieved via calls to gettext()).
  11399. -- 
  11400.  
  11401.    -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  11402.    goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  11403.  
  11404. From icon-group-request@arizona.edu  Sat Mar 30 06:33:51 1991
  11405. Resent-From: icon-group-request@arizona.edu
  11406. Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
  11407.     id AA18704; Sat, 30 Mar 91 06:33:51 -0700
  11408. Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 30 Mar
  11409.  1991 06:33 MST
  11410. Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA20646; Sat, 30 Mar 91
  11411.  05:28:33 -0800
  11412. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  11413.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  11414.  usenet@ucbvax.Berkeley.EDU if you have questions)
  11415. Resent-Date: Sat, 30 Mar 1991 06:33 MST
  11416. Date: 29 Mar 91 16:22:11 GMT
  11417. From: eru!kth.se!sunic!mcsun!ukc!mucs!m1!bevan@bloom-beacon.mit.edu (Stephen J
  11418.  Bevan)
  11419. Subject: Survey Results : Perl vs Icon vs .... (> 500 lines)
  11420. Sender: icon-group-request@arizona.edu
  11421. Resent-To: icon-group@cs.arizona.edu
  11422. To: icon-group@arizona.edu
  11423. Resent-Message-Id: <E198C3D4FC6051A9@Arizona.edu>
  11424. Message-Id: <BEVAN.91Mar29162211@panda.cs.man.ac.uk>
  11425. X-Envelope-To: icon-group@CS.Arizona.EDU
  11426. X-Vms-To: icon-group@Arizona.edu
  11427. Organization: Department of Computer Science, University of Manchester
  11428.  
  11429. [Note I've crossposted to all the groups I send my original message
  11430. to.  This was at the request of some of the respondents (sp?)]
  11431.  
  11432. Here are the results of my question regarding which language to use for
  11433. writing programs to extract information from files, generate reports
  11434. ... etc.  I initially suggested languages like Perl, Icon, Python ...
  11435.  
  11436. As part of my original message I said :-
  11437.  
  11438. > Rather than FTP all of them and wade through the documentation, I was
  11439. > wondering if anybody has experiences with them that they'd like to
  11440. > share?
  11441.  
  11442. I would like to thank the following people for replying :-
  11443.  
  11444. Dan Bernstein - brnstnd@kramden.acf.nyu.edu 
  11445. Tom Christiansen - tchrist@convex.COM
  11446. Chris Eich - chrise@hpnmdla.hp.com
  11447. Richard L. Goerwitz - goer@midway.uchicago.edu
  11448. Clinton Jeffery - cjeffery@cs.arizona.edu
  11449. Guido van Rossum - guido@cwi.nl
  11450. Randal L. Schwartz - merlyn@iWarp.intel.com
  11451. Peter da Silva - peter@ficc.ferranti.com
  11452. Alan Thew - QQ11@LIVERPOOL.AC.UK
  11453. Edward Vielmetti - emv@ox.com
  11454. ?? - russell@ccu1.aukuni.ac.nz
  11455.  
  11456. Most of the replies were about Perl, so I didn't learn much about the
  11457. other languages I suggested (other than very general things).
  11458. Even though I was originally hoping not to have to ftp any stuff, I
  11459. ended up getting the source to Python, GAWK, TCL, Icon and the texinfo
  11460. manual for Perl.
  11461.  
  11462. To save you going through my list of good and bad points of the
  11463. languages I looked at, here is the summary of what I see the languages
  11464. as :-
  11465.  
  11466. TCL - an embedded language i.e. an extension language for large
  11467.       programs (IMHO only if you haven't got, or don't
  11468.       like, Scheme based ones like ELK).
  11469. Perl - the de facto UNIX scripting language.  You name it, and you
  11470.        can probably cobble a solution together in Perl.
  11471.        Beyond the fact that a lot of people use it, I can see nothing
  11472.        to recommend it.  It's a bit like C in that respect.
  11473. Python - Good prototyping language with a consistent design.  It might
  11474.          not have all the low level UNIX stuff built in, but by using 
  11475.          modules, its easy to add the necessary things in an ordered way.
  11476. Icon - the `nearly' language.  Well designed language, that never seemed
  11477.        to make it into general use.  Seems to cover the ground all the
  11478.        way from AWK type applications to Prolog/Lisp ones.
  11479.        If I wasn't already happy with Scheme, I'd use this for more
  11480.        general programming.
  11481.        I would recommend people at least look at this language.
  11482. GAWK - simple scripting language.  Definitely better than `old' awk.
  11483.        I would only use it if the job were really simple or if
  11484.        something like Python or TCL were not available.
  11485.  
  11486. Note I wouldn't expect anybody to make a choice on what I say.  I
  11487. suggest you get the source/manuals yourself and have a good long look
  11488. at the language/implementation before you decide.
  11489.  
  11490. For the types of things _I_ want to do, it would be a tie between Icon
  11491. and Python.  Having said that, given that I'd have to extend both to
  11492. cover the sort of things I want to do, I'll probably use Scheme
  11493. instead (ELK in particular).  The reason I didn't just use Scheme in
  11494. the first place is that I was hoping one of the languages would have
  11495. all the facilities I want without me having to extend them myself.
  11496.  
  11497. Before, the summary of the languages themselves, I thought I'd try and
  11498. list some of the things I was looking for.  (Actually, I showed an
  11499. earlier version of this summary to somebody and they didn't understand
  11500. some of the terms I was using, so this is my attempt at an
  11501. explanation).  Note that most of the things are to do with structuring
  11502. the code and alike.  This is not the sort of thing you usually worry
  11503. about when writing small scripts, but I plan to convert and write a
  11504. number of tools, some of which are around the 1000 LOC mark.  For
  11505. example, I'd like to convert a particular lex/yacc/C program I have
  11506. into the chosen language.
  11507.  
  11508. You can skip ahead to the actual summary by searching for SUMMARY.
  11509. (Well I can do this in GNUS, I don't know about other news readers
  11510. like rn)
  11511.  
  11512. Packages/Modules
  11513. ----------------
  11514. These are a mechanism for splitting up the name space so that function
  11515. name clashes are reduced.  Most systems work by declaring a package
  11516. and then all functions listed from then on are members of that
  11517. package.  You then access the functions using the package prefix, or
  11518. import the whole package so that you don't have to use the prefix.
  11519. The following is an example in CommonLisp :-
  11520.  
  11521. ;;; foo.lsp                     ;;; bar.lsp
  11522. (in-package 'foo)        (in-package 'bar)
  11523. (export '(bob))                 (export '(bob))
  11524. (defun bob (a b) ...)        (defun bob (x) ...)
  11525.  
  11526. ;;; main.lsp
  11527. (foo:bob 10 20)
  11528. (bar:bob 3)
  11529.  
  11530. Packages are not perfect, but they do help.  You can get the same
  11531. effect by declaring implicit package prefixes :-
  11532.  
  11533. ;;; foo.lsp            ;; bar.lsp
  11534. (defun foo-bob (a b) ...)    (defun bar-bob (x) ...)
  11535.  
  11536. ;; main.lsp
  11537. (foo-bob 10 30)
  11538. (bar-bob 4)
  11539.  
  11540. The advantage of packages over this is that you don't have to use a
  11541. package prefix in the package itself when you want to call a function.
  11542. This can be a saving if you have lots of functions in a package, and
  11543. only a few are exported.
  11544.  
  11545. Exception Handling
  11546. ------------------
  11547. This is useful for dealing with error that shouldn't happen. e.g.
  11548. reaching the end of the file when you were looking for some valid
  11549. data.  For example, in CommonLisp :-
  11550.  
  11551. (defun foo (x y)
  11552.   ...
  11553.   (if (catch 'some-unexpexted-error (bar x y) nil)
  11554.     (handle-the-exception ...)
  11555.   
  11556. (define bar (a b)
  11557.   ...
  11558.   (if (something-wrong) (throw 'some-unexpected-error t))
  11559.   ...)
  11560.  
  11561. Here the function `foo' calls `bar', and if any error occurs whilst
  11562. processing, it is handled by the exception handler.  (The example is a
  11563. bit primitive as I'm trying to save space).
  11564.  
  11565. The advantage of this is that you don't have to explicitly pass back
  11566. all sorts of error codes from your functions to handle unusual errors.
  11567. It also usually means you won't have so many nested `if's to handle
  11568. the special cases, therefore, making your code clearer.
  11569.  
  11570. Records/Tuples/Aggregates/Structs
  11571. ---------------------------------
  11572. It's handy to be to define objects that contain certain number of
  11573. elements.  You can then pass these objects around and access the
  11574. individual bits.  For example in CommonLisp :-
  11575.  
  11576. (defstruct point x y)
  11577.  
  11578. This declares `point' as a type containing two items called `x' and
  11579. `y'.  Some languages don't name the items, they rely on position
  11580. instead.  I see these as equivalent (assuming you have some sort of
  11581. pattern matching)
  11582.  
  11583. Provide/Require
  11584. ---------------
  11585. This is a primitive facility for declaring that one package depends on
  11586. another one.  For example in CommonLisp :-
  11587.  
  11588. ;;; foo.lsp
  11589. (defun bob (a b) ...)
  11590. (provide 'foo)
  11591.  
  11592. ;;; main.lsp
  11593. (require 'foo)
  11594. (bob 10 3)
  11595.  
  11596. The above declares that the file `foo' provides the function `bob' and
  11597. that the file `main' requires `foo' to be loaded for it to work.
  11598. So when you load in `main' and `foo' hasn't been loaded, it is
  11599. automatically loaded by the system.
  11600.  
  11601. C Interface
  11602. -----------
  11603. How easy is it to call C from the language.
  11604. Is there a dynamic loading facility i.e. do I have to recompile the
  11605. program to use some arbitrary C code, or can it load in a .o file at
  11606. runtime?
  11607.  
  11608. Arbitrary Restrictions
  11609. ----------------------
  11610. This really applies to the implementations rather than the languages.
  11611. However, as there is only one implementation for most of the languages
  11612. I'm looking at, they tend to be synonymous
  11613.  
  11614. If there is one thing I hate about an [implementation of] a languages
  11615. its arbitrary restrictions.  For example, `the length of the input
  11616. line must not exceed 80 characters', or "strings must be less than 255
  11617. characters long".  I can except some initial restrictions if :-
  11618.  
  11619. 1) they are documented.
  11620. 2) they will be removed in future versions.
  11621.  
  11622. Note. I realise that some restrictions are not arbitrary, or at least
  11623. not under the control of the language implementor e.g. the number of
  11624. open files under UNIX.
  11625.  
  11626. SUMMARY
  11627. -------
  11628. If you want to know more about the languages, there follows a brief
  11629. description of the languages, how to get an implementation and some
  11630. good and bad points as I see them.  Each point is preceded by a
  11631. character indicating the type of point :-
  11632.  
  11633.     +  good point
  11634.     -  bad point
  11635.     *  just a point to note
  11636.     !  subjective point
  11637.  
  11638. Other than the `*' items, I guess it is all subjective, however, I've
  11639. tried to put things that are generally good/bad in `+'/`-' and limit
  11640. really subjective statements to `!'.
  11641.  
  11642.                    TCL - version 4.0 patch level 1
  11643.                    -------------------------------
  11644.  
  11645. TCL (Tool Command Language) was developed by John Ousterhout at Berkeley.
  11646. It started out as a small language that could be embedded in
  11647. applications.  It has now been extended by some people at hackercorp
  11648. into more of a general purpose shell type programming language.
  11649. It is described by Peter Da Silva (one of the people who extended it)
  11650. as :-
  11651.  
  11652. > TCL is like a text-oriented Lisp, but lets you write algebraic
  11653. > expressions for simplicity and to avoid scaring people away.
  11654.  
  11655. The language itself for some reason reminds me of csh even though I
  11656. can only point to two things (the use of `set' and `$') which a
  11657. definitely like csh.
  11658.  
  11659. Unless you have other ideas about what an extension language should
  11660. look like (e.g. IMO it should be Scheme), then I'd definitely
  11661. recommend this.  It's small, and integrates easily with other C
  11662. programs (you can even have multiple TCL interpreters in an
  11663. application!)
  11664.  
  11665. Version 5.0 is available by anonymous ftp from sprite.berkeley.edu as
  11666. tk.tar.Z (its part of an X toolkit called Tk).  Note, although it has
  11667. a higher number than the one above, does not include the extensions
  11668. mentioned above.  These will apparently be integrated soon.
  11669.  
  11670. Version 4.0 pl1 is available by anonymous ftp from
  11671. media-lab.ai.mit.edu (sorry can't remember the exact path)
  11672.  
  11673. +  exceptions.
  11674. +  packages, called libraries
  11675.    However there is only one name-space.  The libraries are used as a
  11676.    way of storing single versions of code rather than as a solution to
  11677.    the name space pollution problem.
  11678. +  provide/require
  11679. +  C interface is excellent.  You can easily go TCL->C and C->TCL.
  11680. -  No dynamic loading ability that I'm aware of.
  11681. -  Arbitrary line length limit on `gets' and `scan'. i.e. the commands
  11682.    that read lines from files/strings.  I would guess this will go
  11683.    away in the next version.
  11684. -  No records.  The main data types are strings/lists/associative arrays
  11685. +  extensive test suite included.
  11686. !  doesn't look to have been tested on many systems.  The above
  11687.    version actually failed to link on a SPARCstation running SunOS 4.1
  11688.    as the source refers to `strerror'.  This has apparently been fixed
  11689.    in patch level 2.
  11690. +  lots of example code included in distribution.
  11691. +  extensive documentation (all in nroff)
  11692. +  Can trace execution.
  11693. !  To make arguments evaluate, you must enclose them in {} or []
  11694.    This shouldn't be a problem, except that being used to Lisp like
  11695.    languages I expect to quote constants.
  11696. !  The extensions though useful, are not seamless. e.g. some string
  11697.    facilities are in the core language and some in the extensions.
  11698.    This might happen when the hackercorp extensions are officially
  11699.    merged with the Berkeley core language and released by Berkeley.
  11700. +  As part of the extensions, you get tclsh.  This is a shell which you
  11701.    can type command directly into.
  11702. +  scan contexts.  This is sort of regular expressions on files rather
  11703.    than strings.
  11704.  
  11705.                         Python - version 0.9.1
  11706.                         ----------------------
  11707.  
  11708. Available by anonymous ftp from wuarchive.wustl.edu as
  11709. pub/python0.9.1.tar.Z or for Europeans via the info server at
  11710. hp4nl.nluug.nl
  11711.  
  11712. I couldn't think of a good way to describe this, so I'm blatantly
  11713. copying the following from the Python tutorial :-
  11714.  
  11715.     Python is a simple, yet powerful programming language that bridges
  11716.     the gap between C and shell programming, and is thus ideally
  11717.     suited for rapid prototyping.  Its syntax is put together from
  11718.     constructs borrowed from a variety of other languages; most
  11719.     prominent are influences from ABC, C, Modula-3 and Icon
  11720.  
  11721. So far so good, here's some more from the tutorial :-
  11722.  
  11723.     Because of its more general data types Python is applicable to a
  11724.     much larger problem domain that Awk or even Perl, yet most simple
  11725.     things are at least as easy in Python as in those languages.
  11726.  
  11727. i.e. Python seems to be designed for larger tasks than you would
  11728. undertake using the shell/awk/perl.
  11729.  
  11730. +  packages.
  11731. +  exceptions (based on Modula 2/3 modules)
  11732. +  records (actually tuples.  I'm not sure they do everything I want
  11733.    as the documentation is a bit vague in this area)
  11734.    Other main types are lists, sets, tables (associative arrays)
  11735. +  C interface is good.  No dynamic linking that I am aware of.
  11736. -  Arbitrary Restrictions
  11737.    line length limit on readline.
  11738.    This has been fixed and I would guess will appear in the next release.
  11739. +  lots of example python programs included.
  11740.    There is even a TCL (version 2ish) interpreter!
  11741. +  Object oriented features.
  11742.    Based on Modula 3 i.e. classes with methods, all of which are
  11743.    virtual (to use a C++ term).
  11744. *  any un caught errors produce a stack trace.
  11745. +  disassembler included
  11746. +  can inspect stack frames via traceback module
  11747. -  no single step or breakpoint facility
  11748.    (maybe in the next release)
  11749. +  functions can return multiple values.
  11750. *  The default output command `print' inserts a space between each
  11751.    field output.
  11752. !  I don't like the above, or rather I would like the option of not
  11753.    having it done.
  11754. *  Documentation includes tutorial and library reference as TeX files.
  11755.    Both are incomplete, but there is enough in them to be able to
  11756.    write Python code.  The reference manual is not yet finished, and
  11757.    is not currently distributed with the source.
  11758. +  Python mode for Emacs.
  11759.    (Its primitive, but its a start)
  11760.  
  11761.                            Icon - version 8
  11762.                            ----------------
  11763.  
  11764. To quote from one of the Icon books :-
  11765.  
  11766.     Icon is a high-level, general purpose programming language that
  11767.     contains many features for processing nonnumeric data,
  11768.     particularly for textual material consisting of string of
  11769.     characters.
  11770.  
  11771. Available :-
  11772. In USA :- ??, consult `archie'.
  11773. In UK :-  I picked up a copy form the sources archive at Imperial College.
  11774.           The JANET address is 00000510200001
  11775.  
  11776. -  no packages.  Everything is in one namespace.  However ...
  11777. -  no exceptions.
  11778. +  Object oriented features.
  11779.    An extension to the language called Idol is included.
  11780.    This converts Idol into standard Icon.
  11781.    Idol itself looks (to me) like Smalltalk.
  11782. +  has records.  Other types include :- sets, lists, strings, tables
  11783. +  unlimited line length when reading
  11784.    (Note. the newline is discarded)
  11785. !  The only language that has enough facilities to be able to re-write
  11786.    some of my Lex/Yacc code.
  11787. +  stack trace on error.
  11788. +  C interface is good.  Can extend the language by building `personal
  11789.    interpreter'.  No dynamic linking.
  11790. +  extensive documentation
  11791.    9 technical reports in all (PostScript and ASCII)
  11792. -  Unix interface is quite primitive.
  11793.    If you just want to use a command, you can use `callout', anything
  11794.    more complicated requires building a personal interpreter (not as
  11795.    difficult as it may sound)
  11796. +  extensive test suite
  11797. +  Usenet group exists specifically for it - comp.lang.icon
  11798. -  Unless you use Idol, all procedures are at the same level
  11799.    i.e. one scope.
  11800. -  regular expressions not supported.
  11801.    However, in many cases, you can use an Icon functions `find',
  11802.    `match', `many' and `upto' instead.
  11803. +  Can trace execution.
  11804. *  Pascal/C like syntax
  11805.    i.e. uses {} but has a few more keywords than C.
  11806. +  lots of example programs included.
  11807. +  can define your own iterators
  11808.    i.e. your own procedures for iterating through arbitrary structures.
  11809. +  co-expressions.  Powerful tool, hard to explain briefly.  See
  11810.    chapter 13 of the Icon Programming Language.
  11811. -  co-expressions haven't been implemented on Sun 4s (the type of
  11812.    machine I use)
  11813. +  has an `initial' section in procedures that is only ever executed
  11814.    once and allows you to initialise C like static variables with the
  11815.    result of other functions (unlike C).
  11816. +  arbitrary precision integers.
  11817.  
  11818. As well as the excellent documentation included in the source, there
  11819. are two books on Icon available (I skimmed through both of them) :-
  11820.  
  11821.     The Icon Programmming Language
  11822.     Ralph E. Griswold and Madge T. Griswold
  11823.     Prentice Hall 1983
  11824.  
  11825.     The Implementation of the Icon Programmming Language
  11826.     Ralph E. Griswold and Madge T. Griswold
  11827.     Princeton University Press 1986
  11828.  
  11829. The second one is particularly useful if you are considering
  11830. extending Icon yourself.  Appendix E of this book also contains a list
  11831. of projects that could be undertaken to extend and improve Icon.
  11832.  
  11833. Here are some projects, that if implemented, would greatly improve the
  11834. usefulness of Icon :-
  11835.  
  11836. E.2.4 Add a regular expression data type.  Modify the functions find
  11837.       and match to perate appropriately when their first argument is a
  11838.       regular expression.
  11839.  
  11840. E.2.5 \  All of these suggest extending
  11841. E.5.4  | the string scanning facilities to
  11842. E.5.5 /  cope with files and strings in a uniform way.
  11843.  
  11844. E.12.1 Provide a way to load functions (written in C) at runtime
  11845.  
  11846.  
  11847.                                  Perl
  11848.                                  ----
  11849. Available :-
  11850. USA :- ??, consult `archie'
  11851. UK :- Imperial sources archive
  11852.  
  11853. I received more responses about Perl than anything else, so I that
  11854. most people already know a lot about the language.
  11855.  
  11856. Here are some edited highlights from a message I received from Tom
  11857. Christiansen :-
  11858.  
  11859. First some good words from Tom :-
  11860.  
  11861. > ... I shall now reveal my true colors as perl disciple
  11862. > and perhaps not infrequent evangelist.  Perl is without question the
  11863. > greatest single program to appear to the UNIX community (although it runs
  11864. > elsewhere too) in the last 10 years.  It makes progamming fun again.  It's
  11865. > simple enough to get a quick start on, but rich enough for some very
  11866. > complex tasks.
  11867.  
  11868. > ... perl is a strict superset of sed and awk, so much so that s2p and
  11869. > a2p translators exist for these utilities.  You can do anything in
  11870. > perl that you can do in the shell, although perl is not strictly
  11871. > speaking a command interpreter.  It's more of a programming language.
  11872.  
  11873. and now some of the low points of Perl.  [Note this is only a small
  11874. part of a long post, that explained a lot of good things about Perl.
  11875. As most people seem to use/like Perl, I thought I'd highlight some of
  11876. the things wrong with the language, and what better place to get
  11877. information than from the designer of the language.  Note also that
  11878. this is from a message dated June 90, so some of it may be out of date.]
  11879.  
  11880. Larry Wall :-
  11881.  
  11882. > The basic problem with Perl is that it's not about complex data structures.
  11883. > Just as spreadsheet programs take a single data structure and try to
  11884. > cram the whole world into it, so too Perl takes a few simple data structures
  11885. > and drives them into the ground.  This is both a strength and a weakness,
  11886. > depending on the complexity and structure of the problem.
  11887. > The basic underlying fault of Perl is that there isn't a real good way
  11888. > of building composite structures, or to make one variable refer to a piece
  11889. > of another variable, without giving an operational definition of it.
  11890. > ...  In a sense, the problem with Perl is not that it is too
  11891. > complicated or hard to learn, but that perhaps it is not expressive
  11892. > enough for the effort you put into learning it.  Then again, maybe it
  11893. > is.  Your call.  Some people are excited about Perl because, despite
  11894. > its obvious faults, it lets them get creative.
  11895. > There are many things I'd do differently if I were designing Perl from
  11896. > scratch.  It would probably be a little more object oriented.  Filehandles
  11897. > and their associated magical variables would probably be abstract types
  11898. > of some sort.  I don't like the way the use of $`, $&, $' and $<digit>
  11899. > impact the efficiency of the language.  I'd probably consider some kind
  11900. > of copy-on-write semantics like many versions of BASIC use.  The subroutine
  11901. > linkage is currently somewhat problematical in how efficiently it can
  11902. > be implemented.  And of course there are historical artifacts that wouldn't
  11903. > be there.
  11904.  
  11905. I think the above is a vary fair summary of the low points of the
  11906. language.  At one point it says `... perhaps it is not expressive
  11907. enought for the effort you put into learning it.  Then again maybe it
  11908. is.  Your call'.  Well _my_ call is that it is not.
  11909.  
  11910. Note I didn't actually pick up the source to this, just the manual.
  11911. Consequently I haven't been able to check all the points listed below.
  11912.  
  11913. +  packages.
  11914. !  Note in the examples that I've seen in comp.lang.perl, people don't
  11915.    seem to use the facility, instead they put everything directly in
  11916.    `main' (i.e. the top level scope) rather than in the local scope.
  11917. +  exceptions
  11918. +  provide/require
  11919. *  C Interface ??  I couldn't find this in the documentation I had.
  11920. +  No arbitrary restrictions
  11921. +  has a source level debugger
  11922. +  Well integrated with Unix (nearly all system calls are built in !)
  11923. !  However, like Unix, only one name space seems to be used (see above)
  11924. *  C like syntax
  11925. +  source contains texinfo manual.
  11926.    You can always buy the (Camel) book for more information.
  11927. -  no records.  Other types lists, strings, tables (associative arrays)
  11928. *  some types have distinct scopes.
  11929. !  You prefix the name with `@', '$', '%' to indicate which type
  11930.    you want.  This is one of the ugliest things I've ever seen.
  11931. !  Uses lots of short strings to contain often used things e.g. `$_'
  11932.    is the current input, `$.' is current line number.  I guess some
  11933.    people must like this, but I prefer names like `input' and
  11934.    `line-number' myself.
  11935. +  includes programs to convert existing awk, find and sed scripts into
  11936.    Perl.
  11937. +  Usenet news group - comp.lang.perl
  11938. +  Perl mode for Emacs.
  11939.  
  11940.                  GAWK
  11941.                  ----
  11942. Available :- 
  11943. USA :- prep.ai.mit.edu, probably other places as well.  Consult `archie'
  11944. UK :- Imperial sources archive.
  11945.  
  11946. A few points about GNU awk as it seems to fix some of the problems
  11947. with `old' awk.
  11948.  
  11949. -  no packages
  11950. -  no exceptions
  11951. -  no C interface 
  11952. -  no records
  11953. +  allows user defined functions
  11954. +  can read and write to arbitrary files
  11955. +  much more informative error messages than the old awk.
  11956.  
  11957. From ralph  Sat Mar 30 07:47:16 1991
  11958. Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
  11959.     id AA19362; Sat, 30 Mar 91 07:47:16 -0700
  11960. Date: Sat, 30 Mar 91 07:47:14 MST
  11961. From: "Ralph Griswold" <ralph>
  11962. Message-Id: <9103301447.AA11191@cheltenham.cs.arizona.edu>
  11963. Received: by cheltenham.cs.arizona.edu; Sat, 30 Mar 91 07:47:14 MST
  11964. To: icon-group
  11965. Subject: Icon compiler
  11966.  
  11967. The Icon compiler is now available for five more UNIX platforms:
  11968.  
  11969.     Intel 386 running System V
  11970.     Macintosh running AU/X
  11971.     PS/2 running AIX
  11972.     UNIX PC (3B1)
  11973.     VAX-11 running Ultrix
  11974.  
  11975. To get a copy of the compiler, do an anonymous FTP to cs.arizona.edu,
  11976. cd /icon/v8/Compiler/Packages, and see what's there.  Documentation for
  11977. the compiler is in /icon/v8/Compiler/Docs.
  11978.  
  11979. Please check the READ.MEs for the specific implementations in Packages --
  11980. since the Icon compiler presently is distributed in object form, operating
  11981. system and related software must be compatible. For example, some sites
  11982. have been unable to run the Sun 4 implemenation of the Icon compiler because
  11983. they are using a version of the system software that is earlier than the
  11984. version needed by the Icon compiler.
  11985.  
  11986. If you are successful in getting the Icon compiler to run on a different
  11987. configuration than listed in a READ.ME, please let us know so that we
  11988. can add that information for other users.
  11989.  
  11990.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  11991.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  11992.  
  11993.