home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group89a.txt < prev    next >
Internet Message Format  |  1989-06-27  |  344KB

  1. From ralph  Sun Jan  1 05:33:30 1989
  2. Date: Sun, 1 Jan 89 05:33:30 MST
  3. From: "Ralph Griswold" <ralph>
  4. Message-Id: <8901011233.AA09482@megaron.arizona.edu>
  5. Received: by megaron.arizona.edu (5.59-1.7/15)
  6.     id AA09482; Sun, 1 Jan 89 05:33:30 MST
  7. To: icon-group
  8. Subject: Happy New Year!
  9.  
  10.  
  11.     Best wishes for the new year from the Icon Project!
  12.  
  13.  
  14.    Ralph Griswold / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  15.    +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  16.  
  17.  
  18. From spqr@computer-science.southampton.ac.uk  Wed Jan  4 02:25:11 1989
  19. Received: from rvax.ccit.arizona.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  20.     id AA13911; Wed, 4 Jan 89 02:25:11 MST
  21. Received: from UKACRL.BITNET by rvax.ccit.arizona.edu; Wed, 4 Jan 89 02:17 MST
  22. Received: from RL.IB by UKACRL.BITNET (Mailer X1.25) with BSMTP id 7299; Wed,
  23.  04 Jan 89 09:08:36 GMT
  24. Received: from caxton.cm.soton.ac.uk by hilliard.ecs.soton.ac.uk; Wed, 4 Jan 89
  25.  09:03:55 GM
  26. Date: Wed, 4 Jan 89 09:03:43 GMT
  27. From: Sebastian Rahtz <spqr@computer-science.southampton.ac.uk>
  28. Subject: returning a procedure from a procedure
  29. To: icon-group@arizona.edu
  30. Via:        UK.AC.SOTON.ECS;  4 JAN 89  9:08:33 GMT
  31. Message-Id: <15891.8901040903@caxton.cm.soton.ac.uk>
  32.  
  33.  
  34. having just sat happily through a workshop on the Scheme dialect of
  35. Lisp, run by a colleague here, my brain started to mull over how I
  36. could persuade the colleague that Icon was even better than Scheme....
  37. But he threw me with Lisp ability for a function to return a function
  38. as its result. Can anyone suggest to me EITHER how I pretend this
  39. isn't a good thing, OR how Icon would be persuaded to think likewise?
  40.  
  41. I once wrote a SNOLBOL program which read in data mixed with patterns,
  42. and turned those patterns into valid code to apply to the associated
  43. data. It sounds like a not dissimilar problem.
  44.  
  45. Any ideas?
  46.  
  47. Sebastian Rahtz
  48. Computer Science
  49. University
  50. Southampton
  51.  
  52. From lti!lti.com!talmage  Wed Jan  4 10:05:37 1989
  53. Received: from BU-IT.BU.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  54.     id AA01265; Wed, 4 Jan 89 10:05:37 MST
  55. Received: from BUITA.BU.EDU by bu-it.BU.EDU (5.58/4.7)
  56.     id AA23315; Wed, 4 Jan 89 11:15:05 EST
  57. Received:  by buita.bu.edu (3.2/4.7)
  58.     id AA03345; Wed, 4 Jan 89 11:15:42 EST
  59. Received: from waltham.lti.com by lti.com (4.0/SMI-4.0)
  60.     id AA03283; Wed, 4 Jan 89 09:45:05 EST
  61. Date: Wed, 4 Jan 89 09:45:05 EST
  62. From: talmage@lti.com (David Talmage)
  63. Message-Id: <8901041445.AA03283@lti.com>
  64. Received: by waltham.lti.com (4.0/SMI-4.0)
  65.     id AA01754; Wed, 4 Jan 89 09:44:58 EST
  66. To: spqr@computer-science.southampton.ac.uk
  67. Cc: icon-group@arizona.edu
  68. In-Reply-To: Sebastian Rahtz's message of Wed, 4 Jan 89 09:03:43 GMT <15891.8901040903@caxton.cm.soton.ac.uk>
  69. Subject: returning a procedure from a procedure
  70.  
  71. In <15891.8901040903@caxton.cm.soton.ac.uk>,
  72. Sebastian Rahtz <buita!spqr@computer-science.southampton.ac.uk> writes:
  73.  
  74. >But he threw me with Lisp ability for a function to return a function
  75. >as its result. Can anyone suggest to me EITHER how I pretend this
  76. >isn't a good thing, OR how Icon would be persuaded to think likewise?
  77.  
  78.  
  79. Couldn't you make your functions return strings which name other functions?
  80. Then you could use the Icon "call by string value" feature to call the
  81. result of the first function.  It might look like this:
  82.  
  83.  
  84. procedure main()
  85.  
  86. local result
  87.  
  88. # Tell me what to do next based on the argument to the procedure choose
  89. #
  90.   result = choose( "the other thing" )
  91.  
  92. #
  93. # Use the value of result as the name of a procedure.
  94. #
  95.   result()
  96.  
  97. end # main
  98.  
  99.  
  100. procedure choose( x )
  101.  
  102. #
  103. # Returns the name of a procedure based on the value of x.
  104. #
  105.   if x == "this" return "foo"
  106.   if x == "that" return "bar"
  107.   return "baz"
  108.  
  109. end # choose
  110.  
  111.  
  112. procedure foo()
  113.  
  114.   write( "Hi!  I'm foo." )
  115.  
  116. end #foo
  117.  
  118.  
  119. procedure bar()
  120.  
  121.   write( "Hello, my name is bar.  What's yours?" )
  122.  
  123. end # bar
  124.  
  125.  
  126. procedure baz()
  127.  
  128.  
  129.   write( "Baz is my name and sax is my axe." )
  130.  
  131. end # baz
  132.  
  133.  
  134. Regards,
  135.  
  136. David
  137.  
  138. ------------------------------------------------------------------------------
  139. David W. Talmage                ...!{buita,bbn}!lti!talmage
  140. Language Technology, Inc.            talmage%lti.uucp@bu-it.bu.edu
  141. 27 Congress St., Salem, MA 01970        (508) 741-1507
  142.  
  143. From naucse!sbw  Wed Jan  4 11:33:50 1989
  144. Received: by megaron.arizona.edu (5.59-1.7/15)
  145.     id AA05603; Wed, 4 Jan 89 11:33:50 MST
  146. Date: Wed, 4 Jan 89 11:24:56 mst
  147. From: naucse!sbw (Steve Wampler)
  148. Message-Id: <8901041824.AA00834@naucse>
  149. X-Mailer: Mail User's Shell (6.3 6/25/88)
  150. To: arizona!icon-group
  151. Subject: Returning functions...
  152.  
  153. You must mean to return a function that is created on the fly?
  154. Otherwise, there's no problem.  E.g.
  155.  
  156.     procedure nextfunc()
  157.        suspend foo | nextfunc | write | read | stop
  158.     end
  159.  
  160.     procedure foo()
  161.     end
  162.  
  163. returns the procedures 'foo' and 'nextfunc', then the functions
  164. 'write', 'read', and 'stop'.
  165.  
  166. The names of functions and procedures are just global variables
  167. that have been 'initialized' to contain the function and procedure
  168. definitions.  The functions and procedures themselves are just
  169. data values, and can be treated as such (with only a few operators
  170. defined on them).
  171.  
  172. I think what the original poster wanted was related to SNOBOL4's
  173. CODE function - the ability to construct procedures at runtime.
  174. It would take a new operation (say a conversion from string to
  175. function) which is difficult to implement primarily because it
  176. requires the icon translator to be available at run time.  In
  177. SNOBOL4 or LISP, this isn't so bad because the translators for
  178. those languages are fairly simple.  For Icon, it's huge.
  179.  
  180.  
  181. -- 
  182.     Steve Wampler
  183.     {....!arizona!naucse!sbw}
  184.  
  185. From @x-sphinx.uchicago.edu:goer@sophist.uchicago.edu  Wed Jan  4 11:47:06 1989
  186. Received: from x-sphinx.uchicago.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  187.     id AA06046; Wed, 4 Jan 89 11:47:06 MST
  188. Received: from sophist.uchicago.edu by x-sphinx.uchicago.edu (5.52/2.0Sx)
  189.     id AA06969; Wed, 4 Jan 89 12:51:03 CST
  190. Return-Path: <goer@sophist.uchicago.edu>
  191. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  192.     id AA13716; Wed, 4 Jan 89 12:39:26 CST
  193. Date: Wed, 4 Jan 89 12:39:26 CST
  194. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  195. Message-Id: <8901041839.AA13716@sophist.uchicago.edu>
  196. To: icon-group@arizona.edu
  197. Subject: returning a procedure
  198.  
  199. Icon has no trouble with procedures returning procedures.  You
  200. don't have to get fancy with the call by string function.  It's
  201. very straightforward.  (I made the same mistake some months ago,
  202. using the call by string function where it is completely unneces-
  203. sary.)
  204.  
  205. The following collection of procedures, when "compiled" and run
  206. via the interpreter, will repeatedly write either FOO, BAR, or
  207. BAZ, depending on tty input.
  208.  
  209. procedure main()
  210.   choose(!&input)()  # choose(x) returns a procedure;
  211.                      # choose(x)() returns a procedure, then invokes it
  212. end
  213.  
  214. procedure choose(x)
  215.   case x of {
  216.     "this" : return foo
  217.     "that" : return bar
  218.     ""     : fail
  219.     default : return baz
  220.     }
  221. end
  222.  
  223. procedure foo()
  224.   write("FOO")
  225. end
  226. procedure bar()
  227.   write("BAR")
  228. end
  229. procedure baz()
  230.   write("BAZ")
  231. end
  232.  
  233. From shafto@eos.arc.nasa.gov  Wed Jan  4 14:08:25 1989
  234. Received: from eos.arc.nasa.gov by megaron.arizona.edu (5.59-1.7/15) via SMTP
  235.     id AA12169; Wed, 4 Jan 89 14:08:25 MST
  236. Received: Wed, 4 Jan 89 13:07:31 PST by eos.arc.nasa.gov (5.59/1.2)
  237. Date: Wed, 4 Jan 89 13:07:31 PST
  238. From: Michael Shafto <shafto@eos.arc.nasa.gov>
  239. Message-Id: <8901042107.AA22079@eos.arc.nasa.gov>
  240. To: icon-group@arizona.edu, sbw%naucse.UUCP@arizona.edu
  241. Subject: Re:  Returning functions...
  242. Cc: shafto@EOS.ARC.NASA.GOV
  243.  
  244. In response to the observation that maintaining the Icon translator
  245. in memory at run-time is not feasible due to the size of the translator:
  246.  
  247. Understood.  Hypothetically, suppose the size problem disappeared.
  248.  
  249. Is there anything about the Icon language or its implementation that
  250. would preclude having a run-time "build, compile, & execute" capability
  251. like SNOBOL4's CODE()?  Or, say, "EVAL()" for bounded expressions?
  252.  
  253. Mike
  254.  
  255. From wgg@june.cs.washington.edu  Wed Jan  4 15:37:52 1989
  256. Received: from june.cs.washington.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  257.     id AA15561; Wed, 4 Jan 89 15:37:52 MST
  258. Received: by june.cs.washington.edu (5.59/6.13+)
  259.     id AA14237; Wed, 4 Jan 89 14:36:47 PST
  260. Date: Wed, 4 Jan 89 14:36:47 PST
  261. From: wgg@june.cs.washington.edu (William Griswold)
  262. Return-Path: <wgg@june.cs.washington.edu>
  263. Message-Id: <8901042236.AA14237@june.cs.washington.edu>
  264. To: icon-group@arizona.edu
  265. Subject: Re:  returning a procedure from a procedure
  266.  
  267. >From: Sebastian Rahtz <spqr@computer-science.southampton.ac.uk>
  268. >Subject: returning a procedure from a procedure
  269.  
  270. >having just sat happily through a workshop on the Scheme dialect of
  271. >Lisp, run by a colleague here, my brain started to mull over how I
  272. >could persuade the colleague that Icon was even better than Scheme....
  273. >But he threw me with Lisp ability for a function to return a function
  274. >as its result. Can anyone suggest to me EITHER how I pretend this
  275. >isn't a good thing, OR how Icon would be persuaded to think likewise?
  276.  
  277.  
  278. In Icon it is possible to achieve an effect *similar* to dynamically
  279. created procedures returned from procedures by using coexpressions.
  280.  
  281. The idea is to return a coexpression rather than a procedure.  Clearly, you
  282. do not have the flexibility of creating an arbitrary coexpression.  But when
  283. a coexpression is created, the values of the variables local to the
  284. containing procedure are copied into the state of the coexpression, giving
  285. some flexibility through parameterization.  However, you still only have a
  286. coexpression, not a procedure, but it is something.
  287.  
  288. Now consider the example below, which is followed by its output.  The
  289. result is slightly less than satisfactory (I have troubles understanding
  290. it sometimes):
  291.  
  292. procedure main()
  293.     every i := 1 to 5 do
  294.     {
  295.     plusi := plusNexp(i)
  296.     every j := 1 to 5 do
  297.         write("(is ",j @ plusi,", check ",i+j,")")
  298.     }
  299. end
  300.     
  301. # Create a coexpression that adds N to the input number
  302. procedure plusNexp(N)
  303.     local cexp, T           # N and T are copied into coexpression
  304.  
  305.     cexp := create repeat { T := N+T @ &source }
  306.     @cexp    # dummy call to get things going
  307.     return cexp
  308. end
  309.  
  310.  
  311. (is 2, check 2)
  312. (is 3, check 3)
  313. (is 4, check 4)
  314. (is 5, check 5)
  315. (is 6, check 6)
  316. (is 3, check 3)
  317. (is 4, check 4)
  318. (is 5, check 5)
  319. (is 6, check 6)
  320. (is 7, check 7)
  321. (is 4, check 4)
  322. (is 5, check 5)
  323. (is 6, check 6)
  324. (is 7, check 7)
  325. (is 8, check 8)
  326. (is 5, check 5)
  327. (is 6, check 6)
  328. (is 7, check 7)
  329. (is 8, check 8)
  330. (is 9, check 9)
  331. (is 6, check 6)
  332. (is 7, check 7)
  333. (is 8, check 8)
  334. (is 9, check 9)
  335. (is 10, check 10)
  336.  
  337.  
  338. In Scheme when a local variable is bound into a lambda expression
  339. (runtime-created function) the value of the variable is not copied into
  340. the new function, but rather the lambda function points to the local
  341. variable on the stack.  This requires the state of the parent function to
  342. persist after return.  One of the major results in Scheme was finding
  343. efficient ways to provide this feature.  
  344.  
  345. Shared locals can be *simulated* in Icon by using static (or global)
  346. variables, rather than locals, since the former are not copied.  This
  347. permits two coexpressions to share (and update!) a static variable outside
  348. the scope of the function that declares the static. 
  349.  
  350. The example below shows how this works:
  351.  
  352. procedure main()
  353.     sum1 := texp("first"); sum2 := texp("second")
  354.     every i := 1 to 3 do
  355.         {
  356.         i @ sum1 
  357.         i @ sum2
  358.         }
  359. end
  360.     
  361. # shows that Z is shared
  362. procedure texp(N)
  363.     local cexp           # Z is copied into coexpression
  364.     static Z
  365.     initial Z := 1
  366.  
  367.     cexp := create repeat { write("exp ",N," ",Z +:= Z @ &source) }
  368.     @cexp    # dummy call to get things going
  369.     return cexp
  370. end
  371.  
  372.  
  373. exp first 2
  374. exp second 3
  375. exp first 5
  376. exp second 7
  377. exp first 10
  378. exp second 13
  379.  
  380.  
  381. The limitations and drawbacks of these mechanisms are obvious, but still
  382. have some usefulness.
  383.  
  384.  
  385.                     Bill Griswold
  386.  
  387. From wgg@june.cs.washington.edu  Wed Jan  4 15:58:16 1989
  388. Received: from june.cs.washington.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  389.     id AA16320; Wed, 4 Jan 89 15:58:16 MST
  390. Received: by june.cs.washington.edu (5.59/6.13+)
  391.     id AA16121; Wed, 4 Jan 89 14:57:13 PST
  392. Date: Wed, 4 Jan 89 14:57:13 PST
  393. From: wgg@june.cs.washington.edu (William Griswold)
  394. Return-Path: <wgg@june.cs.washington.edu>
  395. Message-Id: <8901042257.AA16121@june.cs.washington.edu>
  396. To: icon-group@arizona.edu
  397. Subject: Re: Returning functions...
  398.  
  399.  
  400. >From: Michael Shafto <shafto@eos.arc.nasa.gov>
  401. >Subject: Re:  Returning functions...
  402.  
  403. >In response to the observation that maintaining the Icon translator
  404. >in memory at run-time is not feasible due to the size of the translator:
  405.  
  406. >Understood.  Hypothetically, suppose the size problem disappeared.
  407.  
  408. >Is there anything about the Icon language or its implementation that
  409. >would preclude having a run-time "build, compile, & execute" capability
  410. >like SNOBOL4's CODE()?  Or, say, "EVAL()" for bounded expressions?
  411.  
  412. >Mike
  413.  
  414. I have implemented a dynamic linker (based on one by Bill Mitchell) for
  415. Icon that is capable of loading procedures during execution.  To make
  416. linking easier, record field lookup is a bit slower.  Also, it is very
  417. difficult to return unreachable procedures to free-store (I don't do it,
  418. though with a lot of work it might be possible to implement it).
  419.  
  420. This doesn't address compiling during runtime, though it is certainly
  421. possible using the system() or write(...,"p") functions, good
  422. performance aside.
  423.  
  424. I don't see any fundamental problem in combining the translator and 
  425. interpreter, if ignoring space limitations.
  426.  
  427. I think implementing a function like EVAL() might have peculiar properties
  428. in Icon, because Icon is statically rather than dynamically scoped.  This
  429. would imply that the string passed to eval would be evaluated in the
  430. static context of EVAL(), rather than the procedure calling EVAL.  I
  431. don't see any obvious way around this.
  432.  
  433. There has been some talk of more exotic control features in Icon (such
  434. as Ken Walker's c-expressions. Ken?) that could address some of the 
  435. issues discussed, but little has come of it to date, as far as I know.
  436.  
  437.                     Bill Griswold
  438.  
  439. From icon-group-request  Wed Jan  4 22:56:54 1989
  440. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  441.     id AA03319; Wed, 4 Jan 89 22:56:54 MST
  442. Received: by ucbvax.Berkeley.EDU (5.61/1.33)
  443.     id AA01669; Wed, 4 Jan 89 16:24:55 PST
  444. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  445.     for icon-group@arizona.edu (icon-group@arizona.edu)
  446.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  447. Date: 5 Jan 89 00:14:41 GMT
  448. From: encore!pierson%mist@husc6.harvard.edu  (Dan Pierson)
  449. Organization: Encore Computer Corp
  450. Subject: Re: Returning functions...
  451. Message-Id: <4583@xenna.Encore.COM>
  452. References: <8901041824.AA00834@naucse>
  453. Sender: icon-group-request@arizona.edu
  454. To: icon-group@arizona.edu
  455.  
  456. In article <8901041824.AA00834@naucse>, sbw@naucse (Steve Wampler) writes:
  457. >I think what the original poster wanted was related to SNOBOL4's
  458. >CODE function - the ability to construct procedures at runtime.
  459. >It would take a new operation (say a conversion from string to
  460. >function) which is difficult to implement primarily because it
  461. >requires the icon translator to be available at run time.  In
  462. >SNOBOL4 or LISP, this isn't so bad because the translators for
  463. >those languages are fairly simple.  For Icon, it's huge.
  464.  
  465. Returning new functions from functions doesn't have to involve
  466. runtime translation.  Try writing the Lisp function in following in
  467. Icon:
  468.  
  469. (defun account (balance)
  470.   (flet ((deposit (n)
  471.        (incf balance n)
  472.        balance)
  473.      (withdraw (n)
  474.        (if (<= n balance)
  475.            (progn
  476.          (decf balance n)
  477.          balance)
  478.            (error "Tried to withdraw more money than in account")))
  479.      (balance ()
  480.        balance))
  481.     #'(lambda (action &optional (n 0))
  482.     (case action
  483.       (deposit (deposit n))
  484.       (withdraw (withdraw n))
  485.       (balance (balance))))))
  486.  
  487. For the non-Lispers in the group, a call of account returns an
  488. anonymous function that is a closure over the argument to account.
  489. Each call to account returns a different such function, each with it's
  490. own balance "cell".  A good Lisp compiler can compile all the code in
  491. the function and just compose that compiled code with a different
  492. closure at call time.
  493.  
  494. In hopes of forestalling may other examples, Lisp is far from being
  495. the only language that can do this.  The purpose of this example is to
  496. explain the concept, not start an "examples war" unrelated to Icon.
  497. -- 
  498.                                             dan
  499.  
  500. In real life: Dan Pierson, Encore Computer Corporation, Research
  501. UUCP: {talcott,linus,necis,decvax}!encore!pierson
  502. Internet: pierson@multimax.encore.com
  503.  
  504. From kwalker  Thu Jan  5 11:06:28 1989
  505. Date: Thu, 5 Jan 89 11:06:28 MST
  506. From: "Kenneth Walker" <kwalker>
  507. Message-Id: <8901051806.AA24260@megaron.arizona.edu>
  508. Received: by megaron.arizona.edu (5.59-1.7/15)
  509.     id AA24260; Thu, 5 Jan 89 11:06:28 MST
  510. In-Reply-To: <8901042257.AA16121@june.cs.washington.edu>
  511. To: icon-group
  512. Subject: Re: Returning functions...
  513.  
  514. > Date: Wed, 4 Jan 89 14:57:13 PST
  515. > From: wgg@june.cs.washington.edu (William Griswold)
  516.  
  517.   [deleted text] 
  518.  
  519. > I think implementing a function like EVAL() might have peculiar properties
  520. > in Icon, because Icon is statically rather than dynamically scoped.  This
  521. > would imply that the string passed to eval would be evaluated in the
  522. > static context of EVAL(), rather than the procedure calling EVAL.  I
  523. > don't see any obvious way around this.
  524.  
  525. EVAL() should be able to get to the environment of it's caller, along
  526. with it's caller's "procedure block". The names of local variables are
  527. stored in the procedure block, so I don't see any problem with EVAL()
  528. evaluating a string in the caller's context. The remaining issue is
  529. what to do if the string contains identifiers which do not exist
  530. in the context. Should this be an implicit declaration of the
  531. variable? Where does the variable get allocated? What is its lifetime?
  532.  
  533. > There has been some talk of more exotic control features in Icon (such
  534. > as Ken Walker's c-expressions. Ken?) that could address some of the 
  535. > issues discussed, but little has come of it to date, as far as I know.
  536.  
  537. C-expressions are a variation on co-expressions, making them more like
  538. Lisp closures. They differ from co-expressions in three ways.
  539.  
  540.    1) They share locals with the procedure that created them, along
  541.       with other co-expressions created by that procedure (technically,
  542.       they share locals with a particular invocation of the procedure).
  543.       It is this sharing rather than copying that really makes them
  544.       like Lisp closures.
  545.  
  546.    2) They can be invoked using ! to generate all the results of the
  547.       expression, starting from the beginning. This differs from @
  548.       which produces one result at time, remembering between activation
  549.       where it left off. (Note that unary @ is still supported.) Thus !
  550.       is like a parameterless procedure invocation.
  551.  
  552.    3) Value transmission (binary @) is not supported, though it can
  553.       probably be done.
  554.  
  555. C-expressions, when used with !, are like pararmeterless Lisp closures
  556. with no local variables. However, as a feature of Icon, they have the
  557. ability to generate results, something a Lisp closure cannot do.
  558.  
  559. There are presently no plans for including them in a destributed version
  560. of Icon.
  561.       
  562.    Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  563.    +1 602 621 2858  kwalker@Arizona.EDU   {uunet|allegra|noao}!arizona!kwalker
  564.  
  565. From naucse!sbw  Thu Jan  5 12:37:49 1989
  566. Received: by megaron.arizona.edu (5.59-1.7/15)
  567.     id AA28092; Thu, 5 Jan 89 12:37:49 MST
  568. Date: Thu, 5 Jan 89 11:20:33 mst
  569. From: naucse!sbw (Steve Wampler)
  570. Message-Id: <8901051820.AA11572@naucse>
  571. X-Mailer: Mail User's Shell (6.3 6/25/88)
  572. To: arizona!icon-group
  573. Subject: Re: functions that return functions...
  574.  
  575. On Jan 5 at  0:14, Dan Pierson writes:
  576.  >
  577.  >In article <8901041824.AA00834@naucse>, sbw@naucse (Steve Wampler) writes:
  578.  >>I think what the original poster wanted was related to SNOBOL4's
  579.  >>CODE function - the ability to construct procedures at runtime.
  580.  >>It would take a new operation (say a conversion from string to
  581.  >>function) which is difficult to implement primarily because it
  582.  >>requires the icon translator to be available at run time.  In
  583.  >>SNOBOL4 or LISP, this isn't so bad because the translators for
  584.  >>those languages are fairly simple.  For Icon, it's huge.
  585.  >
  586.  >Returning new functions from functions doesn't have to involve
  587.  >runtime translation.
  588.  
  589. I have to disagree that this returns a 'new function', just new
  590. instances of an existing function, with different data bindings
  591. in each instance.  It is quite useful, however.  It can be done in
  592. Icon using co-expressions, though it is easy to create (sorry)
  593. examples that don't work this way.  See the end of this note.
  594.  
  595. What I was refering to was the ability to read a string in as
  596. input and evaluate it - thus the code for the function is non-existent
  597. at run time and you MUST have a translator around.
  598.  
  599.  >.................... Try writing the Lisp function in following in
  600.  >Icon:
  601.  >
  602.  >(defun account (balance)
  603.  >  (flet ((deposit (n)
  604.  >       (incf balance n)
  605.  >       balance)
  606.  >     (withdraw (n)
  607.  >       (if (<= n balance)
  608.  >           (progn
  609.  >         (decf balance n)
  610.  >         balance)
  611.  >           (error "Tried to withdraw more money than in account")))
  612.  >     (balance ()
  613.  >       balance))
  614.  >    #'(lambda (action &optional (n 0))
  615.  >    (case action
  616.  >      (deposit (deposit n))
  617.  >      (withdraw (withdraw n))
  618.  >      (balance (balance))))))
  619.  >
  620.  
  621. This is a nice example, I like it.  It can be done in Icon as well,
  622. though not as cleanly.  Here it is, slightly simplified through
  623. the use of overdraft protection:
  624.  
  625.     procedure new_account(bal)
  626.         # most of the oddness here is to pass information
  627.         # back and forth to the co-expression
  628.        accnt := create |(bal := process_account(bal, bal @ &source))
  629.        @accnt    # to get the co-expression rolling
  630.        return accnt
  631.     end
  632.  
  633.     procedure process_account(cur_bal,action_list)
  634.         # a list is needed because we can only pass one thing
  635.         # to a co-expression
  636.        return case action_list[1] of {
  637.                  "balance" : cur_bal
  638.                  "deposit" : cur_bal + action_list[2]
  639.                  "withdrawal" : cur_bal - action_list[2]
  640.                  }
  641.     end
  642.  
  643. Can you (in LISP) return a list of three functions (specifically the
  644. three actions in the above function) that share the common balance? -
  645. this is what is missing in Icon at the current time, though there have
  646. been some schemes discussed for getting around this.  This is easy in
  647. OO languages, but I was wondering if LISP had that ability (just curious).
  648.  
  649. -- 
  650.     Steve Wampler
  651.     {....!arizona!naucse!sbw}
  652.  
  653. From jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK  Thu Jan  5 12:37:50 1989
  654. Received: from NSS.CS.UCL.AC.UK by megaron.arizona.edu (5.59-1.7/15) via SMTP
  655.     id AA28096; Thu, 5 Jan 89 12:37:50 MST
  656. Received: from aiai.edinburgh.ac.uk by NSS.Cs.Ucl.AC.UK   via Janet with NIFTP
  657.            id aa06958; 5 Jan 89 19:32 GMT
  658. Date: Thu, 5 Jan 89 19:26:51 GMT
  659. Message-Id: <3933.8901051926@subnode.aiai.ed.ac.uk>
  660. From: Jeff Dalton <jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK>
  661. Subject: Re: Returning functions...
  662. To: William Griswold <wgg@june.cs.washington.edu>, icon-group@arizona.edu
  663. In-Reply-To: William Griswold's message of Wed, 4 Jan 89 14:57:13 PST
  664.  
  665. > I think implementing a function like EVAL() might have peculiar properties
  666. > in Icon, because Icon is statically rather than dynamically scoped.  This
  667. > would imply that the string passed to eval would be evaluated in the
  668. > static context of EVAL(), rather than the procedure calling EVAL.  I
  669. > don't see any obvious way around this.
  670.  
  671. This problem occurs in Lisps that are lexicaly scoped.  In Common Lisp,
  672. EVAL evaluates the expression in the null lexical environment.  In some
  673. other Lisps, it is possible to pass an extra parameter that gives the
  674. environment to use for evaluation.  Then you also need a way to create
  675. environments of the appropriate sort.
  676.  
  677. Jeff Dalton,                      JANET: J.Dalton@uk.ac.ed             
  678. AI Applications Institute,        ARPA:  J.Dalton%uk.ac.ed@nss.cs.ucl.ac.uk
  679. Edinburgh University.             UUCP:  ...!ukc!ed.ac.uk!J.Dalton
  680.  
  681. From wgg@june.cs.washington.edu  Thu Jan  5 17:45:43 1989
  682. Received: from june.cs.washington.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  683.     id AA00586; Thu, 5 Jan 89 17:45:43 MST
  684. Received: by june.cs.washington.edu (5.59/6.13+)
  685.     id AA09547; Thu, 5 Jan 89 13:52:04 PST
  686. Date: Thu, 5 Jan 89 13:52:04 PST
  687. From: wgg@june.cs.washington.edu (William Griswold)
  688. Return-Path: <wgg>
  689. Message-Id: <8901052152.AA09547@june.cs.washington.edu>
  690. To: icon-group@arizona.edu
  691. Subject: Re: Returning functions...
  692.  
  693. >From: "Kenneth Walker" <kwalker@arizona.edu>
  694. >Subject: Re: Returning functions...
  695.  
  696. [regarding implementing EVAL() in Icon]
  697.  
  698. >EVAL() should be able to get to the environment of it's caller, along
  699. >with it's caller's "procedure block". The names of local variables are
  700. >stored in the procedure block, so I don't see any problem with EVAL()
  701. >evaluating a string in the caller's context. The remaining issue is
  702. >what to do if the string contains identifiers which do not exist
  703. >in the context. Should this be an implicit declaration of the
  704. >variable? Where does the variable get allocated? What is its lifetime?
  705.  
  706. I have no doubts about its implementation, but it would create a second kind
  707. of scoping in Icon.  Once you have made it available to EVAL(), what about
  708. other cool functions that could use dynamic scoping (or whatever it would
  709. turn out to be)?  It wouldn't be ``fair'' (or regular) to give it only to
  710. EVAL(), but having two scoping mechanisms in Icon could considerably
  711. complicate the implementation of Icon.  Also, it would make Icon programs
  712. harder to understand, since you could never be sure what scoping mechanism
  713. is used (unless of course you found a way to syntactically differentiate the
  714. *use* of dynamic and static variables, and that would be a mess).   This is
  715. what I meant by no obvious (easy) way out.
  716.  
  717.                     Bill Griswold
  718.  
  719. From jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK  Thu Jan  5 19:48:31 1989
  720. Received: from NSS.CS.UCL.AC.UK by megaron.arizona.edu (5.59-1.7/15) via SMTP
  721.     id AA03951; Thu, 5 Jan 89 19:48:31 MST
  722. Received: from aiai.edinburgh.ac.uk by NSS.Cs.Ucl.AC.UK   via Janet with NIFTP
  723.            id aa08632; 6 Jan 89 0:01 GMT
  724. Date: Thu, 5 Jan 89 23:56:28 GMT
  725. Message-Id: <4191.8901052356@subnode.aiai.ed.ac.uk>
  726. From: Jeff Dalton <jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK>
  727. Subject: Re: functions that return functions...
  728. To: sbw <naucse!@arizona.edu:sbw>,
  729.         icon-group <@arizona.edu:icon-group@arizona>
  730. In-Reply-To: Steve Wampler's message of Thu, 5 Jan 89 11:20:33 mst
  731.  
  732. > I have to disagree that this returns a 'new function', just new
  733. > instances of an existing function, with different data bindings
  734. > in each instance.
  735.  
  736. You might also say it's a new function that happens to execute the
  737. same code as some other functions, but I don't think whether a closure
  738. is really a new function is a very interesting question.
  739.  
  740. > Can you (in LISP) return a list of three functions (specifically the
  741. > three actions in the above function) that share the common balance? -
  742.  
  743. Yes.
  744.  
  745. -- Jeff
  746.  
  747.  
  748. From jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK  Thu Jan  5 19:51:55 1989
  749. Received: from NSS.CS.UCL.AC.UK by megaron.arizona.edu (5.59-1.7/15) via SMTP
  750.     id AA04016; Thu, 5 Jan 89 19:51:55 MST
  751. Received: from aiai.edinburgh.ac.uk by NSS.Cs.Ucl.AC.UK   via Janet with NIFTP
  752.            id aa08519; 5 Jan 89 23:41 GMT
  753. Date: Thu, 5 Jan 89 23:36:24 GMT
  754. Message-Id: <4139.8901052336@subnode.aiai.ed.ac.uk>
  755. From: Jeff Dalton <jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK>
  756. Subject: Re: returning a procedure from a procedure
  757. To: David Talmage <talmage%lti.com@NSS.Cs.Ucl.AC.UK>,
  758.         spqr%computer-science.southampton.ac.uk@NSS.Cs.Ucl.AC.UK
  759. In-Reply-To: David Talmage's message of Wed, 4 Jan 89 09:45:05 EST
  760. Cc: icon-group@arizona.edu
  761.  
  762. > Couldn't you make your functions return strings which name other functions?
  763. > Then you could use the Icon "call by string value" feature to call the
  764. > result of the first function.  It might look like this:
  765.  
  766. Not good enough, because the number of procedure objects is fixed.
  767. In Scheme, I can do this:
  768.  
  769.   (define (make-counter)
  770.     (let ((count 0))
  771.       (lambda () (set! count (+ count 1))
  772.                  count)))
  773.  
  774. The two calls to MAKE-COUNTER would return two different procedures,
  775. as in:
  776.  
  777. > (define c1 (make-counter))
  778. #<procedure 1>
  779.  
  780. > (define c2 (make-counter))
  781. #<procedure 2>
  782.  
  783. > (c1)
  784. 1
  785.  
  786. > (c1) ;gets one bigger each time
  787. 2
  788.  
  789. > (c2) ;but this one hasn't started counting yet.
  790. 1
  791.  
  792. Jeff Dalton,                      JANET: J.Dalton@uk.ac.ed             
  793. AI Applications Institute,        ARPA:  J.Dalton%uk.ac.ed@nss.cs.ucl.ac.uk
  794. Edinburgh University.             UUCP:  ...!ukc!ed.ac.uk!J.Dalton
  795.  
  796. From jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK  Thu Jan  5 20:17:41 1989
  797. Received: from NSS.CS.UCL.AC.UK by megaron.arizona.edu (5.59-1.7/15) via SMTP
  798.     id AA04780; Thu, 5 Jan 89 20:17:41 MST
  799. Received: from aiai.edinburgh.ac.uk by NSS.Cs.Ucl.AC.UK   via Janet with NIFTP
  800.            id aa08486; 5 Jan 89 23:32 GMT
  801. Date: Thu, 5 Jan 89 23:27:36 GMT
  802. Message-Id: <4119.8901052327@subnode.aiai.ed.ac.uk>
  803. From: Jeff Dalton <jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK>
  804. Subject: Re: returning a procedure from a procedure
  805. To: Sebastian Rahtz <spqr%computer-science.southampton.ac.uk@NSS.Cs.Ucl.AC.UK>,
  806.         icon-group@arizona.edu
  807. In-Reply-To: Sebastian Rahtz's message of Wed, 4 Jan 89 09:03:43 GMT
  808.  
  809. > having just sat happily through a workshop on the Scheme dialect of
  810. > Lisp, run by a colleague here, my brain started to mull over how I
  811. > could persuade the colleague that Icon was even better than Scheme....
  812. > But he threw me with Lisp ability for a function to return a function
  813. > as its result. Can anyone suggest to me EITHER how I pretend this
  814. > isn't a good thing, OR how Icon would be persuaded to think likewise?
  815. >  
  816. > I once wrote a SNOLBOL program which read in data mixed with patterns,
  817. > and turned those patterns into valid code to apply to the associated
  818. > data. It sounds like a not dissimilar problem.
  819.  
  820. There are two Lispish capabilities that might be confused.  One is
  821. tha ability to turn some list-structure data into code or to treat
  822. it as code, the other is the ability to return procedural values.
  823. For example,
  824.  
  825.    (define (compose f g)
  826.      (lambda (x) (f (g x))))
  827.  
  828. COMPOSE is a function that returns the composition of two other
  829. functions.
  830.  
  831. Jeff Dalton,                      JANET: J.Dalton@uk.ac.ed             
  832. AI Applications Institute,        ARPA:  J.Dalton%uk.ac.ed@nss.cs.ucl.ac.uk
  833. Edinburgh University.             UUCP:  ...!ukc!ed.ac.uk!J.Dalton
  834.  
  835.      
  836.  
  837. From icon-group-request  Fri Jan  6 21:10:09 1989
  838. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  839.     id AA09037; Fri, 6 Jan 89 21:10:09 MST
  840. Received: by ucbvax.Berkeley.EDU (5.61/1.33)
  841.     id AA22601; Fri, 6 Jan 89 18:30:48 PST
  842. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  843.     for icon-group@arizona.edu (icon-group@arizona.edu)
  844.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  845. Date: 7 Jan 89 00:01:50 GMT
  846. From: encore!pierson%mist@bu-cs.bu.edu  (Dan Pierson)
  847. Organization: Encore Computer Corp
  848. Subject: Re: functions that return functions...
  849. Message-Id: <4606@xenna.Encore.COM>
  850. References: <8901051820.AA11572@naucse>
  851. Sender: icon-group-request@arizona.edu
  852. To: icon-group@arizona.edu
  853.  
  854. In article <8901051820.AA11572@naucse>, sbw@naucse (Steve Wampler) writes:
  855.  >Can you (in LISP) return a list of three functions (specifically the
  856.  >three actions in the above function) that share the common balance? -
  857.  >this is what is missing in Icon at the current time, though there have
  858.  >been some schemes discussed for getting around this.  This is easy in
  859.  >OO languages, but I was wondering if LISP had that ability (just curious).
  860.  
  861. Sure, just replace the return value of my previous example with:
  862.  
  863.     '(#'deposit #'withdraw #'balance)
  864. -- 
  865.                                             dan
  866.  
  867. In real life: Dan Pierson, Encore Computer Corporation, Research
  868. UUCP: {talcott,linus,necis,decvax}!encore!pierson
  869. Internet: pierson@multimax.encore.com
  870.  
  871. From icon-group-request  Fri Jan 13 17:40:12 1989
  872. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  873.     id AA27491; Fri, 13 Jan 89 17:40:12 MST
  874. Received: by ucbvax.Berkeley.EDU (5.61/1.33)
  875.     id AA13254; Fri, 13 Jan 89 16:29:54-0800
  876. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  877.     for icon-group@arizona.edu (icon-group@arizona.edu)
  878.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  879. Date: 13 Jan 89 04:12:00 GMT
  880. From: uxg.cso.uiuc.edu!uicbert.eecs.uic.edu!wilson@uxc.cso.uiuc.edu
  881. Subject: Re: Returning functions...
  882. Message-Id: <93400001@uicbert.eecs.uic.edu>
  883. References: <8901041824.AA00834@naucse>
  884. Sender: icon-group-request@arizona.edu
  885. To: icon-group@arizona.edu
  886.  
  887.  
  888. Excuse me if *I've* misunderstood the issue, but it seems to me that
  889. somebody should separate the issues of scope and extent clearly.
  890.  
  891. (Preferably, somebody who knows Icon better than me -- I'm just
  892. starting a class on it.  But here goes.  I'm hoping this will motivate
  893. a discussion of potential cross-fertilization between the Scheme and
  894. Icon communities.  I would expect people who like either language to
  895. like the other, and I'm considering snarfing some Icon features for
  896. an extended Scheme implementation.)
  897.  
  898. Some important things:
  899.  
  900.   1. Scheme and Common Lisp are both lexically scoped.  There is an easy
  901.      way of implementing this, though it's not the most efficient.  If
  902.      Icon worked that way, there wouldn't be any confusion of which
  903.      scoping mechanism was being used -- Icon's two-level static
  904.      scoping is a degenerate case of Scheme's lexical scoping.
  905.  
  906.      (Note that Common Lisp and most implementations of Scheme *also*
  907.      support dynamically scoped variables, but lexical scope is the
  908.      default.  The combination of the two is harder to implement
  909.      than either one alone.)
  910.  
  911.   2. What's peculiar about Scheme (and Common Lisp when you exploit
  912.      lexical closures) is that variable bindings have "indefinite
  913.      extent".  This means that the space for the local variables of
  914.      a procedure are allocated on the garbage-collected heap, not
  915.      on the stack (in the general case).
  916.  
  917.   Scheme's scoping is essentially the same as Pascal's, and it can
  918. be implemented the same way, using static chains or displays at run
  919. time for variable lookup.  That is, at run-time each executing
  920. procedure's activation record holds a pointer to an activation
  921. record of the procedure it was declared inside.  In Pascal, I never
  922. cared much about scoping -- two or three levels is enough for me.
  923. But when it's combined with indefinite extent, as in Scheme, you can
  924. do a lot of interesting and useful things.
  925.  
  926.   If you avoid a few particlar operations in Scheme, the "environment
  927. frames" that hold the local variables for a procedure call become
  928. garbage when the procedure returns, because the activation records
  929. they belong to are popped off the stack.  The only consequence of
  930. heap-allocated variables in such circumstances is that you have to
  931. wait for a garbage collection to reclaim the space, rather than
  932. the activation's space for variables off the stack too.
  933.  
  934.   But something funny happens if a procedure creates a new procedure
  935. at run time.  The variable bindings that the currently executing
  936. procedure is using are "captured" when the new procedure is created.
  937. Whenever the new procedure is executed, that binding environment
  938. will be restored for it to execute in.  So if there's as long as there's
  939. a possibility of executing a procedure that was created in a particular
  940. binding environment, that environment won't be reclaimed by the gc.
  941.  
  942.    Let me make that a little more concrete.  If you use a static
  943. chain, the links in the static chain reflect the nesting of
  944. he procedures in the source code.  Suppose procedure B s nested inside
  945. procedure A in the source code ("lexically").   When procedure B
  946. is called, an environment frame is created to hold its local variables
  947. for that call.  This environment frame has a scoping pointer (static
  948. link) to an environment frame for an activation of A.  The
  949. procedure can only see the versions of variables along that static
  950. chain.
  951.  
  952.    The "capture" of a binding environment is then just the saving
  953. of a pointer to the currently executing procedure's environment frame.
  954. The garbage collector won't reclaim the space for any of the frames
  955. along the chain because each keeps a pointer to the next one.  To
  956. restore the environment for a procedure to execute in, the system
  957. just puts the pointer to that environment back in the "current environment"
  958. register.  (Or does something equivalent with a display.)
  959.  
  960.    So whenever a new procedure is created by a running program, a
  961. "lexical closure" is created.  This is just an object that holds two
  962. things: the code to execute, and a pointer to the environment to
  963. execute it in (the current environment when the object is created). So
  964. if you save the closure (by storing it in a global variable, say), you're
  965. implicitly saving all of the variable bindings that were in effect when
  966. it was created.  But if you don't save any new procedures, you can
  967. treat Scheme just like Pascal.
  968.  
  969. --------------------------------------------------------------------------
  970. I needed to write this out for some undergrads I'm teaching anyway,
  971. so here's an example:
  972.  
  973.  
  974.    So suppose we're in the top-level loop in Scheme, just typing things
  975. to the interpreter and having it interpret them.  If we type
  976.  
  977.      (let ((x 0))
  978.          (some-procedure x))
  979.  
  980. what we're doing is creating a new environment frame and executing a
  981. procedure in it.  "let" creates a frame that has space for one
  982. variable, "x", whose initial value will be zero.  That environment will
  983. be an extension to whatever environment had been in effect. It then executes
  984. the rest of the expressions in that environment.  When it's done,
  985. it restores the old environment.  If we're starting out in the usual
  986. user-interaction mode, the "current environment" is just the global
  987. variable bindings.  While we're inside the body of the let, variable
  988. lookups will look in the new frame it creates (holding a binding for x)
  989. before looking in the globals.
  990.  
  991.    A slightly more interesting example is to execute a procedure, inside
  992. the "let" that creates a new procedure object.
  993.  
  994.      (let ((x 0))
  995.          (make-procedure ()
  996.             (set! x (+ x 1))
  997.             (return x)))
  998.  
  999.    (This isn't quite real Scheme, but it's clearer to non-lispers.)
  1000.  
  1001.    What happens here is that the new environment is created and then
  1002. a new procedure is constructed.  When executed, that procedure will
  1003. restore the environment created by the let and add 1 to the value
  1004. of x in that environment.  It will then return the value of x from
  1005. that environment to whoever called it.  Since that version of x
  1006. exists between calls (as long as the procedure exists), it keeps
  1007. its state between calls, and the procedure acts as a counter. Every
  1008. time you call it, it computes the next number and gives it back to you.
  1009.  
  1010.    But how do we get ahold of the procedure, to keep it around so that we
  1011. can call it?  We can take advantage of the fact that "let" returns the
  1012. value of the last statement that it executes.  In this case, that's
  1013. just the call to make-procedure.
  1014.  
  1015.    We can save the procedure object by making it the value of a global
  1016. variable, say, "count".
  1017.  
  1018.       (set! count
  1019.             (let ((x 0))
  1020.                 (make-procedure ()
  1021.                     (set! x (+ x 1))
  1022.                     (return x))))
  1023.  
  1024.    So now we can call the procedure, which is the value of variable "count",
  1025. the way we call any procedure in Scheme:  (count) will do it.
  1026.  
  1027.    Finally, we can easily generalize this to make a procedure that will
  1028. create a new counter procedure every time we call it.  We'll store this
  1029. procedure in the variable "create-counter".
  1030.  
  1031.       (set! create-counter
  1032.            (make-procedure ()
  1033.               (let ((x 0))
  1034.                   (make-procedure ()
  1035.                       (set! x (+ x 1))
  1036.                       (return x)))))
  1037.  
  1038.    Every time we execute the procedure stored in make-counter, it will
  1039. create a new binding environment with its own version of the variable x.
  1040. It will then create a new procedure that increments that version of x
  1041. and returns its value.
  1042.  
  1043.    In real Scheme, "make-procedure" is called "lambda", for historical
  1044. reasons.  And you don't have to explicitly return a value -- most procedures
  1045. automatically return their last subexpression's value by default.  Setq
  1046. returns the value it has assigned to the variable being set.  So the
  1047. above procedure would really look like this:
  1048.  
  1049.       (set! create-counter
  1050.             (lambda ()
  1051.                (let ((x 0))
  1052.                    (lambda ()
  1053.                       (set! x (+ x 1))))))
  1054.  
  1055.  
  1056.    This is how Scheme's combination of lexical scoping and indefinite
  1057. extent gives you the ability to package procedures and data together
  1058. to get the funcionality of objects.  Slightly more complicated programs
  1059. can be written that compute infinite "streams" of data, one piece at
  1060. a time, on demand.  These can be combined into streams that are mappings
  1061. of other streams, all of them potentially infinite, and each asking others
  1062. only for the information it needs, as it needs it.  This gives you the
  1063. ability to manipulate potentially infinite lists, as long as you don't
  1064. actually ever need the whole list at any given time.
  1065.  
  1066.    For example, you might create an object similar to the counter that
  1067. calls a counter and then returns the square of the result, giving a 
  1068. consecutive squares.  A slightly more general procedure may be used to
  1069. combine any function with any stream, producing a stream that always
  1070. maps the function onto the next element of the stream.  Thus a few
  1071. types of streams and a few types of functions can easily be combined
  1072. to yield a large variety of streams, each yielding an infinite sequence,
  1073. one element at a time.
  1074.  
  1075. -------------------------------------------------------------------------
  1076.  
  1077. For a beautiful (though dense) introduction to programming in Scheme
  1078. and implementing Scheme, the standard text is Abelson and Sussman's
  1079. "Structure and Interpretation of Computer Programs".  They show how
  1080. to write basic programs in Scheme, using elegant techniques like
  1081. stream combination and object-centered programming;  they even show
  1082. how to implement a Scheme interpreter in Scheme, and even a Scheme
  1083. compiler.  It's a great book -- it's easy enough to understand, although
  1084. there is a temptation to try to breeze through it.  The ideas are
  1085. simple and powerful, but there are enough of them that you should digest
  1086. them reasonably well.  (That one book contains half of a good education
  1087. in Computer Science, if you ask me.)
  1088.  
  1089. Oh yeah -- another important thing about Scheme's scoping is that it
  1090. can be compiled efficiently.  The fact that the static chain or display
  1091. corresponds to the static structure of the program means that the
  1092. compiler can infer enough stuff at compile time that the code can be
  1093. quite good.  And there's no problem with concurrent versions of Scheme,
  1094. with several threads executing in their own "current" environments.
  1095. (Dynamic binding can be a real headache combined with multitasking.)
  1096.  
  1097.  
  1098.     -- Paul
  1099.  
  1100. Paul R. Wilson                         
  1101. Human-Computer Interaction Laboratory
  1102. U. of Ill. at C. EECS Dept. (M/C 154)   wilson@uicbert.eecs.uic.edu
  1103. Box 4348   Chicago,IL 60680 
  1104.  
  1105. From hdan@sleepy.cc.utexas.edu  Sun Jan 15 00:37:43 1989
  1106. Received: from emx.utexas.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1107.     id AA20100; Sun, 15 Jan 89 00:37:43 MST
  1108. Received: by emx.utexas.edu (5.54/5.51)
  1109.     id AA29961; Sun, 15 Jan 89 01:38:03 CST
  1110. Date: Sun, 15 Jan 89 01:36:31 CST
  1111. From: hdan@sleepy.cc.utexas.edu (Dan Higdon)
  1112. Posted-Date: Sun, 15 Jan 89 01:36:31 CST
  1113. Message-Id: <8901150736.AA22446@sleepy.cc.utexas.edu>
  1114. Received: by sleepy.cc.utexas.edu (5.51/5.51)
  1115.     id AA22446; Sun, 15 Jan 89 01:36:31 CST
  1116. To: icon-group@arizona.edu
  1117. Subject: tools
  1118.  
  1119. Does anyone out there know where I can find the MS-DOS or OS/2
  1120. versions of YACC/LEX/AWK?  Obviously I would prefer shareware or pd
  1121. over having to purchase "commercial" software.
  1122. (I know this seems to have little to do with Icon, but they all fit into
  1123.  the programming languages topic, right?)
  1124.  
  1125. hdan@sleepy.cc.utexas.edu
  1126. .s
  1127.  
  1128. From ralph  Sun Jan 15 18:23:43 1989
  1129. Date: Sun, 15 Jan 89 18:23:43 MST
  1130. From: "Ralph Griswold" <ralph>
  1131. Message-Id: <8901160123.AA22086@megaron.arizona.edu>
  1132. Received: by megaron.arizona.edu (5.59-1.7/15)
  1133.     id AA22086; Sun, 15 Jan 89 18:23:43 MST
  1134. To: icon-group
  1135. Subject: Version 7.5 of Icon for UNIX and VMS
  1136.  
  1137. Version 7.5 of Icon is now available for UNIX and VMS systems.
  1138.  
  1139. The changes are minor as far as the language itself is concerned.
  1140. The main changes are in the implementation, which has been somewhat
  1141. reorganized.
  1142.  
  1143. If you're using an earlier Version 7 Icon and having no troubles, there
  1144. is no particular reason for you to get Version 7.5 (although we no
  1145. longer support earlier versions).  If you're still using Version 6,
  1146. you should seriously consider upgrading to Version 7.5.
  1147.  
  1148. Version 7.5 for UNIX and VMS is available via FTP.  Do an anonymous
  1149. FTP to arizona.edu; cd to icon; and get README, which lists what's
  1150. available.
  1151.  
  1152. If you do not have access to FTP, Version 7.5 Icon for UNIX and VMS
  1153. can be obtained on magnetic tape for $25 each, which includes shipping in
  1154. the United States and Canada, as well as hardcopy documentation.
  1155. Order tapes from
  1156.  
  1157.     Icon Project
  1158.     Department of Computer Science
  1159.     Gould-Simpson Building
  1160.     The University of Arizona
  1161.     Tucson, AZ   85721
  1162.     USA
  1163.  
  1164. There is a $10 shipping charge per tape for orders sent outside the
  1165. United States and Canada.
  1166.  
  1167. Payment must be in US dollars. Checks must be drawn on a bank with a branch in
  1168. the United States. Postal Money orders in US dollars also are acceptable.
  1169.  
  1170. Please address any questions to me (not to icon-group).
  1171.  
  1172.    Ralph E. Griswold
  1173.    Department of Computer Science
  1174.    Gould-Simpson Building
  1175.    University of Arizona
  1176.    Tucson, AZ 85721
  1177.    USA
  1178.  
  1179.    ralph@Arizona.EDU
  1180.    uunet!arizona!ralph
  1181.  
  1182.  
  1183. From dscargo@cim-vax.honeywell.com  Mon Jan 16 07:44:39 1989
  1184. Message-Id: <8901161444.AA15247@megaron.arizona.edu>
  1185. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1186.     id AA15247; Mon, 16 Jan 89 07:44:39 MST
  1187. Date: 16 Jan 89 08:24:00 CST
  1188. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  1189. Subject: changes from v7 to v7.5
  1190. To: "icon-group" <icon-group@arizona.edu>
  1191.  
  1192. If you aren't going to summarize the changes between v7 and v7.5, can
  1193. you at least point to a file for FTP that discusses the differences?  Most
  1194. importantly, is the new version completely upward compatible?
  1195.  
  1196. dsc
  1197.  
  1198.  
  1199. From dscargo@cim-vax.honeywell.com  Mon Jan 16 08:05:33 1989
  1200. Message-Id: <8901161505.AA16153@megaron.arizona.edu>
  1201. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1202.     id AA16153; Mon, 16 Jan 89 08:05:33 MST
  1203. Date: 16 Jan 89 08:52:00 CST
  1204. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  1205. Subject: Areas for possible enhancement
  1206. To: "icon-group" <icon-group@arizona.edu>
  1207.  
  1208. While writing what is a fairly simple program in Icon, I discovered some
  1209. aspects of the language that could be changed to make certain programs even
  1210. easier to write.
  1211.  
  1212. Of the built-in character sets, there isn't one that's just the printable
  1213. characters.  There are the upper- and lower-case letters, and more recently
  1214. the digits, but there's also all the punctuation.  I realize that a global
  1215. variable and an initialization could solve the lack, but I was wondering if
  1216. this lack might be a common problem.
  1217.  
  1218. Is there a simple way to do radix conversion from the user level?  Sometimes
  1219. I've wanted to translate a byte from 8-bit integer to hexadecimal
  1220. representation.  There appears to be something internal used for conversion
  1221. to octal (used for image of control charcters), but again it doesn't seem to
  1222. be user accessible.  Decimal, hex, octal, and maybe binary would be the
  1223. set of radices most likely to be used, I expect.
  1224.  
  1225. I also found myself wondering if there was a way to discover from a running
  1226. program how close to the limits of memory capacity I'd come, some way to
  1227. measure the "high water marks" in the various structures that are of fixed
  1228. size.  Of hand I don't know how many of them there are, but it would be
  1229. nice to know actual maximum and max available for whatever there are.
  1230.  
  1231. Actually, I shouldn't call these "language changes".  They are more like
  1232. additions to built-ins.
  1233.  
  1234. I was wondering what the fastest (and clearest) method of testing for the
  1235. the membership of a character in a cset.  Has member been generalized to work
  1236. on csets as well as sets and tables?
  1237.  
  1238. I was noticing in the one page Icon reference sheet that came in the latest
  1239. newsletter that the built-in function "collect()" was listed.  I didn't
  1240. recognize it.  What does it do?  Also, there seems to be enough space that
  1241. some of the syntax  for the data types could be added.  While using the
  1242. quotation marks for strings and apostrophes for csets would be useful only
  1243. to the rankest beginners, specifying the radix of integers is a syntactical
  1244. element used infrequently enough that noting it on the sheet seems reasonable.
  1245. Some of the type constructors (like list and set) would also be useful for
  1246. beginners.
  1247.  
  1248. I'm sorry if I'm sounding picky, but by-and-large the work done with Icon
  1249. seems to be so good and useful that only some of the little things are left
  1250. to discuss.
  1251.  
  1252. One more thing just occurred to me.  For people trying to manage their own
  1253. program's runtime resources, would a "size" or "memsize" function that lets
  1254. them measure the actual memory size of variables be hard to do?  Sizing of
  1255. things is not something that's discussed much at the language level.
  1256.  
  1257. Appreciatively yours,
  1258.  
  1259. David S. Cargo
  1260.  
  1261.  
  1262. From ralph  Mon Jan 16 16:26:03 1989
  1263. Date: Mon, 16 Jan 89 16:26:03 MST
  1264. From: "Ralph Griswold" <ralph>
  1265. Message-Id: <8901162326.AA07224@megaron.arizona.edu>
  1266. Received: by megaron.arizona.edu (5.59-1.7/15)
  1267.     id AA07224; Mon, 16 Jan 89 16:26:03 MST
  1268. To: icon-group
  1269. Subject: Icon Version 7.5 vs 7.0
  1270.  
  1271. A few persons have asked for the details of the minor language changes
  1272. between Version 7.5 and 7.0 of Icon.  Here's the information:
  1273. =======================================================================
  1274. Command-Line Options:
  1275.  
  1276.    Options to icont must precede file names on the command line.
  1277. For example,
  1278.  
  1279.         icont -o manager proto.icn
  1280.  
  1281. not
  1282.  
  1283.         icont proto.icn -o manager
  1284.  
  1285. The position of options has always been documented this way, but
  1286. it was not enforced previously. Consequently, options in the
  1287. incorrect position that worked before will not work now. This
  1288. problem is most likely to occur in scripts that were composed
  1289. under earlier version of Icon.
  1290.  
  1291.    Note that the -x option is an exception; it must occur after
  1292. all file names for icont, since any command-line arguments after
  1293. -x apply to execution (iconx).
  1294.  
  1295. Co-Expressions:
  1296.  
  1297.    The initial size of &main is now 1, instead of 0, to reflect
  1298. its activation to start program execution.
  1299.  
  1300.    An attempt to refresh &main results in a run-time error.
  1301. (Formerly, it caused a memory violation.)
  1302.  
  1303. Change in Function to Force Garbage Collection:
  1304.  
  1305.    Garbage collection is forced by the function collect(i,j).
  1306. The value of i specifies the region and the value of j specifies
  1307. the amount of space that must be free following the collection.
  1308. The regions are designated as follows:
  1309.  
  1310.         i    region
  1311.  
  1312.         1    static
  1313.         2    string
  1314.         3    block
  1315.  
  1316. The region specified is reflected in the values generated by
  1317. &collections.  A value of 0 for i causes a garbage collection
  1318. without a specific region. In this case, the value of j is
  1319. irrelevant.  The default values for i and j are 0.
  1320.  
  1321. Miscellaneous:
  1322.  
  1323.    ``Unprintable'' characters in strings now are imaged with hex-
  1324. adecimal escape sequences rather than with octal ones.
  1325.  
  1326.    The function display(f,i) now prints the image of the current
  1327. co-expression before listing the values of variables.
  1328.  
  1329.    If the value of &trace is negative, it is decremented every
  1330. time a trace message is written. Previously it was left
  1331. unchanged. This change does not affect tracing itself, but it
  1332. does allow the number of trace messages that have been written to
  1333. be determined by a running program.
  1334.  
  1335.    The environment variable BLOCKSIZE is now a synonym for HEAP-
  1336. SIZE.
  1337. =======================================================================
  1338.  
  1339. A printable copy of a technical report describing Version 7.5 of Icon
  1340. is in the FTP area as decsribed earlier.  Get version7.doc.
  1341.  
  1342.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  1343.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  1344.  
  1345.  
  1346. From kwalker  Wed Jan 18 17:25:17 1989
  1347. Date: Wed, 18 Jan 89 17:25:17 MST
  1348. From: "Kenneth Walker" <kwalker>
  1349. Message-Id: <8901190025.AA14525@megaron.arizona.edu>
  1350. Received: by megaron.arizona.edu (5.59-1.7/15)
  1351.     id AA14525; Wed, 18 Jan 89 17:25:17 MST
  1352. In-Reply-To: <8901161505.AA16153@megaron.arizona.edu>
  1353. To: icon-group
  1354. Subject: Re:  Areas for possible enhancement
  1355.  
  1356. > Date: 16 Jan 89 08:52:00 CST
  1357. > From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  1358.  
  1359. > Of the built-in character sets, there isn't one that's just the printable
  1360. > characters.  There are the upper- and lower-case letters, and more recently
  1361. > the digits, but there's also all the punctuation.  I realize that a global
  1362. > variable and an initialization could solve the lack, but I was wondering if
  1363. > this lack might be a common problem.
  1364.  
  1365. Is there a subset of the ASCII character set which is "officially"
  1366. printable? If not, then it will be difficult to decide what &printable
  1367. should contain. Even if such a subset does exist, the Icon Project
  1368. is trying to support EBCDIC for the IBM mainframe world; can &printable
  1369. be the same for both character sets? &digits was added because it is
  1370. very commonly needed. I suspect there are other csets which are commonly
  1371. used, but, as you point out, they are easy to construct with a global
  1372. variable and an initialization.
  1373.  
  1374. > Is there a simple way to do radix conversion from the user level?  Sometimes
  1375. > I've wanted to translate a byte from 8-bit integer to hexadecimal
  1376. > representation.  There appears to be something internal used for conversion
  1377. > to octal (used for image of control charcters), but again it doesn't seem to
  1378. > be user accessible.  Decimal, hex, octal, and maybe binary would be the
  1379. > set of radices most likely to be used, I expect.
  1380.  
  1381. I beleive there are radix conversion routines in the Icon program library,
  1382. though I haven't looked at them. Have you looked at the new built-in
  1383. functions for bit manipulation and the ones for converting between
  1384. characters and integers?
  1385.  
  1386. > I also found myself wondering if there was a way to discover from a running
  1387. > program how close to the limits of memory capacity I'd come, some way to
  1388. > measure the "high water marks" in the various structures that are of fixed
  1389. > size.  Of hand I don't know how many of them there are, but it would be
  1390. > nice to know actual maximum and max available for whatever there are.
  1391.  
  1392. Icon storage is divided into 3 regions: static, string, and block. Most
  1393. data except strings and co-expressions are allocated in the block region.
  1394. The current size of these regions can be found using the new keyword
  1395. ®ions:
  1396.  
  1397.    every write(®ions)
  1398.  
  1399. This prints the 3 sizes in the order given above. If you are using a
  1400. "fixed regions" version of Icon, the size of the static region is
  1401. meaningless (the run-time system does a C malloc() to get storage
  1402. for co-expressions). If you are running an "expandable regions" version
  1403. of Icon these regions may grow in size, so this doesn't really tell
  1404. you how close you are to using up available storage.
  1405.  
  1406. The keyword &storage can be used to tell home much of each region is
  1407. currently being used:
  1408.  
  1409.    every write(&storage)
  1410.  
  1411. The value for the static region is given for consistancy, but does not,
  1412. in fact, tell you how much of the region has been used. To accurately find
  1413. out how much storage is being used, you should force a garbage collection
  1414. first to compact the string and block regions:
  1415.  
  1416.    collect()
  1417.    every write(&storage)
  1418.  
  1419. > I was wondering what the fastest (and clearest) method of testing for the
  1420. > the membership of a character in a cset.  Has member been generalized to work
  1421. > on csets as well as sets and tables?
  1422.  
  1423. A difficulty with extending member() is that Icon has no character data
  1424. type, which is, of course, what a member of a cset is. The best thing
  1425. you can do is cset intersection and see if the result is the empty
  1426. cset:
  1427.  
  1428.    if (c ** 'a') == '' then ...
  1429.  
  1430. > I was noticing in the one page Icon reference sheet that came in the latest
  1431. > newsletter that the built-in function "collect()" was listed.  I didn't
  1432. > recognize it.  What does it do? 
  1433.  
  1434. As noted above, it forces a garbage collection.
  1435.  
  1436. > Also, there seems to be enough space that
  1437. > some of the syntax  for the data types could be added.  While using the
  1438. > quotation marks for strings and apostrophes for csets would be useful only
  1439. > to the rankest beginners, specifying the radix of integers is a syntactical
  1440. > element used infrequently enough that noting it on the sheet seems reasonable.
  1441. > Some of the type constructors (like list and set) would also be useful for
  1442. > beginners.
  1443.  
  1444. Those sound to me like reasonable additions to consider.
  1445.  
  1446. > One more thing just occurred to me.  For people trying to manage their own
  1447. > program's runtime resources, would a "size" or "memsize" function that lets
  1448. > them measure the actual memory size of variables be hard to do?  Sizing of
  1449. > things is not something that's discussed much at the language level.
  1450.  
  1451. It shouldn't be too difficult, you just need to be familar with how
  1452. all the data types are implemented so you can compute their sizes (of
  1453. course, that doesn't insure that someone here will actually to do it).
  1454. Are you thinking of a function which only looks at the first level of
  1455. a structure (just as copy only copies the first level) or do you want
  1456. something which follows sub-structures to the end. The problem, of course,
  1457. is that structures can be circular, so detecting the "end" requires some
  1458. extra book keeping.
  1459.  
  1460.    Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  1461.    +1 602 621 2858  kwalker@Arizona.EDU   {uunet|allegra|noao}!arizona!kwalker
  1462.  
  1463. From icon-group-request  Wed Jan 18 19:09:13 1989
  1464. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1465.     id AA18897; Wed, 18 Jan 89 19:09:13 MST
  1466. Received: by ucbvax.Berkeley.EDU (5.61/1.33)
  1467.     id AA28643; Wed, 18 Jan 89 17:39:02-0800
  1468. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  1469.     for icon-group@arizona.edu (icon-group@arizona.edu)
  1470.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  1471. Date: 18 Jan 89 06:12:00 GMT
  1472. From: uxg.cso.uiuc.edu!uicbert.eecs.uic.edu!wilson@uxc.cso.uiuc.edu
  1473. Subject: data backtracking, more general con
  1474. Message-Id: <93400002@uicbert.eecs.uic.edu>
  1475. Sender: icon-group-request@arizona.edu
  1476. To: icon-group@arizona.edu
  1477.  
  1478.  
  1479. Is anyone working on an Icon-like language with more orthogonal
  1480. control structures and data types?  Is anyone working on a more
  1481. general expression evaluation mechanism?
  1482.  
  1483. I've figured out how to accomplish general data backtracking in a garbage
  1484. collected heap, and in fact how to extend it to "sidetracking."  (More than
  1485. one subexpression may execute simultaneously, with each isolated
  1486. from the others' side effects.  The parent expression can choose to keep the
  1487. side effects of at most one of the subexpressions.)  This can be done with
  1488. a certain amount of continual overhead on stock hardware, and probably with
  1489. negligible overhead on Lisp machines.
  1490.  
  1491. What I'm mostly looking for is ideas of what a language with such powerful
  1492. facilities should look like.  Icon strikes me as a sort of hodgepodge
  1493. of features and types, but the particular combinations of features and
  1494. types seem to work remarkably well together.  You use backtracking where
  1495. appropriate, and assemble the rest as an imperative program.
  1496.  
  1497. Icon's simple backtracking mechanism may be as complex a predefined
  1498. evaluation mechanism as you'd want, since a more general mechanism
  1499. wouldn't give you enough familiar idioms to be able to make sense of
  1500. a program.  On the other hand, a multiway mechanism seems very valuable
  1501. if it is truly parallel, so a certain extra complexity is doubtless
  1502. worthwhile.
  1503.  
  1504. How much of Icon's inconsistency is the source of its simple power?
  1505. How much does backtracking serve to foster abstractions of the operation
  1506. of a system.  (The way an interpreter can usually be considered a
  1507. central DFA that gives its abstract state, but with the actual program
  1508. data *not* being like a DFA -- it's the concrete state that the DFA
  1509. leverages off of to do real work.)
  1510.  
  1511. What would you want control constructs to look like, if you could have
  1512. anything you wanted?  This question has two sides -- one for language
  1513. prototyping, and one for language use.  What should a very general
  1514. evaluation mechanism be like, to enable the prototyping of things
  1515. like backtracking?  What set of fixed or default mechanisms would you
  1516. want if you could only pick a couple of simple ones to actually use
  1517. in programs all the time?
  1518.  
  1519. I've thought of several ways my side-effect isolation system could be
  1520. useful (especially for concurrency), but I'm looking for more.  Any
  1521. suggestions are welcome.  Pointers to related work would be very
  1522. helpful. (I'm a somewhat familiar with multiple-context reasoning
  1523. in AI systems already, but only in the most general way.)
  1524.  
  1525. Thanks prematurely,
  1526.  
  1527.      Paul
  1528.  
  1529. Paul R. Wilson                         
  1530. Human-Computer Interaction Laboratory    lab ph.: (312) 413-0042
  1531. U. of Ill. at Chi. EECS Dept. (M/C 154)  wilson@uicbert.eecs.uic.edu
  1532. Box 4348   Chicago,IL 60680          (or wilson@carcoar.stanford.edu)
  1533.  
  1534. From icon-group-request  Thu Jan 19 01:20:57 1989
  1535. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1536.     id AA00391; Thu, 19 Jan 89 01:20:57 MST
  1537. Received: by ucbvax.Berkeley.EDU (5.61/1.33)
  1538.     id AA05768; Thu, 19 Jan 89 00:09:14-0800
  1539. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  1540.     for icon-group@arizona.edu (icon-group@arizona.edu)
  1541.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  1542. Date: 19 Jan 89 04:31:40 GMT
  1543. From: cjeffery@arizona.edu  (Clinton Jeffery)
  1544. Organization: U of Arizona CS Dept, Tucson
  1545. Subject: Re:  Areas for possible enhancement
  1546. Message-Id: <8768@megaron.arizona.edu>
  1547. References: <8901190025.AA14525@megaron.arizona.edu>
  1548. Sender: icon-group-request@arizona.edu
  1549. To: icon-group@arizona.edu
  1550.  
  1551. From "Kenneth Walker" <kwalker@arizona.edu>
  1552. >> From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  1553. >> Has member been generalized to work on csets as well as sets and tables?
  1554. > A difficulty with extending member() is that Icon has no character data
  1555. > type, which is, of course, what a member of a cset is. The best thing
  1556. > you can do is cset intersection and see if the result is the empty cset:
  1557. >    if (c ** 'a') == '' then ...
  1558.  
  1559. Oh, gross!  Defining member(c1,c2) to be equivalent to ((c1 ** c2) ~=== '')
  1560. would be a minor inelegance for a major improvement in clarity.  It would
  1561. also be trivial to implement and wouldn't break any existing programs.
  1562. -- 
  1563. | Clint Jeffery, University of Arizona Department of Computer Science
  1564. | cjeffery@arizona.edu -or- {noao allegra}!arizona!cjeffery
  1565. --
  1566.  
  1567. From gudeman  Thu Jan 19 11:12:21 1989
  1568. Date: Thu, 19 Jan 89 11:12:21 MST
  1569. From: "David Gudeman" <gudeman>
  1570. Message-Id: <8901191812.AA23609@megaron.arizona.edu>
  1571. Received: by megaron.arizona.edu (5.59-1.7/15)
  1572.     id AA23609; Thu, 19 Jan 89 11:12:21 MST
  1573. To: icon-group@arizona.edu
  1574. In-Reply-To: (Clinton Jeffery's message of 19 Jan 89 04:31:40 GMT <8768@megaron.arizona.edu>
  1575. Subject:  Areas for possible enhancement
  1576.  
  1577. >From: cjeffery@arizona.edu  (Clinton Jeffery)
  1578. >>From "Kenneth Walker" <kwalker@arizona.edu>
  1579. >> ... The best thing you can do is cset intersection and see if the
  1580. >>> result is the empty cset: 
  1581. >>    if (c ** 'a') == '' then ...
  1582.  
  1583. >Oh, gross!  Defining member(c1,c2) to be equivalent to ((c1 ** c2) ~=== '')
  1584. >would be a minor inelegance for a major improvement in clarity.  It would
  1585. >also be trivial to implement and wouldn't break any existing programs.
  1586.  
  1587. Or you can just use
  1588.  
  1589.     any(c,"a")
  1590.  
  1591. ``is "a" a member of c?''
  1592.  
  1593. Is that just too grody for words too Clint?
  1594.  
  1595. From icon-group-request  Thu Jan 19 16:53:01 1989
  1596. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1597.     id AA12289; Thu, 19 Jan 89 16:53:01 MST
  1598. Received: by ucbvax.Berkeley.EDU (5.61/1.33)
  1599.     id AA21378; Thu, 19 Jan 89 15:42:01-0800
  1600. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  1601.     for icon-group@arizona.edu (icon-group@arizona.edu)
  1602.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  1603. Date: 19 Jan 89 21:58:10 GMT
  1604. From: cjeffery@arizona.edu  (Clinton Jeffery)
  1605. Organization: U of Arizona CS Dept, Tucson
  1606. Subject: Re: Areas for possible enhancement
  1607. Message-Id: <8788@megaron.arizona.edu>
  1608. References: <8901191812.AA23609@megaron.arizona.edu>
  1609. Sender: icon-group-request@arizona.edu
  1610. To: icon-group@arizona.edu
  1611.  
  1612. From: gudeman@ARIZONA.EDU ("David Gudeman"):
  1613. >>From: cjeffery@arizona.edu  (Clinton Jeffery)
  1614. >>>From "Kenneth Walker" <kwalker@arizona.edu>, discussing cset membership
  1615. >>>    if (c ** 'a') == '' then ...
  1616. >>Oh, gross!
  1617. > Or you can just use any(c,"a").
  1618. > Is that just too grody for words too Clint?
  1619.  
  1620. Naw, this is probably what I would do in the current language
  1621. (slower or not; its cleaner).  I guess I would like set functions
  1622. to "do the right thing" with csets.
  1623. -- 
  1624. | Clint Jeffery, University of Arizona Department of Computer Science
  1625. | cjeffery@arizona.edu -or- {noao allegra}!arizona!cjeffery
  1626. --
  1627.  
  1628. From gudeman  Thu Jan 19 18:13:53 1989
  1629. Date: Thu, 19 Jan 89 18:13:53 MST
  1630. From: "David Gudeman" <gudeman>
  1631. Message-Id: <8901200113.AA15815@megaron.arizona.edu>
  1632. Received: by megaron.arizona.edu (5.59-1.7/15)
  1633.     id AA15815; Thu, 19 Jan 89 18:13:53 MST
  1634. To: icon-group@arizona.edu
  1635. In-Reply-To: (Clinton Jeffery's message of 19 Jan 89 21:58:10 GMT <8788@megaron.arizona.edu>
  1636. Subject: Areas for possible enhancement
  1637.  
  1638. >From: cjeffery@arizona.edu  (Clinton Jeffery)
  1639.  
  1640. >From: gudeman@ARIZONA.EDU ("David Gudeman"):
  1641. >>>From: cjeffery@arizona.edu  (Clinton Jeffery)
  1642. >>>>From "Kenneth Walker" <kwalker@arizona.edu>, discussing cset membership
  1643. >>>>    if (c ** 'a') == '' then ...
  1644. >> Or you can just use any(c,"a").
  1645.  
  1646. >... this is probably what I would do in the current language
  1647. >(slower or not; its cleaner).  I guess I would like set functions
  1648. >to "do the right thing" with csets.
  1649.  
  1650. Actually, its hard to imagine anything faster if "a" is already a
  1651. string.  If you have to convert it, then Ken's way may be faster.  How
  1652. about this:
  1653.  
  1654. procedure Member(S,x)
  1655.   if S := cset(S) then return any(S,x) & x
  1656.   return member(S,x)
  1657. end
  1658.  
  1659. The assignment is in case S is a string, then you only have to convert
  1660. it once.  You can leave that out, or avoid it by:
  1661.  
  1662. procedure Member(S,x)
  1663.   return any((cset(S) | return member(S,x))\1, x)
  1664. end
  1665.  
  1666. Isn't Icon a great language?  BTW, I havn't actually tried these...
  1667.  
  1668. From ralph  Fri Jan 20 07:19:47 1989
  1669. Date: Fri, 20 Jan 89 07:19:47 MST
  1670. From: "Ralph Griswold" <ralph>
  1671. Message-Id: <8901201419.AA12268@megaron.arizona.edu>
  1672. Received: by megaron.arizona.edu (5.59-1.7/15)
  1673.     id AA12268; Fri, 20 Jan 89 07:19:47 MST
  1674. To: icon-group
  1675. Subject: cset membership
  1676.  
  1677. Some of you may be wondering about the relative speed of two methods
  1678. suggested for testing membership in csets.  Here are the results of
  1679. benchmark tests (done on a VAX 8650, but I'd not expect the processor
  1680. to have much effect on the relative timings):
  1681.  
  1682.     c := &lcase
  1683.         .
  1684.         .
  1685.         .
  1686.     (c ** 'a') ~== ''    # 0.154ms in loop
  1687.     any(c,"a")        # 0.103ms in loop
  1688.  
  1689. Of course, there are several parameters that might affect timings.  The
  1690. size of the cset, where 'a' is in it, etc, what happens if it isn't in
  1691. the cset, and so forth.  I've not attempted these variations.
  1692.  
  1693. Worth noting is that the cset intersection method allocates 40 bytes
  1694. per instance (cset intersection produces a new cset), while any() allocates
  1695. no storage.  Allocation, even if transient, has to be paid for eventually,
  1696. assuming the program runs long enough to cause a garbage collection.
  1697.  
  1698. Note that the examples above are chosen not to require implicit type
  1699. conversions.
  1700.  
  1701.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  1702.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  1703.  
  1704.  
  1705.  
  1706. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Sat Jan 21 10:05:41 1989
  1707. Received: from mailgw.cc.umich.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1708.     id AA18115; Sat, 21 Jan 89 10:05:41 MST
  1709. Received: from umix.cc.umich.edu by mailgw.cc.umich.edu (5.59/1.0)
  1710.     id AA10157; Sat, 21 Jan 89 12:01:06 EST
  1711. Received: by umix.cc.umich.edu (5.54/umix-2.0)
  1712.     id AA29077; Sat, 21 Jan 89 12:06:40 EST
  1713. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 21 Jan 89 12:03:26 EST
  1714. Date: Sat, 21 Jan 89 11:39:40 EST
  1715. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  1716. To: icon-group@arizona.edu
  1717. Message-Id: <112195@Wayne-MTS>
  1718. Subject: File retrieval with wildcards for MS-DOS
  1719.  
  1720. The following procedure can be useful in operating on a set of files
  1721. specified by wildcards.  I suspect something similar will work for Unix.
  1722.  
  1723. Paul Abrahams
  1724. ========================================================
  1725. # get_filename(pfn) accepts a DOS filename possibly containing wildcards.
  1726. # The filename can also include a drive letter and path.
  1727. # If the filename ends in "\" or ":", "*.*" is appended.
  1728. # The result sequence is a sequence of the filenames corresponding to pfn.
  1729.  
  1730. procedure get_filename(pfn)
  1731.     local asciiz, fnr, prefix, k, name
  1732.     local ds, dx, result, fnloc, string_block
  1733. #get Disk Transfer Address; filename locn is 30 beyond that
  1734.     result := Int86([16r21, 16r2f00] ||| list(7,0))
  1735.     fnloc := 16 * result[8] + result[3]+ 30
  1736. # get the generalized filename
  1737.     fnr := reverse(pfn)
  1738.     k := upto("\\:", fnr) | *fnr + 1
  1739.     prefix := reverse(fnr[k:0])
  1740.     name := "" ~== reverse(fnr[1:k]) | "*.*"
  1741. # Get the first file in the sequence
  1742.     asciiz := prefix || name || "\x00"
  1743.     Poke(string_block := GetSpace(*asciiz), asciiz)
  1744.     ds := string_block / 16
  1745.     dx := string_block % 16
  1746.     result := Int86([16r21, 16r4e00, 0, 0, dx, 0, 0, 0, ds])
  1747.     case result[2] of {
  1748.         0 : {}
  1749.         18 : fail
  1750.         default : stop("i/o error ", result[2])
  1751.         }
  1752.     suspend prefix || extract_name(fnloc)
  1753. # Get the remaining files in the sequence
  1754.     while Int86([16r21, 16r4f00, 0, 0, 0, 0, 0, 0, 0])[2] = 0 do
  1755.         suspend prefix || extract_name(fnloc)
  1756. end
  1757.  
  1758. procedure extract_name(fnloc)
  1759.     local asciiz
  1760.     asciiz := Peek(fnloc, 13)
  1761.     return asciiz[1:upto("\x00", asciiz)]
  1762. end
  1763. ==================================================================
  1764. P.S. - In using Int86, I noticed that the first item on the returned list,
  1765. which should be the contents of the flag register, seems not to be correct.
  1766. It seems to be always the same as the second item (the ax register).  Is
  1767. there a bug here?
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773. From @x-sphinx.uchicago.edu:goer@sophist.uchicago.edu  Sat Jan 21 11:32:22 1989
  1774. Received: from x-sphinx.uchicago.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1775.     id AA02566; Sat, 21 Jan 89 11:32:22 MST
  1776. Received: from sophist.uchicago.edu by x-sphinx.uchicago.edu (5.52/2.0Sx)
  1777.     id AA04704; Sat, 21 Jan 89 12:31:43 CST
  1778. Return-Path: <goer@sophist.uchicago.edu>
  1779. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  1780.     id AA05880; Sat, 21 Jan 89 12:24:21 CST
  1781. Date: Sat, 21 Jan 89 12:24:21 CST
  1782. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  1783. Message-Id: <8901211824.AA05880@sophist.uchicago.edu>
  1784. To: icon-group@arizona.edu
  1785. Subject: different strokes
  1786.  
  1787. I was looking over Paul Abrahams' get_filename procedure, think about
  1788. how differently icon programmers typically work.  I, for instance would
  1789. probably have written a certain section of his program like this:
  1790.  
  1791.   reverse(pfn) ? {
  1792.     name := reverse("" ~== tab(upto('\\:')|0) | "*.*")
  1793.     prefix := reverse(tab(0))
  1794.     }
  1795.  
  1796. Whereas he himself used:
  1797.  
  1798.   fnr := reverse(pfn)
  1799.   k := upto("\\:", fnr) | *fnr + 1
  1800.   prefix := reverse(fnr[k:0])
  1801.   name := "" ~== reverse(fnr[1:k]) | "*.*"
  1802.  
  1803. I'm not at all sure which is clearer or stylistically better.  The
  1804. first, however, runs about 12% faster on filenames with no path pre-
  1805. pended.  On files with a long path, the difference goes down to about
  1806. 3% or even 1%.  Anyone have any thoughts on why?  Anyone have any
  1807. thoughts on icon programming style in general?
  1808.  
  1809.                                         -Richard L. Goerwitz
  1810.                                         goer@sophist.uchicago.edu
  1811.                                         rutgers!oddjob!gide!sophist!goer
  1812.  
  1813. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Sun Jan 22 20:12:58 1989
  1814. Received: from mailgw.cc.umich.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1815.     id AA18414; Sun, 22 Jan 89 20:12:58 MST
  1816. Received: from umix.cc.umich.edu by mailgw.cc.umich.edu (5.59/1.0)
  1817.     id AA29168; Sun, 22 Jan 89 22:08:23 EST
  1818. Received: by umix.cc.umich.edu (5.54/umix-2.0)
  1819.     id AA20308; Sun, 22 Jan 89 22:13:59 EST
  1820. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sun, 22 Jan 89 22:10:54 EST
  1821. Date: Sun, 22 Jan 89 20:26:28 EST
  1822. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  1823. To: icon-group@arizona.edu
  1824. Message-Id: <112392@Wayne-MTS>
  1825. Subject: DOS filename generator
  1826.  
  1827. I think that Richard's parser of the filename is much more elegant than mine.
  1828. I was just trying to get the job done quickly.  The time is irrelevant since
  1829. the generator is hardly likely to be used in an inner loop.
  1830.  
  1831. Writing the generator actually raised another interesting question of style.
  1832. The int86 function wants a list of nine items.  What I would really like to
  1833. do, however, is to define:
  1834.  
  1835.     record registers(int_nbr, ax, bx, cx, dx, si, di, es, ds)
  1836.     params := record()
  1837.     every !params := 0
  1838.     record.int_nbr := ...    # etc. for the other nontrivial components
  1839.  
  1840. and then pass params to Int86.  But Int86 wants a list of nine items --
  1841. nothing else will do.  It would be nice if I could write:
  1842.  
  1843.     Int86(list(params))
  1844.  
  1845. but that's not legal as far as I know.  Is there an elegant way to convert
  1846. params to the list that I want?  About the best I could come up with was:
  1847.  
  1848.     l := list(9, 0)
  1849.     g1 := create !params
  1850.     g2 := create !l
  1851.     while @g2 := @g1
  1852.     Int86(l)
  1853.  
  1854.  
  1855. Paul Abrahams
  1856.  
  1857.  
  1858.  
  1859. From kwalker  Mon Jan 23 14:28:36 1989
  1860. Date: Mon, 23 Jan 89 14:28:36 MST
  1861. From: "Kenneth Walker" <kwalker>
  1862. Message-Id: <8901232128.AA02752@megaron.arizona.edu>
  1863. Received: by megaron.arizona.edu (5.59-1.7/15)
  1864.     id AA02752; Mon, 23 Jan 89 14:28:36 MST
  1865. In-Reply-To: <93400002@uicbert.eecs.uic.edu>
  1866. To: icon-group
  1867. Subject: Re:  data backtracking, more general con
  1868.  
  1869. from Paul R. Wilson:
  1870. > From: uxg.cso.uiuc.edu!uicbert.eecs.uic.edu!wilson@uxc.cso.uiuc.edu
  1871. > Subject: data backtracking, more general con
  1872. > Is anyone working on an Icon-like language with more orthogonal
  1873. > control structures and data types?  Is anyone working on a more
  1874. > general expression evaluation mechanism?
  1875. > I've figured out how to accomplish general data backtracking in a garbage
  1876. > collected heap, and in fact how to extend it to "sidetracking."  (More than
  1877. > one subexpression may execute simultaneously, with each isolated
  1878. > from the others' side effects.  The parent expression can choose to keep the
  1879. > side effects of at most one of the subexpressions.)  This can be done with
  1880. > a certain amount of continual overhead on stock hardware, and probably with
  1881. > negligible overhead on Lisp machines.
  1882.  
  1883. Have you looked at parallel execution of Prolog and other logic prgramming
  1884. languages?
  1885.  
  1886. > What I'm mostly looking for is ideas of what a language with such powerful
  1887. > facilities should look like.  Icon strikes me as a sort of hodgepodge
  1888. > of features and types, but the particular combinations of features and
  1889. > types seem to work remarkably well together.  You use backtracking where
  1890. > appropriate, and assemble the rest as an imperative program.
  1891.  
  1892. I would say that Icon works well, because, in spite of some very important
  1893. innovations, it is based mostly on features that have proven their usefulness.
  1894. For example, the data types integer, real, (true) string, list (really
  1895. vector and queue, just combined), table, record, and set all have
  1896. a history of extensive use. The majority of operations follow directly from
  1897. the needs of the data types, though there are some exceptions. Most of
  1898. Icon's control structures are based on the ones commonly found in traditional
  1899. languages and that many programmers would feel sifled without.
  1900.  
  1901. Actually, you should view backtracking (control backtracking, not data
  1902. backtracking) as a pervasive feature of the language, though, of course,
  1903. many individual operations are deterministic in nature. This backtracking
  1904. is then "bounded" by various control structures. This bounding typically
  1905. occurs the the control structures that try to mimic those of conventional
  1906. languages. Several control structures (every, suspend, |, \) make use of
  1907. this goal-directed evaluation, but there is currently no underlying model
  1908. of the control structures possible in the presence of backtracking.
  1909.  
  1910. > Icon's simple backtracking mechanism may be as complex a predefined
  1911. > evaluation mechanism as you'd want, since a more general mechanism
  1912. > wouldn't give you enough familiar idioms to be able to make sense of
  1913. > a program.  On the other hand, a multiway mechanism seems very valuable
  1914. > if it is truly parallel, so a certain extra complexity is doubtless
  1915. > worthwhile.
  1916.  
  1917. [text deleted]
  1918.  
  1919. > What would you want control constructs to look like, if you could have
  1920. > anything you wanted?  This question has two sides -- one for language
  1921. > prototyping, and one for language use.  What should a very general
  1922. > evaluation mechanism be like, to enable the prototyping of things
  1923. > like backtracking?  What set of fixed or default mechanisms would you
  1924. > want if you could only pick a couple of simple ones to actually use
  1925. > in programs all the time?
  1926.  
  1927. The U of A Technical Report TR82-16a, "Programmer Defined Evaluation
  1928. Regimes" by Michael Novak and Ralph E. Griswold explores some of these
  1929. questions. They use co-expressions as an implementation tool. This
  1930. turns out to be somewhat awkward, but is adaquate for experimentation.
  1931. In fact, Programmer Defined Control Operations (PDCOs) is a feature in
  1932. the distributed versions of Icon that support co-expressions.
  1933.  
  1934. Kelvin Nilsen added concurrent processes to Icon, based on co-expressions.
  1935. His work is described in his dissertation, which is available as
  1936. TR88-30, "The Design and Implementation of High-Level Programming
  1937. Language Features for Pattern Matching in Real Time".
  1938.  
  1939. If you are interested in a more theoretical framework for goal-directed
  1940. evaluation and Icon-style control structures, you might look at TR86-15,
  1941. "A Continuation Semantics For Icon Expressions" by David Gudeman. On the
  1942. other hand, a more "systems" approach can be found in Janalee O'Bagy's
  1943. dissertation. It is available as TR88-31, "The Implemantation of
  1944. Generators and Goal-Directed Evaluation in Icon".
  1945.  
  1946. There are some obvious (?) ways to extend Icon's evaluation scheme. You
  1947. can generalize generators to full co-routines or extend goal-directed
  1948. evaluation from a sylized use of success and failure continuations to
  1949. fully general use of continuations, but it is not clear that these are
  1950. directions you want to take. Sometime too much power can get in your
  1951. way.
  1952.  
  1953. The above technical reports are available through the Icon Project:
  1954.  
  1955.         icon-project@arizona.edu
  1956.         {uunet|allegra|noao}!arizona!icon-project
  1957.  
  1958.     Icon Project
  1959.     Department of Computer Science
  1960.     Gould-Simpson Building
  1961.     The University of Arizona
  1962.     Tucson, AZ   85721
  1963.  
  1964.    Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  1965.    +1 602 621 2858  kwalker@Arizona.EDU   {uunet|allegra|noao}!arizona!kwalker
  1966.  
  1967. From dscargo@cim-vax.honeywell.com  Thu Jan 26 14:07:05 1989
  1968. Message-Id: <8901262107.AA22065@megaron.arizona.edu>
  1969. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1970.     id AA22065; Thu, 26 Jan 89 14:07:05 MST
  1971. Date: 26 Jan 89 15:03:00 CST
  1972. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  1973. Subject: two-dimensional arrays
  1974. To: "icon-group" <icon-group@arizona.edu>
  1975.  
  1976. Is there any concensus on the best way to simulate two-dimensional arrays
  1977. in Icon?  It might be that I need to have a table of tables.  My particular
  1978. application requires keeping counts associated with states of origin by
  1979. different conventions.  So I've got a cross product of states (by
  1980. abbreviation) and conventions (a three character code).
  1981.  
  1982. dsc
  1983.  
  1984.  
  1985. From ralph  Thu Jan 26 14:24:05 1989
  1986. Date: Thu, 26 Jan 89 14:24:05 MST
  1987. From: "Ralph Griswold" <ralph>
  1988. Message-Id: <8901262124.AA23177@megaron.arizona.edu>
  1989. Received: by megaron.arizona.edu (5.59-1.7/15)
  1990.     id AA23177; Thu, 26 Jan 89 14:24:05 MST
  1991. To: dscargo@cim-vax.honeywell.com
  1992. Subject: Re:  two-dimensional arrays
  1993. Cc: icon-group
  1994. In-Reply-To: <8901262107.AA22065@megaron.arizona.edu>
  1995.  
  1996. If your array is sparse, I'd use a table of tables.  If it's dense, I'd
  1997. use a list of lists.  If it's in between, you might might want a list
  1998. of tables or a table of lists, depending.
  1999.  
  2000.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  2001.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  2002.  
  2003.  
  2004. From spqr%electronics-and-computer-science.southampton.ac.uk@NSS.Cs.Ucl.AC.UK  Wed Feb  1 02:04:44 1989
  2005. Received: from NSS.CS.UCL.AC.UK by megaron.arizona.edu (5.59-1.7/15) via SMTP
  2006.     id AA20535; Wed, 1 Feb 89 02:04:44 MST
  2007. Received: from electronics-and-computer-science.southampton.ac.uk
  2008.           by NSS.Cs.Ucl.AC.UK   via Janet with NIFTP  id aa03051;
  2009.           1 Feb 89 8:40 GMT
  2010. From: Sebastian Rahtz <spqr%electronics-and-computer-science.southampton.ac.uk@NSS.Cs.Ucl.AC.UK>
  2011. Date: Wed, 1 Feb 89 08:54:26 GMT
  2012. Message-Id: <11636.8902010854@hilliard.ecs.soton.ac.uk>
  2013. To: icon-group@arizona.edu
  2014. Cc: dder%electronics-and-computer-science.southampton.ac.uk@NSS.Cs.Ucl.AC.UK
  2015. Subject:  on the fly procedure definition
  2016.  
  2017. I must apologize to the people who contributed their thoughts on why
  2018. Icon cannot generate a completely new procedure at runtime; I went away
  2019. immediately after posting my query, and only just returned. I cannot see
  2020. an immediate answer to my problem, though I am grateful to Bill Griswold
  2021. for another working example of a co-expression (one of those things I
  2022. lie awake at night pondering). As a follow up, can I ask gurus to
  2023. confirm that 
  2024.  
  2025.  a) dynamic linking is impossible, unless you are Ken Walker. So I can't
  2026.     even do a system("icont -c ...") etc ?
  2027.  b) there is no chance of a vast Icon run-time system appearing with
  2028.     a translator and linker present?
  2029.  c) I can't convert a string to a variable (if you see what I mean)?
  2030.      Thus if I have a program:
  2031.      ..
  2032.      foo("set","a","hello")
  2033.      write(foo("get","a"))
  2034.      ..
  2035.      procedure foo(message,var,text)
  2036.      static a,b,c
  2037.      case message of 
  2038.       {
  2039.     "set" :
  2040.         case var of
  2041.         {
  2042.         "a" : a:=text
  2043.         "b" : b:=text
  2044.         "c" : c:=text
  2045.         }
  2046.     "get" :
  2047.         case var of
  2048.         {
  2049.         "a" : return a
  2050.         "b" : return b
  2051.         "c" : return c
  2052.         }
  2053.     }
  2054.       return
  2055.      end
  2056.     ...
  2057.  
  2058.  my program duly writes "hello"; but I want to avoid the inner case
  2059. constructs and when I pass foo "a" have it look at variable a. It seems
  2060. to me that I cannot do this, except by listing all the static variables
  2061. in a static table (ie have a table 'vars' with an entry vars["a"]:=a, and
  2062. then referring to vars[var].) But that means I have to list out all the
  2063. static variables again in the table, with concomitant possibility of
  2064. error. Can I acquire a list of the variables in a procedure, in the
  2065. manner of display()?
  2066.  
  2067. And yes, I am doing this out of a purist desire to avoid global variables.
  2068.  
  2069. Sebastian Rahtz. Computer Science, Southampton, UK.
  2070. spqr@uk.ac.soton.ecs
  2071.  
  2072. From wgg@june.cs.washington.edu  Wed Feb  1 12:38:45 1989
  2073. Received: from june.cs.washington.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  2074.     id AA18810; Wed, 1 Feb 89 12:38:45 MST
  2075. Received: by june.cs.washington.edu (5.59/6.13+)
  2076.     id AA01865; Wed, 1 Feb 89 11:37:18 PST
  2077. Date: Wed, 1 Feb 89 11:37:18 PST
  2078. From: wgg@june.cs.washington.edu (William Griswold)
  2079. Return-Path: <wgg@june.cs.washington.edu>
  2080. Message-Id: <8902011937.AA01865@june.cs.washington.edu>
  2081. To: icon-group@arizona.edu
  2082. Subject: Re:  on the fly procedure definition
  2083.  
  2084. This is a preliminary response to Sebastian Rahtz's question on dynamic
  2085. features in Icon.  Corrections from the Home Office would be appreciated.
  2086.  
  2087. >From: Sebastian Rahtz <spqr%electronics-and-computer-science....
  2088. >Date: Wed, 1 Feb 89 08:54:26 GMT
  2089. >To: icon-group@arizona.edu
  2090. >Subject:  on the fly procedure definition
  2091. >
  2092. >I must apologize to the people who contributed their thoughts on why
  2093. >Icon cannot generate a completely new procedure at runtime; I went away
  2094. >immediately after posting my query, and only just returned. I cannot see
  2095. >an immediate answer to my problem, though I am grateful to Bill Griswold
  2096. >for another working example of a co-expression (one of those things I
  2097. >lie awake at night pondering). As a follow up, can I ask gurus to
  2098. >confirm that 
  2099. >
  2100. > a) dynamic linking is impossible, unless you are Ken Walker. So I can't
  2101. >    even do a system("icont -c ...") etc ?
  2102.  
  2103. You cannot in the current system.  I have built a dynamic linker for Icon,
  2104. but it isn't the most integrated design possible, and it hurts the performance
  2105. of the interpreter a bit.  I haven't upgraded it to version 7, either.
  2106. As I (think) I said in earlier messages, it can be done, and done efficiently,
  2107. but it's a lot of work.
  2108.  
  2109. > b) there is no chance of a vast Icon run-time system appearing with
  2110. >    a translator and linker present?
  2111.  
  2112. I have no doubt that it is possible.  It's been done for Lisp, and it's just
  2113. a program, after all.  It would be a lot of work to implement it, however,
  2114. and the program would be rather large.  For example, the executable program
  2115. for Franz Lisp on my machine is about 1 megabyte.  Icon wouldn't be that
  2116. big (probably not much bigger than the sum of the sizes of all the
  2117. executables for Icon now), but you get the idea. 
  2118.  
  2119. > c) I can't convert a string to a variable (if you see what I mean)?
  2120.  
  2121. In Icon you can't convert a string to a variable, but you can
  2122. convert a string to a procedure (but not a procedure variable, I believe).
  2123. It probably wouldn't be too hard to implement an operator or function that
  2124. did the equivalent of foo, however. 
  2125.  
  2126. In my implementation of a dynamic linker for Icon, a newly linked file can
  2127. link to any existing variables, and introduce new ones as well (which files
  2128. linked later can refer to).  However, a file cannot all-of-a-sudden 
  2129. reference variables that it had no idea existed before.  This is not a
  2130. damaging restriction because I can still convert strings to procedures, so
  2131. older parts of the program can *call* newly introduced procedures.  From
  2132. my experience procedural extension works just fine, and doesn't cramp my
  2133. style at all.
  2134.  
  2135. >     Thus if I have a program:
  2136. >     ..
  2137. >     foo("set","a","hello")
  2138. >     write(foo("get","a"))
  2139. >     ..
  2140. >     procedure foo(message,var,text)
  2141. >     static a,b,c
  2142. >     case message of 
  2143. >      {
  2144. >    "set" :
  2145. >        case var of
  2146. >        {
  2147. >        "a" : a:=text
  2148. >        "b" : b:=text
  2149. >        "c" : c:=text
  2150. >        }
  2151. >    "get" :
  2152. >        case var of
  2153. >        {
  2154. >        "a" : return a
  2155. >        "b" : return b
  2156. >        "c" : return c
  2157. >        }
  2158. >    }
  2159. >      return
  2160. >     end
  2161. >    ...
  2162. >
  2163. > my program duly writes "hello"; but I want to avoid the inner case
  2164. >constructs and when I pass foo "a" have it look at variable a. It seems
  2165. >to me that I cannot do this, except by listing all the static variables
  2166. >in a static table (ie have a table 'vars' with an entry vars["a"]:=a, and
  2167. >then referring to vars[var].) But that means I have to list out all the
  2168. >static variables again in the table, with concomitant possibility of error. 
  2169.  
  2170. Of course, if someone wanted to refer to a normal variable in the normal
  2171. way, or through the table, the result should be the same, so you're back to
  2172. using the case statement for these variables. 
  2173.  
  2174. >Can I acquire a list of the variables in a procedure, in the
  2175. >manner of display()?
  2176.  
  2177. Right now the implementation of Icon does not allow for a ``variable'' type
  2178. per-se; you could get the name of a variable, or its value, but not a 
  2179. reference to the variable itself.  I suspect its addition could complicate 
  2180. the language:  does addition of two variables mean the addition of the 
  2181. variables' values?  Would the only operation on variables be ``get''
  2182. and ``set''?  Or would you introduce an explicit dereferencing operator for 
  2183. variables, and if so could it mean anything to other types?  You could
  2184. refer back to SNOBOL on this, which has a lot of the features you're looking
  2185. for and more.  I think it's more trouble than it's worth.
  2186.  
  2187. >
  2188. >And yes, I am doing this out of a purist desire to avoid global variables.
  2189. >
  2190. >Sebastian Rahtz. Computer Science, Southampton, UK.
  2191. >spqr@uk.ac.soton.ecs
  2192. >
  2193.  
  2194.                     Bill Griswold
  2195.  
  2196.  
  2197. From @NSS.Cs.Ucl.AC.UK,@electronics-and-computer-science.southampton.ac.uk:spqr@computer-science.southampton.ac.uk  Thu Feb  2 08:59:39 1989
  2198. Received: from NSS.CS.UCL.AC.UK by megaron.arizona.edu (5.59-1.7/15) via SMTP
  2199.     id AA29082; Thu, 2 Feb 89 08:59:39 MST
  2200. Received: from electronics-and-computer-science.southampton.ac.uk
  2201.           by NSS.Cs.Ucl.AC.UK   via Janet with NIFTP  id aa04480;
  2202.           2 Feb 89 13:22 GMT
  2203. From: Sebastian Rahtz <spqr%computer-science.southampton.ac.uk@NSS.Cs.Ucl.AC.UK>
  2204. Received: from caxton.cm.soton.ac.uk by hilliard.ecs.soton.ac.uk; Thu, 2 Feb 89 13:37:40 GMT
  2205. Date: Thu, 2 Feb 89 13:38:38 GMT
  2206. Message-Id: <3805.8902021338@caxton.cm.soton.ac.uk>
  2207. To: wgg@june.cs.washington.edu
  2208. Cc: icon-group@arizona.edu
  2209. In-Reply-To: William Griswold's message of Wed, 1 Feb 89 11:37:18 PST <8902011937.AA01865@june.cs.washington.edu>
  2210. Subject:  on the fly procedure definition
  2211.  
  2212. thanks for the thoughts; i'll concentrate on things Icon is good at,
  2213. rather than complaining about things it doesn't have!
  2214.  
  2215.    refer back to SNOBOL on this, which has a lot of the features you're looking
  2216.    for and more.  I think it's more trouble than it's worth.
  2217. yes but Snobol isnt half as much fun as Icon! anyway, the fact that
  2218. you have built a dynamic linker suggests to me that you have
  2219. identified a gap in the implementation yourself?
  2220.  
  2221. i think one thing that bothers me is that Icon has the bad points of a compiled
  2222. language (ie the dynamic features are gone), but doesnt have the
  2223. virtue of generating standalone code. But thats an old debate which I
  2224. think Arizona have answered quite clearly.
  2225.  
  2226. Sebastian Rahtz. Computer Science, Southampton, UK.
  2227. spqr@uk.ac.soton.ecs
  2228.  
  2229.  
  2230.  
  2231.  
  2232. From R21014@UQAM.BITNET  Tue Feb  7 09:12:04 1989
  2233. Message-Id: <8902071612.AA03629@megaron.arizona.edu>
  2234. Received: from rvax.ccit.arizona.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  2235.     id AA03629; Tue, 7 Feb 89 09:12:04 MST
  2236. Received: from UQAM.BITNET by rvax.ccit.arizona.edu; Tue, 7 Feb 89 08:40 MST
  2237. Received: by UQAM (Mailer X1.25) id 9573; Tue, 07 Feb 89 10:25:40 EST
  2238. Date: Tue, 07 Feb 89 10:24:42 EST
  2239. From: Luc Dupuy <R21014@UQAM.BITNET>
  2240. Subject: Icon Compiler
  2241. To: Icon-Group <icon-group@arizona.edu>
  2242.  
  2243.      I see in "The Icon Programming Language" some reference to an
  2244. Icon Compiler; is there such a compiler for version 7.5?
  2245.  
  2246.  
  2247. thank you.
  2248.  
  2249. From ralph  Tue Feb  7 09:31:02 1989
  2250. Date: Tue, 7 Feb 89 09:31:02 MST
  2251. From: "Ralph Griswold" <ralph>
  2252. Message-Id: <8902071631.AA04603@megaron.arizona.edu>
  2253. Received: by megaron.arizona.edu (5.59-1.7/15)
  2254.     id AA04603; Tue, 7 Feb 89 09:31:02 MST
  2255. To: R21014@UQAM.BITNET
  2256. Subject: Re:  Icon Compiler
  2257. Cc: icon-group
  2258. In-Reply-To: <8902071612.AA03629@megaron.arizona.edu>
  2259.  
  2260. Early versions of Icon supported a "compiler", which is mentioned in
  2261. the Icon book.  However, it mostly generated subroutine calls and
  2262. was only 5-10% faster than the interpreter.  Since there was little
  2263. speed advantage and the compiler was much less portable than the
  2264. interpreter, we stopped supporting the compiler some time ago.
  2265. Version 7.5 only provides an interpreter.
  2266.  
  2267. We are working on a true, production-quality compiler for Icon, but
  2268. this is presently in the research stage and we have no projections
  2269. for when such an implementation might be available.
  2270.  
  2271.  
  2272.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  2273.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  2274.  
  2275.  
  2276. From sboisen@REGULUS.BBN.COM  Tue Feb  7 11:39:19 1989
  2277. Message-Id: <8902071839.AA12576@megaron.arizona.edu>
  2278. Received: from REGULUS.BBN.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  2279.     id AA12576; Tue, 7 Feb 89 11:39:19 MST
  2280. To: icon-group@arizona.edu
  2281. Subject: GNU Emacs documenter for Icon (LONG)
  2282. From: Sean Boisen <sboisen@REGULUS.BBN.COM>
  2283. Sender: sboisen@REGULUS.BBN.COM
  2284. Reply-To: sboisen@bbn.com
  2285. Date: Tue, 7 Feb 89 13:26:04 EST
  2286.  
  2287. This is a quick syntax helper for Icon users that work with GNU Emacs.
  2288. The idea is a simple one: while creating a program, say, you're unsure
  2289. about the arguments or their orders for push(). With icon-describe, you
  2290. simple execute the function "describe-icon-symbol" with point
  2291. somewhere around the word push, and the following information
  2292. is displayed in the mini-buffer:
  2293.  
  2294. push(list,x)
  2295.  
  2296. This works with procedures, infix/prefix operators, control
  2297. structures/reserved words, and keywords. Note that you get notified if
  2298. something isn't in the documentation file, so you can also use it to
  2299. check whether you've got the right symbol name or not (but you'd have
  2300. to go look to see what the _right_ one is :-).
  2301.  
  2302.  
  2303. Caveats:
  2304.  
  2305. See your Emacs manual for how to load this automatically when you
  2306. visit .icn files (look at auto-mode-alist and icon-mode-hook, assuming
  2307. you're using an icon-mode).
  2308.  
  2309. describe-icon-symbol is not initially bound to a key, but you'll
  2310. probably want to do so.
  2311.  
  2312. The format of the documentation file is one to a line: this is nice
  2313. because it can be displayed in the minibuffer instead of a pop-up
  2314. which then has to be gotten rid of. It's not so nice in that it limits
  2315. the amount of information pretty severely. If somebody wants to
  2316. provide a larger documentation file i might provide a pop-up version
  2317. (or some hybrid): i'm too lazy to do all the typing, for one thing!
  2318. There's also an uneven mix of bare syntax description with some
  2319. discussion of what (especially prefix) operators do. A few keywords
  2320. have no description because they're newer than the Icon book, and i
  2321. didn't have a description handy. Please contribute to this doc file if
  2322. you can!
  2323.  
  2324. The function which determines the symbol at point isn't perfect
  2325. (surprise surprise!). In particular it depends on the syntax tables to
  2326. determine what punctuation is, so if your syntax tables aren't right,
  2327. this won't be either. I'm open to suggestions for better algorithms.
  2328. The current version has a preference for looking backward if not
  2329. actually on part of a symbol: this seemed more useful for those cases
  2330. where you become hesitant about the arguments to a function just after
  2331. typing it.
  2332.  
  2333. While the usual lack of warranty and support applies, i'd still like
  2334. to hear if there are problems with this.
  2335.  
  2336. Sean Boisen
  2337. sboisen@bbn.com
  2338. BBN Systems and Technologies Corporation
  2339.  
  2340.  
  2341. Two files follow: i call the first icon-describe.el (don't forget to
  2342. byte-compile it!), and the second icondoc.txt. Whatever you decide to
  2343. call the latter, make sure you set the variable doc-file accordingly! 
  2344.  
  2345. -------------------- cut here for icon-describe.el --------------------
  2346. ;;; Icon syntax describer: by Sean Boisen, BBN Systems and
  2347. ;;; Technologies Corporation, sboisen@bbn.com. Standard lack of
  2348. ;;; warranty applies: may be freely distributed subject to the
  2349. ;;; restrictions of the GNU Emacs copyright. Please send me any bug
  2350. ;;; fixes and/or improvements!
  2351. ;;;
  2352. ;;; This still has at least the following known deficiences:
  2353. ;;;
  2354. ;;; The descriptive text file lacks descriptions for the newer
  2355. ;;; keywords. Please add them and send me a version if you can!
  2356. ;;;
  2357. ;;; It might be nice if icon-symbol-at-point did escape sequences as
  2358. ;;; well: it doesn't.
  2359. ;;;
  2360. ;;; Someday it might be more useful to provide more than one line of
  2361. ;;; information, especially for procedures: the main hurdle here is
  2362. ;;; that i'm too lazy to type all the text in.
  2363.  
  2364.  
  2365. (provide 'icon-describe)
  2366.  
  2367. (defvar doc-file "/usr/sboisen/emacs/icondoc.txt"
  2368.   "Where the documentation file can be found.")
  2369.  
  2370. ;; a helper function: get a string containing all the characters matching
  2371. ;; some spec in a syntax table. Class is an atom. Useful in conjunction with
  2372. ;; skip-chars-forward. Doesn't do the eighth bit.
  2373.  
  2374. (defun get-chars-in-class (class syntax-table)
  2375.   (let ((classcode
  2376.       (cond
  2377.         ((eq class 'whitespace) 0)
  2378.         ((eq class 'punctuation) 1)
  2379.         ((eq class 'word) 2)
  2380.         ((eq class 'symbol) 3)
  2381.         ((eq class 'open) 4)    ;this doesn't work!
  2382.         ((eq class 'close) 5)
  2383.         ((eq class 'prefix) 6)
  2384.         ((eq class 'stringquote) 7)
  2385.         ((eq class 'charquote) 9)
  2386.         ((eq class 'startcomment) 11)
  2387.         ((eq class 'endcomment) 12)
  2388.         ))
  2389.     (index 0)
  2390.     (str ""))
  2391.     (while (< index 128)
  2392.       (if (eql (aref syntax-table index) classcode)
  2393.       (setq str (concat str (char-to-string index))))
  2394.       (setq index (1+ index)))
  2395.     str))
  2396.  
  2397. (defvar wordchars "a-zA-Z0-9_")
  2398. (defvar junkchars (concat " \n\t\r" "({[)}]"))
  2399. (defvar punct (get-chars-in-class 'punctuation icon-mode-syntax-table))
  2400.  
  2401. (defun icon-symbol-at-point ()
  2402.   "Get the closest Icon symbol to point, but don't change your
  2403.        position. Has a preference for looking backward when not
  2404.        directly on a symbol."
  2405.   (let (start end symbol)
  2406.     (save-excursion
  2407.       ;; first see if you're just past a symbol
  2408.       (if (looking-at "\\s-\\|\\s(\\|\\s)\\|\\s>")
  2409.       (skip-chars-backward junkchars)
  2410.     ;; else move forward one character, presumably either a \w or
  2411.     ;; a symbol
  2412.     (forward-char 1))
  2413.       (if (eql (aref icon-mode-syntax-table (preceding-char)) 2)
  2414.       ;; just past a \\w
  2415.       (progn
  2416.         (skip-chars-backward wordchars)
  2417.         (setq start (point))
  2418.         (skip-chars-forward wordchars))
  2419.     ;; else a symbol?
  2420.     (progn
  2421.         (skip-chars-backward punct)
  2422.         (setq start (point))
  2423.         (skip-chars-forward punct)))
  2424.       ;; THE OLD WAY THAT LOOKED FORWARD INSTEAD OF BACKWARD
  2425. ;;      ;; skip past whitespace and parens
  2426. ;;      (while (looking-at "\\s-\\|\\s(\\|\\s)\\|\\s>")
  2427. ;;    (skip-chars-forward junkchars))
  2428. ;;      (if (looking-at "\\w")
  2429. ;;      (progn
  2430. ;;        (skip-chars-forward wordchars)
  2431. ;;        (setq start (point))
  2432. ;;        (skip-chars-backward wordchars))
  2433. ;;    ;; else a symbol?
  2434. ;;    (progn
  2435. ;;        (skip-chars-forward punct)
  2436. ;;        (setq start (point))
  2437. ;;        (skip-chars-backward punct)))
  2438.       (buffer-substring start (point)))))
  2439.  
  2440. (defun describe-icon-symbol (symbol)
  2441.   "Display the documentation of SYMBOL, an Icon operator."
  2442.   (interactive
  2443.     (let ((fn (icon-symbol-at-point))
  2444.       (enable-recursive-minibuffers t)
  2445.       (case-fold-search nil)    ;require that case match for search
  2446.       val args-file regexp)
  2447.       (setq val (read-from-minibuffer
  2448.           (if fn
  2449.               (format "Symbol (default %s): " fn)
  2450.             "Symbol: ")))
  2451.       (if (string= val "")
  2452.       (setq val fn))
  2453.       ;; this may not work for characters which are special to regexp
  2454.       ;; (like ".")
  2455.       (setq regexp (concat "^" val "[ \t(]"))
  2456.       (if (not (get-file-buffer doc-file))
  2457.       (progn
  2458.         (setq args-file
  2459.           (find-file-noselect doc-file))
  2460.         (set-buffer args-file)
  2461.         (rename-buffer "*ICON-DOC*")))
  2462.       (set-buffer (get-file-buffer doc-file))
  2463.       (goto-char (point-min))
  2464.       (list (if (re-search-forward regexp (point-max) t)
  2465.       (save-excursion
  2466.         (beginning-of-line 1)
  2467.         (let ((lnstart (point)))
  2468.           (end-of-line)
  2469.           (message (buffer-substring lnstart (point)))))
  2470.     (error (format "No definition for %s" val)))))))
  2471. -------------------- cut here for icondoc.txt --------------------
  2472. FORMAT: a regexp like "^word(args)" of "^word[\t ]descriptive_text 
  2473. abs(numeric)
  2474. any(cset,string,i,j)
  2475. bal(cset1,cset2,cset3,string,i,j)
  2476. center(string1,i,string2)
  2477. char(i)
  2478. close(file)
  2479. collect()
  2480. copy(x)
  2481. cset(x)
  2482. delete(x1,x2)
  2483. detab(string,i1,i2,...,in)
  2484. display(i,file)
  2485. entab(string,i1,i2,...,in)
  2486. errorclear()
  2487. exit(i)
  2488. find(string1,string2,i,j)
  2489. get(list)
  2490. getenv(string)
  2491. iand(i,j)
  2492. icom(i)
  2493. image(x)
  2494. insert(x1,x2,x3)
  2495. integer(x)
  2496. ior(i,j)
  2497. ixor(i,h)
  2498. ishift(i,j)
  2499. left(string1,i,string2)
  2500. list(i,x)
  2501. many(cset,string,i,j)
  2502. map(string1,string2,string3)
  2503. match(string1,string2,i,j)
  2504. member(x1,x2)
  2505. move(i)
  2506. numeric(x)
  2507. open(string1,string2)
  2508. ord(string)
  2509. pop(list)
  2510. pos(i)
  2511. proc(x)
  2512. pull(list)
  2513. push(list,x)
  2514. put(list,x)
  2515. read(file)
  2516. reads(file,i)
  2517. real(x)
  2518. remove(string)
  2519. rename(string1,string2)
  2520. repl(string,i)
  2521. reverse(string)
  2522. right(string1,i,string2)
  2523. runerr(i,x)
  2524. save(string)
  2525. seek(file,i)
  2526. seq(i,j)
  2527. set(list)
  2528. sort(list)
  2529. sort(table,i)
  2530. stop(x1,x2,...,xn)
  2531. string(x)
  2532. system(string)
  2533. tab(i)
  2534. table(x)
  2535. trim(string,cset)
  2536. type(x)
  2537. upto(cset,string,i,j)
  2538. where(file)
  2539. write(x1,x2,...,xn)
  2540. writes(x1,x2,...,xn)
  2541. CONTROL STRUCTURES/RESERVED WORDS
  2542. break expr
  2543. by    i to j by k
  2544. case expr of {...}
  2545. create x
  2546. default : expr
  2547. do    every expr1 do expr2; until expr1 do expr2; while expr1 do expr2
  2548. dynamic identifiers
  2549. else    if expr1 then expr2 else expr3
  2550. end
  2551. every expr1 do expr2
  2552. fail 
  2553. global identifiers
  2554. if expr1 then expr2 else expr3
  2555. initial expr
  2556. link file1,file2,...filen
  2557. local identifiers
  2558. next 
  2559. not expr
  2560. of    case expr of {...}
  2561. procedure identifier(identifiers)
  2562. record identifiers(fields)
  2563. repeat expr
  2564. return expr
  2565. static identifiers
  2566. suspend expr
  2567. then    if expr1 then expr2 else expr3
  2568. to    i to j by k
  2569. until expr1 do expr2
  2570. while expr1 do expr2
  2571. |    expr1 | expr2; |expr
  2572. \    expr \ i ; \x produces x if x is not null, otherwise fails
  2573. ?:=    s ?:= x
  2574. ?    s ? x; ?x produces a random element of x, failing if x is empty
  2575. INFIX OPERATIONS
  2576. +    n + m produces the sum of n and m; +n produces the numeric value of n
  2577. -    n - m produces the difference of n and m; -n produces the negative of n
  2578. *    n * m produces the product of n and m; *x produces the size of x
  2579. /      n / m produces n divided by m; /x produces x if x is null, or else fails
  2580. %    n % m    produces the remainder of n divided by m
  2581. ^    n ^ m produces n to the power of m; ^e produces a refreshed copy of e
  2582. <    n < m produces m if n is less than m, else fails
  2583. <=    n <= m produces m if n is less than or equal to m, else fails
  2584. =    n = m produces m if n equals m, else fails; =s equiv. to tab(match(s))
  2585. >=    n >= m produces m if n is greater than or equal to m, else fails
  2586. >    n > m produces m if n is greater than m, else fails
  2587. ~=    n ~= m produces m if n is not equal to m, else fails
  2588. ++    c1 ++ c2 produces the cset union of c1 and c2
  2589. --    c1 -- c2 produces the cset difference of c1 and c2
  2590. **    c1 ** c2 produces the cset intersection of c1 and c2
  2591. ||    s1 || s2 produces a string consisting of s1 followed by s2
  2592. <<    s1 << s2  produces s2 if s1 is lexically less than s2, else fails
  2593. <<=    s1 <<= s2  produces s2 if s1 is lexically <= s2, else fails
  2594. ==    s1 == s2 produces s2 if s1 is lexically equal to s2, else fails
  2595. >>=    s1 >>= s2 produces s2 if s1 is lexically >= s2, else fails
  2596. >>    s1 >> s2 produces s2 if s1 is lexically greater than s2, else fails
  2597. ~==    s1 ~== s2 produces s2 if s2 isn't lexically equal to s2, else fails
  2598. |||    a1 ||| a2 produces a list of the values of a1 followed by those of a2
  2599. @    x @ e activates e and transmits x to it; @e produces the outcome of activating e
  2600. :=    x := y assigns the value of y to x, and produces the variable x
  2601. <-    x <- y assigns y to x and produces x; reverses assignment if resumed
  2602. :=:    x :=: y exchanges the values of x and y and produces the variable x
  2603. <->    x <-> y exchanges x and y and produces x; reverses exchange if resumed
  2604. ===    x === y produces y if x and y have the same value, else fails
  2605. ~===    x ~=== y produces y if x and y don't have the same value, else fails
  2606. &    x & y produces y; produces a variable if y is a variable
  2607. .    x . y produces a variable for the y field of record x
  2608. +:=    n +:= m assigns the sum of n and m to n and produces n
  2609. -:=    n -:= m assigns the difference of n and m to n and produces n
  2610. *:=    n *:= m assigns the product of n and m to n and produces n
  2611. /:=    n /:= m assigns the difference of n and m to n and produces n
  2612. %:=    n %:= m assigns the remainder of n divided by m to n and produces n
  2613. ^:=    n ^:= m assigns n raised to the power m to n and produces n
  2614. <:=    n <:= m assigns m to n if n < m, else fails; produces n
  2615. <=:=    n <=:= m assigns m to n if n <= m, else fails; produces n
  2616. =:=    n =:= m assigns m to n if n = m, else fails; produces n
  2617. >=:=    n >=:= m assigns m to n if n >= m, else fails; produces n
  2618. >:=    n >:= m assigns m to n if n > m, else fails; produces n
  2619. ~=:=    n ~=:= m assigns m to n if n ~= m, else fails; produces n
  2620. ++:=    c1 ++:= c2 assigns the cset union of c1 and c2 to c1 and produces c1
  2621. --:=    c1 --:= c2 assigns the cset difference of c1 and c2 to c1, producing c1
  2622. **:=    c1 **:= c2 assigns the intersection of c1 and c2 to c1, producing c1
  2623. ||:=    s1 ||:= s2 assigns the string s1 || s2 to s1 and produces s1
  2624. <<:=    s1 <:= s2 assigns s2 to s1 if s1 << s2, else fails; produces s1
  2625. <<=:=    s1 <=:= s2 assigns s2 to s1 if s1 <<= s2, else fails; produces s1
  2626. ==:=    s1 =:= s2 assigns s2 to s1 if s1 == s2, else fails; produces s1
  2627. >>=:=    s1 >=:= s2 assigns s2 to s1 if s1 >>= s2, else fails; produces s1
  2628. >>:=    s1 >:= s2 assigns s2 to s1 if s1 >> s2, else fails; produces s1
  2629. ~==:=    s1 ~=:= s2 assigns s2 to s1 if s1 ~== s2, else fails; produces s1
  2630. |||:=    a1 |||:= a2 assigns to a1 the concatenation of a1 and a2; produces a1
  2631. @:=    x @:= e activates e with the value of x, and assigns the result to x
  2632. ===:=    x ===:= y assigns y to x if x === y, else fails; produces x
  2633. ~===:=    x ~===:= y assigns y to x if x ~=== y, else fails; produces x
  2634. &:=    x &:= y assigns the value of y to x and produces x
  2635. PREFIX OPERATIONS (some under infix instead)
  2636. ~    ~c produces the cset complement of c with respect to &cset
  2637. !    !x generates the elements of x, failing if x is empty (x may be a file)
  2638. .    .x produces the value of x
  2639. KEYWORDS
  2640. &ascii    produces a cset of the 128 ASCII characters
  2641. &clock    produces a string consisting of the current time of day
  2642. &collections    
  2643. &cset    produces a cset consisting of all 256 characters
  2644. ¤t    
  2645. &date    produces a string consisting of the current date
  2646. &dateline    produces a string of the current date and time of day
  2647. &digits
  2648. &error
  2649. &errornumber
  2650. &errortext
  2651. &errorvalue
  2652. &errout    produces the standard error output file
  2653. &fail    fails
  2654. &features
  2655. &file
  2656. &host    produces a string that identifies the host computer
  2657. &input    produces the standard input file
  2658. &lcase    produces a cset consisting of the 26 lowercase letters
  2659. &level    produces the integer level of the current procedure call
  2660. &line
  2661. &main    produces a co-expression for the initial call of main
  2662. &null    produces the null value
  2663. &output    produces the standard output file
  2664. &pos    produces the integer position of scanning in &subject
  2665. &random    produces the value of the seed for the psuedo-random sequence
  2666. ®ions
  2667. &source    produces a co-expression for the activator of the current co-expression
  2668. &storage    how much of each storage region is currently being used
  2669. &subject    produces the variable whose value is the string being scanned
  2670. &time    produces the integer number of msecs since beginning of execution
  2671. &trace    produces a variable whose value controls procedure tracing
  2672. &ucase    produces a cset consisting of the 26 uppercase characters
  2673. &version    produces a string that identifies the version of Icon
  2674. -------------------- cut here: no more --------------------
  2675.  
  2676. From @UICVM.uic.edu:EM302723@VMTECMEX.BITNET  Tue Feb  7 12:33:05 1989
  2677. Message-Id: <8902071933.AA16028@megaron.arizona.edu>
  2678. Received: from uicvm.cc.uic.edu.2.248.128.in-addr.arpa by megaron.arizona.edu (5.59-1.7/15) via SMTP
  2679.     id AA16028; Tue, 7 Feb 89 12:33:05 MST
  2680. Received: from VMTECMEX.BITNET by UICVM.uic.edu (IBM VM SMTP R1.2) with BSMTP id 1395; Tue, 07 Feb 89 13:27:55 CST
  2681. Date: Tue, 07 Feb 89 13:16:43 MEX
  2682. To: icon-group@arizona.edu
  2683. From: EM302723%VMTECMEX.BITNET@UICVM.uic.edu
  2684. Comment: CROSSNET mail via SMTP@INTERBIT
  2685. Subject: Extension Interpreter request
  2686.  
  2687. Date: 7 February 89, 13:14:51 MEX
  2688. From: Mario Camou Riveroll                           EM302723 at VMTECMEX
  2689. To:   ICON-GROUP at ARIZONA
  2690.  
  2691. A few Icon Newsletters ago I read about an 'extension interpreter' which
  2692. was under development and supposed to let you call C functions without
  2693. modifying the compiler. What's the status on it?
  2694.  
  2695. -Mario Camou
  2696. EM302723@VMTECMEX.BITNET
  2697.  
  2698. From ralph  Tue Feb  7 12:53:18 1989
  2699. Date: Tue, 7 Feb 89 12:53:18 MST
  2700. From: "Ralph Griswold" <ralph>
  2701. Message-Id: <8902071953.AA16991@megaron.arizona.edu>
  2702. Received: by megaron.arizona.edu (5.59-1.7/15)
  2703.     id AA16991; Tue, 7 Feb 89 12:53:18 MST
  2704. To: EM302723%VMTECMEX.BITNET@UICVM.uic.edu
  2705. Subject: Re:  Extension Interpreter request
  2706. Cc: icon-group
  2707. In-Reply-To: <8902071933.AA16028@megaron.arizona.edu>
  2708.  
  2709. The Extension Interpreter is a larger project at the University of
  2710. Washington, part of which required calling C functions from Icon
  2711. and vice-versa.
  2712.  
  2713. The modifications to Icon for this are included in the Version 7.5
  2714. source code, but they've not been tested yet.
  2715.  
  2716. You'll probably hear more on this subject from the author of the
  2717. Icon modifications, Bill Griswold.
  2718.  
  2719.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  2720.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  2721.  
  2722.  
  2723. From sboisen@IZAR.BBN.COM  Tue Feb  7 16:29:22 1989
  2724. Message-Id: <8902072329.AA29277@megaron.arizona.edu>
  2725. Received: from IZAR.BBN.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  2726.     id AA29277; Tue, 7 Feb 89 16:29:22 MST
  2727. To: icon-group@arizona.edu
  2728. Subject: why you shouldn't make last minute changes to your code!
  2729. From: Sean Boisen <sboisen@IZAR.BBN.COM>
  2730. Sender: sboisen@IZAR.BBN.COM
  2731. Reply-To: sboisen@bbn.com
  2732. Date: Tue, 7 Feb 89 18:21:15 EST
  2733.  
  2734. Sorry folks, a minor error in the code i just sent out: all
  2735. occurrences of "doc-file" in icon-describe.el should be replaced with
  2736. "icon-doc-file". 
  2737.  
  2738. ........................................
  2739. Sean Boisen -- sboisen@bbn.com
  2740. BBN Systems and Technologies Corporation, Cambridge MA
  2741. Disclaimer: these opinions void where prohibited by lawyers.
  2742.  
  2743. From sboisen@REGULUS.BBN.COM  Wed Feb  8 07:41:43 1989
  2744. Message-Id: <8902081441.AA04963@megaron.arizona.edu>
  2745. Received: from REGULUS.BBN.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  2746.     id AA04963; Wed, 8 Feb 89 07:41:43 MST
  2747. To: mwb5y <@bbn.com:mwb5y@uvacs.cs.virginia.edu>
  2748. Cc: icon-group@arizona.edu
  2749. In-Reply-To: "Mark W. Bailey"'s message of Wed, 8 Feb 89 09:28:46 EST <8902081428.AA13060@uvacs.cs.virginia.edu>
  2750. Subject: Icon mode from emacs
  2751. From: Sean Boisen <sboisen@REGULUS.BBN.COM>
  2752. Sender: sboisen@REGULUS.BBN.COM
  2753. Reply-To: sboisen@bbn.com
  2754. Date: Wed, 8 Feb 89 9:36:55 EST
  2755.  
  2756. >  Date: Wed, 8 Feb 89 09:28:46 EST
  2757. >  From: "Mark W. Bailey" <mwb5y@uvacs.cs.virginia.edu>
  2758. >  Posted-Date: Wed, 8 Feb 89 09:28:46 EST
  2759. >
  2760. >
  2761. >  Sean, 
  2762. >       I received your icon documenter and it looks great. However, I
  2763. >  am in need of icon-mode...I assume you have one, could you forward
  2764. >  this to me?
  2765. >
  2766. >  Mark Bailey
  2767. >
  2768. >  mwb5y@virginia
  2769.  
  2770. Expecting others may be interested, here's my icon-mode: i may have
  2771. mangled the original to suit my tastes, so don't blame Chris Smith if
  2772. you find fault (maybe if Chris is listening he could post his
  2773. original? or at least check). This appears to be modeled after c-mode,
  2774. so if you find your indentation tastes offended you ought to be able
  2775. to make the icon variables follow the ones for C (i happen to like
  2776. these values just fine).
  2777.  
  2778. ........................................
  2779. Sean Boisen -- sboisen@bbn.com
  2780. BBN Systems and Technologies Corporation, Cambridge MA
  2781. Disclaimer: these opinions void where prohibited by lawyers.
  2782.  
  2783. ==================== cut here for icon-mode.el ====================
  2784. ;; Icon code editing commands for Emacs
  2785. ;; Derived from c-mode.el  15-Apr-88  Chris Smith  convex!csmith
  2786. ;; Copyright (C) 1988 Free Software Foundation, Inc.
  2787.  
  2788. ;; This file is part of GNU Emacs.
  2789.  
  2790. ;; GNU Emacs is distributed in the hope that it will be useful,
  2791. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  2792. ;; accepts responsibility to anyone for the consequences of using it
  2793. ;; or for whether it serves any particular purpose or works at all,
  2794. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  2795. ;; License for full details.
  2796.  
  2797. ;; Everyone is granted permission to copy, modify and redistribute
  2798. ;; GNU Emacs, but only under the conditions described in the
  2799. ;; GNU Emacs General Public License.   A copy of this license is
  2800. ;; supposed to have been given to you along with GNU Emacs so you
  2801. ;; can know your rights and responsibilities.  It should be in a
  2802. ;; file named COPYING.  Among other things, the copyright notice
  2803. ;; and this notice must be preserved on all copies.
  2804.  
  2805.  
  2806. (defvar icon-mode-abbrev-table nil
  2807.   "Abbrev table in use in Icon-mode buffers.")
  2808. (define-abbrev-table 'icon-mode-abbrev-table ())
  2809.  
  2810. (defvar icon-mode-map ()
  2811.   "Keymap used in Icon mode.")
  2812. (if icon-mode-map
  2813.     ()
  2814.   (setq icon-mode-map (make-sparse-keymap))
  2815.   (define-key icon-mode-map "{" 'electric-icon-brace)
  2816.   (define-key icon-mode-map "}" 'electric-icon-brace)
  2817.   (define-key icon-mode-map "\e\C-h" 'mark-icon-function)
  2818.   (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun)
  2819.   (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun)
  2820.   (define-key icon-mode-map "\e\C-q" 'indent-icon-exp)
  2821.   (define-key icon-mode-map "\177" 'backward-delete-char-untabify)
  2822.   (define-key icon-mode-map "\t" 'icon-indent-command))
  2823.  
  2824. (defvar icon-mode-syntax-table nil
  2825.   "Syntax table in use in Icon-mode buffers.")
  2826.  
  2827. (if icon-mode-syntax-table
  2828.     ()
  2829.   (setq icon-mode-syntax-table (make-syntax-table))
  2830.   (modify-syntax-entry ?\\ "\\" icon-mode-syntax-table)
  2831.   (modify-syntax-entry ?# "<" icon-mode-syntax-table)
  2832.   (modify-syntax-entry ?\n ">" icon-mode-syntax-table)
  2833.   (modify-syntax-entry ?$ "." icon-mode-syntax-table)
  2834.   (modify-syntax-entry ?/ "." icon-mode-syntax-table)
  2835.   (modify-syntax-entry ?* "." icon-mode-syntax-table)
  2836.   (modify-syntax-entry ?+ "." icon-mode-syntax-table)
  2837.   (modify-syntax-entry ?- "." icon-mode-syntax-table)
  2838.   (modify-syntax-entry ?= "." icon-mode-syntax-table)
  2839.   (modify-syntax-entry ?% "." icon-mode-syntax-table)
  2840.   (modify-syntax-entry ?< "." icon-mode-syntax-table)
  2841.   (modify-syntax-entry ?> "." icon-mode-syntax-table)
  2842.   (modify-syntax-entry ?& "." icon-mode-syntax-table)
  2843.   (modify-syntax-entry ?| "." icon-mode-syntax-table)
  2844.   (modify-syntax-entry ?\' "\"" icon-mode-syntax-table))
  2845.  
  2846. (defconst icon-indent-level 4
  2847.   "*Indentation of Icon statements with respect to containing block.")
  2848. (defconst icon-brace-imaginary-offset 0
  2849.   "*Imagined indentation of a Icon open brace that actually follows a statement.")
  2850. (defconst icon-brace-offset 0
  2851.   "*Extra indentation for braces, compared with other text in same context.")
  2852. (defconst icon-continued-statement-offset 4
  2853.   "*Extra indent for lines not starting new statements.")
  2854. (defconst icon-continued-brace-offset 0
  2855.   "*Extra indent for substatements that start with open-braces.
  2856. This is in addition to icon-continued-statement-offset.")
  2857.  
  2858. (defconst icon-auto-newline nil
  2859.   "*Non-nil means automatically newline before and after braces,
  2860. and after colons and semicolons, inserted in C code.")
  2861.  
  2862. (defconst icon-tab-always-indent t
  2863.   "*Non-nil means TAB in Icon mode should always reindent the current line,
  2864. regardless of where in the line point is when the TAB command is used.")
  2865.  
  2866. (defun icon-mode ()
  2867.   "Major mode for editing Icon code.
  2868. Expression and list commands understand all Icon brackets.
  2869. Tab indents for Icon code.
  2870. Paragraphs are separated by blank lines only.
  2871. Delete converts tabs to spaces as it moves back.
  2872. \\{icon-mode-map}
  2873. Variables controlling indentation style:
  2874.  icon-tab-always-indent
  2875.     Non-nil means TAB in Icon mode should always reindent the current line,
  2876.     regardless of where in the line point is when the TAB command is used.
  2877.  icon-auto-newline
  2878.     Non-nil means automatically newline before and after braces
  2879.     inserted in Icon code.
  2880.  icon-indent-level
  2881.     Indentation of Icon statements within surrounding block.
  2882.     The surrounding block's indentation is the indentation
  2883.     of the line on which the open-brace appears.
  2884.  icon-continued-statement-offset
  2885.     Extra indentation given to a substatement, such as the
  2886.     then-clause of an if or body of a while.
  2887.  icon-continued-brace-offset
  2888.     Extra indentation given to a brace that starts a substatement.
  2889.     This is in addition to icon-continued-statement-offset.
  2890.  icon-brace-offset
  2891.     Extra indentation for line if it starts with an open brace.
  2892.  icon-brace-imaginary-offset
  2893.     An open brace following other text is treated as if it were
  2894.     this far to the right of the start of its line.
  2895.  
  2896. Turning on Icon mode calls the value of the variable icon-mode-hook with no args,
  2897. if that value is non-nil."
  2898.   (interactive)
  2899.   (kill-all-local-variables)
  2900.   (use-local-map icon-mode-map)
  2901.   (setq major-mode 'icon-mode)
  2902.   (setq mode-name "Icon")
  2903.   (setq local-abbrev-table icon-mode-abbrev-table)
  2904.   (set-syntax-table icon-mode-syntax-table)
  2905.   (make-local-variable 'paragraph-start)
  2906.   (setq paragraph-start (concat "^$\\|" page-delimiter))
  2907.   (make-local-variable 'paragraph-separate)
  2908.   (setq paragraph-separate paragraph-start)
  2909.   (make-local-variable 'indent-line-function)
  2910.   (setq indent-line-function 'icon-indent-line)
  2911.   (make-local-variable 'require-final-newline)
  2912.   (setq require-final-newline t)
  2913.   (make-local-variable 'comment-start)
  2914.   (setq comment-start "# ")
  2915.   (make-local-variable 'comment-end)
  2916.   (setq comment-end "")
  2917.   (make-local-variable 'comment-column)
  2918.   (setq comment-column 32)
  2919.   (make-local-variable 'comment-start-skip)
  2920.   (setq comment-start-skip "# *")
  2921.   (make-local-variable 'comment-indent-hook)
  2922.   (setq comment-indent-hook 'icon-comment-indent)
  2923.   (run-hooks 'icon-mode-hook))
  2924.  
  2925. ;; This is used by indent-for-comment
  2926. ;; to decide how much to indent a comment in Icon code
  2927. ;; based on its context.
  2928. (defun icon-comment-indent ()
  2929.   (if (looking-at "^#")
  2930.       0                ;Existing comment at bol stays there.
  2931.     (save-excursion
  2932.       (skip-chars-backward " \t")
  2933.       (max (1+ (current-column))    ;Else indent at comment column
  2934.        comment-column))))    ; except leave at least one space.
  2935.  
  2936. (defun electric-icon-brace (arg)
  2937.   "Insert character and correct line's indentation."
  2938.   (interactive "P")
  2939.   (let (insertpos)
  2940.     (if (and (not arg)
  2941.          (eolp)
  2942.          (or (save-excursion
  2943.            (skip-chars-backward " \t")
  2944.            (bolp))
  2945.          (if icon-auto-newline
  2946.              (progn (icon-indent-line) (newline) t)
  2947.            nil)))
  2948.     (progn
  2949.       (insert last-command-char)
  2950.       (icon-indent-line)
  2951.       (if icon-auto-newline
  2952.           (progn
  2953.         (newline)
  2954.         ;; (newline) may have done auto-fill
  2955.         (setq insertpos (- (point) 2))
  2956.         (icon-indent-line)))
  2957.       (save-excursion
  2958.         (if insertpos (goto-char (1+ insertpos)))
  2959.         (delete-char -1))))
  2960.     (if insertpos
  2961.     (save-excursion
  2962.       (goto-char insertpos)
  2963.       (self-insert-command (prefix-numeric-value arg)))
  2964.       (self-insert-command (prefix-numeric-value arg)))))
  2965.  
  2966. (defun icon-indent-command (&optional whole-exp)
  2967.   (interactive "P")
  2968.   "Indent current line as Icon code, or in some cases insert a tab character.
  2969. If icon-tab-always-indent is non-nil (the default), always indent current line.
  2970. Otherwise, indent the current line only if point is at the left margin
  2971. or in the line's indentation; otherwise insert a tab.
  2972.  
  2973. A numeric argument, regardless of its value,
  2974. means indent rigidly all the lines of the expression starting after point
  2975. so that this line becomes properly indented.
  2976. The relative indentation among the lines of the expression are preserved."
  2977.   (if whole-exp
  2978.       ;; If arg, always indent this line as Icon
  2979.       ;; and shift remaining lines of expression the same amount.
  2980.       (let ((shift-amt (icon-indent-line))
  2981.         beg end)
  2982.     (save-excursion
  2983.       (if icon-tab-always-indent
  2984.           (beginning-of-line))
  2985.       (setq beg (point))
  2986.       (forward-sexp 1)
  2987.       (setq end (point))
  2988.       (goto-char beg)
  2989.       (forward-line 1)
  2990.       (setq beg (point)))
  2991.     (if (> end beg)
  2992.         (indent-code-rigidly beg end shift-amt "#")))
  2993.     (if (and (not icon-tab-always-indent)
  2994.          (save-excursion
  2995.            (skip-chars-backward " \t")
  2996.            (not (bolp))))
  2997.     (insert-tab)
  2998.       (icon-indent-line))))
  2999.  
  3000. (defun icon-indent-line ()
  3001.   "Indent current line as Icon code.
  3002. Return the amount the indentation changed by."
  3003.   (let ((indent (calculate-icon-indent nil))
  3004.     beg shift-amt
  3005.     (case-fold-search nil)
  3006.     (pos (- (point-max) (point))))
  3007.     (beginning-of-line)
  3008.     (setq beg (point))
  3009.     (cond ((eq indent nil)
  3010.        (setq indent (current-indentation)))
  3011.       ((eq indent t)
  3012.        (setq indent (calculate-icon-indent-within-comment)))
  3013.       ((looking-at "[ \t]*#")
  3014.        (setq indent 0))
  3015.       (t
  3016.        (skip-chars-forward " \t")
  3017.        (if (listp indent) (setq indent (car indent)))
  3018.        (cond ((and (looking-at "else\\b")
  3019.                (not (looking-at "else\\s_")))
  3020.           (setq indent (save-excursion
  3021.                  (icon-backward-to-start-of-if)
  3022.                  (current-indentation))))
  3023.          ((or (= (following-char) ?})
  3024.               (looking-at "end\\b"))
  3025.           (setq indent (- indent icon-indent-level)))
  3026.          ((= (following-char) ?{)
  3027.           (setq indent (+ indent icon-brace-offset))))))
  3028.     (skip-chars-forward " \t")
  3029.     (setq shift-amt (- indent (current-column)))
  3030.     (if (zerop shift-amt)
  3031.     (if (> (- (point-max) pos) (point))
  3032.         (goto-char (- (point-max) pos)))
  3033.       (delete-region beg (point))
  3034.       (indent-to indent)
  3035.       ;; If initial point was within line's indentation,
  3036.       ;; position after the indentation.  Else stay at same point in text.
  3037.       (if (> (- (point-max) pos) (point))
  3038.       (goto-char (- (point-max) pos))))
  3039.     shift-amt))
  3040.  
  3041. (defun calculate-icon-indent (&optional parse-start)
  3042.   "Return appropriate indentation for current line as Icon code.
  3043. In usual case returns an integer: the column to indent to.
  3044. Returns nil if line starts inside a string, t if in a comment."
  3045.   (save-excursion
  3046.     (beginning-of-line)
  3047.     (let ((indent-point (point))
  3048.       (case-fold-search nil)
  3049.       state
  3050.       containing-sexp
  3051.       toplevel)
  3052.       (if parse-start
  3053.       (goto-char parse-start)
  3054.     (setq toplevel (beginning-of-icon-defun)))
  3055.       (while (< (point) indent-point)
  3056.     (setq parse-start (point))
  3057.     (setq state (parse-partial-sexp (point) indent-point 0))
  3058.     (setq containing-sexp (car (cdr state))))
  3059.       (cond ((or (nth 3 state) (nth 4 state))
  3060.          ;; return nil or t if should not change this line
  3061.          (nth 4 state))
  3062.         ((and containing-sexp
  3063.           (/= (char-after containing-sexp) ?{))
  3064.          ;; line is expression, not statement:
  3065.          ;; indent to just after the surrounding open.
  3066.          (goto-char (1+ containing-sexp))
  3067.          (current-column))
  3068.         (t
  3069.           ;; Statement level.  Is it a continuation or a new statement?
  3070.           ;; Find previous non-comment character.
  3071.           (if toplevel
  3072.           (progn (icon-backward-to-noncomment (point-min))
  3073.              (if (icon-is-continuation-line)
  3074.                  icon-continued-statement-offset 0))
  3075.         (if (null containing-sexp)
  3076.             (progn (beginning-of-icon-defun)
  3077.                (setq containing-sexp (point))))
  3078.         (goto-char indent-point)
  3079.         (icon-backward-to-noncomment containing-sexp)
  3080.         ;; Now we get the answer.
  3081.         (if (icon-is-continuation-line)
  3082.             ;; This line is continuation of preceding line's statement;
  3083.             ;; indent  icon-continued-statement-offset  more than the
  3084.             ;; first line of the statement.
  3085.             (progn
  3086.               (icon-backward-to-start-of-continued-exp containing-sexp)
  3087.               (+ icon-continued-statement-offset (current-column)
  3088.              (if (save-excursion (goto-char indent-point)
  3089.                          (skip-chars-forward " \t")
  3090.                          (eq (following-char) ?{))
  3091.                  icon-continued-brace-offset 0)))
  3092.           ;; This line starts a new statement.
  3093.           ;; Position following last unclosed open.
  3094.           (goto-char containing-sexp)
  3095.           ;; Is line first statement after an open-brace?
  3096.           (or
  3097.             ;; If no, find that first statement and indent like it.
  3098.             (save-excursion
  3099.               (if (looking-at "procedure\\s ")
  3100.               (forward-sexp 3)
  3101.             (forward-char 1))
  3102.               (while (progn (skip-chars-forward " \t\n")
  3103.                     (looking-at "#"))
  3104.             ;; Skip over comments following openbrace.
  3105.             (forward-line 1))
  3106.               ;; The first following code counts
  3107.               ;; if it is before the line we want to indent.
  3108.               (and (< (point) indent-point)
  3109.                (current-column)))
  3110.             ;; If no previous statement,
  3111.             ;; indent it relative to line brace is on.
  3112.             ;; For open brace in column zero, don't let statement
  3113.             ;; start there too.  If icon-indent-level is zero,
  3114.             ;; use icon-brace-offset + icon-continued-statement-offset instead.
  3115.             ;; For open-braces not the first thing in a line,
  3116.             ;; add in icon-brace-imaginary-offset.
  3117.             (+ (if (and (bolp) (zerop icon-indent-level))
  3118.                (+ icon-brace-offset icon-continued-statement-offset)
  3119.              icon-indent-level)
  3120.                ;; Move back over whitespace before the openbrace.
  3121.                ;; If openbrace is not first nonwhite thing on the line,
  3122.                ;; add the icon-brace-imaginary-offset.
  3123.                (progn (skip-chars-backward " \t")
  3124.                   (if (bolp) 0 icon-brace-imaginary-offset))
  3125.                ;; here we are
  3126.                (current-indentation))))))))))
  3127.  
  3128. (defun icon-is-continuation-line ()
  3129.   (let* ((ch (preceding-char))
  3130.      (ch-syntax (char-syntax ch)))
  3131.     (if (eq ch-syntax ?w)
  3132.     (assoc (buffer-substring
  3133.          (progn (forward-word -1) (point))
  3134.          (progn (forward-word 1) (point)))
  3135.            '(("do") ("dynamic") ("else") ("initial") ("link")
  3136.          ("local") ("of") ("static") ("then")))
  3137.       (not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\n))))))
  3138.  
  3139. (defun icon-backward-to-noncomment (lim)
  3140.   (let (opoint stop)
  3141.     (while (not stop)
  3142.       (skip-chars-backward " \t\n\f" lim)
  3143.       (setq opoint (point))
  3144.       (beginning-of-line)
  3145.       (if (and (search-forward "#" opoint 'move)
  3146.            (< lim (point)))
  3147.       (forward-char -1)
  3148.     (setq stop t)))))
  3149.  
  3150. (defun icon-backward-to-start-of-continued-exp (lim)
  3151.   (if (memq (preceding-char) '(?\) ?\]))
  3152.       (forward-sexp -1))
  3153.   (while (icon-is-continued-line)
  3154.     (end-of-line 0))
  3155.   (beginning-of-line)
  3156.   (if (<= (point) lim)
  3157.       (goto-char (1+ lim)))
  3158.   (skip-chars-forward " \t"))
  3159.  
  3160. (defun icon-is-continued-line ()
  3161.   (save-excursion
  3162.     (end-of-line 0)
  3163.     (icon-is-continuation-line)))
  3164.  
  3165. (defun icon-backward-to-start-of-if (&optional limit)
  3166.   "Move to the start of the last ``unbalanced'' if."
  3167.   (or limit (setq limit (save-excursion (beginning-of-icon-defun) (point))))
  3168.   (let ((if-level 1)
  3169.     (case-fold-search nil))
  3170.     (while (not (zerop if-level))
  3171.       (backward-sexp 1)
  3172.       (cond ((looking-at "else\\b")
  3173.          (setq if-level (1+ if-level)))
  3174.         ((looking-at "if\\b")
  3175.          (setq if-level (1- if-level)))
  3176.         ((< (point) limit)
  3177.          (setq if-level 0)
  3178.          (goto-char limit))))))
  3179.  
  3180. (defun mark-icon-function ()
  3181.   "Put mark at end of Icon function, point at beginning."
  3182.   (interactive)
  3183.   (push-mark (point))
  3184.   (end-of-icon-defun)
  3185.   (push-mark (point))
  3186.   (beginning-of-line 0)
  3187.   (beginning-of-icon-defun))
  3188.  
  3189. (defun beginning-of-icon-defun ()
  3190.   "Go to the start of the enclosing procedure; return t if at top level."
  3191.   (interactive)
  3192.   (if (re-search-backward "^procedure\\s \\|^end[ \t\n]" (point-min) 'move)
  3193.       (looking-at "e")
  3194.     t))
  3195.  
  3196. (defun end-of-icon-defun ()
  3197.   (interactive)
  3198.   (if (not (bobp)) (forward-char -1))
  3199.   (re-search-forward "\\(\\s \\|^\\)end\\(\\s \\|$\\)" (point-max) 'move)
  3200.   (forward-word -1)
  3201.   (forward-line 1))
  3202.  
  3203. (defun indent-icon-exp ()
  3204.   "Indent each line of the Icon grouping following point."
  3205.   (interactive)
  3206.   (let ((indent-stack (list nil))
  3207.     (contain-stack (list (point)))
  3208.     (case-fold-search nil)
  3209.     restart outer-loop-done inner-loop-done state ostate
  3210.     this-indent last-sexp
  3211.     at-else at-brace at-do
  3212.     (opoint (point))
  3213.     (next-depth 0))
  3214.     (save-excursion
  3215.       (forward-sexp 1))
  3216.     (save-excursion
  3217.       (setq outer-loop-done nil)
  3218.       (while (and (not (eobp)) (not outer-loop-done))
  3219.     (setq last-depth next-depth)
  3220.     ;; Compute how depth changes over this line
  3221.     ;; plus enough other lines to get to one that
  3222.     ;; does not end inside a comment or string.
  3223.     ;; Meanwhile, do appropriate indentation on comment lines.
  3224.     (setq innerloop-done nil)
  3225.     (while (and (not innerloop-done)
  3226.             (not (and (eobp) (setq outer-loop-done t))))
  3227.       (setq ostate state)
  3228.       (setq state (parse-partial-sexp (point) (progn (end-of-line) (point))
  3229.                       nil nil state))
  3230.       (setq next-depth (car state))
  3231.       (if (and (car (cdr (cdr state)))
  3232.            (>= (car (cdr (cdr state))) 0))
  3233.           (setq last-sexp (car (cdr (cdr state)))))
  3234.       (if (or (nth 4 ostate))
  3235.           (icon-indent-line))
  3236.       (if (or (nth 3 state))
  3237.           (forward-line 1)
  3238.         (setq innerloop-done t)))
  3239.     (if (<= next-depth 0)
  3240.         (setq outer-loop-done t))
  3241.     (if outer-loop-done
  3242.         nil
  3243.       (if (/= last-depth next-depth)
  3244.           (setq last-sexp nil))
  3245.       (while (> last-depth next-depth)
  3246.         (setq indent-stack (cdr indent-stack)
  3247.           contain-stack (cdr contain-stack)
  3248.           last-depth (1- last-depth)))
  3249.       (while (< last-depth next-depth)
  3250.         (setq indent-stack (cons nil indent-stack)
  3251.           contain-stack (cons nil contain-stack)
  3252.           last-depth (1+ last-depth)))
  3253.       (if (null (car contain-stack))
  3254.           (setcar contain-stack (or (car (cdr state))
  3255.                     (save-excursion (forward-sexp -1)
  3256.                             (point)))))
  3257.       (forward-line 1)
  3258.       (skip-chars-forward " \t")
  3259.       (if (eolp)
  3260.           nil
  3261.         (if (and (car indent-stack)
  3262.              (>= (car indent-stack) 0))
  3263.         ;; Line is on an existing nesting level.
  3264.         ;; Lines inside parens are handled specially.
  3265.         (if (/= (char-after (car contain-stack)) ?{)
  3266.             (setq this-indent (car indent-stack))
  3267.           ;; Line is at statement level.
  3268.           ;; Is it a new statement?  Is it an else?
  3269.           ;; Find last non-comment character before this line
  3270.           (save-excursion
  3271.             (setq at-else (looking-at "else\\W"))
  3272.             (setq at-brace (= (following-char) ?{))
  3273.             (icon-backward-to-noncomment opoint)
  3274.             (if (icon-is-continuation-line)
  3275.             ;; Preceding line did not end in comma or semi;
  3276.             ;; indent this line  icon-continued-statement-offset
  3277.             ;; more than previous.
  3278.             (progn
  3279.               (icon-backward-to-start-of-continued-exp (car contain-stack))
  3280.               (setq this-indent
  3281.                 (+ icon-continued-statement-offset (current-column)
  3282.                    (if at-brace icon-continued-brace-offset 0))))
  3283.               ;; Preceding line ended in comma or semi;
  3284.               ;; use the standard indent for this level.
  3285.               (if at-else
  3286.               (progn (icon-backward-to-start-of-if opoint)
  3287.                  (setq this-indent (current-indentation)))
  3288.             (setq this-indent (car indent-stack))))))
  3289.           ;; Just started a new nesting level.
  3290.           ;; Compute the standard indent for this level.
  3291.           (let ((val (calculate-icon-indent
  3292.                (if (car indent-stack)
  3293.                    (- (car indent-stack))))))
  3294.         (setcar indent-stack
  3295.             (setq this-indent val))))
  3296.         ;; Adjust line indentation according to its contents
  3297.         (if (or (= (following-char) ?})
  3298.             (looking-at "end\\b"))
  3299.         (setq this-indent (- this-indent icon-indent-level)))
  3300.         (if (= (following-char) ?{)
  3301.         (setq this-indent (+ this-indent icon-brace-offset)))
  3302.         ;; Put chosen indentation into effect.
  3303.         (or (= (current-column) this-indent)
  3304.         (progn
  3305.           (delete-region (point) (progn (beginning-of-line) (point)))
  3306.           (indent-to this-indent)))
  3307.         ;; Indent any comment following the text.
  3308.         (or (looking-at comment-start-skip)
  3309.         (if (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t)
  3310.             (progn (indent-for-comment) (beginning-of-line))))))))))
  3311.  
  3312.  
  3313.  
  3314. From wgg@june.cs.washington.edu  Wed Feb  8 13:05:05 1989
  3315. Received: from june.cs.washington.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3316.     id AA23818; Wed, 8 Feb 89 13:05:05 MST
  3317. Received: by june.cs.washington.edu (5.59/6.13+)
  3318.     id AA05068; Wed, 8 Feb 89 12:02:14 PST
  3319. Date: Wed, 8 Feb 89 12:02:14 PST
  3320. From: wgg@june.cs.washington.edu (William Griswold)
  3321. Return-Path: <wgg@june.cs.washington.edu>
  3322. Message-Id: <8902082002.AA05068@june.cs.washington.edu>
  3323. To: EM302723%VMTECMEX.BITNET@UICVM.uic.edu
  3324. Subject: Re:  Extension Interpreter request
  3325. Cc: icon-group@arizona.edu
  3326.  
  3327.  
  3328. >Date: Tue, 07 Feb 89 13:16:43 MEX
  3329. >To: icon-group@arizona.edu
  3330. >From: EM302723%VMTECMEX.BITNET@UICVM.uic.edu
  3331. >Comment: CROSSNET mail via SMTP@INTERBIT
  3332. >Subject: Extension Interpreter request
  3333. >
  3334. >Date: 7 February 89, 13:14:51 MEX
  3335. >From: Mario Camou Riveroll                           EM302723 at VMTECMEX
  3336. >To:   ICON-GROUP at ARIZONA
  3337. >
  3338. >A few Icon Newsletters ago I read about an 'extension interpreter' which
  3339. >was under development and supposed to let you call C functions without
  3340. >modifying the compiler. What's the status on it?
  3341. >
  3342. >-Mario Camou
  3343. >EM302723@VMTECMEX.BITNET
  3344. >
  3345. The Extension Interpreter is a research prototype.  Although work is continuing
  3346. on the EI (I am building new applications on top of the EI, and I'm adding
  3347. C++ to the list of languages it supports), there is no intent to distribute
  3348. it.  The EI is not an Icon-specific tool (Icon is one of the languages it
  3349. supports), but it is Unix specific in that the C dynamic loader works on the
  3350. Berkeley object format.  The Icon C-calling feature itself is fully portable.
  3351.  
  3352. On the Icon side, The C-calling feature is on the list of things to be added
  3353. to Icon (some of the hooks are there), but time is scarce.   It probably
  3354. won't get done unless there is sufficient interest. 
  3355.  
  3356.                     Bill Griswold
  3357.  
  3358. From icon-group-request  Thu Feb  9 04:47:18 1989
  3359. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3360.     id AA11778; Thu, 9 Feb 89 04:47:18 MST
  3361. Received: by ucbvax.Berkeley.EDU (5.61/1.33)
  3362.     id AA29644; Thu, 9 Feb 89 03:26:09 -0800
  3363. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  3364.     for icon-group@arizona.edu (icon-group@arizona.edu)
  3365.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  3366. Date: 8 Feb 89 17:33:15 GMT
  3367. From: grand!day@uunet.uu.net  (Dave Yost)
  3368. Organization: Grand Software, Inc., Los Angels, CA 213-650-1089
  3369. Subject: Re:  Icon Compiler
  3370. Message-Id: <478@grand.UUCP>
  3371. References: <8902071612.AA03629@megaron.arizona.edu>, <8902071631.AA04603@megaron.arizona.edu>
  3372. Sender: icon-group-request@arizona.edu
  3373. To: icon-group@arizona.edu
  3374.  
  3375. In article <8902071631.AA04603@megaron.arizona.edu> ralph@ARIZONA.EDU ("Ralph Griswold") writes:
  3376. >Early versions of Icon supported a "compiler", which is mentioned in
  3377. >the Icon book.  However, it mostly generated subroutine calls and
  3378. >was only 5-10% faster than the interpreter.
  3379.  
  3380. As an Icon fan who would like to see it
  3381. spread, I offer this:
  3382.  
  3383. The speed advantage is only one goal of a
  3384. compiler.  Another important one is to be
  3385. able to generate a self-contained single
  3386. executable, preferably as small as possible
  3387. because it contains only the runtime routines
  3388. it needs.
  3389.  
  3390. If one could do this, then one could build a
  3391. binary of an icon program for someone who has
  3392. the same machine but doesn't want to commit
  3393. to installing the icon interpreter.  Ideally,
  3394. it would be nice to get a tape with icon
  3395. runtime libraries for all machines in some
  3396. machine independent format and have the
  3397. ability to generate binaries for many
  3398. different machines without having to have
  3399. those machines and without requiring that the
  3400. icon interpreter be installed separately on
  3401. a user's machine.
  3402.  
  3403. I believe Icon would spread faster if it were
  3404. easier to give someone an Icon program you
  3405. wrote, at least in binary form for them to
  3406. try out.  As it is now, you have to convince
  3407. them to install a major language system for
  3408. them to be able to use some little tool you
  3409. whipped up in Icon.  I have found monumental
  3410. resistance to installing *some weirdo
  3411. nonstandard [fill in your own xenolingophobic
  3412. epithets] language*.  People don't even want
  3413. to install a ready-made interpreter in their
  3414. file system.
  3415.  
  3416. Maybe if we could hand out runnable binaries
  3417. of our useful Icon programs then maybe they
  3418. would listen when we tell them how it was so
  3419. much easier to write in Icon and would have
  3420. never been written at all if it had to be
  3421. done in C.
  3422.  
  3423. And I conclude with a prayer.
  3424.  
  3425. May some great organization see the wisdom in
  3426. giving nice grants to the deserving Icon Group.
  3427.  
  3428.  --dave
  3429.  
  3430. From sunquest!whm  Thu Feb  9 10:35:54 1989
  3431. Received: by megaron.arizona.edu (5.59-1.7/15)
  3432.     id AA28047; Thu, 9 Feb 89 10:35:54 MST
  3433. Date: Thu, 9 Feb 89 10:29:33 MST
  3434. From: "Bill Mitchell" <sunquest!whm>
  3435. Message-Id: <8902091729.AA07281@sunquest>
  3436. Received: by sunquest; Thu, 9 Feb 89 10:29:33 MST
  3437. To: arizona!icon-group
  3438. Subject: Re:  Icon Compiler
  3439.  
  3440. Well, you can make standalone executables with the save() function with a
  3441. minimum of trouble.  However, they're pretty big -- I just tried one and
  3442. got about a 340k file.  I compressed that and got down to about 100k, but
  3443. that's still a lot.
  3444.  
  3445. I wonder if it would work to ship someone a copy of the interpreter and then
  3446. have a program to change the location of the interpreter in the icode file.
  3447. That would be two programs that one could stick in one's bin and then you could
  3448. send around icode files for machines of the same architecture.  However, with
  3449. only five files (icont, itran, ilink, iconx.hdr, and iconx), you can have a
  3450. complete Icon system and then just ship around Icon source files.
  3451.  
  3452. I think that it's really just a packaging problem -- there just needs to be a
  3453. way to clone a minimal Icon system from an installed system.  Of course,
  3454. solving packaging problems isn't research.  (Unless you're an industrial
  3455. engineer??)
  3456. --------------------------------------------------------------------
  3457. Bill Mitchell                whm@sunquest.com
  3458. Sunquest Information Systems        sunquest!whm@arizona.edu
  3459. Tucson, AZ                 {arizona,uunet}!sunquest!whm
  3460. 602-885-7700
  3461.  
  3462.  
  3463. From sunquest!arizona!ralph  Thu Feb  9 11:19:04 1989
  3464. Received: by megaron.arizona.edu (5.59-1.7/15)
  3465.     id AA01123; Thu, 9 Feb 89 11:19:04 MST
  3466. Received: by sunquest; Thu, 9 Feb 89 11:12:41 MST
  3467. Date: Thu, 9 Feb 89 11:08:39 MST
  3468. From: "Ralph Griswold" <sunquest!arizona!ralph>
  3469. Message-Id: <8902091808.AA00547@megaron.arizona.edu>
  3470. Received: by megaron.arizona.edu (5.59-1.7/15)
  3471.     id AA00547; Thu, 9 Feb 89 11:08:39 MST
  3472. To: sunquest!arizona!icon-group, sunquest!whm
  3473. Subject: Re:  Icon Compiler
  3474. In-Reply-To: <8902091729.AA07281@sunquest>
  3475.  
  3476. The save() function is presently available only on BSD UNIX versions of
  3477. Icon and I don't see it being much help except in certain very special
  3478. kinds of environments.
  3479.  
  3480.  
  3481.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  3482.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  3483.  
  3484.  
  3485. From icon-group-request  Thu Feb  9 11:19:46 1989
  3486. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3487.     id AA01144; Thu, 9 Feb 89 11:19:46 MST
  3488. Received: by ucbvax.Berkeley.EDU (5.61/1.33)
  3489.     id AA05994; Thu, 9 Feb 89 10:16:17 -0800
  3490. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  3491.     for icon-group@arizona.edu (icon-group@arizona.edu)
  3492.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  3493. Date: 8 Feb 89 11:51:51 GMT
  3494. From: mcvax!hp4nl!mhres!jv@uunet.uu.net  (Johan Vromans)
  3495. Organization: Multihouse NV, the Netherlands
  3496. Subject: GNU Emacs Icon mode
  3497. Message-Id: <2862@mhres.mh.nl>
  3498. Sender: icon-group-request@arizona.edu
  3499. To: icon-group@arizona.edu
  3500.  
  3501. Does someone have a GNU Emacs electric-icon mode? Or other
  3502. Icon-specialized editing environment?
  3503.  
  3504. [Yes, I did receive the recently posted "describe-icon-symbol"
  3505.  command for GNU Emacs. Thank you.]
  3506.  
  3507. -- 
  3508. Johan Vromans             jv@mh.nl via european backbone (mcvax)
  3509. Multihouse [A-Za-z ]* [NB]V            uucp: ..!mcvax!mh.nl!jv
  3510. Gouda - The Netherlands                  phone: +31 1820 62944
  3511.  
  3512. From att!ihuxy!nowlin  Thu Feb  9 13:04:24 1989
  3513. Date: Thu, 9 Feb 89 13:04:24 MST
  3514. Message-Id: <8902092004.AA07470@megaron.arizona.edu>
  3515. Received: by megaron.arizona.edu (5.59-1.7/15)
  3516.     id AA07470; Thu, 9 Feb 89 13:04:24 MST
  3517. Received: by att.ATT.COM (smail2.6 - att-ih)
  3518.     id AA01172; 9 Feb 89 14:01:01 CST (Thu)
  3519. From: ihuxy!nowlin (Jerry D Nowlin +1 312 979 0441)
  3520. To: att!arizona!icon-group
  3521. Subject: Re: Icon Compiler (files needed)
  3522.  
  3523. At AT&T we (Rick Fonorow and myself) have had to modify Icon in order to
  3524. install it in a semi-official place on all the R&D systems in the
  3525. Naperville Area.  The result of this is that only two files are needed for
  3526. a complete Icon system, icont and iconx.  These files can be placed in any
  3527. directory that's in a users PATH (a UNIX environment is needed) and the
  3528. user has Icon.  This makes for a much easier system to distribute to a lot
  3529. of machines.  I think the Icon Project has agreed to include these
  3530. modifications in a future release.  They'll have to confirm that though.
  3531.  
  3532. Jerry Nowlin
  3533. (...!att!ihuxy!nowlin)
  3534.  
  3535. From spqr%electronics-and-computer-science.southampton.ac.uk@NSS.Cs.Ucl.AC.UK  Fri Feb 10 01:32:43 1989
  3536. Received: from NSS.CS.UCL.AC.UK by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3537.     id AA11047; Fri, 10 Feb 89 01:32:43 MST
  3538. Received: from electronics-and-computer-science.southampton.ac.uk
  3539.           by NSS.Cs.Ucl.AC.UK   via Janet with NIFTP  id aa03525;
  3540.           10 Feb 89 8:03 GMT
  3541. From: Sebastian Rahtz <spqr%electronics-and-computer-science.southampton.ac.uk@NSS.Cs.Ucl.AC.UK>
  3542. Date: Fri, 10 Feb 89 08:23:32 GMT
  3543. Message-Id: <14993.8902100823@hilliard.ecs.soton.ac.uk>
  3544. To: icon-group@arizona.edu
  3545. Subject:  whats in a name
  3546.  
  3547. Its really trivial of me, and nosey, but what is the relationship
  3548. between Bill Griswold and Ralph Griswold?
  3549.  
  3550. sebastian rahtz
  3551.  
  3552. From sboisen@REGULUS.BBN.COM  Tue Feb 14 12:54:07 1989
  3553. Message-Id: <8902141954.AA26787@megaron.arizona.edu>
  3554. Received: from REGULUS.BBN.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3555.     id AA26787; Tue, 14 Feb 89 12:54:07 MST
  3556. To: unido!infbs!neitzel <@bbn.com:unido!infbs!neitzel@UUNET.UU.NET>
  3557. Cc: icon-group@arizona.edu
  3558. Subject: GNU Emacs -- icon-*.el bug(s)
  3559. From: Sean Boisen <sboisen@REGULUS.BBN.COM>
  3560. Sender: sboisen@REGULUS.BBN.COM
  3561. Reply-To: sboisen@bbn.com
  3562. Date: Tue, 14 Feb 89 14:50:09 EST
  3563.  
  3564. Martin Neitzel <unido!infbs!sigserv!neitzel@UUNET.UU.NET> pointed out
  3565. a bug to me: if point is at the end of the buffer, it errors out. This
  3566. can be fixed as follows: replace, in icon-symbol-at-point (line 67 in
  3567. my version) 
  3568.  
  3569.     (forward-char 1)
  3570.  
  3571. with
  3572.     (or (= (point) (point-max))
  3573.         (forward-char 1))
  3574.  
  3575. There is also a problem in the icon-mode i posted with indentation:
  3576. auto-filled comments get an extra space at the beginning of subsequent lines.
  3577.  
  3578. # so that comments like this
  3579.  # turn out this ugly way
  3580.  
  3581. I tried to figure this out once but couldn't come up with anything.
  3582.  
  3583.  
  3584. We now return to your regularly scheduled content....
  3585.  
  3586. ........................................
  3587. Sean Boisen -- sboisen@bbn.com
  3588. BBN Systems and Technologies Corporation, Cambridge MA
  3589. Disclaimer: these opinions void where prohibited by lawyers.
  3590.  
  3591. From dscargo@cim-vax.honeywell.com  Thu Feb 16 09:39:21 1989
  3592. Message-Id: <8902161639.AA04530@megaron.arizona.edu>
  3593. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3594.     id AA04530; Thu, 16 Feb 89 09:39:21 MST
  3595. Date: 16 Feb 89 10:19:00 CST
  3596. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  3597. Subject: table default values
  3598. To: "icon-group" <icon-group@arizona.edu>
  3599.  
  3600. Must be time for another strange idea from the frozen north.  I was looking
  3601. at tables, this time for the purpose of doing some ASCII to PostScript
  3602. conversion.  Most characters are fine, but there are some that need to
  3603. be escaped or otherwise translated.  There are lots of mechanisms for doing
  3604. this, but most of them are something of a pain to set up.  Would it be
  3605. reasonable to have the default value for table() have a way of knowing that
  3606. the default assigned value for an entry value should be the entry value?
  3607.  
  3608. Depending on you point of view this might be something like
  3609.  
  3610. translations := table(&self)
  3611.  
  3612. or maybe
  3613.  
  3614. translations := table(&entry_value)
  3615.  
  3616. Once again, it's because the programs I write do lots of mapping that makes
  3617. me want to find easy ways of mapping a single input byte to a potentially
  3618. multibyte output.  Map won't do what I want.  I suppose I could take each
  3619. input character, convert it to an integer, and then use that as an index
  3620. into a list.  That sounds like it would generate lots of garbage; I'm also
  3621. concerned that the list access might be slower than the table access
  3622. (which I suppose I could actual test).
  3623.  
  3624. Anybody else have common single char to multichar mapping problems? Do
  3625. you use tables or some other mechanisms?
  3626.  
  3627.  
  3628. From gudeman  Thu Feb 16 10:18:03 1989
  3629. Date: Thu, 16 Feb 89 10:18:03 MST
  3630. From: "David Gudeman" <gudeman>
  3631. Message-Id: <8902161718.AA06968@megaron.arizona.edu>
  3632. Received: by megaron.arizona.edu (5.59-1.7/15)
  3633.     id AA06968; Thu, 16 Feb 89 10:18:03 MST
  3634. To: dscargo@cim-vax.honeywell.com
  3635. Cc: icon-group@arizona.edu
  3636. In-Reply-To: "DAVE CARGO"'s message of 16 Feb 89 10:19:00 CST <8902161639.AA04530@megaron.arizona.edu>
  3637. Subject: table default values
  3638.  
  3639. >Date: 16 Feb 89 10:19:00 CST
  3640. >From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  3641.  
  3642. >...[wants to have the default value for a table be the entry key]...
  3643.  
  3644. I suppose you are aware of this method:
  3645.  
  3646.   t := table()
  3647.   ...
  3648.   elem := \t[elem] | elem
  3649.  
  3650. >Would it be reasonable to have the default value for table() have a
  3651. >way of knowing that the default assigned value for an entry value
  3652. >should be the entry value?...
  3653. >
  3654. >translations := table(&entry_value)
  3655.  
  3656. I like that idea.  It would also be nice to have keywords like
  3657.  
  3658.   &new_list -- produces a new list for default values
  3659.   &new_table -- produces a new table for default values
  3660.   &new_set -- produces a new set for default values
  3661.  
  3662. From wgg@june.cs.washington.edu  Thu Feb 16 13:20:37 1989
  3663. Received: from june.cs.washington.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3664.     id AA16994; Thu, 16 Feb 89 13:20:37 MST
  3665. Received: by june.cs.washington.edu (5.59/6.13+)
  3666.     id AA05346; Thu, 16 Feb 89 12:18:47 PST
  3667. Date: Thu, 16 Feb 89 12:18:47 PST
  3668. From: wgg@june.cs.washington.edu (William Griswold)
  3669. Return-Path: <wgg@june.cs.washington.edu>
  3670. Message-Id: <8902162018.AA05346@june.cs.washington.edu>
  3671. To: icon-group@arizona.edu
  3672. Subject: Re:  table default values
  3673.  
  3674. >Date: 16 Feb 89 10:19:00 CST
  3675. >From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  3676. >Subject: table default values
  3677. >To: "icon-group" <icon-group@arizona.edu>
  3678. >
  3679. >Must be time for another strange idea from the frozen north.  I was looking
  3680. >at tables, this time for the purpose of doing some ASCII to PostScript
  3681. >conversion.  Most characters are fine, but there are some that need to
  3682. >be escaped or otherwise translated.  There are lots of mechanisms for doing
  3683. >this, but most of them are something of a pain to set up.  Would it be
  3684. >reasonable to have the default value for table() have a way of knowing that
  3685. >the default assigned value for an entry value should be the entry value?
  3686. >
  3687. >Depending on you point of view this might be something like
  3688. >
  3689. >translations := table(&self)
  3690. >
  3691. >or maybe
  3692. >
  3693. >translations := table(&entry_value)
  3694.  
  3695. As mentioned in the previous message, one way of solving
  3696. this problem is by saying
  3697.  
  3698.     (\translations[value] | value)     # may be resumed if outer 
  3699.                        #  expression fails!
  3700.  
  3701. however, if used as a general expression, you might prefer:
  3702.  
  3703.     {\translations[value] | value}     # won't be resumed if outer 
  3704.                        #  expression fails
  3705.  
  3706. or by encapuslating the code in a procedure to prevent resumption.
  3707.  
  3708. If efficiency is your thing, you can iterate through &cset before doing
  3709. your multi-byte assignments;
  3710.  
  3711.     translations := table()
  3712.     every translations[v := !&cset] := v
  3713.     # multi-byte mappings...
  3714.  
  3715. and then lookup would revert to
  3716.  
  3717.     mapping := translations[char]
  3718.  
  3719. These lookups won't return null unless the input isn't a single character 
  3720. string.
  3721.  
  3722. >Once again, it's because the programs I write do lots of mapping that makes
  3723. >me want to find easy ways of mapping a single input byte to a potentially
  3724. >multibyte output.  Map won't do what I want.  I suppose I could take each
  3725. >input character, convert it to an integer, and then use that as an index
  3726. >into a list.  That sounds like it would generate lots of garbage; I'm also
  3727. >concerned that the list access might be slower than the table access
  3728. >(which I suppose I could actual test).
  3729. >
  3730. >Anybody else have common single char to multichar mapping problems? Do
  3731. >you use tables or some other mechanisms?
  3732. >
  3733.  
  3734. You might find that performing list lookup on the ord of the input value
  3735. is faster, since hashing and chaining won't be performed.  The code might
  3736. look like this:
  3737.  
  3738.     translations := list(*&cset)
  3739.     every translations[ord(v := !&cset] := v
  3740.     # multi-byte mappings...
  3741.  
  3742. and lookups would look like
  3743.  
  3744.     mapping := translations[ord(char)]
  3745.  
  3746.  
  3747.                 Bill Griswold
  3748.  
  3749. From dscargo@cim-vax.honeywell.com  Mon Feb 20 11:10:12 1989
  3750. Message-Id: <8902201810.AA07072@megaron.arizona.edu>
  3751. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3752.     id AA07072; Mon, 20 Feb 89 11:10:12 MST
  3753. Date: 19 Feb 89 09:46:00 CST
  3754. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  3755. Subject: tables and &self
  3756. To: "icon-group" <icon-group@arizona.edu>
  3757.  
  3758. I found another circumstance where the table(&self) would have been useful,
  3759. though it would have been a generalization of what I suggested last time.
  3760. In particular, I was needing to sort some records according to the
  3761. magnitude of one of their components. In this case, a generalization
  3762. of what I had before,
  3763.  
  3764. to_be_sorted := table(&self.magnitude)
  3765. ....
  3766. insert(to_be_sorted,appropriate_record)
  3767.  
  3768. Granted there are many problems with this.  The initialization of the
  3769. table is really producing some kind of a "thunk".  It's code that isn't
  3770. evaluated until an insertion is performed.  The original &self is a relatively
  3771. trivial thunk, equivalent to identity.  Going beyond that adds more complex
  3772. expressions that are evaluated at insertion time, whose results are used
  3773. as the assigned values.
  3774.  
  3775. Partly I wanted to avoid initializing a table composed mostly of identities.
  3776. I can see that what I have above might almost be better served by
  3777. user-defined functions that do something like
  3778.  
  3779. Insert(to_be_sorted,appropriate_record,appropriate_record.magnitude)
  3780.  
  3781. In many cases this would work well enough, but it still doesn't give me my
  3782. avoidance of initialization except for exceptional cases.
  3783.  
  3784. dsc
  3785.  
  3786.  
  3787. From icon-group-request  Mon Feb 20 11:13:36 1989
  3788. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3789.     id AA07261; Mon, 20 Feb 89 11:13:36 MST
  3790. Received: by ucbvax.Berkeley.EDU (5.61/1.34)
  3791.     id AA19833; Sat, 18 Feb 89 02:35:58 -0800
  3792. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  3793.     for icon-group@arizona.edu (icon-group@arizona.edu)
  3794.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  3795. Date: 16 Feb 89 17:49:10 GMT
  3796. From: mcvax!hp4nl!kunivv1!atcmpe!gertjan@uunet.uu.net  (Gertjan Vinkesteyn)
  3797. Organization: AT Computing, Nijmegen, The Netherlands
  3798. Subject: Re: Icon Lectures Part 3/3
  3799. Message-Id: <483@atcmpe.atcmp.nl>
  3800. References: <481@atcmpe.atcmp.nl>, <482@atcmpe.atcmp.nl>
  3801. Sender: icon-group-request@arizona.edu
  3802. To: icon-group@arizona.edu
  3803.  
  3804.  
  3805.  
  3806. #! /bin/sh
  3807. # This is a shell archive.  Remove anything before this line, then unpack
  3808. # it by saving it into a file and typing "sh file".  To overwrite existing
  3809. # files, type "sh file -c".  You can also feed this as standard input via
  3810. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  3811. # will see the following message at the end:
  3812. #        "End of archive 3 (of 3)."
  3813. # Contents:  icon/course/course08.29 icon/course/course09.03
  3814. #   icon/course/course09.10 icon/solution/sample.02
  3815. #   icon/solution/sample.icn icon/solution/solution.07
  3816. # Wrapped by gertjan@atcmp.nl on Thu Feb 16 18:28:16 1989
  3817. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  3818. if test -f icon/course/course08.29 -a "${1}" != "-c" ; then 
  3819.   echo shar: Will not over-write existing file \"icon/course/course08.29\"
  3820. else
  3821. echo shar: Extracting \"icon/course/course08.29\" \(3603 characters\)
  3822. sed "s/^X//" >icon/course/course08.29 <<'END_OF_icon/course/course08.29'
  3823. XIn the previous note I forgot to mention that there is homework as well.
  3824. XThe homework for 8-27 was : Read Chapter 1-3 in the ICON book.
  3825. X
  3826. XCourse 8/29
  3827. X
  3828. XTechnical Aspects of ICON:
  3829. X- automatic storage management
  3830. X- no declaration of variables, no partition, varying size, runtime creation
  3831. X
  3832. XCharacteristics:
  3833. X- high level programming oriented
  3834. X- non-numerical scientific computation
  3835. X- novel, experimental features
  3836. X- less regard for efficiency than facility
  3837. X- pointer semantic to structures
  3838. X
  3839. XThere are many types, but no type declaration - variables are 'untyped'
  3840. XRun-time type system (late-binding) as opposed to compile type system.
  3841. XThere is strong run-time type checking and automatic conversion.
  3842. XScoping is static (for that is clear and simple)
  3843. X
  3844. XThe syntax is expession based. In Algol like languages you have
  3845. Xdistinction between statements and expressions. A negative aspect of
  3846. Xexpression based syntax is : where does the compiler make localisation
  3847. Xof syntax errors (least of Griswold's concern).
  3848. X
  3849. XIcon has traditional control structures, not like Snobol, but like Algol.
  3850. XThere are some novel control structures.
  3851. XA large repertoir of operations and functions, especially on strings.
  3852. XThere are some "extra" features:
  3853. X- string scanning (analog to pattern matching in Snobol4)
  3854. X- co-expressions
  3855. XSnobol has extensive dynamic binding, more then Icon. Because most
  3856. Xprograms are incorrect any way verification is not important :-)
  3857. X
  3858. XGetting Started with Icon:
  3859. X==========================
  3860. XThe most important declaration is the 'procedure'. Like in C programs
  3861. Xneed to start with a 'procedure main()'
  3862. XThere are i/o write and read function (this is a nice side-effect which
  3863. Xis not always available in Functional Languages!)
  3864. X
  3865. XEssential is the expression evaluation mechanism. An expression may
  3866. X    succeed    == produces a result
  3867. X    fail    == produces not a result
  3868. XE.g. 
  3869. X    while line:=read() do write(line)
  3870. X
  3871. Xis driven by success or failure of    line:=read()
  3872. XYou can see it as            :=(line,read())
  3873. Xif read() fails the assignment is not performed.
  3874. XThis is different than in Algol like languages because if
  3875. X    while line:=read()
  3876. Xfails then 'line' will still holds its old value, that is not changed
  3877. XA site effect is that you really better always check function calls
  3878. Xbecause if you have written somewhere
  3879. X    line:=read()
  3880. Xthen the program can 'fail' without letting you know where!
  3881. XIn Algol line:=read() is a boolean expression
  3882. X
  3883. XEvery expression delivers a value
  3884. Xi > j    delivers the value of 'j'
  3885. Xi > j > k works then okay because it is like (i > j) > k and works as
  3886. Xaspected. You can write that in most language but they don't do what you
  3887. Xthink they should do.
  3888. XAlso k := i > j        for your own ideocratic programming style.
  3889. X
  3890. XAlmost ever operator  has an augmented assigment version.
  3891. XLike i +:= j delivers i := i + j but in one step (internally)
  3892. XThe operator set is fixed and cannot be changed like in Algol68 and
  3893. XSnobol4. That is done mainly for machine convenience, it could be part
  3894. Xof the language. There are 68 different kind of operators like x ~===:= y
  3895. Xis on page 273 in the Icon book.
  3896. X
  3897. XFunctions are data-objects which values can be changed. That is used to
  3898. Xpass functions as parameters to procedures.
  3899. XSo you never really know if
  3900. X    while line:=read()
  3901. Xis what you think it is. If you have written somewhere in the beginning
  3902. Xof your programming
  3903. X    read:=write
  3904. Xthen you might be in big trouble! But that does not happen too often in
  3905. Xthis case. 
  3906. X
  3907. XSo a lot is dependent on your own programming style and social conduct.
  3908. XThat is the responsibility of the writer not of the language.
  3909. X
  3910. XHOMEWORK: Read Chapter 4
  3911. X
  3912. XThe biggest chapter with a lot of details.
  3913. END_OF_icon/course/course08.29
  3914. if test 3603 -ne `wc -c <icon/course/course08.29`; then
  3915.     echo shar: \"icon/course/course08.29\" unpacked with wrong size!
  3916. fi
  3917. # end of overwriting check
  3918. fi
  3919. if test -f icon/course/course09.03 -a "${1}" != "-c" ; then 
  3920.   echo shar: Will not over-write existing file \"icon/course/course09.03\"
  3921. else
  3922. echo shar: Extracting \"icon/course/course09.03\" \(4428 characters\)
  3923. sed "s/^X//" >icon/course/course09.03 <<'END_OF_icon/course/course09.03'
  3924. XToday Ralph started to talk about homework. An interesting point is that
  3925. Xhe uses a background program to check your homework in your directory
  3926. X~/550 (550 is the course number). Just a quote out if his handout for the
  3927. Xfun of it:
  3928. X
  3929. X    The demon usually will be unleashed just before class on the day
  3930. X    homework is due. The demon will be annoyed if it does not find
  3931. X    a file with the expected name. Half a program is considerably
  3932. X    better than none. The demon will be infuriated if your program
  3933. X    loops endlessly. It is unwise to infuriate a demon. It is better
  3934. X    to have a program that commits hari-kiri than one that runs amok.
  3935. X    ...
  3936. X    The grading of the homework will depend on the quality of solutions
  3937. X    as well as their correctness. As the course develops, we will discuss
  3938. X    good "idiomatic" Icon. To start, make your best guess as to what
  3939. X    constitutes good style in Icon.
  3940. X
  3941. XOf course you cannot hand in your homework but in that case please send
  3942. Xit in to me ('mail gertjan') and I will check it for you.
  3943. X
  3944. XHOMEWORK Assignment 1 - Due Thursday, September 12, 1985
  3945. X
  3946. X1. (nest.icn, 10 pts) Do Exercise 2.8 from the Icon book. You may assume
  3947. Xthat all braces in the input file are syntactically meaningful - that
  3948. Xnone are quoted, for example.
  3949. X
  3950. X2. (case.icn, 10 pts) Write a program that counts the number of
  3951. Xuppercase and lowercase letters in the standard input file, and then
  3952. Xprints the counts and their ratio.
  3953. X
  3954. X3. (palin.icn, 10 pts) Do Exercise 4.8 in the Icon book. Supply a main
  3955. Xprogram that reads lines from standard input and filters out any lines
  3956. Xthat are not palindromic sentences.
  3957. X
  3958. X===
  3959. X
  3960. XIcon is not designed to be a production oriented language.
  3961. XTranslation in to executable code goes very fast for a virtual machine.
  3962. X
  3963. XThere are different ways representing data.
  3964. XIn Icon strings are ATOMIC, they are not arrays of characters.
  3965. XThere is no operation in Icon what can change a character in a string.
  3966. XStrings can be very long and are only dependent of your amount of
  3967. X(virtual) memory in your hardware.
  3968. XSo operations on strings are applicative.
  3969. X
  3970. XThere is no char data type.
  3971. XIn Icon the characters are 8-bits long independent of machine type. So
  3972. Xthere are 256 different characters. (ed. this is not easy to change to
  3973. Xtwo-byte or three-byte character code, see note of Ralph about that)
  3974. XThese 256 chars have an ASCII representation. So "a" -> 01100001
  3975. XThat is also on an IBM EBCDIC machine! The {null} character can be used
  3976. Xas any ordinary character (it is not an eos marker like in C).
  3977. X
  3978. XSingle quotes are used to enclose character sets.
  3979. XThese are "sets" of characters and called: csets
  3980. X
  3981. XSize of 'abc' represented as *'abc' -> 3
  3982. X    *'aaa' -> 1 and *'' -> 0 (the empty set)
  3983. XThere are some predefined sets like: &lcase :=: 'a b c d ... z'
  3984. Xothers are &ucase, &ascii (7-bits ascii set), &cset (the whole 256 range)
  3985. X
  3986. XConverting of a set to a string will cause the characters to appear as
  3987. Xan ASCII collating sequence. 
  3988. X
  3989. XStrings are represented in "double quotes". The amount of strings is
  3990. Xconceptually infinite.
  3991. XConcatenation:         s1 || s2    produces a NEW data object
  3992. XHow do you identify subsequences (linguistically spoken)
  3993. XEg.
  3994. X        s := "Front"        Positions are between
  3995. X    -5   -4   -3   -2   -1   0    characters, they can never
  3996. X       F    r    o    n    t    cut characters in parts.
  3997. X     1    2    3    4    5   6    
  3998. XPositive in respect to the first character. Negative or zero to the last data
  3999. X
  4000. XSo a substring goes from [2:-2] -> "ro"
  4001. XA substring is done with two indices hold in square braces:
  4002. X    s[i:j]
  4003. X    s[0:2]        # for right to left data
  4004. X    s[2:0]
  4005. XIf any of these indices are outside the string it will 'fail' which is
  4006. Xnot an error and can be checked on.
  4007. XEg. s[-2] == s[4]    s[i] == s[i:i+1] (i>0)    s[i+:j] == s[i:i+1]
  4008. X
  4009. Xs := "Front" then s[2] := "xy" will result in s := "Fxyont"
  4010. XYou can delete a character by s[i] := ""
  4011. XThis looks like a change of char in a string: it is not!
  4012. X
  4013. XExample:
  4014. X    i:=3    s:="Front"
  4015. X    j:=i    t:=s
  4016. X    i:=i+1    s[2]:="xy"
  4017. XYou don't expect that the value of the integer 'j' will be changed so
  4018. Xneither will 't'.
  4019. Xt:=s is a shorthand notation, it will never effect the string 's';
  4020. XSo not like in C. If the assignment would really copy the string than
  4021. Xyou would not worry about it. It is, however, pointer oriented.
  4022. X
  4023. XThe Icon memory is in fact one big string, being extented at the end and
  4024. Xhaving pointers all over the place.
  4025. X
  4026. XComparing strings
  4027. X    s1 == s2    "a" is lexicographically less than "aA"
  4028. X    s1 ~== s2
  4029. Xpage 33 has the six lexical operators.
  4030. X
  4031. X    End-of-course.9-3
  4032. END_OF_icon/course/course09.03
  4033. if test 4428 -ne `wc -c <icon/course/course09.03`; then
  4034.     echo shar: \"icon/course/course09.03\" unpacked with wrong size!
  4035. fi
  4036. # end of overwriting check
  4037. fi
  4038. if test -f icon/course/course09.10 -a "${1}" != "-c" ; then 
  4039.   echo shar: Will not over-write existing file \"icon/course/course09.10\"
  4040. else
  4041. echo shar: Extracting \"icon/course/course09.10\" \(4321 characters\)
  4042. sed "s/^X//" >icon/course/course09.10 <<'END_OF_icon/course/course09.10'
  4043. XRemember: everything what is not understood in these notes is
  4044. X      probably due to my typing (gertjan)
  4045. X
  4046. XGood Tuesday 11am Rm 321 Comp Sc building Univ. of Arizona, Tucson
  4047. XProf. Ralph Griswold teaches
  4048. X
  4049. XSome remarks about homework: Think Unix, that means do it terse, 
  4050. X                 only do what have been
  4051. X                 asked and supply a main procedure
  4052. X                 so that it can run!
  4053. X
  4054. XString construction operators -> return string, cannot fail
  4055. X-----------------------------
  4056. X    s1 || s2        reverse(s)
  4057. X    read(s1, s2)        trim(s, c)
  4058. X    right(   )        map(s1, s2, s3)
  4059. X    left(   )
  4060. X
  4061. XString analisys operation -> return number (index), it may fail
  4062. X-------------------------
  4063. X{you will actually hardly use the number, but use these
  4064. X            procedures as parameters to other procedures}
  4065. X
  4066. X    find(s1, s2)    match(s1, s2)
  4067. X
  4068. XThe remaining operations deal with character sets
  4069. X-------------------------------------------------
  4070. Xupto(c, s)  reads upto (before) the first char in s in cset c
  4071. Xany(c, s)   produces the position after the first char in s is
  4072. X        the first char c, or fail
  4073. Xmany(c, s)  same as 'any', but any char in c will do
  4074. Xbal(c1,c2,c3,c4)  a little horror
  4075. X
  4076. XKeep in mind that 'bal' is 'upto' with 2 additional args. Eg:
  4077. Xbal('+-*/', '(', ')', "(a+(c-d))") fails
  4078. Xbal('+-*/', '(', ')', "(a+(c-d))*d") succeeds and leaves index here |
  4079. X                ^___________________________________|
  4080. Xthe optional arguments, here '(' and ')', are optional char sets and set
  4081. Xdefault to '(' and ')'.
  4082. X
  4083. XLeft to right scanning is inheritated and part of all these
  4084. Xprocedures, like in english. It can be done right to left by
  4085. Xrewriting these procedures. Icon provides the tools for that with
  4086. Xits C interfacing (Personalized Icon).
  4087. XA good thing at least is that the positions are always between
  4088. Xcharacters, so at least that is consistent to left and right.
  4089. X
  4090. XStructures
  4091. X==========
  4092. XThese are really aggregates of variables, or values. There are
  4093. X
  4094. X    lists    these are like vectors, so not like in LISP
  4095. X    tables    set of pair of values, like fruit["apple"] := 2
  4096. X    records    like the records in PASCAL
  4097. X    sets    not mentioned in the book, part of Icon 5.9 and up *)
  4098. X        this are unordered collections of values and have the
  4099. X        properties normally associated with sets in the
  4100. X        mathematical sense.
  4101. X
  4102. X{ At the beginning of each course we install a new version of
  4103. XIcon, so you get 5.10 now. But we are not going to send it out of
  4104. Xtown before the end of the course! }
  4105. X
  4106. X*) I will try to get a copy of TR85-16 which gives an overview of
  4107. X5.10 and send it over (gertjan). Ask Larry Versaw for "Extensions
  4108. Xto Version 5 of the Icon Programming Language", TR-84-10b, that
  4109. Xtalks about sets.
  4110. X
  4111. XLists are linear, accessed positions. Eg.
  4112. X
  4113. X    a1 := [exp1, exp2, ..., expn]
  4114. X    a2 := list(i, expr)
  4115. X        like in a1 := [read(), 10, s1 || s2]
  4116. X
  4117. XSize operations succeed on lists as well, *a1 -> 3 (polymorphic)
  4118. XIndex referencing goes like in arrays
  4119. X    a1[2] subscribes the list
  4120. X    write(a1[2]) writes 10
  4121. Xlast subscript can be written as -1, a1[-1] -> s1 || s2
  4122. X
  4123. X    a1 ||| a2    three vertical bars concatenates lists 
  4124. X    a3 := a1 ||| a2 constructs a totally new list
  4125. X    a4 := a3[2:4]    [1, 2, "x", 13.7] -> [2, "x"]
  4126. X
  4127. XInteresting in lists are queue and stack acceses
  4128. X
  4129. X    push(a, x) like in    a := []        # empty list
  4130. X                while push(a, read())
  4131. X
  4132. X    pull <-    -------------------- <- push
  4133. X        |      LIST        |
  4134. X    put ->    -------------------- -> pop, get
  4135. X
  4136. XQuite important to realize is that Icon uses pointer semantics
  4137. Xfor structures. This will say that a:=list(1000000) result in a
  4138. Xpointer 'a'. What does  b:=a  mean?
  4139. XSome programming languages copy the content of structures. In Icon
  4140. Xit doesn't care what the value is, it copies the pointer. But
  4141. Xalso you can do interesting things like  a[2]:=a
  4142. X
  4143. XIf you read papers in the Police State of Programming, you find:
  4144. X                        pointers are harmful.
  4145. X
  4146. XThe  reason that we choose for pointer semantics is that in a
  4147. Xtypeless language you are forced to it. Motivation was:
  4148. Xwanting to have lists of lists, sets of sets, etc.
  4149. X
  4150. XBut it happens to be also efficient, although that was not the
  4151. Xreason. There is procedure called 'copy' what will it do for you.
  4152. X
  4153. XTrees and graphs can really represented isomorph. There is an
  4154. XIcon program library which has some procedures to make printable
  4155. Xrepresentation of structures in Icon. Ths is done quite primitive.
  4156. X
  4157. XThere is no facility to make pictures of this yet. Somebody wants
  4158. Xto do that?
  4159. X
  4160. X    end of course.9-10
  4161. END_OF_icon/course/course09.10
  4162. if test 4321 -ne `wc -c <icon/course/course09.10`; then
  4163.     echo shar: \"icon/course/course09.10\" unpacked with wrong size!
  4164. fi
  4165. # end of overwriting check
  4166. fi
  4167. if test -f icon/solution/sample.02 -a "${1}" != "-c" ; then 
  4168.   echo shar: Will not over-write existing file \"icon/solution/sample.02\"
  4169. else
  4170. echo shar: Extracting \"icon/solution/sample.02\" \(6062 characters\)
  4171. sed "s/^X//" >icon/solution/sample.02 <<'END_OF_icon/solution/sample.02'
  4172. X#     Extend your solution to include tables, sets, and record
  4173. X# types. You should handle structures that point to structures, but you
  4174. X# need not handle loops. You can continue to ignore "difficult"
  4175. X# characters in strings and csets. You should plan to make corrections
  4176. X# that may show up as a result of the grading of your original solution.
  4177. X# You also may wish to modify your previous solution to take advantage
  4178. X# of generators. The coding scheme is the same as before, with the
  4179. X# following additions: Sets are handled as lists by sorting them into
  4180. X# lists before encoding. Tables are handled similarly, with the default
  4181. X# value is kept as the first encoded value. For records, the record
  4182. X# type is also kept as the first encoded value. Note that when records
  4183. X# are reconstructed, a recored with no specified (i.e., null-valued)
  4184. X# fields is constructed using the string invocation extension in Version
  4185. X# 5.10.  The fields are then filled in using positional access.
  4186. X
  4187. Xlink "/usr/ralph/main"
  4188. X
  4189. Xprocedure code(x)
  4190. X   if match("record",image(x)) then return "R"
  4191. X   if type(x) == ("set" | "co-expression")
  4192. X      then return map(type(x)[1],&lcase,&ucase)
  4193. X   else return type(x)[1]
  4194. Xend
  4195. X
  4196. Xprocedure decode(s)
  4197. X   local p
  4198. X   every p := pair(s) do
  4199. X      suspend case p[1] of {
  4200. X         "i":  integer(p[2])
  4201. X         "s":  p[2]
  4202. X         "c":  cset(p[2])
  4203. X         "r":  real(p[2])
  4204. X         "n":  &null
  4205. X         "l":  delist(p[2])
  4206. X         "t":  detable(p[2])
  4207. X         "S":  deset(p[2])
  4208. X         "R":  derecord(p[2])
  4209. X         default: stop("unexpected type in decode: ",p[1])
  4210. Xend
  4211. X
  4212. Xprocedure delist(s)
  4213. X   local a
  4214. X   a := []
  4215. X   every put(a,decode(s))
  4216. X   return a
  4217. Xend
  4218. X
  4219. Xprocedure derecord(s)
  4220. X   local a,z,i
  4221. X   a := []
  4222. X   every put(a,decode(s))
  4223. X   z := a[1]()                   # string invocation to create record
  4224. X   every i:=1 to *(a[2]) do      # fill in the fields
  4225. X      z[i] := a[2][i]
  4226. X   return z
  4227. Xend
  4228. X
  4229. Xprocedure deset(s)
  4230. X   return set(decode(s))
  4231. Xend
  4232. X
  4233. Xprocedure detable(s)
  4234. X   local a,t,i
  4235. X   a := []
  4236. X   every put(a,decode(s))
  4237. X   t := table(a[1])              # first value is default for table
  4238. X   a := a[2]
  4239. X   every i:=1 to *a-1 by 2 do
  4240. X      t[a[i]] := a[i+1]
  4241. X   return t
  4242. Xend
  4243. X
  4244. Xprocedure encode(x)
  4245. X   local s,T
  4246. X   return case T := code(x) of {
  4247. X      "n":  "0n"
  4248. X      !"risc": {
  4249. X         s := string(x)
  4250. X         *s || T || s
  4251. X      }
  4252. X      "l":  enlist(x)
  4253. X      "S":  enset(x)
  4254. X      "t":  entable(x)
  4255. X      "R":  enrecord(x)
  4256. X      default: stop("unsupported type in encode ",image(x))
  4257. X   }
  4258. Xend
  4259. X
  4260. Xprocedure enlist(a)
  4261. X   local s
  4262. X   s := ""
  4263. X   every s ||:= encode(!a)
  4264. X   return *s || "l" || a
  4265. Xend
  4266. X
  4267. Xprocedure enrecord(x)
  4268. X   local s1,s2,a
  4269. X   s1 := encode(type(x))         # first value is record type
  4270. X   a := []
  4271. X   every put(a,!x)
  4272. X   s2 := enlist(a)
  4273. X   return (*s1 + *s2) || "R" || s1 || s2
  4274. Xend
  4275. X
  4276. Xprocedure enset(S)
  4277. X   local s
  4278. X   a := enlist(sort(S))
  4279. X   return *s || "S" || s
  4280. Xend
  4281. X
  4282. Xprocedure entable(t)
  4283. X   local a,s1,s2
  4284. X   a := sort(t,3)
  4285. X   s1 := encode(t[[]])           # default value
  4286. X   s2 := enlist(a)
  4287. X   return (*s1 + *s2) || "t" || s1 || s2
  4288. Xend
  4289. X
  4290. Xprocedure pair(s)
  4291. X   local i,j,k
  4292. X   j := 1
  4293. X   while i := many('0123456789',s,j) do {
  4294. X      k := integer(s[j:i])
  4295. X      suspend [s[i],s[i+1 +: k]]
  4296. X      j := i + k + 1
  4297. X   }
  4298. Xend
  4299. X
  4300. X                            end-of-solution 5
  4301. X# The coding scheme is the same as before, with the following additions:
  4302. X# Sets are handled as lists by sorting them into lists before
  4303. X# encoding. Tables are handled similarly, with the default value
  4304. X# is kept as the first encoded value. For records, the
  4305. X# record type is also kept as the first encoded value.
  4306. X# Note that when records are reconstructed, a recored with no specified
  4307. X# (i.e., null-valued) fields is constructed using the string invocation
  4308. X# extension in Version 5.10.  The fields are then filled in using positional
  4309. X# access.
  4310. X
  4311. Xlink "/usr/ralph/main"
  4312. X
  4313. Xprocedure code(x)
  4314. X   if match("record",image(x)) then return "R"
  4315. X   if type(x) == ("set" | "co-expression")
  4316. X      then return map(type(x)[1],&lcase,&ucase)
  4317. X   else return type(x)[1]
  4318. Xend
  4319. X
  4320. Xprocedure decode(s)
  4321. X   local p
  4322. X   every p := pair(s) do
  4323. X      suspend case p[1] of {
  4324. X         "i":  integer(p[2])
  4325. X         "s":  p[2]
  4326. X         "c":  cset(p[2])
  4327. X         "r":  real(p[2])
  4328. X         "n":  &null
  4329. X         "l":  delist(p[2])
  4330. X         "t":  detable(p[2])
  4331. X         "S":  deset(p[2])
  4332. X         "R":  derecord(p[2])
  4333. X         default: stop("unexpected type in decode: ",p[1])
  4334. Xend
  4335. X
  4336. Xprocedure delist(s)
  4337. X   local a
  4338. X   a := []
  4339. X   every put(a,decode(s))
  4340. X   return a
  4341. Xend
  4342. X
  4343. Xprocedure derecord(s)
  4344. X   local a,z,i
  4345. X   a := []
  4346. X   every put(a,decode(s))
  4347. X   z := a[1]()                   # string invocation to create record
  4348. X   every i:=1 to *(a[2]) do      # fill in the fields
  4349. X      z[i] := a[2][i]
  4350. X   return z
  4351. Xend
  4352. X
  4353. Xprocedure deset(s)
  4354. X   return set(decode(s))
  4355. Xend
  4356. X
  4357. Xprocedure detable(s)
  4358. X   local a,t,i
  4359. X   a := []
  4360. X   every put(a,decode(s))
  4361. X   t := table(a[1])              # first value is default for table
  4362. X   a := a[2]
  4363. X   every i:=1 to *a-1 by 2 do
  4364. X      t[a[i]] := a[i+1]
  4365. X   return t
  4366. Xend
  4367. X
  4368. Xprocedure encode(x)
  4369. X   local s,T
  4370. X   return case T := code(x) of {
  4371. X      "n":  "0n"
  4372. X      !"risc": {
  4373. X         s := string(x)
  4374. X         *s || T || s
  4375. X      }
  4376. X      "l":  enlist(x)
  4377. X      "S":  enset(x)
  4378. X      "t":  entable(x)
  4379. X      "R":  enrecord(x)
  4380. X      default: stop("unsupported type in encode ",image(x))
  4381. X   }
  4382. Xend
  4383. X
  4384. Xprocedure enlist(a)
  4385. X   local s
  4386. X   s := ""
  4387. X   every s ||:= encode(!a)
  4388. X   return *s || "l" || a
  4389. Xend
  4390. X
  4391. Xprocedure enrecord(x)
  4392. X   local s1,s2,a
  4393. X   s1 := encode(type(x))         # first value is record type
  4394. X   a := []
  4395. X   every put(a,!x)
  4396. X   s2 := enlist(a)
  4397. X   return (*s1 + *s2) || "R" || s1 || s2
  4398. Xend
  4399. X
  4400. Xprocedure enset(S)
  4401. X   local s
  4402. X   a := enlist(sort(S))
  4403. X   return *s || "S" || s
  4404. Xend
  4405. X
  4406. Xprocedure entable(t)
  4407. X   local a,s1,s2
  4408. X   a := sort(t,3)
  4409. X   s1 := encode(t[[]])           # default value
  4410. X   s2 := enlist(a)
  4411. X   return (*s1 + *s2) || "t" || s1 || s2
  4412. Xend
  4413. X
  4414. Xprocedure pair(s)
  4415. X   local i,j,k
  4416. X   j := 1
  4417. X   while i := many('0123456789',s,j) do {
  4418. X      k := integer(s[j:i])
  4419. X      suspend [s[i],s[i+1 +: k]]
  4420. X      j := i + k + 1
  4421. X   }
  4422. Xend
  4423. X
  4424. X                            end-of-solution 5
  4425. END_OF_icon/solution/sample.02
  4426. if test 6062 -ne `wc -c <icon/solution/sample.02`; then
  4427.     echo shar: \"icon/solution/sample.02\" unpacked with wrong size!
  4428. fi
  4429. # end of overwriting check
  4430. fi
  4431. if test -f icon/solution/sample.icn -a "${1}" != "-c" ; then 
  4432.   echo shar: Will not over-write existing file \"icon/solution/sample.icn\"
  4433. else
  4434. echo shar: Extracting \"icon/solution/sample.icn\" \(5019 characters\)
  4435. sed "s/^X//" >icon/solution/sample.icn <<'END_OF_icon/solution/sample.icn'
  4436. X# Devise a scheme for encoding the various types of data in Icon as
  4437. X# strings. Write a procedure encode(x) that encodes the value of x as a
  4438. X# string and a function decode(s) that produces value encoded in s. In
  4439. X# general
  4440. X# 
  4441. X#     x := decode(encode(y))
  4442. X# 
  4443. X# should result in x being assigned a value that is the same as the 
  4444. X# value of y, except that for structures, the values should be 
  4445. X# "similar", not identical. Thus, in
  4446. X# 
  4447. X#     a := []
  4448. X#     b := decode(encode(a))
  4449. X# 
  4450. X# the value assigned to b should be an empty list, but not the 
  4451. X# empty list that is the value of a.
  4452. X# 
  4453. X# This is the first phase of this problem. For this first phase, 
  4454. X# you should handle the null value, integers, real numbers, 
  4455. X# strings, csets, and lists. You need not to handle strings and 
  4456. X# csets that contain characters that would require escape 
  4457. X# conventions for their literal representation. You need not handle 
  4458. X# lists whose values are lists, and so on, but plan ahead.
  4459. X# 
  4460. X# Do not provide a main procedure. Instead, include the following 
  4461. X# declaration at the beginning of your program:
  4462. X# 
  4463. X#     link "/usr/ralph/main"
  4464. X# 
  4465. X# This will incorporate a main procedure that tests your encode and 
  4466. X# decode procedures. (This main procedure will remain the same 
  4467. X# until the assignment is due, unless you are informed otherwise, 
  4468. X# but will be changed when your assignment is run by the daemon.)
  4469. X# 
  4470. X# A value is encoded as a string consisting of three parts: 
  4471. X# giving the length of the encoded value itself, a character code for
  4472. X# the type of the value, and the encoded value. Examples:
  4473. X#
  4474. X#
  4475. X#  1        1i1
  4476. X#  "xyz"    3sxyz
  4477. X#  'abc'    3cabc
  4478. X#
  4479. X#
  4480. X# List are encoded similarly, except the encoded values of the elements
  4481. X# are simply concatenated and the total size is given at the beginning.
  4482. X# Example:
  4483. X#
  4484. X#  [1,"xyz",'abc']   13l1i13sxyz3cabc
  4485. X#
  4486. X
  4487. X#     Extend your solution to include tables, sets, and record
  4488. X# types. You should handle structures that point to structures, but you
  4489. X# need not handle loops. You can continue to ignore "difficult"
  4490. X# characters in strings and csets. You should plan to make corrections
  4491. X# that may show up as a result of the grading of your original solution.
  4492. X# You also may wish to modify your previous solution to take advantage
  4493. X# of generators. The coding scheme is the same as before, with the
  4494. X# following additions: Sets are handled as lists by sorting them into
  4495. X# lists before encoding. Tables are handled similarly, with the default
  4496. X# value is kept as the first encoded value. For records, the record
  4497. X# type is also kept as the first encoded value. Note that when records
  4498. X# are reconstructed, a recored with no specified (i.e., null-valued)
  4499. X# fields is constructed using the string invocation extension in Version
  4500. X# 5.10.  The fields are then filled in using positional access.
  4501. X
  4502. Xlink "/usr/ralph/main"
  4503. X
  4504. Xprocedure code(x)
  4505. X   if match("record",image(x)) then return "R"
  4506. X   if type(x) == ("set" | "co-expression")
  4507. X      then return map(type(x)[1],&lcase,&ucase)
  4508. X   else return type(x)[1]
  4509. Xend
  4510. X
  4511. Xprocedure decode(s)
  4512. X   local p
  4513. X   every p := pair(s) do
  4514. X      suspend case p[1] of {
  4515. X         "i":  integer(p[2])
  4516. X         "s":  p[2]
  4517. X         "c":  cset(p[2])
  4518. X         "r":  real(p[2])
  4519. X         "n":  &null
  4520. X         "l":  delist(p[2])
  4521. X         "t":  detable(p[2])
  4522. X         "S":  deset(p[2])
  4523. X         "R":  derecord(p[2])
  4524. X         default: stop("unexpected type in decode: ",p[1])
  4525. X      }
  4526. Xend
  4527. X
  4528. Xprocedure delist(s)
  4529. X   local a
  4530. X   a := []
  4531. X   every put(a,decode(s))
  4532. X   return a
  4533. Xend
  4534. X
  4535. Xprocedure derecord(s)
  4536. X   local a,z,i
  4537. X   a := []
  4538. X   every put(a,decode(s))
  4539. X   z := a[1]()                   # string invocation to create record
  4540. X   every i:=1 to *(a[2]) do      # fill in the fields
  4541. X      z[i] := a[2][i]
  4542. X   return z
  4543. Xend
  4544. X
  4545. Xprocedure deset(s)
  4546. X   return set(decode(s))
  4547. Xend
  4548. X
  4549. Xprocedure detable(s)
  4550. X   local a,t,i
  4551. X   a := []
  4552. X   every put(a,decode(s))
  4553. X   t := table(a[1])              # first value is default for table
  4554. X   a := a[2]
  4555. X   every i:=1 to *a-1 by 2 do
  4556. X      t[a[i]] := a[i+1]
  4557. X   return t
  4558. Xend
  4559. X
  4560. Xprocedure encode(x)
  4561. X   local s,T
  4562. X   return case T := code(x) of {
  4563. X      "n":  "0n"
  4564. X      !"risc": {
  4565. X         s := string(x)
  4566. X         *s || T || s
  4567. X      }
  4568. X      "l":  enlist(x)
  4569. X      "S":  enset(x)
  4570. X      "t":  entable(x)
  4571. X      "R":  enrecord(x)
  4572. X      default: stop("unsupported type in encode ",image(x))
  4573. X   }
  4574. Xend
  4575. X
  4576. Xprocedure enlist(a)
  4577. X   local s
  4578. X   s := ""
  4579. X   every s ||:= encode(!a)
  4580. X   return *s || "l" || a
  4581. Xend
  4582. X
  4583. Xprocedure enrecord(x)
  4584. X   local s1,s2,a
  4585. X   s1 := encode(type(x))         # first value is record type
  4586. X   a := []
  4587. X   every put(a,!x)
  4588. X   s2 := enlist(a)
  4589. X   return (*s1 + *s2) || "R" || s1 || s2
  4590. Xend
  4591. X
  4592. Xprocedure enset(S)
  4593. X   local s
  4594. X   a := enlist(sort(S))
  4595. X   return *s || "S" || s
  4596. Xend
  4597. X
  4598. Xprocedure entable(t)
  4599. X   local a,s1,s2
  4600. X   a := sort(t,3)
  4601. X   s1 := encode(t[[]])           # default value
  4602. X   s2 := enlist(a)
  4603. X   return (*s1 + *s2) || "t" || s1 || s2
  4604. Xend
  4605. X
  4606. Xprocedure pair(s)
  4607. X   local i,j,k
  4608. X   j := 1
  4609. X   while i := many('0123456789',s,j) do {
  4610. X      k := integer(s[j:i])
  4611. X      suspend [s[i],s[i+1 +: k]]
  4612. X      j := i + k + 1
  4613. X   }
  4614. Xend
  4615. END_OF_icon/solution/sample.icn
  4616. if test 5019 -ne `wc -c <icon/solution/sample.icn`; then
  4617.     echo shar: \"icon/solution/sample.icn\" unpacked with wrong size!
  4618. fi
  4619. # end of overwriting check
  4620. fi
  4621. if test -f icon/solution/solution.07 -a "${1}" != "-c" ; then 
  4622.   echo shar: Will not over-write existing file \"icon/solution/solution.07\"
  4623. else
  4624. echo shar: Extracting \"icon/solution/solution.07\" \(3679 characters\)
  4625. sed "s/^X//" >icon/solution/solution.07 <<'END_OF_icon/solution/solution.07'
  4626. X                    C.Sc. 550 - String and List Processing
  4627. X
  4628. X                 Suggested Solutions to Homework Assignment 7
  4629. X
  4630. X
  4631. X1. odd.icn
  4632. X
  4633. X   procedure odd(a)
  4634. X      while e1 := @a[1] do {
  4635. X         suspend e1
  4636. X         @a[1] | break
  4637. X      }
  4638. X   end
  4639. X
  4640. X
  4641. X2, coscan.icn
  4642. X
  4643. X   link "/usr/ralph/comain"
  4644. X
  4645. X   procedure Scan(a)                            # Scan{e1,e2}
  4646. X      local e1, e2, outersubj, innersubj, outerpos, innerpos
  4647. X
  4648. X      outersubj := &subject                     # save outer environment
  4649. X      outerpos := &pos
  4650. X      while e1 := @a[1] do {           # iterate over results of first argument
  4651. X         s := string(e1) | stop(
  4652. X            "Run-time error 103\nstring expected\noffending value:", image(e1))
  4653. X         &subject := s                          # set up the new environment
  4654. X         &pos := 1
  4655. X         while e2 := @a[2] do {       # iterate over results of second argument
  4656. X            innersubj := &subject               # save inner environment
  4657. X            innerpos := &pos
  4658. X            &subject := outersubj               # restore outer environment
  4659. X            &pos := outerpos
  4660. X            suspend e2                          # produce result
  4661. X            &subject := innersubj               # restore inner environment
  4662. X            &pos := innerpos
  4663. X         }
  4664. X         a[2] := ^a[2]                          # refresh second argument
  4665. X         &subject := outersubj                  # restore outer environment
  4666. X         &pos := outerpos
  4667. X      }
  4668. X   end
  4669. X
  4670. X   procedure main()
  4671. X      a := ["Hello", "world", "!"]
  4672. X      every write(Scan{!a, move(1 to 10) | tab(0 to -5 by -1)})
  4673. X      every snap("level zero")
  4674. X      &subject := "ABCDEF"
  4675. X      &pos := 4
  4676. X      snap(1) & Scan{"abcdef", tab(upto(&lcase)) & snap(2)} & snap(3) & &fail
  4677. X      every snap("the end")
  4678. X   end
  4679. X
  4680. X   procedure snap(i)
  4681. X      write("entering ", i)
  4682. X      write(&subject = ", &subject)
  4683. X      write(&pos = ", &pos)
  4684. X      suspend
  4685. X      write("resuming ", i)
  4686. X      write("&subject = ", &subject)
  4687. X      write("&pos = ", &pos)
  4688. X      fail
  4689. X   end
  4690. X
  4691. XThe correct output for this test is:
  4692. X
  4693. X   H
  4694. X   He
  4695. X   Hel
  4696. X   Hell
  4697. X   Hello
  4698. X   Hello
  4699. X   Hell
  4700. X   Hel
  4701. X   He
  4702. X   H
  4703. X
  4704. X   w
  4705. X   wo
  4706. X   wor
  4707. X   worl
  4708. X   world
  4709. X   world
  4710. X   worl
  4711. X   wor
  4712. X   wo
  4713. X   w
  4714. X
  4715. X   !
  4716. X   !
  4717. X
  4718. X   entering level zero
  4719. X   &subject = 
  4720. X   &pos = 1
  4721. X   resuming level zero
  4722. X   &subject = 
  4723. X   &pos = 1
  4724. X   entering 1
  4725. X   &subject = ABCDEF
  4726. X   &pos = 4
  4727. X   enetring 2
  4728. X   &subject = abcdef
  4729. X   &pos = 1
  4730. X   entering 3
  4731. X   &subject = ABCDEF
  4732. X   &pos = 4
  4733. X   resuming 3
  4734. X   &subject = ABCDEF
  4735. X   &pos = 4
  4736. X   resuming 2
  4737. X   &subject = abcdef
  4738. X   &pos = 1
  4739. X   entering 2
  4740. X   &subject = abcdef
  4741. X   &pos = 1
  4742. X   entering 3
  4743. X   &subject = ABCDEF
  4744. X   &pos = 4
  4745. X   resuming 3
  4746. X   &subject = ABCDEF
  4747. X   &pos = 4
  4748. X   resuming 2
  4749. X   &subject = abcdef
  4750. X   &pos = 2
  4751. X   entering 2
  4752. X   &subject = abcdef
  4753. X   &pos = 3
  4754. X   entering 3
  4755. X   &subject = ABCDEF
  4756. X   &pos = 4
  4757. X   resuming 3
  4758. X   &subject = ABCDEF
  4759. X   &pos = 4
  4760. X   resuming 2
  4761. X   &subject = abcdef
  4762. X   &pos = 3
  4763. X   entering 2
  4764. X   &subject = abcdef
  4765. X   &pos = 4
  4766. X   entering 3
  4767. X   &subject = ABCDEF
  4768. X   &pos = 4
  4769. X   resuming 3
  4770. X   &subject = ABCDEF
  4771. X   &pos = 4
  4772. X   resuming 2
  4773. X   &subject = abcdef
  4774. X   &pos = 4
  4775. X   entering 2
  4776. X   &subject = abcdef
  4777. X   &pos = 5
  4778. X   entering 3
  4779. X   &subject = ABCDEF
  4780. X   &pos = 4
  4781. X   resuming 3
  4782. X   &subject = ABCDEF
  4783. X   &pos = 4
  4784. X   resuming 2
  4785. X   &subject = abcdef
  4786. X   &pos = 5
  4787. X   entering 2
  4788. X   &subject = abcdef
  4789. X   &pos = 6
  4790. X   entering 3
  4791. X   &subject = ABCDEF
  4792. X   &pos = 4
  4793. X   resuming 3
  4794. X   &subject = ABCDEF
  4795. X   &pos = 4
  4796. X   resuming 2
  4797. X   &subject = abcdef
  4798. X   &pos = 6
  4799. X   resuming 1
  4800. X   &subject = ABCDEF
  4801. X   &pos = 4
  4802. X   entering the end
  4803. X   &subject = ABCDEF
  4804. X   &pos = 4
  4805. X   resuming the end
  4806. X   &subject = ABCDEF
  4807. X   &pos = 4
  4808. X
  4809. X                         end-of-solution-assignment-9
  4810. END_OF_icon/solution/solution.07
  4811. if test 3679 -ne `wc -c <icon/solution/solution.07`; then
  4812.     echo shar: \"icon/solution/solution.07\" unpacked with wrong size!
  4813. fi
  4814. # end of overwriting check
  4815. fi
  4816. echo shar: End of archive 3 \(of 3\).
  4817. cp /dev/null ark3isdone
  4818. MISSING=""
  4819. for I in 1 2 3 ; do
  4820.     if test ! -f ark${I}isdone ; then
  4821.     MISSING="${MISSING} ${I}"
  4822.     fi
  4823. done
  4824. if test "${MISSING}" = "" ; then
  4825.     echo You have unpacked all 3 archives.
  4826.     rm -f ark[1-9]isdone
  4827. else
  4828.     echo You still need to unpack the following archives:
  4829.     echo "        " ${MISSING}
  4830. fi
  4831. ##  End of shell archive.
  4832. exit 0
  4833. -- 
  4834. UUCP and other network      )\/(    ..!hp4nl!kunivv1!atcmpe!gertjan
  4835.   connections via mcvax      )/\(    gertjan@atcmp.nl (internet)
  4836. This note does not necessarily represent the position of AT Computing BV
  4837.  
  4838. From icon-group-request  Mon Feb 20 11:14:46 1989
  4839. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  4840.     id AA07327; Mon, 20 Feb 89 11:14:46 MST
  4841. Received: by ucbvax.Berkeley.EDU (5.61/1.34)
  4842.     id AA19732; Sat, 18 Feb 89 02:34:52 -0800
  4843. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  4844.     for icon-group@arizona.edu (icon-group@arizona.edu)
  4845.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  4846. Date: 16 Feb 89 17:47:48 GMT
  4847. From: mcvax!hp4nl!kunivv1!atcmpe!gertjan@uunet.uu.net  (Gertjan Vinkesteyn)
  4848. Organization: AT Computing, Nijmegen, The Netherlands
  4849. Subject: Re: Icon Lectures Part 2/3
  4850. Message-Id: <482@atcmpe.atcmp.nl>
  4851. References: <481@atcmpe.atcmp.nl>
  4852. Sender: icon-group-request@arizona.edu
  4853. To: icon-group@arizona.edu
  4854.  
  4855.  
  4856.  
  4857. #! /bin/sh
  4858. # This is a shell archive.  Remove anything before this line, then unpack
  4859. # it by saving it into a file and typing "sh file".  To overwrite existing
  4860. # files, type "sh file -c".  You can also feed this as standard input via
  4861. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  4862. # will see the following message at the end:
  4863. #        "End of archive 2 (of 3)."
  4864. # Contents:  icon/course/course09.05 icon/course/course09.19
  4865. #   icon/course/course10.01 icon/course/course10.17
  4866. #   icon/course/course10.22 icon/homework/assign.mid
  4867. #   icon/solution/solution.02 icon/solution/solution.04
  4868. #   icon/solution/solution.05 icon/solution/solution.09
  4869. # Wrapped by gertjan@atcmp.nl on Thu Feb 16 18:28:15 1989
  4870. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  4871. if test -f icon/course/course09.05 -a "${1}" != "-c" ; then 
  4872.   echo shar: Will not over-write existing file \"icon/course/course09.05\"
  4873. else
  4874. echo shar: Extracting \"icon/course/course09.05\" \(3315 characters\)
  4875. sed "s/^X//" >icon/course/course09.05 <<'END_OF_icon/course/course09.05'
  4876. XHOMEWORK for next Tuesday: Read Chapter V on Structures.
  4877. X
  4878. XRalph started out with talking about character sets and defending
  4879. Xhis choice for 8-bit character code.
  4880. X
  4881. XCHARACTER SETS:
  4882. X6-bits        BCD, CDC Display code
  4883. X7-bits        ASCII
  4884. X8-bits        EBCDIC
  4885. X9-bits        GE
  4886. X
  4887. XMore bits per character may blow up wordsize tables which are
  4888. Xexplained later on. The DEC-10 has the possibilty to specify the
  4889. Xbyte length. More than 8-bit character codes are mostly be used
  4890. Xin linguistics and typesetting.
  4891. XThere are also methods of encoding the output stream if you need
  4892. Xmore than 256 characters. Eg. for driving laser printers.
  4893. X
  4894. XEBCDIC has the advances that the ordening is more logical in the
  4895. Xsense that the value of "a" is "smaller" than "A" and "0" but
  4896. Xthere gaps in the sequence
  4897. X           129                     193
  4898. XEBCDIC        a ... i  -gap- j ... r -gap- s ... z -gap A ... etc
  4899. X
  4900. XThese gaps makes it quite bizarre. ASCII is at least contiguous.
  4901. X
  4902. X           48       65       97
  4903. XASCII        0 ... 9  A ... Z  a ... z
  4904. X
  4905. XIn Icon Version 5 the value of the characters is standarized. So
  4906. Xno matter what the inside character set is in the computer the
  4907. Xvalue of data in Icon is always in ASCII values. Even on an
  4908. XEBCDIC machine.
  4909. X
  4910. XC uses the {null} character as an end of string marker. In Icon
  4911. Xstrings are stored as a string AND a length. So storage goes
  4912. Xlike:
  4913. X                      -6-5-4-3-2-1 0    
  4914. X                       1 2 3 4 5 6 7
  4915. Xs := "abc" -|        a b c x y z
  4916. X(lgt = 3)   |        ^ ^          |-- t := s1[2:7]  (lgt = 5)
  4917. X            |-----------| |----------|
  4918. X              |        |---- s1 := s || "xyz" (lgt = 6)
  4919. X              |-------------|
  4920. X
  4921. XSo Icon stores strings packed. 
  4922. X
  4923. X    s[1] := "r"  or  s1 := "r" || s1[2:0]
  4924. XThis will construct a new string at the end of the string pool.
  4925. XIt is not plausible efficient to look for an already available
  4926. Xpattern in the string pool.
  4927. X
  4928. XSTRINGS:
  4929. XConcatenation        s3 := s1 || s2
  4930. XAnalytic        s[i:j]
  4931. X
  4932. XA rich set of functions is available
  4933. X
  4934. Xright(s1,i,s2)        |    string|    s2 is the filler string
  4935. Xleft(s1,i,s2)        |string    |    leaving out will be a blank
  4936. Xcenter(s1,i,s2)        |  string  |
  4937. X
  4938. XYou will always get a string of length i. s1 will be cut off, if
  4939. Xi is shorter than the length of the string. (No fun to implement this!)
  4940. X
  4941. Xrepl(s,i)    replicate a string
  4942. Xreverse(s)    reverse strings, its use is questionable
  4943. Xtrim(s,c)    remove blanks from card images
  4944. X
  4945. XAn real interesting function is 'map'.
  4946. X
  4947. Xmap(s1,s2,s3)    character mapping function
  4948. Xs1 := "abcabcca"
  4949. Xs2 := "a+c"
  4950. Xs3 := "z-z"
  4951. Xmap(s1,s2,s3) will then result in "zbzzbzzz"
  4952. X
  4953. Xmap(s,"aeiouAEIOU","++++++++++") replaces all vowels by "+"
  4954. X
  4955. XThe following program will highlight all the vowels in a string s:
  4956. X
  4957. X trim(map(s,&cset || &vowel, repl(" ",*&cset) || repl("|", *&vowel)))
  4958. Xso
  4959. X s := "boy this is something"
  4960. X write(s)
  4961. X write(trim(map(s...)))
  4962. X
  4963. Xwill result in
  4964. X
  4965. X    boy this is something
  4966. X         ||   |  |   | |  |
  4967. X
  4968. Xremark that it is only one statement doing this! The
  4969. Ximplementation of this is quite interesting. It is done by
  4970. Xcharacter mapping tables.
  4971. X
  4972. XSo in a table of 256 characters the "a" is 97 ascii. This becomes
  4973. X"|" which is value 124. Etc.
  4974. X
  4975. XThis table is cached, if you take it out the loop (as in map), it
  4976. Xwill not being rebuild. It is fast, much more faster than picking
  4977. Xup a character, change it value, etc.
  4978. X
  4979. XThis is not just a weird function, it was motivated because 'map'
  4980. Xwas hardwired in the IBM370 models.
  4981. X
  4982. X    end of course.9-5
  4983. END_OF_icon/course/course09.05
  4984. if test 3315 -ne `wc -c <icon/course/course09.05`; then
  4985.     echo shar: \"icon/course/course09.05\" unpacked with wrong size!
  4986. fi
  4987. # end of overwriting check
  4988. fi
  4989. if test -f icon/course/course09.19 -a "${1}" != "-c" ; then 
  4990.   echo shar: Will not over-write existing file \"icon/course/course09.19\"
  4991. else
  4992. echo shar: Extracting \"icon/course/course09.19\" \(2469 characters\)
  4993. sed "s/^X//" >icon/course/course09.19 <<'END_OF_icon/course/course09.19'
  4994. X              19 Sept 1985
  4995. X              ------------
  4996. X
  4997. XASSIGNMENT: Read up to chapter 10
  4998. X
  4999. XImplementations of Icon
  5000. X=======================
  5001. X1. Icon is supported by the NSF, so public domain
  5002. X2. Primary implemented on the UNIX Operating System
  5003. X   VAX, PDP11, Ridge-32 (RISC machine), SUN, AT&T 3B20, IBM PC (PC/IX),
  5004. X   UNIX-PC (AT&T 7300), various Motorola machines (Integrated Solutions)
  5005. X3. others: VAX/VMS, MSDOS (has a bug in co-expressions)
  5006. X
  5007. Xprocedures
  5008. X==========
  5009. X    p := write
  5010. X
  5011. XProgramming example as in passing on an actual parameter as procedure:
  5012. X
  5013. X    procedure foo(p,s)
  5014. X        p(s)
  5015. X    end
  5016. X
  5017. Xreturning
  5018. X---------
  5019. X    return [ expr ]     -> return result or fails if 'expr' fails
  5020. X    fail            -> does not return previous, fails
  5021. X    flowing off end        -> same as fail
  5022. X
  5023. Xwarning
  5024. X-------
  5025. X    syntactic shortcoming: Do no put anything behind 'return'.
  5026. X
  5027. Xrecursion
  5028. X=========
  5029. XLater on we will show some good examples on text. So for the time
  5030. Xwe use the boring numerical ones:
  5031. X
  5032. X    procedure fib(i)
  5033. X        if i = 1 then return 1
  5034. X        if i = 2 then return 2
  5035. X        return fib(i-1) + fib(i-2)
  5036. X    end
  5037. X
  5038. XThe only reason that this works is because 'fib' is a global
  5039. Xvariable. So placing 
  5040. X    local fib
  5041. Xin the body is disastrous (returns {null})
  5042. XAcceptable would be
  5043. X    local gib; gib := fib
  5044. X    ...
  5045. X    return gib(i-1) + gib(i+1)
  5046. X
  5047. XOrder of evaluation
  5048. X-------------------
  5049. X    Expr ( expr1, expr2, expr3, ..., exprn)
  5050. X        n+1     1      2      3           n
  5051. X
  5052. X'Expr' will fail if any of the others fail.
  5053. X
  5054. X    Too few parameters    -> null values supplied
  5055. X    Too many        -> discards
  5056. X
  5057. XArguments are not dereferenced until ALL are evaluated.
  5058. XThat means if you do things what you are not supposed to like in
  5059. X
  5060. X    trim(s,c,if i>j then trim := &null)
  5061. X
  5062. X    write(s,s:="x")    -> result "xx" no matter what
  5063. X
  5064. Xdereferencing
  5065. X=============
  5066. XThe dot before a variable will always cause it to dereference,
  5067. Xright to left assignment will always dererence. If you don't
  5068. Xtrust anything you could always use
  5069. X    .c    instead of    c
  5070. X
  5071. X    procedure calc(...)
  5072. X        local i
  5073. X        ...
  5074. X        return i        # dereferences
  5075. X    end
  5076. X
  5077. XCan you say:
  5078. X
  5079. X    calc(s) := 3
  5080. X
  5081. XIf the 'i' was global instead of local than 
  5082. X    calc(s) := 3    is the same as        i := 3
  5083. X
  5084. XWe could dereference everything but there is no need for.
  5085. XIt is not really a problem because it only can give a problem in
  5086. X    procedure := variable
  5087. X
  5088. X    procedure awful(s,i)
  5089. X        local s
  5090. X        return s[i]
  5091. X    end
  5092. X
  5093. XSo awful(x,3) := "xxx" would suggest s[i] := "xxx".
  5094. XWrong! Error message: assignment which is not a variable.
  5095. X
  5096. XThis is a language design issue, not part of this course.
  5097. X
  5098. X               end-of-course.9-19
  5099. END_OF_icon/course/course09.19
  5100. if test 2469 -ne `wc -c <icon/course/course09.19`; then
  5101.     echo shar: \"icon/course/course09.19\" unpacked with wrong size!
  5102. fi
  5103. # end of overwriting check
  5104. fi
  5105. if test -f icon/course/course10.01 -a "${1}" != "-c" ; then 
  5106.   echo shar: Will not over-write existing file \"icon/course/course10.01\"
  5107. else
  5108. echo shar: Extracting \"icon/course/course10.01\" \(2681 characters\)
  5109. sed "s/^X//" >icon/course/course10.01 <<'END_OF_icon/course/course10.01'
  5110. X             C.Sc. 550 - String and List Processing
  5111. X                             10/1/85
  5112. X
  5113. XToday we are talking on the concept of GENERATORS.
  5114. X
  5115. Xgenerators
  5116. X----------
  5117. X
  5118. XTogether with `string-scanning' and `co-expressions' belong 
  5119. X`generators' to the extension of the `basics' of Icon.
  5120. XGenerators are quite important and we will spend quite a bit of 
  5121. Xtime on it. Why? Because I like it. (Griswold)
  5122. X
  5123. XConsider s1:="Here are later answers"
  5124. X           |          |      |
  5125. X           2          13     20
  5126. X
  5127. X  every i := find("er", s1) do write(i)
  5128. X
  5129. XThis results in a zero length result sequence.
  5130. XIt fails only if it produces no result at all.
  5131. X
  5132. X    5 + find("er", s1) -> {7, 18, 25}
  5133. X
  5134. XThe do clause is optional, another way of writing is  every write("er",s1))
  5135. X
  5136. XThis one is a better way of writing it and produces more efficient code.
  5137. XIf you compare
  5138. X    every write(find("er",s1))    outcome does not have a result
  5139. X    write(every find("er",s1))    outcome will fail (so not very helpful)
  5140. X
  5141. Xa break is permitted like in
  5142. X    every e1 do { ... break ... }
  5143. X
  5144. XThe expression
  5145. X    while i:=find("er",s1) do write(i)
  5146. Xis not a generator and will produces only 2's
  5147. X
  5148. Xgoal-directed evaluation (GDE)
  5149. X------------------------
  5150. X    if find("er",s1) > 10 then e1 else e2
  5151. X
  5152. XThe evaluation tries to find a position in s1 > 10. So GDE goes on till it 
  5153. Xfinds the first result. In the previous example of s1:="Here are later answers"
  5154. Xthe result of the if clause is
  5155. X    {2, 13 20} -> 13 and is > 10
  5156. X
  5157. XExample:
  5158. X    if 18 > find("er",s1) > 10 then e2 else e3
  5159. X
  5160. XYou find this through the whole language. PROLOG has some of it.
  5161. X
  5162. X    every write(find(s1,s2) = find(s3,s4))
  5163. X
  5164. Xgives all the possible results. 'S' stands for 'result-sequence'
  5165. X
  5166. X    s1 := "Here are later answers"
  5167. X    s2 := "Here are later results to read"
  5168. X
  5169. X1)    S(find("er",s1)) = {2,13,20}
  5170. X2)    S(find("re",s2)) = {3,7,16,27}
  5171. X
  5172. X    S(find("er",s1)) + find("re",s2))
  5173. X
  5174. Xevaluation: In all operations there is left to right evaluation
  5175. Xresumption: Last in, first out. All resumption are LIFO
  5176. X
  5177. X    1) + 2)        = {5,9,18,29,16,20,29,40,23,27,36,47}
  5178. X    2  +  3
  5179. X    2  +  7
  5180. X    2  + 16        If the operator was > instead of +
  5181. X    2  + 27        the result sequence is
  5182. X    13 +  3        {3,7,3,7,16}
  5183. X       .
  5184. X           .        The result sequence is {}
  5185. X           .        if the operator is =
  5186. X    20 + 27
  5187. X
  5188. XOther generators:
  5189. X
  5190. X    1 to 10    -> {1,2,3,4,5,6,7,8,9,10}
  5191. X
  5192. Xwhat does     every i:=1 to 10 do f(i)
  5193. X
  5194. XIn Icon this is easier composed than in Algol like languages
  5195. Xeasier written as
  5196. X        every if(1 to 10)
  5197. X
  5198. XThis takes some getting used to. This is a conceptual change from other 
  5199. Xlanguages. You have to see how to use this. It is hard to brak from C like 
  5200. Xprejustice.
  5201. X
  5202. XThis is the point in the the course that you can get lost.
  5203. XSo ask QUESTIONS if you have any.
  5204. X
  5205. X    end-of-course 10-1-85
  5206. END_OF_icon/course/course10.01
  5207. if test 2681 -ne `wc -c <icon/course/course10.01`; then
  5208.     echo shar: \"icon/course/course10.01\" unpacked with wrong size!
  5209. fi
  5210. # end of overwriting check
  5211. fi
  5212. if test -f icon/course/course10.17 -a "${1}" != "-c" ; then 
  5213.   echo shar: Will not over-write existing file \"icon/course/course10.17\"
  5214. else
  5215. echo shar: Extracting \"icon/course/course10.17\" \(3283 characters\)
  5216. sed "s/^X//" >icon/course/course10.17 <<'END_OF_icon/course/course10.17'
  5217. X                    C.Sc. 550 - String and List Processing
  5218. X
  5219. X                                 85/10/17
  5220. X
  5221. XDiscussion Midterm Examination
  5222. XHanding out homework #6
  5223. XRead Chapt 13  co-expressions
  5224. X
  5225. XString Scanning
  5226. X===============
  5227. X
  5228. XFinishing up this subject today. This is together with 'generator' and 'co-
  5229. Xexpression' one of the most important features of Icon.
  5230. X
  5231. XString scanning, or pattern matching, was the reason behind Snobol4. Pattern 
  5232. Xand pattern matching in Snobol motivated Icon.
  5233. X
  5234. XMotivation: get a higher level of string scanning, especially for analysis 
  5235. Xdecoding information (and to less extent for synthesis).
  5236. XAutomatically handling of string position, etc.
  5237. Xone string - subject
  5238. Xone place (focus) for attention - position
  5239. XOperator is ? like in   s ? expr
  5240. X
  5241. XExample:
  5242. X   while line := read() do {                 # low level
  5243. X      i := 1                                 # programming
  5244. X      while j := upto(wchar,line,i) do {
  5245. X         i := many(wchar,line,j)
  5246. X         words[line[i:j]] +:= 1
  5247. X      }
  5248. X   }
  5249. X
  5250. X   s ? expr    tab(i)   sets position to i
  5251. Xline ? expr    move(i)  increment position by i
  5252. X
  5253. Xthese are called -> matching functions
  5254. X
  5255. X   upto(wchar) is then  upto(wchar,"subject","position")
  5256. X
  5257. XSo
  5258. X   while line := read() do {
  5259. X      line ? while tab(upto(wchar)) {
  5260. X         words[tab(many(wchar))] +:= 1
  5261. X      }
  5262. X   }
  5263. X
  5264. XSo you don't have to mention i,j,line etc. This is 2/3 of the story of string 
  5265. Xscanning. This way of programming is very difficult programming, so I warn you 
  5266. Xthat you get frustated about it. But it pays off!
  5267. X
  5268. XIn general the outcome of  s?expr
  5269. X        is the outcome of  expr
  5270. X
  5271. XThere is also an augentation ?: operator. Take care because of precedence. 
  5272. XLike 
  5273. X   s ? expr1 & expr2    groups as  (s ? expr1) & expr2
  5274. XSo use braces as in 
  5275. X   s ? (expr1 & expr2)
  5276. X
  5277. Xexpr1 ? expr2  both expressions can be generators.
  5278. X
  5279. X                             L(S(expr1))
  5280. X   S(expr1 ? expr2) = S(expr2)
  5281. X
  5282. X      ^
  5283. X      |__ this is a control structure and not an operation
  5284. X
  5285. X             ( operators + - * ...
  5286. X   operation <                      evaluation always from left to right
  5287. X             ( functions: to by
  5288. X
  5289. XString scanning is a control structure. You evaluate expr1 to set the subject 
  5290. Xand the position and then you do expr2. So before the operation is done before 
  5291. Xall the evaluation is done.
  5292. X
  5293. X   &subject    is used for non-Icon matching procedures
  5294. X   &pos
  5295. X
  5296. X      &subject := read()   side effect &pos := 1
  5297. X
  5298. Xstacking subjects
  5299. X
  5300. X   if s ? expr
  5301. X
  5302. XThe subject is restored afterwards as it was before. The environment saving 
  5303. Xand restoring is dynamic. So
  5304. X
  5305. X   every (s ? expr1) ? expr2
  5306. X
  5307. Xdoes what you expect it to do.
  5308. X
  5309. Xdata-backtracking
  5310. X=================
  5311. X
  5312. X   tab(i) & move(17)    if move fails it resumes as before tab(i).
  5313. X
  5314. XThe assignment of the position is implicit here
  5315. X
  5316. X   expr1 |  if expr1 fails it restores the subject so
  5317. X   expr2 |  you can count on it by going in to expr2
  5318. X   expr3    etc.
  5319. X
  5320. XCurious effects:
  5321. X
  5322. X   while tab(upto(wchar)) do
  5323. X      suspend tab(many(wchar))
  5324. X
  5325. XSo this is not a generator because this is a programming pitfall!!
  5326. XHow do you prefend this? One way is
  5327. X
  5328. X   while tab(upto(wchar)) do {
  5329. X      word := tab(many(wchar))
  5330. X      suspend word
  5331. X   }
  5332. Xanother way, replace
  5333. X      suspend tab(many(wchar))
  5334. Xby
  5335. X      suspend tab(many(wchar)) \ 1
  5336. X
  5337. XTHIS PITFALL IS GROSS..!
  5338. X
  5339. END_OF_icon/course/course10.17
  5340. if test 3283 -ne `wc -c <icon/course/course10.17`; then
  5341.     echo shar: \"icon/course/course10.17\" unpacked with wrong size!
  5342. fi
  5343. # end of overwriting check
  5344. fi
  5345. if test -f icon/course/course10.22 -a "${1}" != "-c" ; then 
  5346.   echo shar: Will not over-write existing file \"icon/course/course10.22\"
  5347. else
  5348. echo shar: Extracting \"icon/course/course10.22\" \(2874 characters\)
  5349. sed "s/^X//" >icon/course/course10.22 <<'END_OF_icon/course/course10.22'
  5350. X                    C.Sc. 550 - String and List Processing
  5351. X
  5352. X                                 85/10/22
  5353. X
  5354. X
  5355. XEvaluation order and Resuming
  5356. X
  5357. X      e1 ? e2 -> Escan ( Bscan (e1), e2 )
  5358. X                   4       2     1    3
  5359. X
  5360. XIf you can see this without looking at the code, you understand what is going 
  5361. Xon.
  5362. X
  5363. X   record ScanState(subject,pos)
  5364. X
  5365. X   procedure Bscan(e1)
  5366. X      .
  5367. X      . 
  5368. X      CenterState := ScanState(&subject,&pos)
  5369. X      &subject := s
  5370. X      &pos := 1
  5371. X      suspend OuterState                  # 1 and 2 done
  5372. X      &subject := OuterState.subject
  5373. X      &pos := OuterState.pos
  5374. X   end
  5375. X
  5376. X   procedure Escan(OuterState,e2)
  5377. X      local InnerState
  5378. X      InnerState := ScanState(&subject,&pos)
  5379. X      &subject := OuterState.subject
  5380. X      &pos := OuterState.pos
  5381. X      suspend e2                          # at this point, the whole thing is 
  5382. X                                          # succeeded. Itonly resumes unless                                           
  5383. X# another result is requested.
  5384. X      &subject := InnerState.subj
  5385. X      &pos := InnerState.pos
  5386. X      fail
  5387. X   end
  5388. X
  5389. XLater on if we get further on string scanning (this is only the surface) we 
  5390. Xwill do more on this. We have some programs to display the state of scanning 
  5391. Xon a SUN. The book is not really indepth on this.
  5392. X
  5393. X   e0 & ( e1 ? e2 ) & e3
  5394. Xouterstate        outerstate
  5395. X         innerstate
  5396. X
  5397. XA practical example: f("abc" ? e1)
  5398. X
  5399. XThe trick to all of this, write these procedures as reversable arguments.
  5400. XThis mechanism is a rather general way and this can be part of a database, 
  5401. Xetc.
  5402. X
  5403. XCo-expressions
  5404. X==============
  5405. X
  5406. XThey were added later on to solve a difficulty.
  5407. X   e1 +o e2 gives a kind of cross product evaluation, e1 will only go to next 
  5408. Xone if all of e2 is evaluated. This is built in to Icon and does mean that you 
  5409. Xcannot do certain things. See intro Chapter 13.
  5410. X
  5411. X   S(!&lcase) = {"a", "b", ..., "z"}
  5412. X   e1 := create !&lcase
  5413. X   e2 := create !&ucase
  5414. X
  5415. X   So first time     write(@e1) -> "a"
  5416. X   second time       write(@e1) -> "b"
  5417. X                     write(@e2) -> "A"
  5418. X   then
  5419. X      while write(@e1, @e2)
  5420. X      ->    cB
  5421. X            dC
  5422. X            .
  5423. X            .
  5424. X            zY
  5425. X
  5426. X   this fails and stops the loop (and no core dump anymore in Version 5.10!!!)
  5427. X
  5428. Xwhat is this good for?
  5429. X   label generating in assembly/compiler
  5430. X   labgen := create "L" || (1 to 1000)
  5431. X      .
  5432. X      .
  5433. X   @labgen
  5434. X
  5435. Xif you want to reset the co-expression
  5436. X
  5437. X   e1 := ^e1                     # refresh, uses a different copy
  5438. X
  5439. XExample
  5440. X-------
  5441. X   procedure Labgengen(s,i,j)
  5442. X      return creat (s || (i to j + 100))
  5443. X   end
  5444. X
  5445. X   s,i,j are local
  5446. X   but it returns a dat-object
  5447. X
  5448. X      X := labgengen("L",1000,1003)
  5449. X
  5450. X   what actually happens is that co-expression make copies of all the local 
  5451. Xvariables at the time the create is done. So, copies s,i, and j.
  5452. X
  5453. XEvery co-expression has its own stack
  5454. X
  5455. X                             end-of-course-10.22
  5456. END_OF_icon/course/course10.22
  5457. if test 2874 -ne `wc -c <icon/course/course10.22`; then
  5458.     echo shar: \"icon/course/course10.22\" unpacked with wrong size!
  5459. fi
  5460. # end of overwriting check
  5461. fi
  5462. if test -f icon/homework/assign.mid -a "${1}" != "-c" ; then 
  5463.   echo shar: Will not over-write existing file \"icon/homework/assign.mid\"
  5464. else
  5465. echo shar: Extracting \"icon/homework/assign.mid\" \(2828 characters\)
  5466. sed "s/^X//" >icon/homework/assign.mid <<'END_OF_icon/homework/assign.mid'
  5467. X                                                    Name: ___________________
  5468. X
  5469. X
  5470. X                                  Midterm 1
  5471. X
  5472. XGeneral Instructions: 
  5473. XThis is a closed book examination. Show all your work. Use the backs of pages 
  5474. Xif necessary, but be sure to mark such work clearly. Cross out any work you do 
  5475. Xnot want to be considered in grading. If you can not do all of a problem, do 
  5476. Xwhat you can and indicate what you have in mind for the remaining portion - 
  5477. Xpartial credit will be given. If you make an assumption in interpreting a 
  5478. Xproblem, state that assumption. If you do not recall sopme detail of Icon, do 
  5479. Xthe best you can and explain what you have in mind.
  5480. X
  5481. XNote: Style counts. In the case of programming problems, produce the best 
  5482. Xprogram you can.
  5483. X
  5484. X
  5485. X1. (16 points) Write a program that counts the number of times each different 
  5486. Xcharactert occurs in the input file and writes out the results. For example, 
  5487. Xfor the input file
  5488. X
  5489. X   Of the bells, bells, bells, bells,
  5490. X   Bells, bells, bells-
  5491. X
  5492. Xthe output might look like
  5493. X
  5494. X   :     7
  5495. X  ,:     6
  5496. X  -:     1
  5497. X  B:     1
  5498. X  O:     1
  5499. X  b:     6
  5500. X  e:     8
  5501. X  f:     1
  5502. X  h:     1
  5503. X  l:    14
  5504. X  s:     7
  5505. X  t:     1
  5506. X
  5507. X
  5508. X2. (25 points) After evaluation of
  5509. X
  5510. X   a := [5,10]
  5511. X
  5512. Xthe value of a can be diagrammed as follows
  5513. X           --------
  5514. X   a ----->|    5 |
  5515. X           |------|
  5516. X           |   10 |
  5517. X           --------
  5518. X
  5519. XAssuming a has this value originally, diagram the value of a, b, and c as they 
  5520. Xare after completion of the evaluation of the following epression:
  5521. X
  5522. X   push(a,15)
  5523. X   b := a
  5524. X   put(b,20)
  5525. X   c := [a,30]
  5526. X   c[2] := b
  5527. X   b[2] := c
  5528. X
  5529. X
  5530. X3. (24 points) Show the result sequences for the following expressions. If 
  5531. Xa result is infinite, indicate that by ellipses. For example, the result 
  5532. Xsequence for |1 should be shown as {1,1,1,...}.
  5533. X
  5534. X   (1)   (1 to 3) + 4
  5535. X
  5536. X   (2)   (1|2) to (3|4)
  5537. X
  5538. X   (3)   (2 to 4) - (1 to 3)
  5539. X
  5540. X   (4)   (|(1 to 3)) \ 4
  5541. X
  5542. X   (5)   (1 to 3) || (1 to 3)
  5543. X
  5544. X   (6)   (|(1 to 3)) | (|(2 to 4))
  5545. X
  5546. X   (7)   (|(1 to 5)) \ (3|0)
  5547. X
  5548. X   (8)   (1 to 20) = (5 to 15)
  5549. X
  5550. X
  5551. X4. (15 points) Write a procedure that 'generates' the factorials of the 
  5552. Xpositive integers in increasing order: 1, 2, 6, 24, 120, ...
  5553. X
  5554. X
  5555. X5. (20 points) Using the following notation for result sequences:
  5556. X
  5557. X      S(expr)  the result sequence for expr
  5558. X
  5559. X      L(expr)  the length of the result sequence for expr
  5560. X
  5561. X      S1 +o S2 the concatenation of the result seqeunces S1 and S2
  5562. X
  5563. X      /o       the empty result sequence
  5564. X
  5565. X
  5566. X   (a) Give the result sequence for
  5567. X
  5568. X      (expr1 & expr2) | expr3
  5569. X
  5570. Xin terms of the result sequences for expr1, expr2, and expr3. Assume that 
  5571. Xexpr1, expr2, and expr3 are self-contained.
  5572. X
  5573. X   (b) Under what circumstances is the result sequence for the expression 
  5574. Xabove the same as the result sequence for
  5575. X
  5576. X   if expr1 then expr2 else expr3
  5577. X
  5578. X                             end-of-Midterm-1
  5579. END_OF_icon/homework/assign.mid
  5580. if test 2828 -ne `wc -c <icon/homework/assign.mid`; then
  5581.     echo shar: \"icon/homework/assign.mid\" unpacked with wrong size!
  5582. fi
  5583. # end of overwriting check
  5584. fi
  5585. if test -f icon/solution/solution.02 -a "${1}" != "-c" ; then 
  5586.   echo shar: Will not over-write existing file \"icon/solution/solution.02\"
  5587. else
  5588. echo shar: Extracting \"icon/solution/solution.02\" \(2363 characters\)
  5589. sed "s/^X//" >icon/solution/solution.02 <<'END_OF_icon/solution/solution.02'
  5590. X
  5591. X
  5592. XSuggested Solutions to Homework Assignment 2
  5593. X
  5594. X1. concord.icn
  5595. X
  5596. Xprocedure main()
  5597. X    letters := &lcase ++ &ucase
  5598. X    words := table("")
  5599. X    maxword := lineno := 0
  5600. X    while line := read() do {
  5601. X        lineno +:= 1
  5602. X        write(right(lineno,6)," ",line)
  5603. X        line := map(line)            # fold to lowercase
  5604. X        i := 1
  5605. X        while j := upto(letters,line,i) do {
  5606. X            i := many(letters,line,j)
  5607. X            word := line[j:i]
  5608. X            if *word < 3 then next        # skip short words
  5609. X            maxword <:= *word    # keep track of longes word
  5610. X                        # if it's a new word, start set
  5611. X            if *words[word] = 0 then words[word] := set([lineno])
  5612. X            else insert(words[word],lineno) # else add line number
  5613. X            }
  5614. X        }
  5615. X    write()
  5616. X    wordlist := sort(words,3)        # sort by words
  5617. X    i := 1
  5618. X    while word := wordlist[i] do {
  5619. X        lines := ""            # build up line numbers
  5620. X        numbers := sort(wordlist[i+1])
  5621. X        while lines ||:= get(numbers) || ","
  5622. X        write(left(word,maxword+2), ": ",lines[2])
  5623. X        i +:= 2
  5624. X        }
  5625. Xend
  5626. X
  5627. X
  5628. X2. rational.icn
  5629. X
  5630. Xrecord rational(numer,denom)
  5631. X
  5632. Xprocedure main()
  5633. X    test()                    # put test procedure elsewhere
  5634. Xend
  5635. X
  5636. Xprocedure strrat(s)
  5637. X    i := find("/",s)
  5638. X    return reduce(s[1:i],s[i+1:0])
  5639. Xend
  5640. X
  5641. Xprocedure ratstr(r)
  5642. X    return r.numer || "/" || r.denom
  5643. Xend
  5644. X
  5645. Xprocedure reduce(numer,denom)
  5646. X    if denom = 0 then stop("zero denominator")
  5647. X    if numer = 0 then return rational(0,1)
  5648. X    if denom < 0 then {
  5649. X        numer := -numer
  5650. X        denom := -denom
  5651. X        }
  5652. X    divisor := gcd(abs(numer),denom)
  5653. X    return rational(numer/divisor,denom/divisor)
  5654. Xend
  5655. X
  5656. Xprocedure gcd(i,j)
  5657. X    repeat {
  5658. X        rem := i % j
  5659. X        if rem = 0 then return j
  5660. X        i := j
  5661. X        j := rem
  5662. X        }
  5663. Xend
  5664. X
  5665. Xprocedure mpyrat(r1,r2)
  5666. X    return reduce(r1.numer * r2.numer, r1.denom * r2.denom)
  5667. Xend
  5668. X
  5669. Xprocedure addrat(r1,r2)
  5670. X    return reduce(r1.numer * r2.denom + r2.numer * r1.denom,
  5671. X            r1.denom * r2.denom)
  5672. Xend
  5673. X
  5674. Xprocedure test()
  5675. X    ratlist := []
  5676. X    nlist := [0,1,-1036,-5]
  5677. X    dlist := [1,13,-144]
  5678. X    write("testing conversion")
  5679. X    i := 1
  5680. X    while numer := nlist[i] do {
  5681. X        i +:= 1
  5682. X        j := 1
  5683. X        while denom := dlist[j] do {
  5684. X            j +:= 1
  5685. X            s := numer || "/" || denom
  5686. X            r := strrat(s)
  5687. X            write(s," = ",ratstr(r))
  5688. X            put(ratlist,strrat(s))
  5689. X            }
  5690. X        }
  5691. X    write()
  5692. X    write("testing arithmetic:")
  5693. X    i := 1
  5694. X    while r1 := ratlist[i] do {
  5695. X        i +:= 1
  5696. X        j := 1
  5697. X        while r2 := ratlist[j] do {
  5698. X            j +:= 1
  5699. X        write("(",ratstr(r1),")+(",ratstr(r2),")=",ratstr(addrat(r1,r2)))
  5700. X        write("(",ratstr(r1),")*(",ratstr(r2),")=",ratstr(mpyrat(r1,r2)))
  5701. X              }
  5702. X        }
  5703. X    write("checking zero denominator")
  5704. X    strrat("13/0")
  5705. Xend
  5706. END_OF_icon/solution/solution.02
  5707. if test 2363 -ne `wc -c <icon/solution/solution.02`; then
  5708.     echo shar: \"icon/solution/solution.02\" unpacked with wrong size!
  5709. fi
  5710. # end of overwriting check
  5711. fi
  5712. if test -f icon/solution/solution.04 -a "${1}" != "-c" ; then 
  5713.   echo shar: Will not over-write existing file \"icon/solution/solution.04\"
  5714. else
  5715. echo shar: Extracting \"icon/solution/solution.04\" \(3420 characters\)
  5716. sed "s/^X//" >icon/solution/solution.04 <<'END_OF_icon/solution/solution.04'
  5717. X                 Suggested Solutions to Homework Assignment 4
  5718. X
  5719. X1. balexp.icn
  5720. X
  5721. X   procedure main()
  5722. X      while line := read() do {
  5723. X         bar := repl(" ",*line)
  5724. X         every bar[bal('+-*',,,line)] := "|"
  5725. X         write(line,"\n",trim(bar))
  5726. X      }
  5727. X   end
  5728. X
  5729. X
  5730. X2. code.icn
  5731. X
  5732. X   # A value is encoded as a string consisting of three parts: 
  5733. X   # giving the length of the encoded value itself, a character code for
  5734. X   # the type of the value, and the encoded value. Examples:
  5735. X   #
  5736. X   #
  5737. X   #  1        1i1
  5738. X   #  "xyz"    3sxyz
  5739. X   #  'abc'    3cabc
  5740. X   #
  5741. X   #
  5742. X   # List are encoded similarly, except the encoded values of the elements
  5743. X   # are simply concatenated and the total size is given at the beginning.
  5744. X   # Example:
  5745. X   #
  5746. X   #  [1,"xyz",'abc']   13l1i13sxyz3cabc
  5747. X   #
  5748. X
  5749. X   link "/usr/ralph/main"
  5750. X
  5751. X   procedure decode(s)     # generate pair of form [code,string]
  5752. X      every p := pair(s) do
  5753. X         suspend case p[1] of {
  5754. X            "i":  integer(p[2])
  5755. X            "a":  p[2]
  5756. X            "c":  cset(p[2])
  5757. X            "r":  real(p[2])
  5758. X            "n":  &null
  5759. X            "l":  delist(p[2])
  5760. X            default: stop("unexpected type in decode: ",x)
  5761. X         }
  5762. X   end
  5763. X
  5764. X   procedure delist(s)
  5765. X      a := []
  5766. X      every put(a,decode(s))
  5767. X      return a
  5768. X   end
  5769. X
  5770. X   procedure encode(x)
  5771. X      return case T := code(x) of {
  5772. X         "n":  "0n"
  5773. X         !"risc": {              # reals, integers, strings, and csets are
  5774. X        #N6 := string(x)       # encoded the same way
  5775. X            *s || T || s
  5776. X         }
  5777. X         "l":  enlist(x)
  5778. X         default: stop("unsupported type: ",image(x))
  5779. X      }
  5780. X   end
  5781. X
  5782. X   procedure enlist(a)
  5783. X      s := ""
  5784. X      every s ||:= encode(!a)    # concatenate the encoded elements
  5785. X      return *s || "l" || s
  5786. X   end
  5787. X
  5788. X   procedure pair(s)             # parse a value and generate pairs
  5789. X                                 # of the form [code,string]
  5790. X      local i,j,k
  5791. X      j := 1
  5792. X      while i := many('0123456789',s,j) do {
  5793. X         k := integer(s[j:i]) | stop("size coding error")
  5794. X         suspend [s[i],s[i+1 +: k]]
  5795. X         j := i + k + 1
  5796. X      }
  5797. X   end
  5798. X
  5799. X   procedure code(x)          # plan ahead; generate unique type code letters
  5800. X      if type(x) == "set" then return "S"
  5801. X      else return type(x)[1]
  5802. X   end
  5803. X
  5804. X   #
  5805. X   # main program used for most tests
  5806. X   #
  5807. X   procedure main()
  5808. X      values := [&null,1,2.0,'abc',"abc"]
  5809. X      every write(image(decode(encode(!values))))
  5810. X      s := encode(values)
  5811. X      write(s)
  5812. X      a := decode(s)
  5813. X      write(image(a),": ",image(values))
  5814. X      every i:=1 to *a do
  5815. X         write(image(a[i]),": ",image(values[i]))
  5816. X      tmp := open("/tmp/codedata","w") | stop("cannot open tmp file")
  5817. X      s := string(&cset[20:0])
  5818. X      t := encode(s)
  5819. X      write(tmp,t)
  5820. X      a := [1,2,3,4,"abc",'abc']
  5821. X      b := encode(a)
  5822. X      write(tmp,b)
  5823. X      close(tmp)
  5824. X      tmp := open("/tmp/codedata") | stop("cannot reopen tmp file")
  5825. X      u := read(tmp)
  5826. X      if t ~== u then write("transmission of encoded string fails")
  5827. X      else v := decode(u)
  5828. X      if v ~== s then write("decoding of transmitted string failed")
  5829. X      c := read(tmp) | stop("eof reading tmp")
  5830. X      if b ~== c then write("transmission of encoded list failed")
  5831. X      d := decode(c)
  5832. X      every i:=1 to *a do
  5833. X         if a[i] ~=== d[i] then write("list element comparison failure for ",
  5834. X            i, " = ",image(a[i]))
  5835. X      system("rm -f /tmp/codedata")
  5836. X   end
  5837. X
  5838. X
  5839. X                               end-of-solution 4
  5840. END_OF_icon/solution/solution.04
  5841. if test 3420 -ne `wc -c <icon/solution/solution.04`; then
  5842.     echo shar: \"icon/solution/solution.04\" unpacked with wrong size!
  5843. fi
  5844. # end of overwriting check
  5845. fi
  5846. if test -f icon/solution/solution.05 -a "${1}" != "-c" ; then 
  5847.   echo shar: Will not over-write existing file \"icon/solution/solution.05\"
  5848. else
  5849. echo shar: Extracting \"icon/solution/solution.05\" \(3497 characters\)
  5850. sed "s/^X//" >icon/solution/solution.05 <<'END_OF_icon/solution/solution.05'
  5851. X                 Suggested Solutions to Homework Assignment 5
  5852. X
  5853. X1. ranseq.icn
  5854. X
  5855. X   procedure main()
  5856. X      every write(ranseq(100)) \ 50
  5857. X   end
  5858. X
  5859. X   procedure ranseq(i)
  5860. X      suspend ?|i
  5861. X   end
  5862. X
  5863. X
  5864. X2. ranseql.icn
  5865. X
  5866. X   procedure main()
  5867. X      every write(ranseql(100,35))
  5868. X   end
  5869. X
  5870. X   procedure ranseql(i,j)
  5871. X      suspend |(j ~= ?i) | j
  5872. X   end
  5873. X
  5874. X
  5875. X3. code.icn
  5876. X
  5877. X   # The coding scheme is the same as before, with the following additions:
  5878. X   # Sets are handled as lists by sorting them into lists before
  5879. X   # encoding. Tables are handled similarly, with the default value
  5880. X   # is kept as the first encoded value. For records, the
  5881. X   # record type is also kept as the first encoded value.
  5882. X   # Note that when records are reconstructed, a recored with no specified
  5883. X   # (i.e., null-valued) fields is constructed using the string invocation
  5884. X   # extension in Version 5.10.  The fields are then filled in using positional
  5885. X   # access.
  5886. X
  5887. X   link "/usr/ralph/main"
  5888. X
  5889. X   procedure code(x)
  5890. X      if match("record",image(x)) then return "R"
  5891. X      if type(x) == ("set" | "co-expression")
  5892. X         then return map(type(x)[1],&lcase,&ucase)
  5893. X      else return type(x)[1]
  5894. X   end
  5895. X
  5896. X   procedure decode(s)
  5897. X      local p
  5898. X      every p := pair(s) do
  5899. X         suspend case p[1] of {
  5900. X            "i":  integer(p[2])
  5901. X            "s":  p[2]
  5902. X            "c":  cset(p[2])
  5903. X            "r":  real(p[2])
  5904. X            "n":  &null
  5905. X            "l":  delist(p[2])
  5906. X            "t":  detable(p[2])
  5907. X            "S":  deset(p[2])
  5908. X            "R":  derecord(p[2])
  5909. X            default: stop("unexpected type in decode: ",p[1])
  5910. X   end
  5911. X
  5912. X   procedure delist(s)
  5913. X      local a
  5914. X      a := []
  5915. X      every put(a,decode(s))
  5916. X      return a
  5917. X   end
  5918. X
  5919. X   procedure derecord(s)
  5920. X      local a,z,i
  5921. X      a := []
  5922. X      every put(a,decode(s))
  5923. X      z := a[1]()                   # string invocation to create record
  5924. X      every i:=1 to *(a[2]) do      # fill in the fields
  5925. X         z[i] := a[2][i]
  5926. X      return z
  5927. X   end
  5928. X
  5929. X   procedure deset(s)
  5930. X      return set(decode(s))
  5931. X   end
  5932. X
  5933. X   procedure detable(s)
  5934. X      local a,t,i
  5935. X      a := []
  5936. X      every put(a,decode(s))
  5937. X      t := table(a[1])              # first value is default for table
  5938. X      a := a[2]
  5939. X      every i:=1 to *a-1 by 2 do
  5940. X         t[a[i]] := a[i+1]
  5941. X      return t
  5942. X   end
  5943. X
  5944. X   procedure encode(x)
  5945. X      local s,T
  5946. X      return case T := code(x) of {
  5947. X         "n":  "0n"
  5948. X         !"risc": {
  5949. X            s := string(x)
  5950. X            *s || T || s
  5951. X         }
  5952. X         "l":  enlist(x)
  5953. X         "S":  enset(x)
  5954. X         "t":  entable(x)
  5955. X         "R":  enrecord(x)
  5956. X         default: stop("unsupported type in encode ",image(x))
  5957. X      }
  5958. X   end
  5959. X
  5960. X   procedure enlist(a)
  5961. X      local s
  5962. X      s := ""
  5963. X      every s ||:= encode(!a)
  5964. X      return *s || "l" || a
  5965. X   end
  5966. X
  5967. X   procedure enrecord(x)
  5968. X      local s1,s2,a
  5969. X      s1 := encode(type(x))         # first value is record type
  5970. X      a := []
  5971. X      every put(a,!x)
  5972. X      s2 := enlist(a)
  5973. X      return (*s1 + *s2) || "R" || s1 || s2
  5974. X   end
  5975. X
  5976. X   procedure enset(S)
  5977. X      local s
  5978. X      a := enlist(sort(S))
  5979. X      return *s || "S" || s
  5980. X   end
  5981. X
  5982. X   procedure entable(t)
  5983. X      local a,s1,s2
  5984. X      a := sort(t,3)
  5985. X      s1 := encode(t[[]])           # default value
  5986. X      s2 := enlist(a)
  5987. X      return (*s1 + *s2) || "t" || s1 || s2
  5988. X   end
  5989. X
  5990. X   procedure pair(s)
  5991. X      local i,j,k
  5992. X      j := 1
  5993. X      while i := many('0123456789',s,j) do {
  5994. X         k := integer(s[j:i])
  5995. X         suspend [s[i],s[i+1 +: k]]
  5996. X         j := i + k + 1
  5997. X      }
  5998. X   end
  5999. X
  6000. X                               end-of-solution 5
  6001. END_OF_icon/solution/solution.05
  6002. if test 3497 -ne `wc -c <icon/solution/solution.05`; then
  6003.     echo shar: \"icon/solution/solution.05\" unpacked with wrong size!
  6004. fi
  6005. # end of overwriting check
  6006. fi
  6007. if test -f icon/solution/solution.09 -a "${1}" != "-c" ; then 
  6008.   echo shar: Will not over-write existing file \"icon/solution/solution.09\"
  6009. else
  6010. echo shar: Extracting \"icon/solution/solution.09\" \(2743 characters\)
  6011. sed "s/^X//" >icon/solution/solution.09 <<'END_OF_icon/solution/solution.09'
  6012. X                    C.Sc. 550 - String and List Processing
  6013. X
  6014. X                 Suggested Solutions to Homework Assignment 9
  6015. X
  6016. X
  6017. X1. recgen.icn
  6018. X
  6019. X   procedure main()
  6020. X      system("rm -rf /tmp/ralph");
  6021. X      system("mkdir /tmp/ralph");
  6022. X      output := open("/tmp/ralph/recog.icn","w")|stop("cannot opem tmp file");
  6023. X      input := open("/usr/ralph/recgen.gmr") | stop("sannot open input file");
  6024. X      while line := read(input) do
  6025. X         if line ? {
  6026. X            nt := tab(any(&ucase)) &
  6027. X            ="::=" &
  6028. X            write(output, "procedure ", nt, "()") &
  6029. X            body := "" & {
  6030. X               every body ||:= altern(tab(0))
  6031. X               write(output, "   suspend(\n", body[1:-3]", "\n     )\nend\n")
  6032. X            }
  6033. X         } then next
  6034. X         else if line ? (goal := tab(any(&ucase))) & pos(0) then {
  6035. X            write(output, "procedure main()")
  6036. X            write(output, "   while writes(image(line := read())) do")
  6037. X            write(output,
  6038. X              "      if line ? (",goal,"() & pos(0)) then write(\" accepted")")
  6039. X            write(output, "      else write(\" rejected\")")
  6040. X            write(output, "end")
  6041. X            break
  6042. X         } else
  6043. X            stop("invalid input")
  6044. X      system("icont -s /tmp/ralph/recog.icn -x </usr/ralph/recogn.test")
  6045. X   end
  6046. X
  6047. X   procedure altern(s)
  6048. X      s ? while t := tab(upto('|') | 0) do {
  6049. X         clause := ""
  6050. X         every clause ||:= compon(t)
  6051. X         suspend "      (" || clause[1:-4] || ") |\n"
  6052. X         move(1) | break
  6053. X   end
  6054. X
  6055. X   procedure compon(s)
  6056. X      s ? repeat {
  6057. X         if pos(0) then break
  6058. X         if c := tab(any(&ucase)) then suspend c || "() || "
  6059. X         else suspend "=" || image(tab(upto(&ucase) | 0)) \ 1 || " || "
  6060. X      }
  6061. X   end
  6062. X
  6063. XThe grammar used for this test was:
  6064. X
  6065. X   B ::= U|S|C...B|###|***|{{B}}
  6066. X   U ::= v.v|a.a|ooo-ooo| |...   ...|.B
  6067. X   S ::= (o.o)|[oo..oo]|{-x-}
  6068. X   C ::= +++++++|+-+-+-+-+-+-+-
  6069. X   B
  6070. X
  6071. XThe output of the program above for this grammar is:
  6072. X
  6073. X   procedure B()
  6074. X      suspend (
  6075. X         (U()) |
  6076. X         (S()) |
  6077. X         (C()) || ="..." || B()) |
  6078. X         (="###") |
  6079. X         (="***") |
  6080. X         (="{{" || B() || ="}}")
  6081. X      )
  6082. X   end
  6083. X
  6084. X   procedure U()
  6085. X      suspend (
  6086. X         (="v.v") |
  6087. X         (="a.a") |
  6088. X         (="ooo-ooo") |
  6089. X         (=" ") |
  6090. X         (="...   ...") |
  6091. X         (=".") || B()
  6092. X      )
  6093. X   end
  6094. X
  6095. X   procedure S()
  6096. X      suspend (
  6097. X         (="(o.o)") |
  6098. X         (="[oo..oo]") |
  6099. X         (="{-x-}")
  6100. X      )
  6101. X   end
  6102. X
  6103. X   procedure C()
  6104. X      suspend (
  6105. X         (="+++++++") |
  6106. X         (="+-+-+-+-+-+-+-")
  6107. X      )
  6108. X   end
  6109. X
  6110. X
  6111. X2. lprint.icn
  6112. X
  6113. X   procedure lprint(ltree, depth)
  6114. X      /depth := 0
  6115. X      write(repl("   ", depth), ltree[1])
  6116. X      every lprint(ltree[2 to *ltree], depth + 1)
  6117. X   end
  6118. X
  6119. X                              end-of-solution-9
  6120. END_OF_icon/solution/solution.09
  6121. if test 2743 -ne `wc -c <icon/solution/solution.09`; then
  6122.     echo shar: \"icon/solution/solution.09\" unpacked with wrong size!
  6123. fi
  6124. # end of overwriting check
  6125. fi
  6126. echo shar: End of archive 2 \(of 3\).
  6127. cp /dev/null ark2isdone
  6128. MISSING=""
  6129. for I in 1 2 3 ; do
  6130.     if test ! -f ark${I}isdone ; then
  6131.     MISSING="${MISSING} ${I}"
  6132.     fi
  6133. done
  6134. if test "${MISSING}" = "" ; then
  6135.     echo You have unpacked all 3 archives.
  6136.     rm -f ark[1-9]isdone
  6137. else
  6138.     echo You still need to unpack the following archives:
  6139.     echo "        " ${MISSING}
  6140. fi
  6141. ##  End of shell archive.
  6142. exit 0
  6143. -- 
  6144. UUCP and other network      )\/(    ..!hp4nl!kunivv1!atcmpe!gertjan
  6145.   connections via mcvax      )/\(    gertjan@atcmp.nl (internet)
  6146. This note does not necessarily represent the position of AT Computing BV
  6147.  
  6148. From icon-group-request  Mon Feb 20 11:16:12 1989
  6149. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  6150.     id AA07475; Mon, 20 Feb 89 11:16:12 MST
  6151. Received: by ucbvax.Berkeley.EDU (5.61/1.34)
  6152.     id AA19655; Sat, 18 Feb 89 02:33:40 -0800
  6153. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  6154.     for icon-group@arizona.edu (icon-group@arizona.edu)
  6155.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  6156. Date: 16 Feb 89 17:46:12 GMT
  6157. From: mcvax!hp4nl!kunivv1!atcmpe!gertjan@uunet.uu.net  (Gertjan Vinkesteyn)
  6158. Organization: AT Computing, Nijmegen, The Netherlands
  6159. Subject: Icon Lectures Part 1/3
  6160. Message-Id: <481@atcmpe.atcmp.nl>
  6161. Sender: icon-group-request@arizona.edu
  6162. To: icon-group@arizona.edu
  6163.  
  6164.  
  6165. In 1985 I could attend a graduate course in string and list processing
  6166. by Ralph Griswold. In the spring of 1986 I put it on the net in Europe,
  6167. with Ralphs permission of course. Let me do this again, it was an excellent
  6168. course and this might give you some insight in the language. Especially
  6169. if you want to teach it in your computer science class yourself. The 
  6170. language is great to get understanding in compiler building and parsing.
  6171. The text is made available as is. 
  6172.  
  6173.                 gertjan@atcmp.nl
  6174.  
  6175. #! /bin/sh
  6176. # This is a shell archive.  Remove anything before this line, then unpack
  6177. # it by saving it into a file and typing "sh file".  To overwrite existing
  6178. # files, type "sh file -c".  You can also feed this as standard input via
  6179. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  6180. # will see the following message at the end:
  6181. #        "End of archive 1 (of 3)."
  6182. # Contents:  MANIFEST icon icon/course icon/course/course08.27
  6183. #   icon/course/course09.12 icon/course/course09.17
  6184. #   icon/course/course09.23 icon/course/course10.03
  6185. #   icon/course/course10.10 icon/homework icon/homework/assign.03
  6186. #   icon/homework/assign.04 icon/homework/assign.05
  6187. #   icon/homework/assign.06 icon/homework/assign.08
  6188. #   icon/homework/assign.09 icon/homework/assign.10 icon/solution
  6189. #   icon/solution/solution.01 icon/solution/solution.03
  6190. #   icon/solution/solution.06 icon/solution/solution.08
  6191. #   icon/solution/solution.mid
  6192. # Wrapped by gertjan@atcmp.nl on Thu Feb 16 18:28:14 1989
  6193. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  6194. if test -f MANIFEST -a "${1}" != "-c" ; then 
  6195.   echo shar: Will not over-write existing file \"MANIFEST\"
  6196. else
  6197. echo shar: Extracting \"MANIFEST\" \(1285 characters\)
  6198. sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
  6199. X   File Name        Archive #    Description
  6200. X-----------------------------------------------------------
  6201. X MANIFEST                  1    This shipping list
  6202. X icon                      1    
  6203. X icon/course               1    
  6204. X icon/course/course08.27   1    
  6205. X icon/course/course08.29   3    
  6206. X icon/course/course09.03   3    
  6207. X icon/course/course09.05   2    
  6208. X icon/course/course09.10   3    
  6209. X icon/course/course09.12   1    
  6210. X icon/course/course09.17   1    
  6211. X icon/course/course09.19   2    
  6212. X icon/course/course09.23   1    
  6213. X icon/course/course10.01   2    
  6214. X icon/course/course10.03   1    
  6215. X icon/course/course10.10   1    
  6216. X icon/course/course10.17   2    
  6217. X icon/course/course10.22   2    
  6218. X icon/homework             1    
  6219. X icon/homework/assign.03   1    
  6220. X icon/homework/assign.04   1    
  6221. X icon/homework/assign.05   1    
  6222. X icon/homework/assign.06   1    
  6223. X icon/homework/assign.08   1    
  6224. X icon/homework/assign.09   1    
  6225. X icon/homework/assign.10   1    
  6226. X icon/homework/assign.mid  2    
  6227. X icon/solution             1    
  6228. X icon/solution/sample.02   3    
  6229. X icon/solution/sample.icn  3    
  6230. X icon/solution/solution.01 1    
  6231. X icon/solution/solution.02 2    
  6232. X icon/solution/solution.03 1    
  6233. X icon/solution/solution.04 2    
  6234. X icon/solution/solution.05 2    
  6235. X icon/solution/solution.06 1    
  6236. X icon/solution/solution.07 3    
  6237. X icon/solution/solution.08 1    
  6238. X icon/solution/solution.09 2    
  6239. X icon/solution/solution.mid 1    
  6240. END_OF_MANIFEST
  6241. if test 1285 -ne `wc -c <MANIFEST`; then
  6242.     echo shar: \"MANIFEST\" unpacked with wrong size!
  6243. fi
  6244. # end of overwriting check
  6245. fi
  6246. if test ! -d icon ; then
  6247.     echo shar: Creating directory \"icon\"
  6248.     mkdir icon
  6249. fi
  6250. if test ! -d icon/course ; then
  6251.     echo shar: Creating directory \"icon/course\"
  6252.     mkdir icon/course
  6253. fi
  6254. if test -f icon/course/course08.27 -a "${1}" != "-c" ; then 
  6255.   echo shar: Will not over-write existing file \"icon/course/course08.27\"
  6256. else
  6257. echo shar: Extracting \"icon/course/course08.27\" \(2168 characters\)
  6258. sed "s/^X//" >icon/course/course08.27 <<'END_OF_icon/course/course08.27'
  6259. XString and List Processing.    Prof. Ralph Griswold
  6260. XA course of ten weeks, two times 2 hours a week. Graduate Course.
  6261. X
  6262. XData representation, pattern matching, structures. Applications in
  6263. Xsymbolic mathematics, text analysis, document formatting, cryptography, etc.
  6264. X
  6265. XThe course started out with reducing the amount of students to 15. 30
  6266. Xdid came. I was so lucky that I could stay as a sort of special
  6267. Xinvitation of Prof. Griswold. He seems a very, very, intelligent person
  6268. Xand I am proud to follow the course. It is the last course of this kind
  6269. Xfor the coming two years.
  6270. X
  6271. XHe started out to say that the course is a personal approach of looking
  6272. Xat CCS by Griswold and others (Dave Hanson cs.)
  6273. XIt will put the emphasis on concepts, that we will learn ICON is just a
  6274. Xmatter of coincidence. The homework will never be more then 20 lines of
  6275. Xcode (gertjan: that does not mean to much in Icon!). The homework will
  6276. Xbe handed in by electronic mail and a daemon program checks if all the
  6277. Xhomework is hand in on time. A course news mailing list alias is opened
  6278. Xso that Ralph can announce things to the students. Ralph's terminal is
  6279. Xalways on for questions.
  6280. X
  6281. XBiography of Ralph: PhD EE Stanford 1961. Promised himself never to do
  6282. Xany programming. Joined Bell Labs. Started work on Symbolic Mathematics.
  6283. XTogether with Dave Forber and Ivan Polonsky developed various versions
  6284. Xof Snobol up to version IV (1965).
  6285. X1971 joined Univ. of Arizona. Developed Icon in 1976. He has lots of
  6286. Xhumour like: If you hand your homework in in a weird program layout he
  6287. Xwill probably throw it all away without looking in to it. After that he
  6288. Xthinks about it and something you may find that 'new idea' in his next
  6289. Xcourse!
  6290. XIcon: Trying to find linguistic facilities to manupilate strings, lists,
  6291. Xetc. Very little formal mechanism for maupilating text was available
  6292. Xbefore it was done on computers. A lot was done in numerical mathematics
  6293. Xetc. Language does not have a concept to think about it. 
  6294. XA lot of ideas in Icon are not implemented in existing languages. PROLOG
  6295. Xwas thought to be new but actually has a lot of ideas from Snobol and
  6296. XIcon.
  6297. X
  6298. XMSDOS version (public domain) of ICON is due for next week!!!!
  6299. END_OF_icon/course/course08.27
  6300. if test 2168 -ne `wc -c <icon/course/course08.27`; then
  6301.     echo shar: \"icon/course/course08.27\" unpacked with wrong size!
  6302. fi
  6303. # end of overwriting check
  6304. fi
  6305. if test -f icon/course/course09.12 -a "${1}" != "-c" ; then 
  6306.   echo shar: Will not over-write existing file \"icon/course/course09.12\"
  6307. else
  6308. echo shar: Extracting \"icon/course/course09.12\" \(2030 characters\)
  6309. sed "s/^X//" >icon/course/course09.12 <<'END_OF_icon/course/course09.12'
  6310. XHomework: Read Chapter 6-8, take attention to the {null} value
  6311. X
  6312. XDon't be tempted to use that info for earlier assignments, in
  6313. Xanother week we come to the good stuff.
  6314. X
  6315. XSETS
  6316. X====
  6317. X    s := set( [ 1, "a", [] ] )
  6318. X    s := set( [ 1, "a", 1, [] ] )
  6319. X    s := set( [ 1, [], 2, [] ] )
  6320. X    s := set( [ "ab", "a" || "b" ] )
  6321. X
  6322. Xsome functions for sets are:
  6323. X    member(s, x)    -> x
  6324. X    insert(s, x)    -> s  # push
  6325. X    delete(s, x)    -> s  # pop
  6326. X
  6327. X    sort(x) can be used for sets also, it produces a 'list'.
  6328. X    *s and the operators ++ -- etc work as expected
  6329. X    and empy set is  set([[]])  in this case  *s == 0
  6330. X
  6331. XTABLES
  6332. X======
  6333. X
  6334. XThey've been used in the language since day one!
  6335. XInherited from Snobol which was the first language which had it.
  6336. XIt is tabulating and used for: counting words, cross word references, etc
  6337. XTables are sets in which every element has some associated value
  6338. X
  6339. Xcalling sequence: t := table(x)
  6340. Xusage example: t[word] +:= 1
  6341. X
  6342. XIf you read in data then you don't know yet what words you are
  6343. Xgoing to get. So you can put word in without knowing how many and
  6344. Xwhat kind of.
  6345. X
  6346. XThe `sort' procedure is extended in 5.10. Sorting is done by the
  6347. Xstandard queue sort of Unix. So sorting on assigment value order
  6348. Xof ambigious bytes is dependent on the Unix version you have.
  6349. X(4.1bsd acts opposit to 4.2bsd)
  6350. X
  6351. Xsort(t,i) could be called with values i=1 or i=2 which stands for
  6352. Xsorting on index or sorting on value
  6353. Xso a sort(t,i) could produce
  6354. X
  6355. X    [ [ , ] [ , ] ... ]        [   ,  ,  ,   ... ]
  6356. X       ^       ^               ^       ^
  6357. X       |       |               |       |
  6358. X    sort(t,1) sort(t,2)        sort(t,3) sort(t,4)
  6359. X
  6360. X    
  6361. Xi=3 and i=4 give    [ , , , , , ... ]
  6362. Xlike in [ "he", 3, "t", 7, "a", 17 ] (sorted on sort(t, 4) )
  6363. XThis 3 and 4 case takes much less space in memory
  6364. X
  6365. XRECORDS
  6366. X=======
  6367. XThere is for instance a record complex(r,i)
  6368. Xwhich is actually a record constructor complex( , )
  6369. X
  6370. XEvery time you call complex you creat a record
  6371. X
  6372. X    z := complex(1.2, 3.5)
  6373. X    z.i +:= 2.7
  6374. X
  6375. XSo z.i is a pointer in this record.
  6376. X
  6377. XGeneric operations of all these things
  6378. X
  6379. X    *s    size
  6380. X    ?s    random (also polymorphic as * is)
  6381. X
  6382. Xend-of-course.9-12
  6383. END_OF_icon/course/course09.12
  6384. if test 2030 -ne `wc -c <icon/course/course09.12`; then
  6385.     echo shar: \"icon/course/course09.12\" unpacked with wrong size!
  6386. fi
  6387. # end of overwriting check
  6388. fi
  6389. if test -f icon/course/course09.17 -a "${1}" != "-c" ; then 
  6390.   echo shar: Will not over-write existing file \"icon/course/course09.17\"
  6391. else
  6392. echo shar: Extracting \"icon/course/course09.17\" \(69 characters\)
  6393. sed "s/^X//" >icon/course/course09.17 <<'END_OF_icon/course/course09.17'
  6394. XI could not attend classes because Margot was ill. Boy what a job...
  6395. END_OF_icon/course/course09.17
  6396. if test 69 -ne `wc -c <icon/course/course09.17`; then
  6397.     echo shar: \"icon/course/course09.17\" unpacked with wrong size!
  6398. fi
  6399. # end of overwriting check
  6400. fi
  6401. if test -f icon/course/course09.23 -a "${1}" != "-c" ; then 
  6402.   echo shar: Will not over-write existing file \"icon/course/course09.23\"
  6403. else
  6404. echo shar: Extracting \"icon/course/course09.23\" \(1851 characters\)
  6405. sed "s/^X//" >icon/course/course09.23 <<'END_OF_icon/course/course09.23'
  6406. XC.Sc. 550 - String and List Processing
  6407. X9/23/85
  6408. X
  6409. XReading Assignment Chapter 11 for the fun stuff in Icon!
  6410. X
  6411. XHomework Assignments General Comment:
  6412. X    Only comment if you use bizarre code techniques especially  if the code     itself is not clear enough. Put your main() on the front.
  6413. X
  6414. XThursday 9/25 NO CLASS private meditating session!
  6415. X    daemon will be let loose by 1 pm.
  6416. X
  6417. XMT MidTerm is 10/15 (Tuesday)
  6418. X    any objections or comment about that?
  6419. X
  6420. XI prefer not to make up examination
  6421. X    1. I ran out of new assignments and I want to do creative excersises.
  6422. X    2. ...
  6423. XBut don't fail to show up. You just get a zero then.
  6424. X
  6425. XAssignment 4. deserves some discussion
  6426. X    s := encode(x)        y should deliver similar outcome
  6427. X    y := decode(s)        as x. For numbers that's okay, for lists etc.
  6428. X                 that is quite difficult.
  6429. XIn this case you cannot represent the physical structure. There is no physical
  6430. Xstructure between the scalar (null, integer, real, string, cset).
  6431. XIn lists there is only the [] empty list distinctive.
  6432. XLists of scalars like encode
  6433. X
  6434. X    x := ["a",1,2.0,1]
  6435. X
  6436. XFor strings and cset it is a slightlyu big deal.
  6437. XDon't worry about the ascii-control characters in this case.
  6438. X
  6439. XCompiling technique:
  6440. X===================
  6441. X
  6442. X        |--------|    .u1    |--------|
  6443. X    .icn -> | transl | ->       -> | linker | -> object
  6444. X        |--------|    .u2    |--------|
  6445. X                     ^
  6446. X                (ucode)      |
  6447. X                virtual   possible
  6448. X                machine     other
  6449. X                 code       code
  6450. X
  6451. XDiscussion on fail and success
  6452. X==============================
  6453. X
  6454. X    success    -> produces a result
  6455. X    fail    -> produces not a result
  6456. X
  6457. Xterminology:
  6458. X
  6459. X    values, variables -> result
  6460. X    result, failure      -> outcome
  6461. X
  6462. XNow you can describe something without mentioning constantly 'value' or 
  6463. X'variable'.
  6464. X
  6465. XThe outcome of     if e1 then e2 else e3
  6466. Xis        e2    if e1 succeeds
  6467. X        e3    if e1 fails
  6468. X
  6469. Xother examples in compund expressions
  6470. X
  6471. X    { e1; e2; e3; ... ; en } outcome en
  6472. END_OF_icon/course/course09.23
  6473. if test 1851 -ne `wc -c <icon/course/course09.23`; then
  6474.     echo shar: \"icon/course/course09.23\" unpacked with wrong size!
  6475. fi
  6476. # end of overwriting check
  6477. fi
  6478. if test -f icon/course/course10.03 -a "${1}" != "-c" ; then 
  6479.   echo shar: Will not over-write existing file \"icon/course/course10.03\"
  6480. else
  6481. echo shar: Extracting \"icon/course/course10.03\" \(2234 characters\)
  6482. sed "s/^X//" >icon/course/course10.03 <<'END_OF_icon/course/course10.03'
  6483. X             C.Sc. 550 - String and List Processing
  6484. X                             10/3/85
  6485. X
  6486. Xresult sequences    notated as S
  6487. X----------------
  6488. X    S(e) = { ... }    abstract characterization, not produced
  6489. X    S(if e1 then e2 else e3) =
  6490. X
  6491. Xcontext: iteration    (every e1 do e2)
  6492. X
  6493. X    goal-directed evaluation    i:=find(s1,s2) like in Algol
  6494. X
  6495. X    every i := 1 to 10 do f(i)    ->    every f(1 to 10) 
  6496. X
  6497. Xoperators and generators  o+ stands for + bullet, general operator
  6498. X------------------------
  6499. X
  6500. X    S(e1|e2) = S(e1) o+ S(e2)
  6501. X
  6502. XHistorically people were concerned about the "|" operation (Spring, Summer)
  6503. X
  6504. Xtake care that    x := 1|2|(3 to 7) only results in x:=1
  6505. Xsame for write(1 to 7). You need a generator to let this work!
  6506. X
  6507. X    every write(e1|e2)    if e1|e2 then
  6508. X    "e1 then e2"        "e1 or e2"
  6509. X
  6510. XThe way you use it is a reflection of the contents.
  6511. X
  6512. X    (1 to 10) \ (1 to 5) -> {1,1,2,1,2,3,1,2,3,4,1,2,3,4,5}
  6513. X
  6514. X              inf
  6515. XAn empty result sequence {}   just should result in {} but loops.
  6516. X
  6517. XWhat is  |read() ?
  6518. X    S(|read()) = {s1,s2,s3,....} all the lines of a file
  6519. X
  6520. XDefenition is made that it terminates "normally".
  6521. X
  6522. XBlack hole evaluation    0 = 1    fails
  6523. X            0 = |1    evaluation no result
  6524. X                just like  while 1 do
  6525. XNormally Icon programmers don't fall iun to this.
  6526. X
  6527. X    a := [1,3,7,4,"a"]
  6528. X    S(!a) = {1,3,4,5,4,"a"}
  6529. X
  6530. XSo every  write(!a)  writes a result-sequence
  6531. XIt does this with
  6532. X    list    zero a list  every !a:=0
  6533. X    string    (one char substrings)  !"abc" -> {"a","b","c"}
  6534. X    record
  6535. X    set
  6536. X    table    zero a table  every !t:=0
  6537. X    file    &input  every write(!&input)  produces all the input lines
  6538. X        just as well  every line:=&input do
  6539. X        is the same as  while line:=read() do
  6540. X
  6541. XWhat is  S(!10)  -> {"1","0"}
  6542. X
  6543. XComparing two lists  if !a1 == !a2  compares every element of list a1 and a2
  6544. X
  6545. XGenerator procedure are: find, upto, bal
  6546. XGenerator operators are: !x,  i to j,  e1 | e2,  |e1
  6547. X
  6548. XExtensebilty of the language
  6549. X----------------------------
  6550. X
  6551. X    procedure f(x)
  6552. X        .
  6553. X        .
  6554. X        suspend 1
  6555. X        .
  6556. X        .
  6557. X        suspend 2
  6558. X        .
  6559. X        .
  6560. X    end
  6561. X
  6562. XExample:
  6563. X    procedure To(i,j)
  6564. X        while i <= j do {
  6565. X            suspend i
  6566. X            i +:= 1
  6567. X        }
  6568. X    end
  6569. X
  6570. XThe environment of the procedure is retained. This is all you need to write 
  6571. Xyour own generators.
  6572. X
  6573. X    suspend  is like  every
  6574. X
  6575. X    procedure f()
  6576. X        suspend(1|3|5)
  6577. X    end
  6578. X
  6579. Xis as
  6580. X    S(f()) = {1,3,5}
  6581. X
  6582. X                          end-of-course 10-03-85
  6583. END_OF_icon/course/course10.03
  6584. if test 2234 -ne `wc -c <icon/course/course10.03`; then
  6585.     echo shar: \"icon/course/course10.03\" unpacked with wrong size!
  6586. fi
  6587. # end of overwriting check
  6588. fi
  6589. if test -f icon/course/course10.10 -a "${1}" != "-c" ; then 
  6590.   echo shar: Will not over-write existing file \"icon/course/course10.10\"
  6591. else
  6592. echo shar: Extracting \"icon/course/course10.10\" \(1941 characters\)
  6593. sed "s/^X//" >icon/course/course10.10 <<'END_OF_icon/course/course10.10'
  6594. X                    C.Sc. 550 - String and List Processing
  6595. X                                   10/10/85
  6596. X
  6597. XToday Ralph started to talk about the home work assignments. He went a little 
  6598. Xin detail about the following exercise:
  6599. X
  6600. X   procedure ranseq(i)
  6601. X      suspend ?|i
  6602. X   end
  6603. X
  6604. XYou can also use result sequences in the wrong way. What would be the outcome 
  6605. Xbe of:
  6606. X
  6607. X   (1 to 3)(1 to 4, !"abc", 7|6)
  6608. X
  6609. X   {1,2,3}({1,1,1,1,1,1,2,2,2,2,2,2,3...3,4...4,"a","a","b",...})
  6610. X
  6611. XThis is pretty much a mess. Not what you want at least.
  6612. XIf you are in doubt then it is good to see what it is doing, try something and 
  6613. Xsee what you get.
  6614. X
  6615. XRemark: In Icon there is no way to use variable number of arguments.
  6616. X   The reason is the implementation but the syntax definition, perhaps in a 
  6617. X   next release?
  6618. XVariable number of fields can be used in the standard procedures because they 
  6619. Xare written in another language.
  6620. X
  6621. Xbacktracking
  6622. X============
  6623. X
  6624. X   control backtracking
  6625. X   --------------------
  6626. X
  6627. X   Icon has automatic 'control backtracking'
  6628. X      (exp1, exp2, exp3, ..., expn)
  6629. X
  6630. X   when expn fails it goes to exp(n-1) etc.
  6631. X   it is implicit automatic
  6632. X
  6633. X   data backtracking
  6634. X   -----------------
  6635. X
  6636. X   This does not go automatic in Icon, however there are some helps available.
  6637. X   There is an operator <- for that reason, this is best to show with an 
  6638. X   example:
  6639. X
  6640. X   procedure foo()                  # How to keep the original storage of a[i]?
  6641. X      ...  
  6642. X      a[i] := 3
  6643. X      return a[i]
  6644. X   end
  6645. X
  6646. X   #---------------
  6647. X
  6648. X   procedure foo()                  # conventional approach
  6649. X      local x
  6650. X      ...
  6651. X      x : = a[i]                    # save old value
  6652. X      a[i] := 3
  6653. X      suspend a[i]
  6654. X      a[i] := x                     # restore
  6655. X   end
  6656. X
  6657. X   #--------------
  6658. X
  6659. X   procedure foo()                  # use builtin operator
  6660. X      ...
  6661. X      suspend a[i] <- 3
  6662. X      fail
  6663. X   end
  6664. X
  6665. XThere is also a reversible exchange y <-> x
  6666. X
  6667. X                             end-of-notes 10/10/85
  6668. END_OF_icon/course/course10.10
  6669. if test 1941 -ne `wc -c <icon/course/course10.10`; then
  6670.     echo shar: \"icon/course/course10.10\" unpacked with wrong size!
  6671. fi
  6672. # end of overwriting check
  6673. fi
  6674. if test ! -d icon/homework ; then
  6675.     echo shar: Creating directory \"icon/homework\"
  6676.     mkdir icon/homework
  6677. fi
  6678. if test -f icon/homework/assign.03 -a "${1}" != "-c" ; then 
  6679.   echo shar: Will not over-write existing file \"icon/homework/assign.03\"
  6680. else
  6681. echo shar: Extracting \"icon/homework/assign.03\" \(655 characters\)
  6682. sed "s/^X//" >icon/homework/assign.03 <<'END_OF_icon/homework/assign.03'
  6683. X         C.Sc. 550 - String and List Processing
  6684. X             Homework Assignment 3
  6685. X               September 16, 1985
  6686. X
  6687. X1. (chaos.icn, 20 points) Do Exercise 7.5 in the Icon book.
  6688. X   Arrange your output in columns, five across.
  6689. X
  6690. X2. (qcalls.icn, 25 points) Write a program that computes q(i)
  6691. X   recursively as decribed in Exercise 7.4 in the Icon book and
  6692. X   prints out i, q(i), and the number of calls to compute q(i)
  6693. X   for i = 1, ..., 12.
  6694. X
  6695. X3. (comb.icn, 25 points) Do Exercise 7.7 in the Icon book.
  6696. X   Interpret "produce" as "write". Test your program with the
  6697. X   following calls:
  6698. X
  6699. X    comb("abcd",3)
  6700. X    comb("0123456789",8)
  6701. X    comb("ABCDEFGH",2)
  6702. X
  6703. X                           end-of-assignment-3
  6704. END_OF_icon/homework/assign.03
  6705. if test 655 -ne `wc -c <icon/homework/assign.03`; then
  6706.     echo shar: \"icon/homework/assign.03\" unpacked with wrong size!
  6707. fi
  6708. # end of overwriting check
  6709. fi
  6710. if test -f icon/homework/assign.04 -a "${1}" != "-c" ; then 
  6711.   echo shar: Will not over-write existing file \"icon/homework/assign.04\"
  6712. else
  6713. echo shar: Extracting \"icon/homework/assign.04\" \(1649 characters\)
  6714. sed "s/^X//" >icon/homework/assign.04 <<'END_OF_icon/homework/assign.04'
  6715. XHomework Assignment 4 - Due Thursday, October 3, 1985
  6716. X
  6717. X1. (balexp.icn, 15pts). Do Exercise 4.12 in the Icon book. 
  6718. X                        Consider the operators to be
  6719. X
  6720. X    +    -    *    /
  6721. X
  6722. XRead from standard input and write to standard output. Provide 
  6723. Xyour own data for testing; the daemon with provide its test data 
  6724. Xfor grading.
  6725. X
  6726. X
  6727. X2. (code.icn, 50 pts). Devise a scheme for encoding the various 
  6728. Xtypes of data in Icon as strings. Write a procedure encode(x) 
  6729. Xthat encodes the value of x as a string and a function decode(s) 
  6730. Xthat produces value encoded in s. In general
  6731. X
  6732. X    x := decode(encode(y))
  6733. X
  6734. Xshould result in x being assigned a value that is the same as the 
  6735. Xvalue of y, except that for structures, the values should be 
  6736. X"similar", not identical. Thus, in
  6737. X
  6738. X    a := []
  6739. X    b := decode(encode(a))
  6740. X
  6741. Xthe value assigned to b should be an empty list, but not the 
  6742. Xempty list that is the value of a.
  6743. X
  6744. XThis is the first phase of this problem. For this first phase, 
  6745. Xyou should handle the null value, integers, real numbers, 
  6746. Xstrings, csets, and lists. You need not to handle strings and 
  6747. Xcsets that contain characters that would require escape 
  6748. Xconventions for their literal representation. You need not handle 
  6749. Xlists whose values are lists, and so on, but plan ahead.
  6750. X
  6751. XDo not provide a main procedure. Instead, include the following 
  6752. Xdeclaration at the beginning of your program:
  6753. X
  6754. X    link "/usr/ralph/main"
  6755. X
  6756. XThis will incorporate a main procedure that tests your encode and 
  6757. Xdecode procedures. (This main procedure will remain the same 
  6758. Xuntil the assignment is due, unless you are informed otherwise, 
  6759. Xbut will be changed when your assignment is run by the daemon.)
  6760. END_OF_icon/homework/assign.04
  6761. if test 1649 -ne `wc -c <icon/homework/assign.04`; then
  6762.     echo shar: \"icon/homework/assign.04\" unpacked with wrong size!
  6763. fi
  6764. # end of overwriting check
  6765. fi
  6766. if test -f icon/homework/assign.05 -a "${1}" != "-c" ; then 
  6767.   echo shar: Will not over-write existing file \"icon/homework/assign.05\"
  6768. else
  6769. echo shar: Extracting \"icon/homework/assign.05\" \(1097 characters\)
  6770. sed "s/^X//" >icon/homework/assign.05 <<'END_OF_icon/homework/assign.05'
  6771. X            Homework Assignment 5 - Due Thursday, October 10, 1985
  6772. X
  6773. X1. (code.icn, 40 points).
  6774. X    Extend your solutionto Problem 2 on Homework Assignment 4 to include 
  6775. Xtables, sets, and record types. You should handle structures that point to 
  6776. Xstructures, but you need not handle loops. You can continue to ignore 
  6777. X"difficult" characters in strings and csets.
  6778. X
  6779. XYou should plan to make corrections that may show up as a result of the 
  6780. Xgrading of your original solution. You also may wish to modify your previous 
  6781. Xsolution to take advantage of generators.
  6782. X
  6783. X
  6784. X2. (ranseq.icn, 10pts)
  6785. X    Do Exercise 11.8 in the Icon book. Test your oprocedure with a main 
  6786. Xprocedure that write 50 randomly selected integers between 1 and 100, 
  6787. Xinclusive.
  6788. X
  6789. X
  6790. X3. (ranseql.icn, 10pts)
  6791. X    Do Exercise 11.8 as in the previous problem, but provide a second 
  6792. Xargument, j, that terminates the sequence if it ever produces the value j. For 
  6793. Xexample, ranseql(100,35) should produce a sequence of pseudo-random integers 
  6794. Xbetween 1 and 100, inclusive, but stop with 35 as its last value. Provide a 
  6795. Xmain procedure that tests this example.
  6796. END_OF_icon/homework/assign.05
  6797. if test 1097 -ne `wc -c <icon/homework/assign.05`; then
  6798.     echo shar: \"icon/homework/assign.05\" unpacked with wrong size!
  6799. fi
  6800. # end of overwriting check
  6801. fi
  6802. if test -f icon/homework/assign.06 -a "${1}" != "-c" ; then 
  6803.   echo shar: Will not over-write existing file \"icon/homework/assign.06\"
  6804. else
  6805. echo shar: Extracting \"icon/homework/assign.06\" \(971 characters\)
  6806. sed "s/^X//" >icon/homework/assign.06 <<'END_OF_icon/homework/assign.06'
  6807. X                    C.Sc. 550 - String and List Processing
  6808. X
  6809. X             Homework Assigment 6 - Due Thursday, October 23, 1985
  6810. X
  6811. X
  6812. X1. (code.icn, 15 points) Revise your solution of Homework Assignment 5 to use 
  6813. Xstring scanning where appropiate.
  6814. X
  6815. X2. (fix.icn, 35 points) Write a procedure infix(exp) that converts an 
  6816. Xexpression exp in binary prefix form to fully parenthesized infix form. For 
  6817. Xexample, the expression
  6818. X
  6819. X    +(x,-(count,1))
  6820. X
  6821. Xshould be converted to
  6822. X
  6823. X    (x+(count-1))
  6824. X
  6825. XAssume the operator symbols are +, -, *, and /.
  6826. X
  6827. XWrite an inverse procedure prefix(exp) that converts a fully parenthesized 
  6828. Xbinary infix expression to prefiz form.
  6829. X
  6830. XUse string scanning in both procedures. Provide a main procedure that reads in 
  6831. Xprefix expressions, one per line, writes out their infix form, converts the 
  6832. Xinfix form back to prefix form, and prints that out also. You may assume the 
  6833. Xinput expressions are syntactically correct.
  6834. X
  6835. X                              end-of-assignment-6
  6836. END_OF_icon/homework/assign.06
  6837. if test 971 -ne `wc -c <icon/homework/assign.06`; then
  6838.     echo shar: \"icon/homework/assign.06\" unpacked with wrong size!
  6839. fi
  6840. # end of overwriting check
  6841. fi
  6842. if test -f icon/homework/assign.08 -a "${1}" != "-c" ; then 
  6843.   echo shar: Will not over-write existing file \"icon/homework/assign.08\"
  6844. else
  6845. echo shar: Extracting \"icon/homework/assign.08\" \(1897 characters\)
  6846. sed "s/^X//" >icon/homework/assign.08 <<'END_OF_icon/homework/assign.08'
  6847. X                    C.Sc. 550 - String and List Processing
  6848. X
  6849. X             Homework Assigment 8 - Due Thursday, November 7, 1984
  6850. X
  6851. X
  6852. X1. (comb.icn, 30 points) Redo Problem 3 from Homework Assignment 3, but have 
  6853. Xthe procedure 'generate' the combinations. Provide a main program that writes 
  6854. Xthe same combinations as for the previous assignment. Note: Try to find a 
  6855. Xsolution that uses Icon's expression evaluation mechanism to its best 
  6856. Xadvantage. Grading will be divided evenly between the correctness and the 
  6857. Xquality of your solution. Do not use the previous solution as a guide.
  6858. X
  6859. X2. (cosyn.icn, 50 points) The model of string scanning used earlier in 
  6860. Xcoscan.icn is not limited to string analysis. It also can be used for 
  6861. Xsynthesis. Produce a version of the programmer-defined control operation 
  6862. XScan{s,e} as for Problem 2 of Homework Assignment 7, but instead of having it 
  6863. Xreturn the value of e, have it return the value of &subject at the time the 
  6864. Xevaluation of the second argument of Scan is complete. Furthermore, add the 
  6865. Xfollowing synthesis functions:
  6866. X
  6867. X   append(s)    Append the value of s to &subject.
  6868. X   prepend(s)    Prepend the value of s to &subject.
  6869. X   Left(i,s)    Place &subject at the left of a string of length i
  6870. X        using s as a filler (compare to left(s1,i,s2)) and 
  6871. X        note the initial uppercase letter to differentiate 
  6872. X        the two.
  6873. X   Right(i,s)    As for Left(i,s) above, but at the right.
  6874. X
  6875. XFor example,
  6876. X
  6877. X    Scan{"abc",append("--") & prepend("++")}
  6878. X
  6879. Xshould produce
  6880. X
  6881. X    ++abc--
  6882. Xand
  6883. X    Scan{"abc",Left(10,"x")}
  6884. X
  6885. Xshould produce
  6886. X
  6887. X    abcxxxxxxx
  6888. X
  6889. XNote: Since &subject may be changed by synthesis functions, its value should 
  6890. Xbe saved and restored following the same protocol that is used for &pos in 
  6891. Xanalysis functions.
  6892. X
  6893. XDo not provide your own main procedure, but link in /usr/ralph/synmain in a 
  6894. Xfashion similar to that used in previous assignments.
  6895. X
  6896. X                             end-of-assignment-8
  6897. END_OF_icon/homework/assign.08
  6898. if test 1897 -ne `wc -c <icon/homework/assign.08`; then
  6899.     echo shar: \"icon/homework/assign.08\" unpacked with wrong size!
  6900. fi
  6901. # end of overwriting check
  6902. fi
  6903. if test -f icon/homework/assign.09 -a "${1}" != "-c" ; then 
  6904.   echo shar: Will not over-write existing file \"icon/homework/assign.09\"
  6905. else
  6906. echo shar: Extracting \"icon/homework/assign.09\" \(1072 characters\)
  6907. sed "s/^X//" >icon/homework/assign.09 <<'END_OF_icon/homework/assign.09'
  6908. X                    C.Sc. 550 - String and List Processing
  6909. X
  6910. X           Homework Assignment 9 - Due Thursday, November 14, 1985
  6911. X
  6912. X
  6913. X1. (recgen.icn, 50 points) Do Exercise 15.7 in the Icon book. Use the notation 
  6914. Xfor grammars as given in Chapter 15, where uppercase letters denote 
  6915. Xnonterminal symbols and all other characters except the vertical bar stand for 
  6916. Xthemselves as terminal symbols. Assume that the goal will appear as a single 
  6917. Xuppercase letter as the last line of the grammatical specification.
  6918. X
  6919. XRead your grammar input from the file  /usr/ralph/recgen.gmr.  Write the 
  6920. Xrecognizer to /tmp/name/recog.icn, where `name' is your user name. Translate 
  6921. Xand execute recog.icn from your recgen program, giving it 
  6922. X/usr/ralph/recog.test as input.
  6923. X
  6924. X2. (lprint.icn, 15 points) Do Exercise 16.2 in the Icon book. Read trees in 
  6925. Xstring form from /usr/ralph/strees.dat, convert them to list form using ltree 
  6926. Xfrom page 172 of the Icon book. (That procedure can be accessed by linking 
  6927. X/usr/icon/ilib/structs). Print the list forms, indenting 3 characters per 
  6928. Xlevel of depth.
  6929. END_OF_icon/homework/assign.09
  6930. if test 1072 -ne `wc -c <icon/homework/assign.09`; then
  6931.     echo shar: \"icon/homework/assign.09\" unpacked with wrong size!
  6932. fi
  6933. # end of overwriting check
  6934. fi
  6935. if test -f icon/homework/assign.10 -a "${1}" != "-c" ; then 
  6936.   echo shar: Will not over-write existing file \"icon/homework/assign.10\"
  6937. else
  6938. echo shar: Extracting \"icon/homework/assign.10\" \(785 characters\)
  6939. sed "s/^X//" >icon/homework/assign.10 <<'END_OF_icon/homework/assign.10'
  6940. X                    C.Sc. 550 - String and List Processing
  6941. X
  6942. X           Homework Assignment 10 - Due Thursday, December 5, 1985
  6943. X
  6944. X
  6945. X1. (code.icn, 100 points) Extend the solution of Problem 1 of Homework 
  6946. XAssignment 5 to allow pointer loops and multiple pointers to a single object.
  6947. X
  6948. XAny possible object is fair game; do the best you can with types that were not 
  6949. Xconsidered before. You may assume that the program in which the decoding is 
  6950. Xdone contains the same declarations as the program in which the encoding is 
  6951. Xdone.
  6952. X
  6953. XExtra credit (10 points): Arrange to handle any character that may occur in a 
  6954. Xstring or cset.
  6955. X
  6956. XDo not provide your own main procedure, but link to /usr/ralph/codemain, which 
  6957. Xcontains a main procedure and tests.
  6958. X
  6959. X                             end-of-assignment-10
  6960. END_OF_icon/homework/assign.10
  6961. if test 785 -ne `wc -c <icon/homework/assign.10`; then
  6962.     echo shar: \"icon/homework/assign.10\" unpacked with wrong size!
  6963. fi
  6964. # end of overwriting check
  6965. fi
  6966. if test ! -d icon/solution ; then
  6967.     echo shar: Creating directory \"icon/solution\"
  6968.     mkdir icon/solution
  6969. fi
  6970. if test -f icon/solution/solution.01 -a "${1}" != "-c" ; then 
  6971.   echo shar: Will not over-write existing file \"icon/solution/solution.01\"
  6972. else
  6973. echo shar: Extracting \"icon/solution/solution.01\" \(1244 characters\)
  6974. sed "s/^X//" >icon/solution/solution.01 <<'END_OF_icon/solution/solution.01'
  6975. X         C.Sc. 550 - String and List Processing
  6976. X      Suggested Solutions to Homework Assignment 1
  6977. X               September 16, 1985
  6978. X
  6979. X1. nest.icn
  6980. X
  6981. X    procedure main()
  6982. X    lineno := bcount := 0
  6983. X    while line := read() do {
  6984. X        lineno +:= 1
  6985. X        if find("{",line) then bcount +:= 1
  6986. X        else if find("}",line) then {
  6987. X        bcount -:= 1
  6988. X        if bcount < 0 then stop("negative count in line ",lineno)
  6989. X        }
  6990. X        }
  6991. X    if bcount > 0 then stop("positive count at end of file")
  6992. X    end
  6993. X
  6994. X
  6995. X2. cases.icn
  6996. X
  6997. X    procedure main()
  6998. X    ucount := lcount := 0
  6999. X    while line := read() do {
  7000. X        i := 1
  7001. X        while j := upto(&lcase,line,i) do {
  7002. X        i := many(&lcase,line,j)
  7003. X        lcount +:= i-j
  7004. X        }
  7005. X        i := 1
  7006. X        while j := upto(&ucase,line,i) do {
  7007. X        i := many(&ucase,line,j)
  7008. X        ucount +:= i-j
  7009. X        }
  7010. X        }
  7011. X    if lcount = 0 then ratio := "-"
  7012. X    else ration := real(ucount) / lcount
  7013. X    write(right(ucount,10),right(lcount,10),"  ",ratio)
  7014. X    end
  7015. X
  7016. X
  7017. X3. palin.icn
  7018. X
  7019. X    procedure main()
  7020. X    while line := read() do
  7021. X        write(palin(line))
  7022. X    end
  7023. X
  7024. X    procedure palin(line)
  7025. X    sent := delete(map(line,&ucase,&lcase),~&lcase)
  7026. X    if sent == reverse(sent) then return line
  7027. X    else fail
  7028. X    end
  7029. X
  7030. X    procedure delete(s,c)
  7031. X    while i := upto(c,s) do
  7032. X        s[i:many(c,s,i)] := ""
  7033. X    return s
  7034. X    end
  7035. X
  7036. X          end-of-suggested-solutions-1
  7037. END_OF_icon/solution/solution.01
  7038. if test 1244 -ne `wc -c <icon/solution/solution.01`; then
  7039.     echo shar: \"icon/solution/solution.01\" unpacked with wrong size!
  7040. fi
  7041. # end of overwriting check
  7042. fi
  7043. if test -f icon/solution/solution.03 -a "${1}" != "-c" ; then 
  7044.   echo shar: Will not over-write existing file \"icon/solution/solution.03\"
  7045. else
  7046. echo shar: Extracting \"icon/solution/solution.03\" \(1577 characters\)
  7047. sed "s/^X//" >icon/solution/solution.03 <<'END_OF_icon/solution/solution.03'
  7048. X
  7049. X
  7050. X          Suggested Solutions to Homework Assignment 3
  7051. X
  7052. X1. chaos.icn
  7053. X
  7054. X   procedure main()
  7055. X     local i
  7056. X     i := 0
  7057. X     until i = 500 do {
  7058. X       i +:= 1
  7059. X       write(right(q(i),6))         # write without linefeed
  7060. X       if (i % 5) = 0 then write()  # terminate line on 5 columns
  7061. X       }
  7062. X   end
  7063. X
  7064. X   procedure q(i)
  7065. X     static qmem
  7066. X     local j
  7067. X     initial {
  7068. X        q := table()
  7069. X        qmem[1] := qmem[2] := 1
  7070. X        }
  7071. X     if j := \qmem[i] then return j
  7072. X     else return qmem[i] := q(i-q(i-1)) + q(i-q(i-2))
  7073. X   end
  7074. X
  7075. X
  7076. X2. qcalls.icn
  7077. X
  7078. X   global qcalls
  7079. X
  7080. X   procedure main()
  7081. X     i := 0
  7082. X     until i = 12 do {
  7083. X        qcalls := 0
  7084. X        i +:= 1
  7085. X        write(right(1,5),right(q(i),6),right(qcalss,7))
  7086. X        }
  7087. X   end
  7088. X
  7089. X
  7090. X3. comb.icn
  7091. X
  7092. X   procedure main()
  7093. X     comb("abcd",3)
  7094. X     comb("0123456789",8)
  7095. X     comb("ABCDEFGH",2)
  7096. X   end
  7097. X
  7098. X   # This procedure makes use of the fact that the general situation
  7099. X   # in forming combinations is that some objects have been selected
  7100. X   # and some remain to be selected. There are no selected objects
  7101. X   # initially, but omn recursive computation, there are. Hence the
  7102. X   # procedure is given a third argument that is omitted in the 
  7103. X   # initial call, but is supplied in subsequent recursive calls.
  7104. X   #
  7105. X
  7106. X   procedure comb(remaining,i,selected)
  7107. X      local c
  7108. X      /selected := ""                        # supply default
  7109. X      if i = 0 then write(selected)
  7110. X      while c := remaining[i] do {           # select one
  7111. X         remaining[1] := ""                  # and remove it
  7112. X         comb(remaining,i-1,selected || c)
  7113. X         }
  7114. X   end
  7115. END_OF_icon/solution/solution.03
  7116. if test 1577 -ne `wc -c <icon/solution/solution.03`; then
  7117.     echo shar: \"icon/solution/solution.03\" unpacked with wrong size!
  7118. fi
  7119. # end of overwriting check
  7120. fi
  7121. if test -f icon/solution/solution.06 -a "${1}" != "-c" ; then 
  7122.   echo shar: Will not over-write existing file \"icon/solution/solution.06\"
  7123. else
  7124. echo shar: Extracting \"icon/solution/solution.06\" \(2060 characters\)
  7125. sed "s/^X//" >icon/solution/solution.06 <<'END_OF_icon/solution/solution.06'
  7126. X
  7127. X                    C.Sc. 550 - String and List Processing
  7128. X
  7129. X                 Suggested Solutions to Homework Assignment 6
  7130. X
  7131. X
  7132. X1. code.icn. The only procedure affected by string scanning is pair:
  7133. X
  7134. X   procedure pair(s)
  7135. X      local i
  7136. X      s ? while i := tab(many('0123456789')) do {
  7137. X         suspend [move(1),move(i)] \ 1
  7138. X      }
  7139. X   end
  7140. X
  7141. X
  7142. X2. fix.icn. There are many possible approaches to this problem. Here is a 
  7143. X"conservative" one:
  7144. X
  7145. X   procedure main()
  7146. X      while exp := read() do {
  7147. X         write(exp := infix(exp))
  7148. X         write(prefix(exp))
  7149. X      }
  7150. X   end
  7151. X
  7152. X   procedure infix(exp)
  7153. X      local op, arg1, arg2
  7154. X      exp ?:=
  7155. X         if {
  7156. X            op := tab(any('+-/*')) &
  7157. X            =="(" &
  7158. X            arg1 := tab(bal(',')) &
  7159. X            move(1) &
  7160. X            arg2 := tab(bal(')')) &
  7161. X            pos(-1)
  7162. X         } then "(" || infix(arg1) || op || infix(arg2) || ")"
  7163. X      return exp
  7164. X   end
  7165. X
  7166. X   procedure prefix(exp)
  7167. X      local op, arg1, arg2
  7168. X      exp ?:=
  7169. X         if { 
  7170. X            =="(" &
  7171. X            arg1 := tab(bal('+-/*')) &
  7172. X            op := move(1) &
  7173. X            arg2 := tab(bal(')')) &
  7174. X            pos(-1)
  7175. X         } then op || "(" || prefix(arg1) || "," || prefix(arg2) || ")"
  7176. X      return exp
  7177. X   end
  7178. X
  7179. XA more "aggressive" approach avoids auxiliary identifiers by using the oprder 
  7180. Xin which string scanning produces strings to the best advantage:
  7181. X
  7182. X   procedure main()
  7183. X      while exp := read() do {
  7184. X         write(exp := infix(exp))
  7185. X         write(prefix(exp))
  7186. X      }
  7187. X   end
  7188. X
  7189. X   procedure infix(exp)
  7190. X      local rexp
  7191. X      exp ?
  7192. X         if rexp :== tab(any('+-/*')) then
  7193. X            rexp :== =="(" || infix(tab(bal(','))) || (move(1),rexp) ||
  7194. X               infix(tab(bal(')'))) || ==")"
  7195. X         else rexp :== tab(0)
  7196. X      return rexp
  7197. X   end
  7198. X
  7199. X   procedure prefix(exp)
  7200. X      local rexp
  7201. X      exp ?
  7202. X         if rexp :== =="(" || prefix(tab(bal('+-/*'))) then
  7203. X            rexp :== move(1) || rexp || "," || prefix(tab(bal(')'))) || ==")"
  7204. X         else rexp :== tab(0)
  7205. X      return rexp
  7206. X   end
  7207. X
  7208. X                              end-of-solutions-6
  7209. END_OF_icon/solution/solution.06
  7210. if test 2060 -ne `wc -c <icon/solution/solution.06`; then
  7211.     echo shar: \"icon/solution/solution.06\" unpacked with wrong size!
  7212. fi
  7213. # end of overwriting check
  7214. fi
  7215. if test -f icon/solution/solution.08 -a "${1}" != "-c" ; then 
  7216.   echo shar: Will not over-write existing file \"icon/solution/solution.08\"
  7217. else
  7218. echo shar: Extracting \"icon/solution/solution.08\" \(1364 characters\)
  7219. sed "s/^X//" >icon/solution/solution.08 <<'END_OF_icon/solution/solution.08'
  7220. X                    C.Sc. 550 - String and List Processing
  7221. X
  7222. X                 Suggested Solutions to Homework Assignment 8
  7223. X
  7224. X
  7225. X1. comb.icn
  7226. X
  7227. X   procedure comb(s, i)
  7228. X      local j
  7229. X      if i < 1 then fail
  7230. X      suspend if i = 1 then !s
  7231. X         else s[j:=1 to *s-i+1] || comb(s[j + 1:0], i-1)
  7232. X   end
  7233. X
  7234. X
  7235. X2. cosyn.icn
  7236. X
  7237. X   procedure append(s)
  7238. X      suspend &pos <- 1 & .(&subject <- &subject || s)
  7239. X   end
  7240. X
  7241. X   procedure prepend(s)
  7242. X      suspend &pos <- 1 & .(&subject <- s || &subject)
  7243. X   end
  7244. X
  7245. X   procedure Right(i, s)
  7246. X      suspend &pos <- 1 & .(&subject <- right(&subject, i, s))
  7247. X   end
  7248. X
  7249. X   procedure Left(i, s)
  7250. X      suspend &pos <- 1 & .(&subject <- left(&subject, i, s))
  7251. X   end
  7252. X
  7253. XThe main procedure used for testing follows. The procedure snapshot is from 
  7254. Xthe Icon program library; see TR 85-18
  7255. X
  7256. X   link "/usr/icon/ilib/snapshot"
  7257. X
  7258. X   procedure main()
  7259. X      watch()
  7260. X      every write(Scan{("Hi" | "Ahoy") || " there",
  7261. X         watch(move(2)) || watch(append("!!! ")) || watch(move(4) ||
  7262. X            watch(prepend(".")))})
  7263. X      watch()
  7264. X      wlist := ["Here", "we", "go", "again"]
  7265. X      every write(Scan{!wlist, Left(1 to 3, "+-") & Right(1 to 3, "*.")})
  7266. X   end
  7267. X
  7268. X   procedure watch(s)
  7269. X      /s := ""
  7270. X      write("evaluating ...")
  7271. X      snapshot()
  7272. X      suspend s
  7273. X      write("resuming ...")
  7274. X      snapshot()
  7275. X   end
  7276. X
  7277. X                         end-of-suggested-solutions-8
  7278. END_OF_icon/solution/solution.08
  7279. if test 1364 -ne `wc -c <icon/solution/solution.08`; then
  7280.     echo shar: \"icon/solution/solution.08\" unpacked with wrong size!
  7281. fi
  7282. # end of overwriting check
  7283. fi
  7284. if test -f icon/solution/solution.mid -a "${1}" != "-c" ; then 
  7285.   echo shar: Will not over-write existing file \"icon/solution/solution.mid\"
  7286. else
  7287. echo shar: Extracting \"icon/solution/solution.mid\" \(1415 characters\)
  7288. sed "s/^X//" >icon/solution/solution.mid <<'END_OF_icon/solution/solution.mid'
  7289. X                    C.Sc. 550 - String and List Processing
  7290. X
  7291. X                             Results of Midterm 1
  7292. X
  7293. XGrades
  7294. X
  7295. X      high        100
  7296. X      low          75
  7297. X
  7298. X      mean         85.12
  7299. X      median       84
  7300. X      mode         85
  7301. X
  7302. X
  7303. XSolutions
  7304. X
  7305. X1.
  7306. X   procedure main()
  7307. X      chars := table(0)
  7308. X      every chars[!!&input] +:= 1
  7309. X      clist := sort(chars,3)
  7310. X      while write(get(clist),":",right(get(clist),10))
  7311. X   end
  7312. X
  7313. X2.
  7314. X      |--------------|
  7315. X      |              |
  7316. X      v  |--------|  |
  7317. Xa -->--->|     15 |  |
  7318. X      ^  |--------|  |
  7319. Xb ----| -----.    |  |
  7320. X        /|--------|  |
  7321. X       / |     10 |  |
  7322. X       | |--------|  |
  7323. X       | |     20 |  |
  7324. X       v |--------|  |
  7325. X       |             |
  7326. X       \ |--------|  |
  7327. Xc ->---->|    .---->-|
  7328. X         |--------|  ^
  7329. X         |    .------|
  7330. X         |--------|
  7331. X
  7332. X3.
  7333. X   (1)   {5,6,7}
  7334. X   (2)   {1,2,3,1,2,3,4,2,3,2,3,4}
  7335. X   (3)   {1,0,-1,2,1,0,3,2,1}
  7336. X   (4)   {1,2,3,1}
  7337. X   (5)   {"11","12","13","21","22","23","31","32","33"}
  7338. X   (6)   {1,2,3,1,2,3,1,2,3,...}
  7339. X   (7)   {1,2,3}
  7340. X   (8)   {5,6,7,8,9,10,11,12,13,14,15}
  7341. X
  7342. X4.
  7343. X   procedure factorial()
  7344. X      local fact,i
  7345. X      fact := 1
  7346. X      i := 0
  7347. X      suspend fact *:= (i +:= |1)
  7348. X# could have said: suspend fact *:= seq(1)
  7349. X   end
  7350. X
  7351. X5a
  7352. X           L(expr2)
  7353. X   S(expr2)        +o S(expr3)
  7354. X
  7355. X5b
  7356. X   L(expr1) = 0
  7357. Xor
  7358. X   L(expr1) = 1 and L(expr3) = 0
  7359. Xor
  7360. X   L(expr2) = L(expr3) = 0
  7361. X
  7362. X
  7363. X                          end-of-solutions-midterm
  7364. END_OF_icon/solution/solution.mid
  7365. if test 1415 -ne `wc -c <icon/solution/solution.mid`; then
  7366.     echo shar: \"icon/solution/solution.mid\" unpacked with wrong size!
  7367. fi
  7368. # end of overwriting check
  7369. fi
  7370. echo shar: End of archive 1 \(of 3\).
  7371. cp /dev/null ark1isdone
  7372. MISSING=""
  7373. for I in 1 2 3 ; do
  7374.     if test ! -f ark${I}isdone ; then
  7375.     MISSING="${MISSING} ${I}"
  7376.     fi
  7377. done
  7378. if test "${MISSING}" = "" ; then
  7379.     echo You have unpacked all 3 archives.
  7380.     rm -f ark[1-9]isdone
  7381. else
  7382.     echo You still need to unpack the following archives:
  7383.     echo "        " ${MISSING}
  7384. fi
  7385. ##  End of shell archive.
  7386. exit 0
  7387. -- 
  7388. UUCP and other network      )\/(    ..!hp4nl!kunivv1!atcmpe!gertjan
  7389.   connections via mcvax      )/\(    gertjan@atcmp.nl (internet)
  7390. This note does not necessarily represent the position of AT Computing BV
  7391.  
  7392. From att!ihuxy!nowlin  Tue Feb 21 07:18:13 1989
  7393. Date: Tue, 21 Feb 89 07:18:13 MST
  7394. Message-Id: <8902211418.AA24553@megaron.arizona.edu>
  7395. Received: by megaron.arizona.edu (5.59-1.7/15)
  7396.     id AA24553; Tue, 21 Feb 89 07:18:13 MST
  7397. Received: by att.ATT.COM (smail2.6 - att-ih)
  7398.     id AA06769; 21 Feb 89 08:14:24 CST (Tue)
  7399. From: ihuxy!nowlin (Jerry D Nowlin +1 312 979 0441)
  7400. To: att!arizona!icon-group
  7401. Subject: Re: tables and &self
  7402.  
  7403. There are lots of people who look on Icon as a magic lamp and expect it to
  7404. be able to do anything.  That's mostly because Icon is so darn useful right
  7405. out of the box.  We expect it to automatically do all the things we're
  7406. accustomed to doing explicitly in other languages.  I know I sit around
  7407. sometimes trying to find the simplest Icon solution to things and can't
  7408. understand why I still have to do initializations and loops and other busy
  7409. stuff.
  7410.  
  7411. Consider how many languages give you a data type like tables in the first
  7412. place.  How many of them then let you write a simple procedure that makes
  7413. initializing identity tables so easy?
  7414.  
  7415.     procedure main()
  7416.  
  7417.         t := selftbl(&ascii)
  7418.         every p := !sort(t) do
  7419.             write("table[",p[1],"] = '",p[2],"'")
  7420.     end
  7421.  
  7422.     procedure selftbl(self)
  7423.  
  7424.         tbl := table()
  7425.         every tbl[s := !self] := s
  7426.         return tbl
  7427.     end
  7428.  
  7429. I'm just thankful that Icon makes these mundane types of programming tasks
  7430. so simple and easy.
  7431.  
  7432. > I found another circumstance where the table(&self) would have been useful,
  7433. > though it would have been a generalization of what I suggested last time.
  7434. > In particular, I was needing to sort some records according to the
  7435. > magnitude of one of their components. In this case, a generalization
  7436. > of what I had before,
  7437.  
  7438. If you're in need of a way to sort lists of records I have a record sorting
  7439. procedure that will let you sort on any field in a record.  In fact it will
  7440. let you recursively sort on a number of different record fields.  If you're
  7441. interested let me know and I can mail it to you or post it to the group.
  7442.  
  7443. Jerry Nowlin
  7444. (...!att!ihuxy!nowlin)
  7445.  
  7446. From @CUNYVM.CUNY.EDU:EM302723@VMTECMEX.BITNET  Wed Feb 22 16:01:05 1989
  7447. Message-Id: <8902222301.AA26384@megaron.arizona.edu>
  7448. Received: from cunyvm.cuny.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7449.     id AA26384; Wed, 22 Feb 89 16:01:05 MST
  7450. Received: from VMTECMEX.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 3846; Wed, 22 Feb 89 17:58:33 EST
  7451. Date: Wed, 22 Feb 89 13:41:09 MEX
  7452. To: icon-group@arizona.edu
  7453. From: EM302723%VMTECMEX.BITNET@CUNYVM.CUNY.EDU
  7454. Comment: CROSSNET mail via SMTP@INTERBIT
  7455.  
  7456. Date: 22 February 89, 13:39:56 MEX
  7457. From: Mario Camou Riveroll                           EM302723 at VMTECMEX
  7458. To:   ICON-GROUP at ARIZONA
  7459.  
  7460. Hi, all.
  7461. Is there an implementation of Icon for an IBM 4381 running CP/CMS on
  7462. VM/SP?
  7463.  
  7464. Mario Camou R.
  7465. EM302723@VMTECMEX.BITNET
  7466.  
  7467. From KARNA@wharton.upenn.edu  Fri Mar 10 12:11:20 1989
  7468. Received: from REMOTE.DCCS.UPENN.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7469.     id AA00141; Fri, 10 Mar 89 12:11:20 MST
  7470. Return-Path: <KARNA@wharton.upenn.edu>
  7471. Received: from WHARTON.UPENN.EDU by remote.dccs.upenn.edu
  7472.     id AA08241; Fri, 10 Mar 89 14:12:43 EST
  7473. Message-Id: <8903101912.AA08241@remote.dccs.upenn.edu>
  7474. Date: Fri, 10 Mar 89 14:11 EST
  7475. From: KARNA@wharton.upenn.edu
  7476. Subject: Icon 7.0 and Icon 7.5
  7477. To: icon-group@arizona.edu
  7478. X-Vms-To: IN%"icon-group@arizona.edu"
  7479.  
  7480. I'm new to the Icon Mailing List, although I've used version 6.1 of 
  7481. Icon off-and-on for about two years.  I'm wondering . . . can anyone
  7482. tell me what the differences are between 6.1 and 7.x (to the most 
  7483. recent version)?
  7484.  
  7485.     -- Karna@wharton.upenn.edu
  7486.  
  7487. From dscargo@cim-vax.honeywell.com  Fri Mar 10 12:21:26 1989
  7488. Message-Id: <8903101921.AA00602@megaron.arizona.edu>
  7489. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7490.     id AA00602; Fri, 10 Mar 89 12:21:26 MST
  7491. Date: 10 Mar 89 13:18:00 CST
  7492. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  7493. Subject: Icon in Icon
  7494. To: "icon-group" <icon-group@arizona.edu>
  7495.  
  7496. Out of curiousity, has anyone tried to rewrite the C programs for itran
  7497. and ilink into Icon to see hom much shorter and easier (and slower) they
  7498. would be?
  7499.  
  7500. dsc
  7501.  
  7502.  
  7503. From kwalker  Fri Mar 10 15:16:38 1989
  7504. Date: Fri, 10 Mar 89 15:16:38 MST
  7505. From: "Kenneth Walker" <kwalker>
  7506. Message-Id: <8903102216.AA08693@megaron.arizona.edu>
  7507. Received: by megaron.arizona.edu (5.59-1.7/15)
  7508.     id AA08693; Fri, 10 Mar 89 15:16:38 MST
  7509. In-Reply-To: <8903101912.AA08241@remote.dccs.upenn.edu>
  7510. To: icon-group
  7511. Subject: Re:  Icon 7.0 and Icon 7.5
  7512.  
  7513.     Date: Fri, 10 Mar 89 14:11 EST
  7514.     From: KARNA@wharton.upenn.edu
  7515.     
  7516.     I'm wondering . . . can anyone
  7517.     tell me what the differences are between 6.1 and 7.x 
  7518.  
  7519. As listed in the University of Arizona technical report TR88-41, Version
  7520. 7.5 of Icon, the major differences between Version 6 and Verion 7 of 
  7521. Icon are:
  7522.  
  7523.   - New functions, especially for interfacing the operating system and
  7524.       manipulating bits.
  7525.   - Correction of the handling of scanning expressions.
  7526.   - Correction of the handling of co-expression return points and new
  7527.       co-expression facilities.
  7528.   - Declaration of procedures with a variable number of arguments.
  7529.   - The ability to convert potential run-time error to expression failure.
  7530.   - New keywords.
  7531.   - Error traceback, which provides detailed information about the source
  7532.       of run-time errors.
  7533.  
  7534.    Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  7535.    +1 602 621 2858  kwalker@Arizona.EDU   {uunet|allegra|noao}!arizona!kwalker
  7536.  
  7537. From payne@unocss.unl.edu  Mon Mar 20 20:48:26 1989
  7538. Received: from [129.93.1.11] by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7539.     id AA18472; Mon, 20 Mar 89 20:48:26 MST
  7540. Received: by unocss.unl.edu (4.12/4.7)
  7541.     id AA13992; Mon, 20 Mar 89 21:47:10 cst
  7542. Date: Mon, 20 Mar 1989 21:46:47 CST
  7543. From: Matt Payne <payne@unocss.unl.edu>
  7544. Reply-To: payne@unocss.unl.edu
  7545. To: icon-group@arizona.edu
  7546. Subject: icon for the amiga
  7547. Message-Id: <CMM.0.88.606455207.payne@unocss.unl.edu>
  7548.  
  7549. the file /icon/amiga/amiga7.arc appears to only to have source code in it.
  7550. How may I obtain icon for my amiga without compiling it myself?
  7551.  
  7552. Thanks in advance 
  7553.  
  7554.  
  7555. Matt Payne: A proud member of FDR's Small System team 47!
  7556. -------------------------------------+-----------------------------------
  7557.  Consultant                          |  Internet: conslt10@zeus.unl.edu
  7558.  "Computing and Data Communications" |  UUCP:     uunet!btni!unocss!payne
  7559.  University of Nebraska at Omaha     |  Bitnet:   CONSLT10@UNOMA1
  7560.  Omaha, NE 68182                     |  "No matter where you go..." - B.B.
  7561.  
  7562. From ralph  Tue Mar 21 05:44:34 1989
  7563. Date: Tue, 21 Mar 89 05:44:34 MST
  7564. From: "Ralph Griswold" <ralph>
  7565. Message-Id: <8903211244.AA06984@megaron.arizona.edu>
  7566. Received: by megaron.arizona.edu (5.59-1.7/15)
  7567.     id AA06984; Tue, 21 Mar 89 05:44:34 MST
  7568. To: payne@unocss.unl.edu
  7569. Subject: Re:  icon for the amiga
  7570. Cc: icon-group
  7571. In-Reply-To: <CMM.0.88.606455207.payne@unocss.unl.edu>
  7572.  
  7573. We do not yet have an executable Version 7 Icon for the Amiga.  The source
  7574. is there provisionally for persons who are trying to compile it.
  7575.  
  7576. We hope to have executable files before long.
  7577.  
  7578.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  7579.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  7580.  
  7581.  
  7582. From dscargo@cim-vax.honeywell.com  Tue Mar 21 13:19:03 1989
  7583. Message-Id: <8903212019.AA00881@megaron.arizona.edu>
  7584. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7585.     id AA00881; Tue, 21 Mar 89 13:19:03 MST
  7586. Date: 21 Mar 89 14:19:00 CST
  7587. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  7588. Subject: subscripting expression at a data type
  7589. To: "icon-group" <icon-group@arizona.edu>
  7590.  
  7591. Once again in my use of Icon to develop some applications I've found what
  7592. seems like a limitation that, if removed, would simplify my programming.
  7593. What I've discovered is that setting up ranges in a string (or ranges in a
  7594. list) is difficult because of a need to establish the limits of the ranges
  7595. separately. What I was curious about was the establishment of subscripting
  7596. as a data type.  I don't know about the syntax, though I observe that the
  7597. ":" is used only for subscripting or as part of other tokens.  I was
  7598. imagining something like
  7599.  
  7600. range := i:j #range is now a subscripting expression
  7601. new_list := old_list[range] #since range is a subscripting expression
  7602. # do the subscripting as for old_list[i:j]
  7603.  
  7604. subscripting expressions could then be stored in other structures, returned
  7605. as results from functions, etc.  This change doesn't look like it would cause
  7606. too many syntactical problems (from my naive viewpoint), since ":" as an
  7607. operator doesn't occur outside of subscripting expressions.
  7608.  
  7609. dsc
  7610.  
  7611.  
  7612. From keil@apollo.com  Tue Mar 21 17:05:48 1989
  7613. Received: from APOLLO.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7614.     id AA20583; Tue, 21 Mar 89 17:05:48 MST
  7615. Received: from apollo.apollo.com by apollo.com id AA15311; Tue, 21 Mar 89 16:57:17 EST    
  7616. Received: by apollo.apollo.com id AA10420; Tue, 21 Mar 89 16:50:26 EST
  7617. From: Mark Keil <keil@apollo.com>
  7618. Message-Id: <8903212250.AA10420@apollo.apollo.com>
  7619. Date: Tue, 21 Mar 89 17:29:33 EST 
  7620. Subject: Please add me to your meiling list
  7621. To: icon-group@arizona.edu
  7622.  
  7623. Folks:
  7624.  
  7625.  Please add me to your mailing list.
  7626.  
  7627.  My address is keil@apollo.com
  7628.  
  7629.  Thanks, Mark Keil
  7630.  
  7631. From KARNA@wharton.upenn.edu  Tue Mar 21 18:22:28 1989
  7632. Received: from REMOTE.DCCS.UPENN.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7633.     id AA23486; Tue, 21 Mar 89 18:22:28 MST
  7634. Return-Path: <KARNA@wharton.upenn.edu>
  7635. Received: from WHARTON.UPENN.EDU by remote.dccs.upenn.edu
  7636.     id AA04272; Tue, 21 Mar 89 20:20:55 EST
  7637. Message-Id: <8903220120.AA04272@remote.dccs.upenn.edu>
  7638. Date: Tue, 21 Mar 89 20:22 EST
  7639. From: KARNA@wharton.upenn.edu
  7640. Subject: Range data types
  7641. To: icon-group@arizona.edu
  7642. X-Vms-To: IN%"icon-group@arizona.edu"
  7643.  
  7644. Range data types are an interesting, and very useful, addition.  The only
  7645. languages I know of that currently have it are Smalltalk and Actor.  It 
  7646. shouldn't be too difficult to add it to Icon.  I do agree that the standard
  7647. Icon "a:b" syntax is the best for this data type.  Another use for this 
  7648. kind of data type is as a simplification of an "a to b" generator (so 
  7649. we can have statements like "every i:=range do . . .").  
  7650.  
  7651. p.s.: When I say that Smalltalk and Actor support this type, they do so
  7652. in a very limited way.  
  7653.  
  7654. karna@wharton.upenn.edu
  7655.  
  7656. From ralph  Tue Mar 21 18:48:02 1989
  7657. Date: Tue, 21 Mar 89 18:48:02 MST
  7658. From: "Ralph Griswold" <ralph>
  7659. Message-Id: <8903220148.AA24083@megaron.arizona.edu>
  7660. Received: by megaron.arizona.edu (5.59-1.7/15)
  7661.     id AA24083; Tue, 21 Mar 89 18:48:02 MST
  7662. To: KARNA@wharton.upenn.edu
  7663. Subject: Re:  Range data types
  7664. Cc: icon-group
  7665. In-Reply-To: <8903220120.AA04272@remote.dccs.upenn.edu>
  7666.  
  7667. The idea of a range data type for Icon comes up from time to time.  In fact,
  7668. I think I once proposed it in the early days of Icon.
  7669.  
  7670. There is no conceptual difficulty with implementing it.  However, there are
  7671. many small things that have to be worked out.  And *any* new data type
  7672. adds a lot of things -- not just code and what the data type does, but
  7673. how it fits in with the rest of the language.  In other words, it increases
  7674. the "semantic volume" of the language.
  7675.  
  7676. It's easier to see the uses of such an extension than it is to assess the
  7677. negative impact that is diffuse.  Icon already is a huge language and
  7678. frequently criticized (rightly, in my opinion) for its size.
  7679.  
  7680. My general view on such possible extensions, which may make some things
  7681. easier, but not add in a major way to the usefulness of the language, is
  7682. to be conservative.  If such a feature subsumes another or leads to
  7683. unification of apparently disparate features, I get a lot more excited
  7684. than as a "stand-alone" enhancement.
  7685.  
  7686.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  7687.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  7688.  
  7689.  
  7690. From KARNA@wharton.upenn.edu  Tue Mar 21 19:49:32 1989
  7691. Received: from REMOTE.DCCS.UPENN.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7692.     id AA26097; Tue, 21 Mar 89 19:49:32 MST
  7693. Return-Path: <KARNA@wharton.upenn.edu>
  7694. Received: from WHARTON.UPENN.EDU by remote.dccs.upenn.edu
  7695.     id AA05769; Tue, 21 Mar 89 21:48:09 EST
  7696. Message-Id: <8903220248.AA05769@remote.dccs.upenn.edu>
  7697. Date: Tue, 21 Mar 89 21:49 EST
  7698. From: KARNA@wharton.upenn.edu
  7699. Subject: Object-Oriented Icon
  7700. To: icon-group@arizona.edu
  7701. X-Vms-To: IN%"icon-group@arizona.edu"
  7702.  
  7703. Does anyone know of any research currently underway regarding object-oriented
  7704. Icon?  I agree with Dr. Griswald -- simply adding the features to Icon is
  7705. too clumsy (it is yet another case of adding features to an already large
  7706. language); ideally, the extensions would have to be fully integrated into
  7707. Icon, directly to the heart of the language.  
  7708.  
  7709. If there is no formal research in the topic, would anyone like to work
  7710. on it with me (i.e., an "over the network" development scenario)?  If there
  7711. is any research underway, can I join?
  7712.  
  7713. Talk to you later!
  7714.  
  7715. -- karna@wharton.upenn.edu
  7716.  
  7717. From wgg@june.cs.washington.edu  Wed Mar 22 16:43:47 1989
  7718. Received: from june.cs.washington.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  7719.     id AA23574; Wed, 22 Mar 89 16:43:47 MST
  7720. Received: by june.cs.washington.edu (5.59/6.13+)
  7721.     id AA21302; Wed, 22 Mar 89 14:24:54 PST
  7722. Date: Wed, 22 Mar 89 14:24:54 PST
  7723. From: wgg@june.cs.washington.edu (William Griswold)
  7724. Return-Path: <wgg>
  7725. Message-Id: <8903222224.AA21302@june.cs.washington.edu>
  7726. To: KARNA@wharton.upenn.edu, icon-group@arizona.edu
  7727. Subject: Re:  Object-Oriented Icon
  7728.  
  7729. >Date: Tue, 21 Mar 89 21:49 EST
  7730. >From: KARNA@wharton.upenn.edu
  7731. >Subject: Object-Oriented Icon
  7732. >To: icon-group@arizona.edu
  7733. >
  7734. >Does anyone know of any research currently underway regarding object-oriented
  7735. >Icon?  I agree with Dr. Griswald -- simply adding the features to Icon is
  7736. >too clumsy (it is yet another case of adding features to an already large
  7737. >language); ideally, the extensions would have to be fully integrated into
  7738. >Icon, directly to the heart of the language.  
  7739. >
  7740. >...
  7741. >
  7742. >Talk to you later!
  7743. >
  7744. >-- karna@wharton.upenn.edu
  7745.  
  7746. I have used personalized interpreters to implement what some would
  7747. call an object-oriented Icon.  The additions to the translator were
  7748. simple, and no changes were required in the interpreter.
  7749.  
  7750. To really get this right might require creating a new language, rather
  7751. than extending Icon.  For example, a raw record type is a little out of
  7752. place in an OO language.  Also, decisions as to what to do with
  7753. existing (non-OO) types in Icon would require some tough decisions.
  7754. A language with two type models is a little awkward, but so are
  7755. integers implemented in an OO style.  Decisions, decisions....
  7756.  
  7757. What follows is a ``brief'' write-up on Object-Oriented Icon.
  7758.  
  7759.  
  7760.             Programming in Object Icon
  7761.  
  7762. Object Icon is an simple extension of Icon that permits the definition of 9
  7763. types so that a value carries its valid operations with it.  This definition
  7764. does not support encapsulation.  Object Icon will compile old Icon programs.
  7765.  
  7766.  
  7767.  
  7768. A new user type (class) is defined by the class declaration.
  7769.  
  7770.     class type(field1,field2,...)
  7771.  
  7772. This defines type as a class possessing each field[i] as an attribute.
  7773. For example the following definition defines a stack class with attributes
  7774. st, push, pop, size, and init.
  7775.  
  7776.     class stack(rep,push,pop,size,init)
  7777.  
  7778.  
  7779. Each attribute is actually an instance variable.  Any value may be stored
  7780. in an instance variable.  Instance variables might hold class procedures.
  7781. The syntax for a class method is
  7782.  
  7783.     procedure type::name(arg1,arg2,...)
  7784.  
  7785. If name is an attribute of type, creating an instance (object) of
  7786. type will cause the instance variable name to be initialized to the
  7787. procedure defined by type::name.  When called, a class procedure has an
  7788. implicit local variable self that contains the value of the instance
  7789. that is invoking the operation.  This permits a class procedure to access the
  7790. instance variables of the invoking instance.  Consider the following
  7791. class procedure:
  7792.  
  7793.     procedure stack::push(value)
  7794.  
  7795.         push(self.rep,value)
  7796.         return self
  7797.     end
  7798.  
  7799. This procedure uses self to access the instance variable st to perform a push
  7800. operation on the list stored in it.  A class procedure is accessed through the
  7801. '$' operator.  For example
  7802.  
  7803.     mystack$push("hello")
  7804.  
  7805. invokes stack::push for mystack, pushing the value "hello" on it.  A class
  7806. procedure can also be accessed directly with the '::' syntax.  For example
  7807.  
  7808.     mystack.pop := stack::pop
  7809.  
  7810. assigns the procedure stack::pop to the pop field of mystack.  The operation
  7811. can also be invoked directly, as in
  7812.  
  7813.     stack::push("world")
  7814.  
  7815. However, this is unlikely to be meaningful if the push operation accesses
  7816. the self variable (which in this case would be null).  However, this syntax
  7817. is useful for the object creation operation:
  7818.  
  7819.     mystack := stack::stack()
  7820.  
  7821. The self variable in stack::stack is null on entry to the procedure, but
  7822. is initialized during its execution.  Here is the implementation of the
  7823. constructor stack::stack.
  7824.  
  7825.     procedure stack::stack()
  7826.  
  7827.         self := new_stack()
  7828.         self.rep := []
  7829.         return self
  7830.     end
  7831.  
  7832. The procedure new_stack is defined implicitly by the system.  It calls
  7833. the alloction function stack, and initializes all the instance variables
  7834. that have procedures defined for them.
  7835.  
  7836.  
  7837. This concludes the extensions to basic Icon.  The following explains how to
  7838. take advantage of these definitions to aid programming.
  7839.  
  7840. Icon's field access operations are polymorphic.  This means that the field
  7841. reference x.field is defined as long as the value x is a record that has
  7842. a field x.  The same is true for class instances.  This means that instance
  7843. variables of the same name in different classes are implicitly and
  7844. automatically shared (it cannot be prevented).  In many cases this overlap
  7845. is meaningful.  For example consider a class array and the above class stack.
  7846.  
  7847.     class array(rep,size,in,out,clear)
  7848.  
  7849. Both class define a procedure size that returns an integer representing the
  7850. size of the invoking object:
  7851.  
  7852.     array::size()
  7853.         return *self.rep
  7854.     end
  7855.  
  7856.     stack::size
  7857.         return *self.rep
  7858.     end
  7859.  
  7860. If some variable in the program knows it has an aggregate of some sort, but 
  7861. doesn't care which kind, it can invoke the size procedure and find its
  7862. size, regardless of whether its an array or stack.
  7863.  
  7864.     agg_size := some_agg$size()
  7865.  
  7866. Not only can actual fields be shared, but code implementations can as well.
  7867. For example if the stack and array were actually implemented as above,
  7868. the sharing is easy.  Suppose array just reused the implementation of 
  7869. stack::size by borrowing it in its constructor function:
  7870.  
  7871.     procedure array::array()
  7872.  
  7873.         self := new_array()
  7874.         self.rep := []
  7875.         self.size := stack::size
  7876.         return self
  7877.     end
  7878.  
  7879. This works as expected.  
  7880.  
  7881. Some features that might be expected are not supported.  For example,
  7882. there is no notion of an inheritance declaration such as
  7883.  
  7884.     class stack : aggregate (...)
  7885.  
  7886. that would declare that a stack has all the instance variables and procedures of
  7887. aggregate, plus any additionally defined by stack.  This might be
  7888. forthcoming, but to be effective, it must be very general, allowing
  7889. multiple superclasses and arbitrary hiding of inherited attributes,
  7890. and redefinition of inherited procedures.  As shown above this sharing
  7891. can be handled explicitly by overlapping instance variable names and
  7892. assigning a borrowed procedure directly directly into instance
  7893. variables.  See the end of this document for a possible implementation.
  7894.  
  7895. The following notes on the implementation might be useful.  The
  7896. implementation is accomplished (currently) with a variant translator.
  7897. The Object Icon source is converted into Icon and then compiled as an
  7898. Icon program.  This translation results in a number of names being changed,
  7899. possibly obfuscating tracing.
  7900.  
  7901. As may already be evident, the class notion is based directly on records.
  7902. The class declaration is translated directly to a record declaration of the
  7903. same name.  This means that type(mystack) == "stack".  It also means that
  7904. calling the constructor procedure stack directly does not initialize
  7905. stack instances in a meaningful way. 
  7906.  
  7907. The system does not check that a defined procedure actually corresponds to
  7908. a class definition.  For example, the procedure stack::stack defined
  7909. above does not have a corresponding attribute in the class stack
  7910. declaration.  This means spurious procedures can be defined, but it also
  7911. allows for definition of the constructor without actually storing it
  7912. in each instance. 
  7913.  
  7914. Defining the procedure type::name(arg1,arg2,...) results in defining the
  7915. Icon procedure 
  7916.  
  7917.     type_name(self,arg1,arg2,...) 
  7918.  
  7919. Defining a procedure of type_name directly will result in a compile-time
  7920. error due to the multiple definitions.
  7921.  
  7922. The call expr$name(arg1,arg2,...) results in defining the call
  7923.  
  7924.     (_self_temp := expr).name(_self_temp,arg1,arg2,...)
  7925.  
  7926. or some equivalent.  Using the variable _self_temp directly is unwise,
  7927. since its value might get destroyed by a procedure invocation.
  7928.  
  7929.  
  7930. This is a complete Icon program implementing a stack class.
  7931.  
  7932. class stack(st,push,pop,size,init)
  7933.  
  7934. procedure main()
  7935.  
  7936.     mystack := stack::stack()
  7937.     mystack$push("hello")
  7938.     mystack$push("world")
  7939.     size := mystack$size()
  7940.     write("My stack is size ",size)
  7941.     write("popping ",mystack$pop()," ",mystack$pop())
  7942. end
  7943.  
  7944.  
  7945. procedure stack::stack()
  7946.  
  7947.     self := new_stack()
  7948.     self.st := []
  7949.     return self
  7950. end
  7951.  
  7952.  
  7953. procedure stack::push(value)
  7954.  
  7955.     push(self.st,value)
  7956.     return self
  7957. end
  7958.  
  7959.  
  7960. procedure stack::pop()
  7961.  
  7962.     return pop(self.st)
  7963. end
  7964.  
  7965.  
  7966. procedure stack::size()
  7967.  
  7968.     return *self.st
  7969. end
  7970.  
  7971.  
  7972. procedure stack::init()
  7973.  
  7974.     self.st := []
  7975.     return self
  7976. end
  7977.  
  7978.  
  7979. PROPOSED IMPLEMENTATION STUFF
  7980.  
  7981. To implement
  7982.  
  7983.     class type : supertype1 : supertype2 : ... (field1,field2,...)
  7984.  
  7985. simply substitute the fields of supertype in front of the fields
  7986. defined for type.  redeclaring a field could either result in an error,
  7987. or masking the old field (i.e., its initial value).  Masking initial
  7988. values can be done in the new_type operation in the following fashion:
  7989.  
  7990.     procedure new_type()
  7991.     return type(\type_field1 | \supertype_field1 | ... ,...)
  7992.     end
  7993.  
  7994. resulting in taking the "closest" implementation to the type being defined.
  7995. The problem with the inheritance approach is that it is difficult to 
  7996. imagine a nice syntax that can hide stuff explicitly in this declaration.
  7997. Also, this type of sharing does not prohibit the normal sharing of record
  7998. fields, so that there are two ways to share:  not a good idea if clarity
  7999. is what you're after.  It is probably better to leave it the way it is.
  8000. Also, note that the current method permits sharing class procedure
  8001. implementations across types independent of field names.  This means a
  8002. procedure can be borrowed without the names being the same.  This is
  8003. important, since type is considered to be independent of implementation.
  8004.  
  8005. Another problem with the inheritance is that inherited instance
  8006. variables must get initialized in some way.  For instance variables
  8007. holding class procedures this is not difficult, but it is for others.
  8008. Normally this should be done by the constructor of the superclass,
  8009. but the current method does not allow for this in a transparent
  8010. fashion.  This requires some thought: get a prototype, and do a 
  8011. field-for-field copy?
  8012.  
  8013. From icon-group-request  Sat Mar 25 17:34:11 1989
  8014. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8015.     id AA04481; Sat, 25 Mar 89 17:34:11 MST
  8016. Received: by ucbvax.Berkeley.EDU (5.61/1.36)
  8017.     id AA12192; Sat, 25 Mar 89 15:57:53 -0800
  8018. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  8019.     for icon-group@arizona.edu (icon-group@arizona.edu)
  8020.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  8021. Date: 25 Mar 89 22:41:23 GMT
  8022. From: blake!nealiphc@beaver.cs.washington.edu  (Phillip Neal)
  8023. Organization: Univ of Washington, Seattle
  8024. Subject: iconic programming languages
  8025. Message-Id: <1337@blake.acs.washington.edu>
  8026. Sender: icon-group-request@arizona.edu
  8027. To: icon-group@arizona.edu
  8028.  
  8029.  
  8030.  I am working on an Iconic programming language for image processing on the Macintosh computer. It is a lot like HI-VISUAL. Except it is for a pyramid machine with the Mac as a host. My main question is:
  8031.  
  8032.         How do you manage dyadic operations (for example, add two images) without having the programmer specify the actual memory/image name ?
  8033.  
  8034. That's all for now. I am Phil Neal at U. of Washington. I can be reached at:
  8035.  
  8036.     nealiphc@blake.washington.edu
  8037.  
  8038. From ralph  Sat Mar 25 17:45:40 1989
  8039. Date: Sat, 25 Mar 89 17:45:40 MST
  8040. From: "Ralph Griswold" <ralph>
  8041. Message-Id: <8903260045.AA04887@megaron.arizona.edu>
  8042. Received: by megaron.arizona.edu (5.59-1.7/15)
  8043.     id AA04887; Sat, 25 Mar 89 17:45:40 MST
  8044. To: blake!nealiphc@beaver.cs.washington.edu
  8045. Subject: Re:  iconic programming languages
  8046. Cc: icon-group
  8047. In-Reply-To: <1337@blake.acs.washington.edu>
  8048.  
  8049. I think the name "Icon" for our programming language has misled you. The
  8050. Icon programming language has nothing to do with "iconic programming".
  8051. The name was chosen before the word "icon" came into general use for
  8052. screen pictograms.
  8053.  
  8054.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  8055.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  8056.  
  8057.  
  8058. From @UICVM.uic.edu:EM302723@VMTECMEX.BITNET  Mon Mar 27 11:03:09 1989
  8059. Message-Id: <8903271803.AA11901@megaron.arizona.edu>
  8060. Received: from uicvm.cc.uic.edu.2.248.128.in-addr.arpa by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8061.     id AA11901; Mon, 27 Mar 89 11:03:09 MST
  8062. Received: from VMTECMEX.BITNET by UICVM.uic.edu (IBM VM SMTP R1.2) with BSMTP id 5697; Mon, 27 Mar 89 12:02:28 CST
  8063. Date: Mon, 27 Mar 89 11:58:16 MEX
  8064. To: icon-group@arizona.edu
  8065. From: EM302723%VMTECMEX.BITNET@UICVM.uic.edu
  8066. Comment: CROSSNET mail via SMTP@INTERBIT
  8067.  
  8068. Date: 27 March 89, 11:55:38 MEX
  8069. From: Mario Camou Riveroll      (5)5-20-89-45        EM302723 at VMTECMEX
  8070. To:   ICON-GROUP at ARIZONA
  8071.  
  8072. Subject: Re: Object-oriented Icon
  8073.  
  8074. I also am interested in Object-Oriented Icon. Is it possible to get the
  8075. preprocessor described by Dr. William Griswold in his posting of
  8076. 22 March?
  8077.  
  8078. Mario Camou R.
  8079. EM302723@VMTECMEX.BITNET
  8080.  
  8081. From icon-group-request  Tue Mar 28 16:35:38 1989
  8082. Received: from [10.2.0.78] by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8083.     id AA23942; Tue, 28 Mar 89 16:35:38 MST
  8084. Received: by ucbvax.Berkeley.EDU (5.61/1.36)
  8085.     id AA26738; Tue, 28 Mar 89 15:11:38 -0800
  8086. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  8087.     for icon-group@arizona.edu (icon-group@arizona.edu)
  8088.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  8089. Date: 28 Mar 89 18:03:27 GMT
  8090. From: mcvax!hp4nl!botter!star.cs.vu.nl!biep@uunet.uu.net  (J A Biep Durieux)
  8091. Organization: VU Informatica, Amsterdam
  8092. Subject: Re: iconic programming languages
  8093. Message-Id: <2221@ski.cs.vu.nl>
  8094. References: <1337@blake.acs.washington.edu>
  8095. Sender: icon-group-request@arizona.edu
  8096. To: icon-group@arizona.edu
  8097.  
  8098. In article <1337@blake.acs.washington.edu>, (Phillip Neal) writes:
  8099.  
  8100. > I am working on an Iconic programming language
  8101.  
  8102. Alas!  Icon is no iconic language. On the contrary: the name is
  8103. (by some twisted sense of humor) derived from: "icono*clastic* language".
  8104.  
  8105. So you iconolatrists should go elsewhere.   :-)
  8106.  
  8107. (BTW, it's a nice trick:
  8108.     Iconoclasts have no reason to destroy the language, as it is supposed
  8109.         to be as iconoclastic as themselves, and
  8110.     iconolatrists cannot destroy it, because it's called "icon", so they
  8111.         would become iconoclasts by doins so.)
  8112. -- 
  8113.                         Biep.  (biep@cs.vu.nl via mcvax)
  8114.     Who am I to doubt the existence of God?   I am
  8115.       only a simple man,  I already have trouble
  8116.     enough doubting the existence of my neighbour!
  8117.  
  8118. From ralph  Tue Mar 28 16:45:35 1989
  8119. Date: Tue, 28 Mar 89 16:45:35 MST
  8120. From: "Ralph Griswold" <ralph>
  8121. Message-Id: <8903282345.AA24294@megaron.arizona.edu>
  8122. Received: by megaron.arizona.edu (5.59-1.7/15)
  8123.     id AA24294; Tue, 28 Mar 89 16:45:35 MST
  8124. To: icon-group@arizona.edu, mcvax!hp4nl!botter!star.cs.vu.nl!biep@uunet.uu.net
  8125. Subject: Re: iconic programming languages
  8126. In-Reply-To: <2221@ski.cs.vu.nl>
  8127.  
  8128. I'm sorry to spoil a nice theory, but the name "Icon" for the programming
  8129. language was not derived from "iconoclastic", although after the fact,
  8130. the association is a plausible excuse.  "Icon" does not stand for anything,
  8131. nor is it an acronym.
  8132.  
  8133. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Wed Mar 29 02:12:17 1989
  8134. Received: from mailgw.cc.umich.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8135.     id AA16812; Wed, 29 Mar 89 02:12:17 MST
  8136. Received: from him1.cc.umich.edu by mailgw.cc.umich.edu (5.59/1.0)
  8137.     id AA20839; Wed, 29 Mar 89 04:09:05 EST
  8138. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 29 Mar 89 04:11:36 EST
  8139. Date: Tue, 28 Mar 89 22:55:18 EST
  8140. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  8141. To: icon-group@arizona.edu
  8142. Message-Id: <130069@Wayne-MTS>
  8143. Subject: Iconoclasm
  8144.  
  8145. Is an iconoclastic program one that breaks the Icon interpreter? -
  8146. Paul Abrahams
  8147.  
  8148. From shafto@eos.arc.nasa.gov  Thu Mar 30 11:18:26 1989
  8149. Received: from [128.102.21.2] by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8150.     id AA22299; Thu, 30 Mar 89 11:18:26 MST
  8151. Received: Thu, 30 Mar 89 10:18:59 PST by eos.arc.nasa.gov (5.59/1.2)
  8152. Date: Thu, 30 Mar 89 10:18:59 PST
  8153. From: Michael Shafto <shafto@eos.arc.nasa.gov>
  8154. Message-Id: <8903301818.AA17088@eos.arc.nasa.gov>
  8155. To: icon-group@arizona.edu, mcvax!hp4nl!botter!star.cs.vu.nl!biep@uunet.uu.net,
  8156.         ralph@arizona.edu
  8157. Subject: Re: iconic programming languages
  8158. Cc: shafto@EOS.ARC.NASA.GOV
  8159.  
  8160. Ralph --
  8161.  
  8162. How can you say that Icon does not stand for anything?  It stands
  8163. for the brightest and best, for truth and creativity, for open
  8164. systems, for the American way!
  8165.  
  8166. Mike
  8167.  
  8168. From icon-group-request  Thu Mar 30 14:21:59 1989
  8169. Received: from UCBVAX.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8170.     id AA06889; Thu, 30 Mar 89 14:21:59 MST
  8171. Received: by ucbvax.Berkeley.EDU (5.61/1.36)
  8172.     id AA13620; Thu, 30 Mar 89 12:59:00 -0800
  8173. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  8174.     for icon-group@arizona.edu (icon-group@arizona.edu)
  8175.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  8176. Date: 30 Mar 89 20:22:42 GMT
  8177. From: encore!maxzilla!kaufman@husc6.harvard.edu  (Lar Kaufman)
  8178. Organization: Encore Computer Corp, Marlboro, MA
  8179. Subject: Re: iconic programming languages
  8180. Message-Id: <5473@xenna.Encore.COM>
  8181. References: <8903301818.AA17088@eos.arc.nasa.gov>
  8182. Sender: icon-group-request@arizona.edu
  8183. To: icon-group@arizona.edu
  8184.  
  8185. In article <8903301818.AA17088@eos.arc.nasa.gov> shafto@EOS.ARC.NASA.GOV (Michael Shafto) writes:
  8186. >Ralph --
  8187. >
  8188. >How can you say that Icon does not stand for anything?  It stands
  8189. >for the brightest and best, for truth and creativity, for open
  8190. >systems, for the American way!
  8191. >
  8192. >Mike
  8193.  
  8194. Actually, I have to say that the idea that a name like Icon doesn't
  8195. stand for anything is a pretty powerful argument that it does stand
  8196. for "iconoclast."  Maybe Ralph should take the attitude of one of our
  8197. popular authors (whose identity I forget) who was pleased to be told
  8198. what he meant by what he had written. 
  8199.  
  8200. I don't care - I'll use it anyway. 
  8201.  
  8202.   
  8203.   
  8204. Regarding documentation for the Icon language: Is there any more
  8205. current/authoritative book in print than "The Implementation of the
  8206. Icon Programming Language" Griswold & Griswold, Princeton University 
  8207. Press, 1986?
  8208.   
  8209.   -lar
  8210.  
  8211.  
  8212.    "It's about a man, two women, and a revolution.  What could be 
  8213.    simpler than that?"                              - Roger Ebert 
  8214.  
  8215.  Lar Kaufman <= my opinions                       kaufman@Encore.com
  8216.  
  8217. From U379005@HNYKUN11.BITNET  Wed Apr 12 12:08:45 1989
  8218. Message-Id: <8904121908.AA03717@megaron.arizona.edu>
  8219. Received: from rvax.ccit.arizona.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8220.     id AA03717; Wed, 12 Apr 89 12:08:45 MST
  8221. Received: from HNYKUN11.BITNET by rvax.ccit.arizona.edu; Wed, 12 Apr 89 12:04
  8222.  MST
  8223. Received: by HNYKUN11 (Mailer X1.25) id 4961; Wed, 12 Apr 89 20:59:09 MET
  8224. Date: Wed, 12 Apr 89 20:48:59 MET
  8225. From: bob <U379005@HNYKUN11.BITNET>
  8226. Subject: ... & now for something completely different ...
  8227. To: icon-group@arizona.edu
  8228.  
  8229. Hello,
  8230. Although I've been keeping up with this newsgroup for some time, I would
  8231. like to put something quite different to your attention. It's rather
  8232. a personal request concerning the following:
  8233.  
  8234. > ..................
  8235.  
  8236. >> Date: Fri, 24 Mar 89 07:38:06 MST
  8237. >> From: "Saumya K. Debray" <debray@arizona.edu>
  8238. >> Message-Id: <8903241438.AA29859@granjon.arizona.edu>
  8239. >> Received: by granjon.arizona.edu; Fri, 24 Mar 89 07:38:06 MST
  8240. >> To: U379005@HNYKUN11.BITNET
  8241. >> Subject: Re:  SB-PROLOG news-group ?
  8242.  
  8243. >> the current version of sb-prolog (version 2.5) has predicates like
  8244. >> "clause", "listing", etc., but it does not have a garbage collector
  8245. >> yet (we're working on a garbage collector right now).  there is
  8246. >> ongoing development of the system (it's our primary research vehicle),
  8247. >> but as far as I know revisions aren't posted to newsgroups -- the
  8248. >> new versions are put up for anonymous FTP as and when they become
  8249. >> available.
  8250.  
  8251. As I don't have the 'anonymous FTP' facility on BITNET, I wondered
  8252. if some kind soul on the ICON-group could email me the material
  8253. concerned. Presently I have the 2.2 version. PATCH/DIFF-'s against
  8254. mine are allright too. I'll be very much obliged.
  8255.  
  8256. Thank you.
  8257. Bob. (u379005@hnykun11)
  8258.  
  8259. From att!ihlpb!nevin1  Sat Apr 15 04:24:39 1989
  8260. Date: Sat, 15 Apr 89 04:24:39 MST
  8261. Message-Id: <8904151124.AA08811@megaron.arizona.edu>
  8262. Received: by megaron.arizona.edu (5.59-1.7/15)
  8263.     id AA08811; Sat, 15 Apr 89 04:24:39 MST
  8264. From: ihlpb!nevin1 (Nevin J Liber +1 312 979 4751)
  8265. To: att!arizona!icon-group
  8266. Subject: What ever happened to the EZ project?
  8267.  
  8268. I was looking at an old SIGPLAN Notices (June '83), and I came across
  8269. the EZ project.  The EZ project was an attempt to "unify command and
  8270. programming languages by using the concepts of high-level
  8271. string-processing languages, such as SNOBOL4 and Icon".  What ever
  8272. happened to it?  It sounded like an intriguing idea, and a nice
  8273. improvement over the command languages we have now.
  8274.  
  8275. NEVIN ":-)" LIBER  AT&T Bell Laboratories  nevin1@ihlpb.ATT.COM  (312) 979-4751
  8276.  
  8277. From att!ihlpb!nevin1  Sat Apr 15 04:24:42 1989
  8278. Date: Sat, 15 Apr 89 04:24:42 MST
  8279. Message-Id: <8904151124.AA08819@megaron.arizona.edu>
  8280. Received: by megaron.arizona.edu (5.59-1.7/15)
  8281.     id AA08819; Sat, 15 Apr 89 04:24:42 MST
  8282. From: ihlpb!nevin1 (Nevin J Liber +1 312 979 4751)
  8283. To: att!arizona!icon-group
  8284. Subject: Shouldn't main(argl) really be main(argl[])?
  8285.  
  8286. Shouldn't
  8287.  
  8288.     procedure main(argl)
  8289.  
  8290. really be declared as
  8291.  
  8292.     procedure main(argl[])
  8293.  
  8294. Since there wasn't a way of declaring procedures taking a variable
  8295. number of parameters until Version 6, I understand how the current
  8296. declaration came about.  But now that we CAN declare a procedure which
  8297. takes a variable number of parameters, shouldn't this be changed to
  8298. be more "consistent" with the rest of the language (although this
  8299. change would break existing code)?
  8300.  
  8301. For similar reasons (although it's too late for this change), the
  8302. list(x) function should really try to produce a list resulting from the
  8303. type conversion of x, instead of producing a list of size x.  Prior to Version
  8304. 6, this didn't matter too much because the only type that could be converted
  8305. to a list was a list, but with the introduction of sets, and the possible
  8306. future introduction (someday?? :-)) of ordered sets of unique elements
  8307. and unordered lists of (potentially) non-unique elements, I feel that it
  8308. would have been "better" if the list() function were similar to string(),
  8309. integer(), etc.
  8310.  
  8311. NEVIN ":-)" LIBER  AT&T Bell Laboratories  nevin1@ihlpb.ATT.COM  (312) 979-4751
  8312.  
  8313. From drh@Princeton.EDU  Sun Apr 16 06:22:05 1989
  8314. Received: from [128.112.0.1] by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8315.     id AA22916; Sun, 16 Apr 89 06:22:05 MST
  8316. Received: from notecnirp.Princeton.EDU by Princeton.EDU (5.58+++/2.6)
  8317.     id AA13782; Sun, 16 Apr 89 08:41:53 EDT
  8318. Received: by notecnirp.Princeton.EDU (5.51/1.81)
  8319.     id AA05633; Sun, 16 Apr 89 08:41:43 EDT
  8320. Date: Sun, 16 Apr 89 08:41:43 EDT
  8321. From: drh@Princeton.EDU (Dave Hanson)
  8322. Message-Id: <8904161241.AA05633@notecnirp.Princeton.EDU>
  8323. To: ihlpb!nevin1@arizona.edu
  8324. Subject: Re:  What ever happened to the EZ project?
  8325. Cc: icon-group@arizona.edu
  8326.  
  8327. EZ is alive and well at princeton.
  8328. there's a paper in POPL '85 that describes
  8329. developments up to my departure from arizona.
  8330. and i have students working on processes
  8331. in EZ and distributed EZ.
  8332. dave hanson
  8333.  
  8334. From dscargo@cim-vax.honeywell.com  Tue Apr 18 10:52:46 1989
  8335. Message-Id: <8904181752.AA08781@megaron.arizona.edu>
  8336. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8337.     id AA08781; Tue, 18 Apr 89 10:52:46 MST
  8338. Date: 18 Apr 89 12:50:00 CST
  8339. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  8340. Subject: LaTeX \indexentry to \item conversion
  8341. To: "texhax" <texhax@cs.washington.edu>
  8342. Cc: "icon-group" <icon-group@arizona.edu>
  8343.  
  8344. While reading the LaTeX book and trying to understand about \index,
  8345. \indexentry, and \item in "theindex" environment I discovered that
  8346. there was no supplied software for performing the transformation from
  8347. the .idx file's \indexentry to \item lines.  In the spirit of supporting
  8348. the public domain software's user community, here is a simple Icon
  8349. program for converting LaTeX .idx files into a format suitable for
  8350. inclusion into theitem environment.  Icon was developed by Ralph Griswold
  8351. and others.  The University of Arizona distributes Icon for a nominal
  8352. cost.  Icon is in the public domain.  (Icon is also about the same age
  8353. at TeX.)  Icon processors are available for MS-DOS, VAX/VMS, and many
  8354. UNIX systems.  Many systems that use TeX probably also have Icon.
  8355. Icon is close to ideal for writing character and string manipulation
  8356. functions, since many features that have to be written by hand or
  8357. provided by run time libraries are available as language primitives.
  8358.  
  8359. ## latexidx -- latex index file manipulate
  8360. # Author: David S. Cargo, Minneapolis, MN 55408
  8361. # Rights: Released into the public domain.
  8362. # Warrantee: No warrantee is expressed or implied.
  8363. #
  8364. # Input: a latex .idx file containing the \indexentry lines
  8365. # Output: \item lines sorted in order by entry value,
  8366. #         with page references put into sorted order.
  8367. #
  8368. # Processing:
  8369. #     While lines are available from standard input
  8370. #         Read a line containing an \indexentry
  8371. #         If there is no table entry for it
  8372. #         Then create an empty page number set for it
  8373. #         Add the page number to the page number set
  8374. #    Sort the table of index entry topics
  8375. #    For all entries
  8376. #         Sort the set of page references
  8377. #         Write an \item entry for each entry and the page references
  8378. #
  8379. # Limitations:
  8380. #    Items must not contain opening nor closing braces
  8381. #    Length of index handled depends on implementation limits of memory alloc.
  8382. #    Page numbers must be integers (no roman numerals)
  8383. #    Sort key formed by mapping to lower case and removing leading articles
  8384. #        (a separate function is used to produce the sort key, simplifying
  8385. #         customization)--otherwise sorting is done in ASCII order
  8386. #
  8387. record item(entry, page_set)
  8388. procedure main()                       # no parameters, reading from stdin
  8389.     entries := table()                 # create the table for entries
  8390.     while s := read() do               # read strings from standard input
  8391.         {
  8392.         s := s[upto('{',s)+1:0]        # delete up to the opening brace
  8393.         entryval := s[1:upto('}', s)]  # the item goes up to the closing brace
  8394.         key := reform(entryval)        # allow the sort key to be different
  8395.         if /entries[key]               # if the entry is null
  8396.                                        # store the original entryval and
  8397.         then entries[key] := item(entryval,set([]))
  8398.                                        # add the supplied page num to the set
  8399.                                        # use a 0 if the page num is not int.
  8400.         entries[key].page_set ++:= set([integer(s[upto('{',s)+1:-1]) | 0])
  8401.         }
  8402.     entries := sort(entries, 3)        # sort items by entry value
  8403.                                        # dequeue the key
  8404.     while one_entry := get(entries) do
  8405.         {
  8406.                                        # discard the sort key and
  8407.                                        # dequeue and sort the set into a list
  8408.         one_entry := get(entries)      # silently discard page 0 if referenced
  8409.         page_list := sort(one_entry.page_set -- set([0]))
  8410.         refs := string(get(page_list)) # dequeue first int and convert to str
  8411.                                        # dequeue rest of page nums and append
  8412.         while (refs ||:= ", " || string(get(page_list)))
  8413.         write("\\item ", one_entry.entry, " ", refs)
  8414.         }
  8415.     return
  8416. end
  8417.  
  8418. # reform - modify the item to enforce sort order appropriately
  8419. procedure reform(item)
  8420. # map to lowercase
  8421. item := map(item)
  8422. # drop leading article if present
  8423. if match("a ",   item) then return item[3:0]
  8424. if match("an ",  item) then return item[4:0]
  8425. if match("the ", item) then return item[5:0]
  8426. return item
  8427. end
  8428.  
  8429.  
  8430. From kwalker  Wed Apr 19 09:48:10 1989
  8431. Date: Wed, 19 Apr 89 09:48:10 MST
  8432. From: "Kenneth Walker" <kwalker>
  8433. Message-Id: <8904191648.AA09971@megaron.arizona.edu>
  8434. Received: by megaron.arizona.edu (5.59-1.7/15)
  8435.     id AA09971; Wed, 19 Apr 89 09:48:10 MST
  8436. In-Reply-To: <8904151124.AA08819@megaron.arizona.edu>
  8437. To: icon-group
  8438. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8439.  
  8440. > Date: Sat, 15 Apr 89 04:24:42 MST
  8441. > From: ihlpb!nevin1 (Nevin J Liber +1 312 979 4751)
  8442. > Shouldn't
  8443. >     procedure main(argl)
  8444. > really be declared as
  8445. >     procedure main(argl[])
  8446. > Since there wasn't a way of declaring procedures taking a variable
  8447. > number of parameters until Version 6, I understand how the current
  8448. > declaration came about.  But now that we CAN declare a procedure which
  8449. > takes a variable number of parameters, shouldn't this be changed to
  8450. > be more "consistent" with the rest of the language (although this
  8451. > change would break existing code)?
  8452.  
  8453. Yes, logically it should be done that way, but do you have any idea
  8454. how many programs would be broken?. The transition would be quite
  8455. painful for a lot of people. While I would like to see the change, I
  8456. don't think the improvement justifies the problems it would cause.
  8457.  
  8458. > For similar reasons (although it's too late for this change), the
  8459. > list(x) function should really try to produce a list resulting from the
  8460. > type conversion of x, instead of producing a list of size x.  Prior to Version
  8461. > 6, this didn't matter too much because the only type that could be converted
  8462. > to a list was a list, but with the introduction of sets, and the possible
  8463. > future introduction (someday?? :-)) of ordered sets of unique elements
  8464. > and unordered lists of (potentially) non-unique elements, I feel that it
  8465. > would have been "better" if the list() function were similar to string(),
  8466. > integer(), etc.
  8467.  
  8468. I agree that it would be nice if there was a consistent set of functions
  8469. for type conversions and another set for creating structures. (Maybe the
  8470. next language someone designs will be so perfect that no one will find
  8471. any of these mildly annoying inconsistencies :-)
  8472.  
  8473.    Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  8474.    +1 602 621 2858  kwalker@Arizona.EDU   {uunet|allegra|noao}!arizona!kwalker
  8475.  
  8476. From HJJaeger.ANTropos@DMZRZU71.BITNET  Wed Apr 19 10:30:11 1989
  8477. Received: from rvax.ccit.arizona.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8478.     id AA12593; Wed, 19 Apr 89 10:30:11 MST
  8479. Received: from DMZRZU5P.BITNET by rvax.ccit.arizona.edu; Wed, 19 Apr 89 10:26
  8480.  MST
  8481. Received: from DMZRZU71-UNI-MAINZ--GERMANY by DMZRZU5P.BITNET; Wed, 19 Apr 89
  8482.  16:07 N
  8483. Date: Wed, 19 Apr 89 16:06+0200
  8484. From: HJJaeger@DMZRZU71.BITNET
  8485. Subject: index
  8486. To: icon-group@arizona.edu
  8487. Message-Id:  <890419140637.306720@DMZRZU71-UNI-MAINZ--GERMANY>
  8488.  
  8489. send index
  8490.  
  8491. From icon-group-request  Wed Apr 19 20:27:47 1989
  8492. Received: from ucbvax.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8493.     id AA16525; Wed, 19 Apr 89 20:27:47 MST
  8494. Received: by ucbvax.Berkeley.EDU (5.61/1.36)
  8495.     id AA27899; Wed, 19 Apr 89 20:25:22 -0700
  8496. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  8497.     for icon-group@arizona.edu (icon-group@arizona.edu)
  8498.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  8499. Date: 19 Apr 89 20:11:49 GMT
  8500. From: osu-cis!mstar!resource!root@tut.cis.ohio-state.edu  (Super user)
  8501. Organization: Resource Systems
  8502. Subject: Easel
  8503. Message-Id: <979@resource.UUCP>
  8504. Sender: icon-group-request@arizona.edu
  8505. To: icon-group@arizona.edu
  8506.  
  8507. Has anyone heard of a developement language called "EASEL" (company unknown).
  8508. It's supposed to be big into windowing, and icons.  I belive a company called
  8509. COMSHARE used it to develop a product called Commander-EIS.
  8510.  
  8511. Any information would greatly be appreciated.
  8512.  
  8513.                 Thanks,
  8514.                 Bryan
  8515.                     tut!osu-cis!resource!bryan
  8516.                     bryan@resource.uucp        
  8517.  
  8518. From lti!talmage@bu-it.BU.EDU  Tue Apr 25 14:11:28 1989
  8519. Received: from BU-IT.BU.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8520.     id AA15428; Tue, 25 Apr 89 14:11:28 MST
  8521. Received: from BUITA.BU.EDU by bu-it.BU.EDU (5.58/4.7)
  8522.     id AA04982; Tue, 25 Apr 89 17:04:23 EDT
  8523. Received:  by buita.bu.edu (3.2/4.7)
  8524.     id AA28889; Tue, 25 Apr 89 17:07:17 EDT
  8525. Received: from waltham.lti.com by lti.com (4.0/SMI-4.0)
  8526.     id AA03123; Tue, 25 Apr 89 11:25:58 EDT
  8527. Date: Tue, 25 Apr 89 11:25:58 EDT
  8528. From: lti!talmage@bu-it.BU.EDU (David Talmage)
  8529. Message-Id: <8904251525.AA03123@lti.com>
  8530. Received: by waltham.lti.com (4.0/SMI-4.0)
  8531.     id AA00608; Tue, 25 Apr 89 11:25:42 EDT
  8532. To: icon-group@arizona.edu
  8533. Subject: Porting Icon: How long?  What problems?
  8534.  
  8535. Here are some questions for those who have ported Icon to a new system.
  8536.  
  8537. I want to run Icon Version 7.5 (or greater?) on my Amiga.  I've been using
  8538. Version 6 for over a year and have been anxiously awaiting the announcement
  8539. of the new version for My Favorite Micro.  It looks as though I'll have
  8540. some time and disk space this summer, so maybe I'll do it myself.
  8541.  
  8542. What part of porting the hierarchical file system version of "Icon for
  8543. porting" was easy for you?  What problems did you encounter?  Are the
  8544. system-dependent things documented and isolated to a few files?
  8545.  
  8546. How long did you expect to take to do the port?  How long did it really
  8547. take?  I'm usually pretty good at figuring out other people's code.  Did
  8548. you have any trouble understanding what you had to do and how the Icon
  8549. implementers did it?
  8550.  
  8551. Does "Icon for porting" come with instructions for adding new functions to
  8552. the language?  For example, Version 6 on the Amiga lets me use the built-in
  8553. speech synthesizer.  I've used it to make my Amiga pronounce Esperanto
  8554. words.  I'll think about adding an AREXX [1] port too.
  8555.  
  8556. I don't expect this to be a trivial project, really, but I do expect it to
  8557. be fun.  The possibility of Fame And Fortune is also intriguing ;-)  Oh
  8558. yes, and the groupies.  Especially the groupies ;-) ;-)
  8559.  
  8560.  
  8561. Please send me e-mail about this if you want to.  I'll try to summarize the
  8562. replies I receive in about two weeks.
  8563.  
  8564.  
  8565. David Talmage
  8566.  
  8567. ------------------------------
  8568. Notes:
  8569.  
  8570. [1] AREXX is the Amiga version of IBM's REXX langauge.  It was implemented
  8571. on the Amiga by William Hawes.  It includes a way for programs to
  8572. communicate with each other (through "AREXX ports") and has found its way
  8573. into many commercial and public domain programs.
  8574.  
  8575.  
  8576.  
  8577. ------------------------------------------------------------------------------
  8578. David W. Talmage, Systems Programmer        ...!{buita,bbn}!lti!talmage
  8579. Language Technology, Inc.            talmage%lti.uucp@bu-it.bu.edu
  8580. 27 Congress St., Salem, MA 01970        (508) 741-1507
  8581.  
  8582. From cjeffery  Tue Apr 25 14:55:40 1989
  8583. Date: Tue, 25 Apr 89 14:55:40 MST
  8584. From: "Clinton Jeffery" <cjeffery>
  8585. Message-Id: <8904252155.AA17482@megaron.arizona.edu>
  8586. Received: by megaron.arizona.edu (5.59-1.7/15)
  8587.     id AA17482; Tue, 25 Apr 89 14:55:40 MST
  8588. To: icon-group
  8589. Subject: Porting Icon (Amiga); how long, what problems?
  8590.  
  8591. This is in response to a query by David Talmadge.
  8592.  
  8593. I have finished a port of Icon version 7.5 to the Amiga using Aztec C 3.6.
  8594. A version using Lattice 5.0.2 has been delayed by compiler bugs.  The port
  8595. will be validated on the Icon test suite and should be available by early
  8596. summer (I might be persuaded to send out an unofficial copy if promised
  8597. something interesting like an AREXX interface).  The changes were mostly
  8598. minor and easy, but still required some attention to detail.  I would be
  8599. happy to discuss them, but perhaps you would prefer to wait and read them
  8600. for yourself!
  8601.  
  8602. Actually, REXX and Icon provide mostly overlapping functionality.  REXX
  8603. has the advantage of ports, and Icon has the advantage of public domain
  8604. status, a clean implementation with publicly available source code, and
  8605. a superior expression evaluation paradigm (I have a friend who is a REXX
  8606. guru in the IBM world, so my evaluation is not totally one-sided).  I would
  8607. rather add the concept of ports to Icon than add an interface to a product
  8608. (AREXX) that I would have to go out and buy in order to use.
  8609.  
  8610. From att!ihlpb!nevin1  Tue Apr 25 17:41:39 1989
  8611. Date: Tue, 25 Apr 89 17:41:39 MST
  8612. Message-Id: <8904260041.AA26449@megaron.arizona.edu>
  8613. Received: by megaron.arizona.edu (5.59-1.7/15)
  8614.     id AA26449; Tue, 25 Apr 89 17:41:39 MST
  8615. From: ihlpb!nevin1 (Nevin J Liber +1 312 979 4751)
  8616. To: att!arizona!icon-group
  8617. Cc: att!arizona!kwalker
  8618. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8619.  
  8620. NL=Nevin Liber, KW=Ken Walker
  8621.  
  8622. NL> Shouldn't
  8623. NL> 
  8624. NL>     procedure main(argl)
  8625. NL> 
  8626. NL> really be declared as
  8627. NL> 
  8628. NL>     procedure main(argl[])
  8629.  
  8630. KW> Yes, logically it should be done that way, but do you have any idea
  8631. KW> how many programs would be broken?. The transition would be quite
  8632. KW> painful for a lot of people.
  8633.  
  8634. Would it really be all that painful?  It would be fairly easy to write
  8635. an Icon program to do the conversion.  Unless I have overlooked a case,
  8636. all that would be needed to be done is:
  8637.  
  8638. a)  Change the occurance, if any (at most one per program), of
  8639.  
  8640.     procedure main(ArgumentList)
  8641.  
  8642. to
  8643.  
  8644.     procedure main(ArgumentList[])
  8645.  
  8646. to take care of the declaration (needed at compile time), and
  8647.  
  8648. b)  If (a) was done, then add the following to the beginning of the
  8649. initial clause, if any, of main, as well as to the beginning of the
  8650. body of main:
  8651.  
  8652.     if 1 = *ArgumentList & "list" == type(ArgumentList[1]) then
  8653.         ArgumentList := ArgumentList[1]
  8654.  
  8655. to take care of those people who might call main() from within their
  8656. program (the run time case), although personally I don't think that
  8657. there are many programs which call main() recursively within a
  8658. program.
  8659.  
  8660. KW> While I would like to see the change, I
  8661. KW> don't think the improvement justifies the problems it would cause.
  8662.  
  8663. The fixing of, say, the string scanning environment probably caused more
  8664. problems than this change would (and yes, I do think the string scanning
  8665. fix was justified).
  8666.  
  8667. NEVIN ":-)" LIBER  AT&T Bell Laboratories  nevin1@ihlpb.ATT.COM  (312) 979-4751
  8668.  
  8669. From ralph  Tue Apr 25 18:19:31 1989
  8670. Date: Tue, 25 Apr 89 18:19:31 MST
  8671. From: "Ralph Griswold" <ralph>
  8672. Message-Id: <8904260119.AA28109@megaron.arizona.edu>
  8673. Received: by megaron.arizona.edu (5.59-1.7/15)
  8674.     id AA28109; Tue, 25 Apr 89 18:19:31 MST
  8675. To: ihlpb!nevin1
  8676. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8677. Cc: icon-group
  8678. In-Reply-To: <8904260041.AA26449@megaron.arizona.edu>
  8679.  
  8680. Yes, the change, which would be nice in hindsight, is not practical to
  8681. make now.   It isn't just a matter of changing source programs.  There
  8682. are a lot of object programs around.
  8683.  
  8684. This is an object lesson is getting stuck with the decisions you make
  8685. early on.
  8686.  
  8687. Incidentally, the change in scanning environments seems to be largely
  8688. transparent to most programs.  Probably because it essentially fixed a bug.
  8689.  
  8690.  
  8691.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  8692.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  8693.  
  8694.  
  8695. From att!ihlpb!nevin1  Tue Apr 25 21:09:06 1989
  8696. Date: Tue, 25 Apr 89 21:09:06 MST
  8697. Message-Id: <8904260409.AA07201@megaron.arizona.edu>
  8698. Received: by megaron.arizona.edu (5.59-1.7/15)
  8699.     id AA07201; Tue, 25 Apr 89 21:09:06 MST
  8700. From: ihlpb!nevin1 (Nevin J Liber +1 312 979 4751)
  8701. To: att!arizona!icon-group
  8702. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8703.  
  8704. >It isn't just a matter of changing source programs.  There
  8705. >are a lot of object programs around.
  8706.  
  8707. Just wondering:  what do people who only have objects around do whenever a
  8708. new version of Icon gets released?
  8709.  
  8710. NEVIN ":-)" LIBER  AT&T Bell Laboratories  nevin1@ihlpb.ATT.COM  (312) 979-4751
  8711.  
  8712. From ralph  Wed Apr 26 05:26:19 1989
  8713. Date: Wed, 26 Apr 89 05:26:19 MST
  8714. From: "Ralph Griswold" <ralph>
  8715. Message-Id: <8904261226.AA25706@megaron.arizona.edu>
  8716. Received: by megaron.arizona.edu (5.59-1.7/15)
  8717.     id AA25706; Wed, 26 Apr 89 05:26:19 MST
  8718. To: ihlpb!nevin1
  8719. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8720. Cc: icon-group
  8721. In-Reply-To: <8904260409.AA07201@megaron.arizona.edu>
  8722.  
  8723. Because of the way that Icon references the run-time system by an absolute
  8724. path, one way to install a new version is to use a different path than that
  8725. for old versions, leaving old object files referencing old versions.  Not
  8726. pleasant, but it's done.
  8727.  
  8728. I did not state my point well.  It's not old object files that cause problems.
  8729. It's recompiling the source, possibly by folks who know nothing about Icon.
  8730. For example, Icon is used here for a number of utilities.  When a new verion of
  8731. Icon is installed, our staff may run scripts to bring object files up to date.
  8732. Obviously having to change the source for a new version is undesirable in
  8733. such cases.  Icon source also is referenced in many scripts here where
  8734. existing code is concatenated with newly generated code.  Source incompatib-
  8735. ilities between versions tend to cause things to "break" unexpectedly, some-
  8736. times long after the change for infrequently run scripts.  As another
  8737. example, we have performance measuring software that extracts Icon
  8738. programs from archive files and runs them.  I'd not relish de-archiving
  8739. the thousands of programs from a couple of hundred archives, processing
  8740. them to take care of arguments to main(), and re-archiving them.  If I were
  8741. on the receiving end of this cosmetic improvement of Icon, I probably
  8742. would not be very happy about the grief it caused me.
  8743.  
  8744. Thse are just examples.  The underlying problem is that when a programming
  8745. language is used extensively, making changes that are not upward compatible
  8746. becomes impractical.  There are a lot of things we'd like to change, but
  8747. we can't justify the changes because of the annoyance they would cause
  8748. users.  So we live with it.
  8749.  
  8750. One of the more amusing (?) examples I know of in the general area of
  8751. "being stuck with decisions made in the past" is the EBCDIC collating
  8752. sequence.  There are gaps in the middle of the sequences for upper-
  8753. and lowercase letters, where non-alphabetic characters appear.  Obviously
  8754. undesirable if you're sorting anything containing both letters and these
  8755. non-alphabetic characters.  This curiosity is a carry over from the 6-bit
  8756. BCD collating sequence used by IBM.  I investigated the source of this
  8757. problem once and was told it had to do with the way BCD characters were
  8758. encoded on magnetic tape in some early parity scheme.  Imagine how
  8759. far this early decision has spread and how much grief it has caused over
  8760. the years.  Yet IBM was unwilling to make the change (in the 1960s) when
  8761. going from BCD to EBCDIC.  Now it's permanently institutionalized.
  8762.  
  8763. From LEICHTER@Venus.YCC.Yale.Edu  Wed Apr 26 07:31:52 1989
  8764. Message-Id: <8904261431.AA29537@megaron.arizona.edu>
  8765. Received: from VENUS.YCC.YALE.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8766.     id AA29537; Wed, 26 Apr 89 07:31:52 MST
  8767. Date: Wed, 26 Apr 89 10:34 EDT
  8768. From: "Jerry Leichter (LEICHTER-JERRY@CS.YALE.EDU)"
  8769.  <LEICHTER@Venus.YCC.Yale.Edu>
  8770. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8771. To: icon-group@arizona.edu
  8772. X-Vms-To: IN%"icon-group@arizona.EDU"
  8773.  
  8774. There's one alternative:  Define a new "main entry point", say "main_program".
  8775. It would be defined as "main_program(argl[])".  The rules for defining how a
  8776. program is to start up are:
  8777.  
  8778.     - If only main is present, call it as previously;
  8779.     - If only main_program is present, call it;
  8780.     - If both are present, call main as always (but perhaps issue a
  8781.         warning).
  8782.                             -- Jerry
  8783.  
  8784. From ralph  Thu Apr 27 05:17:18 1989
  8785. Date: Thu, 27 Apr 89 05:17:18 MST
  8786. From: "Ralph Griswold" <ralph>
  8787. Message-Id: <8904271217.AA01264@megaron.arizona.edu>
  8788. Received: by megaron.arizona.edu (5.59-1.7/15)
  8789.     id AA01264; Thu, 27 Apr 89 05:17:18 MST
  8790. To: icon-group
  8791. Subject: Icon under Ultrix
  8792.  
  8793. There are a couple of problems with Version 7.x of Icon running under recent
  8794. releases of Ultrix.  If you're having problems, here is a fix and a workaround.
  8795.  
  8796. 1.  One problem is that fopen(s,"wb") fails under recent Ultrix.  Locate
  8797. occurrences of "wb" in the icont directory and change them to "w".
  8798.  
  8799. 2.  Opening a file allocates space before Icon is prepared under the
  8800. "expandable regions" memory configuration.  The workaround is to add
  8801.  
  8802.     #define FixedRegions
  8803.  
  8804. to h/define.h.  This disables region expansion, but region sizes can be
  8805. set large if needed by using environment variables.
  8806.  
  8807. We'll take care of these problems (including supporting expandable memory
  8808. regions) in Version 7.6 of Icon.
  8809.  
  8810.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  8811.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  8812.  
  8813.  
  8814. From ralph  Thu Apr 27 07:28:48 1989
  8815. Date: Thu, 27 Apr 89 07:28:48 MST
  8816. From: "Ralph Griswold" <ralph>
  8817. Message-Id: <8904271428.AA05925@megaron.arizona.edu>
  8818. Received: by megaron.arizona.edu (5.59-1.7/15)
  8819.     id AA05925; Thu, 27 Apr 89 07:28:48 MST
  8820. To: icon-group
  8821. Subject: Version 7.x of Icon under Ultrix
  8822.  
  8823.  
  8824. Bill Idsardi reminded me that there's also a "rb" in a fopen that needs
  8825. changing to "r".
  8826.  
  8827. Summary:
  8828.  
  8829.     icont/link.c:    "wb" -> "w"
  8830.     iconx/imain.c:    "rb" -> "r" (2 places)
  8831.  
  8832.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  8833.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  8834.  
  8835.  
  8836. From keil@apollo.com  Thu Apr 27 08:57:11 1989
  8837. Received: from APOLLO.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8838.     id AA09616; Thu, 27 Apr 89 08:57:11 MST
  8839. Received: from xuucp.ch.apollo.com by amway.apollo.com id <AA05189@amway.apollo.com> Thu, 27 Apr 89 11:51:58 EDT    
  8840. Received: by xuucp.ch.apollo.com id <AA12450@xuucp.ch.apollo.com>; Tue, 25 Apr 89 23:20:19 EDT
  8841. From: Mark Keil <keil@apollo.com>
  8842. Message-Id: <8904260320.AA12450@xuucp.ch.apollo.com>
  8843. Date: Tue, 25 Apr 89 22:52:55 EDT 
  8844. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8845. To: ralph@arizona.edu
  8846. Cc: icon-group@arizona.edu
  8847.  
  8848. Ralph:
  8849.  
  8850.    You said: << It isn't just a matter of changing source programs.  There
  8851. are a lot of object programs around. >>
  8852.  
  8853.    But,... won't all the object files have to be rebuilt when the
  8854.    version code changes the next time?  That would seem to be the
  8855.    time to make such a change.
  8856.  
  8857.    Also,
  8858.      I suppose Itran could also be made to accept both forms of argl or argl[] ,
  8859.      with a warning about old style useage for the former case.
  8860.      That way folks would not immediately have to change their source.
  8861.  
  8862.      Is the current way (argl) special cased? Would the logical way (argl[])
  8863.      be more general, and thus an easy change? (I havn't actually looked...)
  8864.      Then again, if it takes a lot of work it might not be worth it.
  8865.  
  8866.  Mark
  8867.  
  8868.  Mark Keil               Apollo Computer,  Chelmsford MA 01824
  8869.  +1 508-256-6600 x2495   keil@apollo.com  /  {decvax,mit-erl,yale}!apollo!keil
  8870.  
  8871. From att!ihlpb!nevin1  Thu Apr 27 15:46:58 1989
  8872. Date: Thu, 27 Apr 89 15:46:58 MST
  8873. Message-Id: <8904272246.AA12007@megaron.arizona.edu>
  8874. Received: by megaron.arizona.edu (5.59-1.7/15)
  8875.     id AA12007; Thu, 27 Apr 89 15:46:58 MST
  8876. From: ihlpb!nevin1 (Nevin J Liber +1 312 979 4751)
  8877. To: Mark Keil <arpa!apollo.com!keil>
  8878. Cc: att!arizona!icon-group
  8879. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8880.  
  8881. Mark Keil (keil@apollo.com) writes:
  8882. > I suppose Itran could also be made to accept both forms of argl or argl[] ,
  8883. > with a warning about old style useage for the former case.
  8884.  
  8885. This doesn't really help.  If the change from "main(argl)" to
  8886. "main(argl[])" were made, then the new meaning for main(argl) is to store
  8887. the first parameter, if it exists, in the variable argl (as a string
  8888. [assuming this is the initial call to main()], not a list of strings),
  8889. and ignore any other parameters.  It would have to accept either one or
  8890. the other (perhaps via a command line option, but I don't really like
  8891. that solution.  You should not have to remember whether or not your
  8892. code is pre-argl[] or post-argl[]; that should be done automatically)
  8893. but not both; otherwise, all we are doing is moving from one exception
  8894. case to another.
  8895.  
  8896. NEVIN ":-)" LIBER  AT&T Bell Laboratories  nevin1@ihlpb.ATT.COM  (312) 979-4751
  8897.  
  8898. From att!ihlpb!att!arizona!cheyenne  Thu Apr 27 17:55:08 1989
  8899. Received: by megaron.arizona.edu (5.59-1.7/15)
  8900.     id AA18147; Thu, 27 Apr 89 17:55:08 MST
  8901. Date: Thu, 27 Apr 89 17:49:44 MST
  8902. From: "Cheyenne Wills" <arizona!cheyenne>
  8903. Message-Id: <8904280049.AA17593@megaron.arizona.edu>
  8904. Received: by megaron.arizona.edu (5.59-1.7/15)
  8905.     id AA17593; Thu, 27 Apr 89 17:49:44 MST
  8906. In-Reply-To: <8904272246.AA12007@megaron.arizona.edu>
  8907. To: ihlpb!arpa!apollo.com!keil, ihlpb!nevin1
  8908. Subject: Re:  Shouldn't main(argl) really be main(argl[])?
  8909. Cc: ihlpb!att!arizona!icon-group
  8910.  
  8911. There is another thing to look at here.. The purpose of the format of
  8912. proc(arglist[]) is to place the "remaining" parms into a list.  The
  8913. system invocation of main has already placed the arguments into a list
  8914. so what one would get is a list with a single item, which is a list of 
  8915. the arguments.
  8916.  
  8917. Think of it this way:
  8918.     
  8919.    main is called with the following "format":
  8920.  
  8921.    main([ arg1, arg2, arg3 ])
  8922.  
  8923. to have main use the format of "procedure main(argl[])" would cause the
  8924. call to main look like:
  8925.  
  8926.     main([ [arg1, arg2, arg3 ] ])
  8927.  
  8928. Cheyenne
  8929.  
  8930. From icon-group-request  Mon May  1 22:15:18 1989
  8931. Received: from ucbvax.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8932.     id AA15323; Mon, 1 May 89 22:15:18 MST
  8933. Received: by ucbvax.Berkeley.EDU (5.61/1.36)
  8934.     id AA08093; Mon, 1 May 89 21:59:11 -0700
  8935. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  8936.     for icon-group@arizona.edu (icon-group@arizona.edu)
  8937.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  8938. Date: 1 May 89 23:08:39 GMT
  8939. From: umigw!umiami!slores@handies.ucar.edu  (Stanislaw L. Olejniczak)
  8940. Organization: University of Miami (IR)
  8941. Subject: SoftEng or CS Graduate Program Search
  8942. Message-Id: <600@umiami.miami.edu>
  8943. Sender: icon-group-request@arizona.edu
  8944. To: icon-group@arizona.edu
  8945.  
  8946. I would very much appreciate, on my and many other prospective
  8947. graduate students' behalf, your comments on graduate software
  8948. engineering programs.  I have been reading brochures from various
  8949. schools, collected various rankings and read a couple books about
  8950. graduate programs in software engineering or computer science. 
  8951. What I am asking for in this message are personal opinions,
  8952. observations and comments.
  8953.  
  8954. Which school and department do you think is a good place to study
  8955. Software Engineering or Computer Science with Software
  8956. Engineering emphasis?  Why do you think a particular department
  8957. is a good place to spend a couple years getting a Master's, and
  8958. later, a Ph.D.?  What are its strength?  What are its weaknesses? 
  8959. Where do the graduates go?  What kind of research is being
  8960. conducted?  Who (if not yourself) is a good person to contact
  8961. there?  What are other comments you would like to make that I
  8962. have not asked about?  All comments you will send will be
  8963. appreciated.
  8964.  
  8965. Let me apologize for posting this message again, and for posting
  8966. it this time to numerous newsgroups.  When I have initially
  8967. posted this request, I have offered to send summaries to any
  8968. interested person.  I have received several dozens of requests
  8969. for the summaries.  I have received a small handful of replies on
  8970. the subject.  After waiting now a considerable, for Newsnet,
  8971. time, I have decided I did not post it to the right groups; or
  8972. all the right people did not get to see this.  Thus, this second,
  8973. and final, attempt.
  8974.  
  8975. To those who had previously replied, my many thanks.  For those
  8976. who had requested or will request summaries, I will post them to
  8977. you after I feel reasonably certain I have received all replies
  8978. to this second posting.  To those who will reply, many, many
  8979. thanks, from me and from the numerous prospective graduate
  8980. students who will embark on more successful graduate studies
  8981. thanks to the time you take off your busy schedules to advise.
  8982.  
  8983. P.S. If you are so kind as to send your comments but would NOT
  8984.      want be identified in the summary, please let me know.
  8985. -- 
  8986. ----
  8987. Stan Olejniczak           Internet:    slores@umiami.miami.edu
  8988. University of Miami       UUCP:        {uunet!gould}!umbio!solejni
  8989. Miami, Florida, USA       BITNET:      SLORES@UMIAMI
  8990. Voice: (305)-547-6571     FAX:305-547-6412
  8991. My opinions cannot possibly represent the views of anyone else!
  8992.  
  8993. From sboisen@BBN.COM  Tue May  2 08:34:08 1989
  8994. Message-Id: <8905021534.AA14060@megaron.arizona.edu>
  8995. Received: from REGULUS.BBN.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  8996.     id AA14060; Tue, 2 May 89 08:34:08 MST
  8997. To: icon-group@arizona.edu
  8998. Subject: looking for a simple recognizer
  8999. From: Sean Boisen <sboisen@BBN.COM>
  9000. Sender: sboisen@BBN.COM
  9001. Reply-To: sboisen@BBN.COM
  9002. Date: Tue, 2 May 89 11:35:52 EDT
  9003.  
  9004. I need to do some quick-and-dirty parsing of English sentences, and
  9005. while my first instinct is to reach for Prolog and DCG's, i thought
  9006. i'd query this list to see if somebody already has a good Icon
  9007. solution to share.  What i want is a standard top-down,
  9008. recursive-descent, backtracking recognizer: i'd really like to have a
  9009. declarative format for lexicon and grammar rules, however, because i
  9010. expect to change them a lot. Are people doing this in Icon? I'm sure i
  9011. could start with what's in the Icon book, and add the details to deal
  9012. with white-space delimited tokens, etc., but why re-invent the wheel if
  9013. it's already out there, right? Here's your big chance to show what a
  9014. great language Icon is (actually i'm already convinced, but this kind
  9015. of application differs from my typical use, things like small text
  9016. filters and their kin).
  9017.  
  9018.  
  9019. ........................................
  9020. Sean Boisen -- sboisen@bbn.com
  9021. BBN Systems and Technologies Corporation, Cambridge MA
  9022. Disclaimer: these opinions void where prohibited by lawyers.
  9023.  
  9024. From icon-group-request  Fri May  5 02:59:54 1989
  9025. Received: from ucbvax.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  9026.     id AA21438; Fri, 5 May 89 02:59:54 MST
  9027. Received: by ucbvax.Berkeley.EDU (5.61/1.36)
  9028.     id AA15583; Fri, 5 May 89 02:56:25 -0700
  9029. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  9030.     for icon-group@arizona.edu (icon-group@arizona.edu)
  9031.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  9032. Date: 5 May 89 01:31:08 GMT
  9033. From: hubcap!ncrcae!gollum!rolandi@gatech.edu  (wgr)
  9034. Organization: e&m columbia
  9035. Subject: installing Icon on an NCR TOWER 600
  9036. Message-Id: <233@gollum.UUCP>
  9037. Sender: icon-group-request@arizona.edu
  9038. To: icon-group@arizona.edu
  9039.  
  9040. Has anyone had any experience installing Icon on an NCR TOWER 600?
  9041. I have the source code but there is no documented installation procedure
  9042. specifically for NCR Unix machines.   Any clues before we reinvent the 
  9043. wheel?
  9044.  
  9045.  
  9046. Walter Rolandi
  9047. rolandi@ncrcae.Columbia.NCR.COM
  9048. (insert your feed here)!ncrlnk!ncrcae!rolandi
  9049. (803) 791 6693
  9050.  
  9051. From icon-group-request  Sun May  7 18:30:21 1989
  9052. Received: from ucbvax.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  9053.     id AA22636; Sun, 7 May 89 18:30:21 MST
  9054. Received: by ucbvax.Berkeley.EDU (5.61/1.36)
  9055.     id AA25526; Sun, 7 May 89 18:27:22 -0700
  9056. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  9057.     for icon-group@arizona.edu (icon-group@arizona.edu)
  9058.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  9059. Date: 8 May 89 01:10:17 GMT
  9060. From: mailrus!jarvis.csri.toronto.edu!turing.toronto.edu!tarvydas@rutgers.edu  (Paul Tarvydas)
  9061. Organization: University of Toronto, CSRI
  9062. Subject: need hints re. matching across lines
  9063. Message-Id: <89May7.211023edt.4600@turing.toronto.edu>
  9064. Sender: icon-group-request@arizona.edu
  9065. To: icon-group@arizona.edu
  9066.  
  9067. I'd like to solicit suggestions on how to solve the following
  9068. problem (neatly and efficiently).  
  9069.  
  9070. I need to experiment with a some ideas for a post-pass optimizer
  9071. (peephole optimizer) for the output from a particular compiler.
  9072. The problem consists of scanning a file of assembler code
  9073. and replacing certain blocks of 10 or so lines with smaller
  9074. blocks of code.  A few substrings from the original blocks
  9075. (eg. certain operands) need to be pasted into the replacement
  9076. blocks.  For example, something like
  9077.  
  9078.     movl    x,r0
  9079.     addl2    #2,r0
  9080.     movl    r0,r1
  9081.  
  9082. could be replaced by
  9083.  
  9084.     addl3    #2,r0,r1.
  9085.  
  9086. The goal is to measure how effective a certain set of such optimizations
  9087. will be, before actually building a production-version optimizer.
  9088. I'm quite sure that Icon is the appropriate tool for such experimentation,
  9089. but the solutions that I'm coming up with seem to be too cumbersome, due
  9090. to my inexperience with iconomic philosophy.
  9091.  
  9092. I feel that I should be able to treat the input file as a "string"
  9093. and use backtracking pattern matches to find the interesting
  9094. pieces of code while simply emitting rejected chunks of code, but, 
  9095. I can't see how to write this cleanly in Icon
  9096. (brain-damage I've suffered from the teenage APL abuse makes me
  9097. want to believe that this is really a "one-liner"...).
  9098.  
  9099. Hints would be appreciated.
  9100.  
  9101. thanx
  9102. Paul Tarvydas
  9103. tarvydas@tsctrl (or tarvydas@turing.toronto.edu)
  9104.  
  9105. From att!ihuxy!nowlin  Mon May  8 07:16:53 1989
  9106. Date: Mon, 8 May 89 07:16:53 MST
  9107. Message-Id: <8905081416.AA17400@megaron.arizona.edu>
  9108. Received: by megaron.arizona.edu (5.59-1.7/15)
  9109.     id AA17400; Mon, 8 May 89 07:16:53 MST
  9110. From: ihuxy!nowlin (Jerry D Nowlin +1 312 979 0441)
  9111. To: att!arizona!icon-group
  9112. Subject: Re: need hints (peephole optimization)
  9113.  
  9114. > I'd like to solicit suggestions on how to solve the following
  9115. > problem (neatly and efficiently).  
  9116. > I need to experiment with a some ideas for a post-pass optimizer
  9117. > (peephole optimizer) for the output from a particular compiler.
  9118. > The problem consists of scanning a file of assembler code
  9119. > and replacing certain blocks of 10 or so lines with smaller
  9120. > blocks of code.  A few substrings from the original blocks
  9121. > (eg. certain operands) need to be pasted into the replacement
  9122. > blocks.  For example, something like
  9123. >     movl    x,r0
  9124. >     addl2    #2,r0
  9125. >     movl    r0,r1
  9126. > could be replaced by
  9127. >     addl3    #2,r0,r1.
  9128. > The goal is to measure how effective a certain set of such optimizations
  9129. > will be, before actually building a production-version optimizer.
  9130. > I'm quite sure that Icon is the appropriate tool for such experimentation,
  9131. > but the solutions that I'm coming up with seem to be too cumbersome, due
  9132. > to my inexperience with iconomic philosophy.
  9133. > I feel that I should be able to treat the input file as a "string"
  9134. > and use backtracking pattern matches to find the interesting
  9135. > pieces of code while simply emitting rejected chunks of code, but, 
  9136. > I can't see how to write this cleanly in Icon
  9137. > (brain-damage I've suffered from the teenage APL abuse makes me
  9138. > want to believe that this is really a "one-liner"...).
  9139. > Hints would be appreciated.
  9140. > thanx
  9141. > Paul Tarvydas
  9142. > tarvydas@tsctrl (or tarvydas@turing.toronto.edu)
  9143.  
  9144. The main obstacle I see to your plan is using the entire input file as a
  9145. string.  If you could logically break the file up into smaller sections,
  9146. with boundaries that you know local optimizations won't cross, you could
  9147. process smaller strings and make your scanning algorithm less complicated.
  9148.  
  9149. The concept of a basic block of assembler that can't be jumped into or out
  9150. of, except at the boundaries, would seem to be a logical subset of the
  9151. input file to try local optimizations on.  For example, any block of code
  9152. that is bounded at the top by a label or a preceding jump instruction and
  9153. bounded at the bottom by a jump instruction or a subsequent label would
  9154. constitute a basic block of code.  (An over simplification but you get the
  9155. idea.)
  9156.  
  9157. In my experience, the assembler that's generated by compilers contains
  9158. relatively small basic blocks.  You could completely parse a basic block
  9159. into a list of instructions and arguments and do your local optimizations
  9160. without worrying about scanning at the same time.  This may not be the kind
  9161. of hint you were looking for but the thought of scanning an entire file of
  9162. assembly language as a single string sounds like a bad idea to me.
  9163.  
  9164. Jerry Nowlin
  9165. (...!att!ihuxy!nowlin)
  9166.  
  9167. From dscargo@cim-vax.honeywell.com  Tue May 16 12:11:32 1989
  9168. Message-Id: <8905161911.AA04838@megaron.arizona.edu>
  9169. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  9170.     id AA04838; Tue, 16 May 89 12:11:32 MST
  9171. Date: 16 May 89 13:53:00 CST
  9172. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  9173. Subject: workalikes for lex and yacc
  9174. To: "icon-group" <icon-group@arizona.edu>
  9175.  
  9176. Has anybody developed tools for Icon similar to Unix lex and yacc?  Something
  9177. for describing tokens and generating a tokenizer, and something for defining
  9178. syntax and generating a parser?  I've been working on a project where C is
  9179. used for character handling, but I think Icon would be better.  The problem
  9180. with using Icon compared with C is that some of the operations can be done
  9181. at a higher level with C because lex and yacc take care of many of the details.
  9182.  
  9183. David S. Cargo (DSCARGO@CIM-VAX.HONEYWELL.COM)
  9184.  
  9185.  
  9186. From dscargo@cim-vax.honeywell.com  Fri May 19 09:15:53 1989
  9187. Message-Id: <8905191615.AA28127@megaron.arizona.edu>
  9188. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  9189.     id AA28127; Fri, 19 May 89 09:15:53 MST
  9190. Date: 19 May 89 10:39:00 CST
  9191. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  9192. Subject: macro processor wanted
  9193. To: "icon-group" <icon-group@arizona.edu>
  9194.  
  9195. Just in an effort to save some programming time, I was wondering if anybody
  9196. had an Icon program that was a functioning macro processor.  The capabilities
  9197. I'm looking for are modest; if somebody has developed a macro processor,
  9198. it will probably do more than what I am looking for.
  9199.  
  9200. The caabilities are to read a definition file, then read an input file
  9201. making simple substitutions and writing an output file.  The input file
  9202. would look something like a set of lines of the form
  9203.  
  9204. <token>replacement text
  9205.  
  9206. The replacement text would be limited to one line, but the line could be long.
  9207. The token would be characters not including a ">" character.
  9208.  
  9209. The processing would be to read the input file and replace any instances of
  9210. <token> with the corresponding replacement text.  (The "<" and ">" are
  9211. literal characters that actually appear in the input stream; I'm not using
  9212. them as metacharacters.)
  9213.  
  9214. If I don't get any response, I'll write the program and be willing to make it
  9215. available to the Icon Program Library.
  9216.  
  9217. dsc
  9218.  
  9219.  
  9220. From dscargo@cim-vax.honeywell.com  Wed May 31 08:44:15 1989
  9221. Message-Id: <8905311544.AA21349@megaron.arizona.edu>
  9222. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  9223.     id AA21349; Wed, 31 May 89 08:44:15 MST
  9224. Date: 31 May 89 10:38:00 CST
  9225. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  9226. Subject: Null output for write
  9227. To: "icon-group" <icon-group@arizona.edu>
  9228.  
  9229. I ran the following test program on VMS (Icon V7.0)
  9230.  
  9231. procedure main()
  9232.     file := [&output, &null]
  9233.     every write(!file, "There it goes!")
  9234.     return
  9235. end
  9236.  
  9237. I got "There it goes!" twice. Is there any "Icon standard" way of directing
  9238. output  to  a  "null"  device?  My  context was a program where sometimes I
  9239. wanted  to  generate  output  and  sometimes  not.  Rather than using an if
  9240. statement,  I  thought  about an output that sometimes indicated a file and
  9241. sometimes indicated a null device. Does Icon have such a thing?
  9242.  
  9243. dsc
  9244.  
  9245.  
  9246. From ralph  Wed May 31 08:53:04 1989
  9247. Date: Wed, 31 May 89 08:53:04 MST
  9248. From: "Ralph Griswold" <ralph>
  9249. Message-Id: <8905311553.AA22189@megaron.arizona.edu>
  9250. Received: by megaron.arizona.edu (5.59-1.7/15)
  9251.     id AA22189; Wed, 31 May 89 08:53:04 MST
  9252. To: dscargo@cim-vax.honeywell.com
  9253. Subject: Re:  Null output for write
  9254. Cc: icon-group
  9255. In-Reply-To: <8905311544.AA21349@megaron.arizona.edu>
  9256.  
  9257. A null argument to write() defaults to the empty string.
  9258.  
  9259. Most systems have some name or device that serves a to dump output without
  9260. actually writing it.  Open this "file" and use it like any other.  E.g.
  9261.  
  9262.     nullfile := open("/dev/null","w")
  9263.         .
  9264.         .
  9265.         .
  9266.     write(nullfile, ...)
  9267.  
  9268.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  9269.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  9270.  
  9271.  
  9272. From unocc07@zeus.unl.edu  Wed May 31 16:26:01 1989
  9273. Message-Id: <8905312326.AA19953@megaron.arizona.edu>
  9274. Received: from [129.93.1.10] by megaron.arizona.edu (5.59-1.7/15) via SMTP
  9275.     id AA19953; Wed, 31 May 89 16:26:01 MST
  9276. Date: 31 May 89 18:23:00 CST
  9277. From: "Dave Caplinger" <unocc07@zeus.unl.edu>
  9278. Subject: Re:  Null output for write
  9279. To: "icon-group" <icon-group@arizona.edu>
  9280.  
  9281. (Ralph Griswold writes:)
  9282. >Most systems have some name or device that serves a to dump output without
  9283. >actually writing it.  Open this "file" and use it like any other.  E.g.
  9284. >
  9285. >    nullfile := open("/dev/null","w")
  9286. >        .
  9287. >        .
  9288. >        .
  9289. >    write(nullfile, ...)
  9290. >
  9291. >  Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  9292. >  +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  9293.  
  9294. The VMS equivilant for the UNIX /dev/null device is device NLA0:, which may
  9295. be helpfull to you...
  9296.  
  9297. On another note; I recently got a flyer about ProIcon, which apparently is the
  9298. first commercial implementation of Icon, available for the Mac.  Since the 
  9299. flyer was not particularly descriptive (the picture looked like it was taken
  9300. from the MPW version of Icon), can anyone describe the benefits/differences/etc
  9301. of ProIcon?  Does it allow access to the toolboxes (which the MPW version does 
  9302. not)?  Is it compiled (just being able to make "stand-alone" applications is 
  9303. sufficient for me..)?  Any info would be greatly appreciated!
  9304.  
  9305. -/ Dave Caplinger /------------------+-----------------------------------
  9306.  Microcomputer Specialist            |  Internet: unocc07@zeus.unl.edu
  9307.  "Computing and Data Communications" |  UUCP:     uunet!btni!unocss!dent
  9308.  University of Nebraska at Omaha     |  Bitnet:   UNOCC07@UNOMA1
  9309.  Omaha, NE 68182                     |    or      dc3a+@andrew.cmu.edu
  9310.  
  9311.  
  9312. From att!ihlpb!nevin1  Wed May 31 16:35:27 1989
  9313. Date: Wed, 31 May 89 16:35:27 MST
  9314. Message-Id: <8905312335.AA20295@megaron.arizona.edu>
  9315. Received: by megaron.arizona.edu (5.59-1.7/15)
  9316.     id AA20295; Wed, 31 May 89 16:35:27 MST
  9317. From: ihlpb!nevin1 (Nevin J Liber +1 312 979 4751)
  9318. To: att!arizona!icon-group
  9319. Cc: "DAVE CARGO" <arpa!cim-vax.honeywell.com!dscargo>
  9320. Subject: Re: Null output for write
  9321.  
  9322. Dave Cargo (dscargo@cim-vax.HONEYWELL.COM) writes:
  9323. >procedure main()
  9324. >    file := [&output, &null]
  9325. >    every write(!file, "There it goes!")
  9326. >    return
  9327. >end
  9328.  
  9329. >I got "There it goes!" twice. Is there any "Icon standard" way of directing
  9330. >output  to  a  "null"  device?
  9331.  
  9332. This isn't exactly the same (I will point out the difference later) as
  9333. directing output to a "null" device (such as /dev/null in Unix(R)), but
  9334. changing
  9335.  
  9336.     every write(!file, "There it goes!")
  9337.  
  9338. to
  9339.  
  9340.     every write(\!file, "There it goes!")
  9341.  
  9342. should accomplish what you want.
  9343.  
  9344. Here is what happens:  if the value of "!file" is "&null", the expression
  9345. "\!file" fails.  Since failure is inherited, the write fails, and no output
  9346. is produced.
  9347.  
  9348. Because failure gets inherited, this will behave differently than redirecting
  9349. to a "null" device when there is a side effect in a future parameter to this
  9350. particular call to write(), when the write() is a parameter to another
  9351. function, etc.
  9352.  
  9353. NEVIN ":-)" LIBER  AT&T Bell Laboratories  nevin1@ihlpb.ATT.COM  (312) 979-4751
  9354.  
  9355. From dscargo@cim-vax.honeywell.com  Thu Jun  1 10:11:28 1989
  9356. Message-Id: <8906011711.AA09670@megaron.arizona.edu>
  9357. Received: from CIM-VAX.HONEYWELL.COM by megaron.arizona.edu (5.59-1.7/15) via SMTP
  9358.     id AA09670; Thu, 1 Jun 89 10:11:28 MST
  9359. Date: 1 Jun 89 12:00:00 CST
  9360. From: "DAVE CARGO" <dscargo@cim-vax.honeywell.com>
  9361. Subject: null output in Icon
  9362. To: "icon-group" <icon-group@arizona.edu>
  9363.  
  9364. Thanks for the responses to my question about null output devices for
  9365. Icon write statements.  The reason I wanted to do it in Icon instead of
  9366. opening a system-specific file is that I wanted the program to be portable
  9367. among Icon implementations.  Since there isn't a &nullout (only &output
  9368. and &errout), I wanted to find some way to achieve the same result within
  9369. Icon without using nonportable code.  The "write(\file,...)" approach
  9370. meets my needs.
  9371.  
  9372. dsc
  9373.  
  9374.  
  9375. From ralph  Sat Jun  3 05:57:54 1989
  9376. Date: Sat, 3 Jun 89 05:57:54 MST
  9377. From: "Ralph Griswold" <ralph>
  9378. Message-Id: <8906031257.AA07236@megaron.arizona.edu>
  9379. Received: by megaron.arizona.edu (5.59-1.7/15)
  9380.     id AA07236; Sat, 3 Jun 89 05:57:54 MST
  9381. To: icon-group
  9382. Subject: ProIcon
  9383.  
  9384. There have been several questions in recent mail about the new "ProIcon"
  9385. implementation of Icon for the Macintosh.  Here's some information.
  9386.  
  9387. ProIcon is an extended and enhanced implementation of Version 7.5 of Icon.
  9388. It runs on the Macintosh as a "stand-alone" application like most other
  9389. Macintosh applications -- it does not require MPW. The ProIcon application,
  9390. which uses the standard Macintosh interface, contains an editor and has
  9391. menus for compiling and running Icon programs, setting options, managing
  9392. windows, and so forth -- as well as providing the usual services you expect
  9393. on the Mac, such as printing and clipboard facilities.  You can can create,
  9394. run, test, edit and debug programs Icon programs without leaving the ProIcon
  9395. application.
  9396.  
  9397. So far as the ProIcon language itself is concerned, it has everything in
  9398. Version 7.5 plus several enhancements, some of a general nature and
  9399. some specifically for the Mac environment.  It has function tracing (in
  9400. addition to the usual procedure tracing), an optional termination dump,
  9401. optional use of the Macintosh International String Comparison system,
  9402. and several dozen new functions. Many of the functions provide the tools
  9403. necessary for a running Icon program to communicate with users -- dialog
  9404. boxes, screen manipulation, window functions, and so forth. ProIcon, however,
  9405. does not have graphic capabilities (Quickdraw) or access to the Toolbox.
  9406.  
  9407. Icon programs compiled by ProIcon also run as stand-alone applications. They
  9408. need a run-time system, which is provided, but this is essentially invisible.
  9409. Icon programs compiled by ProIcon can be given to others, along with the
  9410. run-time system; there are no licensing requirements or royalties for
  9411. such distribution.
  9412.  
  9413. ProIcon will run on any Macintosh except those with 64K ROM. It needs at
  9414. least 400 KB of free memory (1MB RAM is recommended), and System Version 4.1
  9415. or higher.
  9416.  
  9417. ProIcon is marketed by
  9418.  
  9419.     Catspaw, Inc.
  9420.     P.O. Box 1123
  9421.     Salida, CO   81201-1123
  9422.  
  9423.     (719) 539-3884
  9424.  
  9425. Contact Catspaw for more information.
  9426.  
  9427.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  9428.   +1 602 621 6609   ralph@Arizona.EDU  uunet!arizona!ralph
  9429.  
  9430.  
  9431. From naucse!sbw  Mon Jun 12 21:40:18 1989
  9432. Received: by megaron.arizona.edu (5.59-1.7/15)
  9433.     id AA23692; Mon, 12 Jun 89 21:40:18 MST
  9434. Message-Id: <8906130306.AA20647@naucse>
  9435. Date: Mon, 12 Jun 89 20:06:40 MST
  9436. X-Mailer: Mail User's Shell (6.5 4/17/89)
  9437. From: naucse!naucse!sbw (Steve Wampler)
  9438. To: arizona!icon-group
  9439. Subject: Icon with curses?
  9440.  
  9441. I have an application where I'd like to use curses from an Icon program.
  9442. Has anyone built a personalized interpreter for Icon that includes curses?
  9443.  
  9444. -- 
  9445.     Steve Wampler
  9446.     {....!arizona!naucse!sbw}
  9447.  
  9448. From shafto@eos.arc.nasa.gov  Tue Jun 13 09:26:40 1989
  9449. Received: from eos.arc.nasa.gov by megaron.arizona.edu (5.59-1.7/15) via SMTP
  9450.     id AA26034; Tue, 13 Jun 89 09:26:40 MST
  9451. Received: Tue, 13 Jun 89 09:25:05 PDT by eos.arc.nasa.gov (5.59/1.2)
  9452. Date: Tue, 13 Jun 89 09:25:05 PDT
  9453. From: Michael Shafto <shafto@eos.arc.nasa.gov>
  9454. Message-Id: <8906131625.AA24006@eos.arc.nasa.gov>
  9455. To: icon-group@arizona.edu, naucse!naucse!sbw@arizona.edu
  9456. Subject: Re:  Icon with curses?
  9457. Cc: shafto@EOS.ARC.NASA.GOV
  9458.  
  9459. Steve --
  9460.  
  9461. You're probably aware of Gimpel's insult generator in the orange
  9462. SNOBOL4 book -- Program 17.1 PHRASE, pp. 377ff.
  9463.  
  9464. Mike
  9465.  
  9466.  
  9467.