home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group90a.txt < prev    next >
Internet Message Format  |  1990-06-01  |  578KB

  1. From tenaglia@fps.mcw.edu  Wed Jan  3 08:16:12 1990
  2. Received: from RUTGERS.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  3.     id AA16236; Wed, 3 Jan 90 08:16:12 MST
  4. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  5.     id AA02559; Wed, 3 Jan 90 10:15:21 EST
  6. Received: by uwm.edu; id AA02111; Wed, 3 Jan 90 09:06:14 -0600
  7. Message-Id: <9001031506.AA02111@uwm.edu>
  8. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  9.           Wed,  3 Jan 90 08:31:28 CDT
  10. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  11.           Wed,  3 Jan 90 08:08:07 CDT
  12. Date: Wed,  3 Jan 90 08:08:07 CDT
  13. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  14. To: icon-group@arizona.edu
  15. Subject: Handy icon procedure make hex dumps of strings
  16. Status: O
  17.  
  18. I have another handy but small procedure. It's called dump(str). It's
  19. chiefly a debugging tool. It has to linked with radcon however. dump(str)
  20. converts a string of unknown bytes into a list of hexidecimal formatted
  21. ascii. The string "Hello" becomes list ["48","65","6C","6C","6F"]. This
  22. can be output nicely with the expression : every writes(!dump(str),"  ")
  23.  
  24. -------------------------------------------------------------------------
  25.  
  26. ##################################################################
  27. #                                                                #
  28. # THIS PROCEDURE CONVERTS A MYSTERY STRING TO A HEX DUMP LIST    #
  29. #                                                                #
  30. ##################################################################
  31. procedure dump(Str)             # REQUIRES LINK RADCON !
  32.   Buffer := []
  33.   every put(Buffer,right(map(radcon(ord(!Str),10,16),&lcase,&ucase),2,"0"))
  34.   return Buffer
  35.   end
  36.  
  37. ---------------------------------------------------------------------------
  38.  
  39. Perhaps it could have been done better as a generator or coexpression.
  40. Any ideas for improvements?
  41.  
  42. Chris Tenaglia (System Manager)
  43. Medical College of Wisconsin
  44. 8701 W. Watertown Plank Rd.
  45. Milwaukee, WI 53226
  46. (414)257-8765
  47. tenaglia@mis.mcw.edu
  48.  
  49.  
  50. From gmt  Wed Jan  3 10:29:59 1990
  51. Date: Wed, 3 Jan 90 10:29:59 MST
  52. From: "Gregg Townsend" <gmt>
  53. Message-Id: <9001031729.AA22739@megaron.arizona.edu>
  54. Received: by megaron.arizona.edu (5.59-1.7/15)
  55.     id AA22739; Wed, 3 Jan 90 10:29:59 MST
  56. To: icon-group
  57. Subject: The Icon project has moved
  58. Status: O
  59.  
  60. The Icon project's home machine, formerly "arizona.edu", has changed its
  61. Internet domain name to "cs.arizona.edu".  The uucp sitename of "arizona"
  62. has not changed.
  63.  
  64. FTP files from:            cs.arizona.edu
  65.                 (128.196.128.118 or 192.12.69.1)
  66.  
  67. Send questions to:        icon-project@cs.arizona.edu
  68.                 uunet!arizona!icon-project
  69.  
  70. Mailing list contributions:    icon-group@cs.arizona.edu        
  71.                 uunet!arizona!icon-group
  72.  
  73. Changes of address:        icon-group-request@cs.arizona.edu
  74.                 uunet!arizona!icon-group-request
  75.  
  76. From tenaglia@fps.mcw.edu  Fri Jan  5 09:16:56 1990
  77. Received: from RUTGERS.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  78.     id AA13014; Fri, 5 Jan 90 09:16:56 MST
  79. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  80.     id AA06126; Fri, 5 Jan 90 11:16:00 EST
  81. Received: by uwm.edu; id AA27525; Fri, 5 Jan 90 09:32:05 -0600
  82. Message-Id: <9001051532.AA27525@uwm.edu>
  83. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  84.           Fri,  5 Jan 90 08:50:10 CDT
  85. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  86.           Fri,  5 Jan 90 08:07:21 CDT
  87. Date: Fri,  5 Jan 90 08:07:21 CDT
  88. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  89. To: icon-group@cs.arizona.edu
  90. Subject: Procedures for packed decimal conversions
  91. Status: O
  92.  
  93.  
  94. Dear Icon-Group,
  95.  
  96. Here are two other interesting procedures. pack() and unpack() deal
  97. with translating numbers to and from a packed decimal format. Packed
  98. format is used to de/compress decimal numbers. The packed numbers use
  99. just over 1/2 the space of ascii formatted numbers. I use the format
  100. for experiments with encryption. Sometimes databases may use them.
  101. unpack() requires radcon() from the icon program library. Perhaps
  102. someone would care to improve on my code either in performance or
  103. elegance? pack(num,width) packs a number into a packed decimal string.
  104. num is the number and width is the size of the target packed string.
  105. unpack(val,width) unpacks a packed decimal number into an integer.
  106. width is the width of the returned integer.
  107.  
  108. ##################################################################
  109. #                                                                #
  110. # THIS PROCEDURE PACKS AN INTEGER IN TO PACKED DECIMAL STRING.   #
  111. #                                                                #
  112. ##################################################################
  113. procedure pack(num,width)           # 5p
  114.   local int,sign,prep,packed,i,word,calc
  115.   (int := integer(num)) | fail                
  116.   if int < 0 then sign := "=" else sign := "<"
  117.   prep := int || sign ; packed := ""
  118.   if (*prep % 2) ~= 0 then prep := "0" || prep
  119.   every i := 1 to *prep by 2 do
  120.     {
  121.     word := prep[i+:2]
  122.     if word[-1] == ("=" | "<") then
  123.       {
  124.       calc     := word[1]*16 + ord(word[2])-48
  125.       packed ||:= char(calc)
  126.       next
  127.       }
  128.     calc     := word[1]*16 + word[2]
  129.     packed ||:= char(calc)
  130.     }
  131.   /width := *packed
  132.   return right(packed,width,"\0")
  133.   end                                   
  134.  
  135. ##################################################################
  136. #                                                                #
  137. # THIS PROCEDURE UNPACKS A VALUE INTO AN INTEGER.                #
  138. #                                                                #
  139. ##################################################################
  140. procedure unpack(val,width)         # 6p     REQUIRES LINK RADCON !
  141.   local tmp,number,tens,ones,sign
  142.   tmp := "" ; sign := 1
  143.   every number := ord(!val) do
  144.     {
  145.     hex := map(radcon(number,10,16),&lcase,&ucase)
  146.     tmp ||:= hex
  147.     }
  148.   if tmp[-1] == ("B" | "D") then sign := -1
  149.   tmp[-1] := "" ; tmp *:= sign ; /width := *tmp
  150.   return right(tmp,width)
  151.   end
  152.  
  153. Have Fun !
  154.  
  155. Chris Tenaglia (System Manager)
  156. Medical College of Wisconsin
  157. 8701 W. Watertown Plank Rd.
  158. Milwaukee, WI 53226
  159. (414)257-8765
  160. tenaglia@mis.mcw.edu
  161.  
  162.  
  163. From SHAFIE@UCBEH.SAN.UC.EDU  Thu Jan 11 13:29:03 1990
  164. Received: from ucbeh.san.uc.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  165.     id AA07629; Thu, 11 Jan 90 13:29:03 MST
  166. Date: Thu, 11 Jan 90 14:13 EST
  167. From: Amin Shafie - Univ of Cincinnati Comp Ctr <SHAFIE@UCBEH.SAN.UC.EDU>
  168. Subject: SIGUCCS CALL for PARTICIPATION
  169. To: 386USERS@TWG.COM, 9370-L%HEARN.BITNET@MITVMA.MIT.EDU,
  170.         AAI@ST-LOUIS-EMH2.ARMY.MIL, ADA-SW@WSMR-SIMTEL20.ARMY.MIL,
  171.         ADVISE-L%CANADA01.BITNET@CUNYVM.CUNY.EDU, ADVSYS@EDDIE.MIT.EDU,
  172.         AG-EXP-L%NDSUVM1.BITNET@CUNYVM.CUNY.EDU, AI-ED@SUMEX-AIM.STANFORD.EDU,
  173.         AIDSNEWS%RUTVM1.BITNET@CUNYVM.CUNY.EDU, AIList@AI.AI.MIT.EDU,
  174.         AIX-L%BUACCA.BITNET@MITVMA.MIT.EDU, ALLIN1-L@CCVM.SUNYSB.EDU,
  175.         AMETHYST-USERS@WSMR-SIMTEL20.ARMY.MIL, AMIGA-RELAY@UDEL.EDU,
  176.         ANDREW-DEMOS@ANDREW.CMU.EDU, ANTHRO-L%UBVM.BITNET@CUNYVM.CUNY.EDU,
  177.         apollo@UMIX.CC.UMICH.EDU, ARMS-D@XX.LCS.MIT.EDU,
  178.         ARPANET-BBOARDS@MC.LCS.MIT.EDU, ASM370%UCF1VM.BITNET@CUNYVM.CUNY.EDU,
  179.         AVIATION@MC.LCS.MIT.EDU, AVIATION-THEORY@MC.LCS.MIT.EDU,
  180.         bicycles@BBN.COM, BIG-LAN@SUVM.ACS.SYR.EDU, BIG-LAN@SUVM.BITNET,
  181.         BIOTECH%UMDC.BITNET@CUNYVM.CUNY.EDU, BIOTECH@UMDC.UMD.EDU,
  182.         BITNEWS%BITNIC.BITNET@CUNYVM.CUNY.EDU,
  183.         BMDP-L%MCGILL1.BITNET@CORNELLC.CCS.CORNELL.EDU,
  184.         bug-1100@SUMEX-AIM.STANFORD.EDU, CA@THINK.COM,
  185.         CADinterest^.es@XEROX.COM, CAN-INET@MC.LCS.MIT.EDU,
  186.         cisco@SPOT.COLORADO.EDU
  187. Message-Id: <F5FA22744FDF00D81C@UCBEH.SAN.UC.EDU>
  188. X-Envelope-To: Icon-Group@ARIZONA.EDU
  189. X-Vms-To: @LISTS.DIS
  190. X-Vms-Cc: SHAFIE
  191. Status: O
  192.  
  193. <--------------------------------------------------------------------
  194. <                 SIGUCCS User Services Conference XVIII
  195. <                        Call For Participation
  196. <
  197. <                  New Centerings in Computing Services
  198. <                  September 30 through October 3, 1990
  199. <
  200. <                           Westin Hotel
  201. <                         Cincinnati, Ohio
  202. <
  203. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  204. << 
  205. << 
  206. <<Attention Directors, Managers, Analysts, Consultants, Programmers,
  207. <<Technical Writers, Trainers, and Librarians!
  208. << 
  209. <<The higher education computing scene in the 1990s will present exciting
  210. <<challenges.  To accommodate users' needs, computing service organizations
  211. <<are now visibly transforming in function and structure.  The widespread
  212. <<adoption of personal computing by all disciplines, the increasing demand
  213. <<for desktop access to shared resources, the growth in demand for
  214. <<supercomputing capabilities, and the proliferation of powerful desktop
  215. <<workstations exert irresistible forces on central computing services.
  216. <<In response, the central site grows exponentially in staff and machinery
  217. <<at one academic institution; at another, the computing center is disbanded
  218. <<to provide distributed computing!  At some sites increasing specialization
  219. <<is urged; at others, generalization is required.  Regardless of the
  220. <<transforming strategy adopted by an individual institution, one fact
  221. <<seems clear:  the user is the center toward which all computing services
  222. <<are directed.
  223. << 
  224. <<SIGUCCS '90 invites you to participate in the examination and discussion
  225. <<of the myriad challenges facing user services professionals as we enter a
  226. <<new decade and of the new centerings computing service organizations are
  227. <<discovering to meet them.  Please join us!
  228. << 
  229. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  230. << 
  231. <<You can Participate
  232. << 
  233. <<    Presentations
  234. << 
  235. <<    Papers
  236. << 
  237. <<    Panel Discussions
  238. << 
  239. <<    Quick Workshops
  240. << 
  241. <<    Educational Materials Competition
  242. << 
  243. <<    Newsletter Competition
  244. << 
  245. <<    Technical Writing Competition
  246. << 
  247. <<    Documentation Display
  248. << 
  249. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  250. << 
  251. << 
  252. << 
  253. <<Important Dates
  254. << 
  255. <<    March 1, 1990        Presentation proposals due
  256. <<    April 1, 1990        Notification of proposal acceptance
  257. <<    May 1, 1990        Final Papers due
  258. <<    June 1, 1990        Newsletter entries due
  259. <<    June 1, 1990        Technical writing entries due
  260. <<    June 15, 1990        Notification of paper/panel acceptance
  261. <<    September 1, 1990    Deadline for materials for
  262. <<                documentation display
  263. << 
  264. << 
  265. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  266. << 
  267. <<Presentation Topic Areas
  268. << 
  269. << 
  270. <<Information Exchange Technology
  271. << 
  272. <<Information exchange may well be the most important computing
  273. <<activity of the 1990s. The infrastructure for information delivery, the
  274. <<National Research and Academic Network (NREN), is presently being developed.
  275. <<How do we meet the challenges of a world where the
  276. <<facilitation of information delivery may be a principal user services
  277. <<responsibility?  Topics of particular interest include:
  278. << 
  279. <<    new approaches to information exchange
  280. << 
  281. <<    campus activity in implementing information exchange
  282. <<    facilities that comply with emerging international standards
  283. << 
  284. <<    research and development of computer-mediated information
  285. <<    exchange methods
  286. << 
  287. << 
  288. <<Distributed Services
  289. << 
  290. <<As the role of user services shifts to providing distributed support,
  291. <<we must create new ways of providing traditional services as well as
  292. <<designing new services.  Topics of particular interest include:
  293. << 
  294. <<    providing support staff in departments and colleges
  295. << 
  296. <<    funding issues
  297. << 
  298. <<    if and how to charge back for services
  299. << 
  300. <<    human networking of distributed support staff
  301. << 
  302. <<    nonlabor-intensive support strategies
  303. << 
  304. <<    cooperative efforts with other departments
  305. << 
  306. << 
  307. << 
  308. <<Management Strategies
  309. << 
  310. <<How do user services managers cooperate with other administrative and
  311. <<academic units that use or provide computing resources?  How do they
  312. <<meet the many and diverse demands?  Topics of particular interest include:
  313. << 
  314. <<    reorganization
  315. << 
  316. <<    interaction with faculty advisory groups
  317. << 
  318. <<    delegating and distributing responsibility
  319. << 
  320. <<    coordinating university computing resources
  321. << 
  322. <<    staff professional development
  323. << 
  324. << 
  325. <<Marketing your Services
  326. << 
  327. <<Changing roles may require changing your services and, often, your image on
  328. <<campus as you provide new services to new users.  Topics of particular in-
  329. <<terest include:
  330. << 
  331. <<    promotional strategies
  332. << 
  333. <<    conducting market research
  334. << 
  335. <<    designing services for unique or special audiences
  336. << 
  337. << 
  338. << 
  339. <<Strategies for Small Schools
  340. << 
  341. <<How can a small liberal arts college have distributed user services and
  342. <<centralized user services?  How do distributed and centralized services work
  343. <<together to provide computing services beyond word processing?  The
  344. <<sciences have become computer literate; now, how do we reach out  from the
  345. <<center to the humanities and fine arts?  Are we getting out of the
  346. <<office and into the trenches?  Are we making too many "house calls"?
  347. <<Should we make them at all?
  348. << 
  349. << 
  350. <<Security and Ethics
  351. << 
  352. <<As electronic mail and conferencing become more popular, computing
  353. <<systems are widely accessible to more users.  How secure should academic
  354. <<computing resources be?  What are the ethical guidelines provided for users
  355. <<of electronic mail and conferencing systems?  Topics of particular interest
  356. <<include:
  357. << 
  358. <<    promoting responsible and ethical use of computing resources
  359. << 
  360. <<    security strategies
  361. << 
  362. <<    adopting an ethics policy
  363. << 
  364. << 
  365. <<Serving New Audiences
  366. << 
  367. <<People from the humanities, the arts, and other traditionally nontechnical
  368. <<disciplines are discovering that computers can help in areas other than
  369. <<word processing.  In an increasingly proactive stance in the central
  370. <<computing facility, what do we do to attract and support these new audi-
  371. <<ences?  Topics of interest include:
  372. << 
  373. <<    providing information about off-the-shelf specialized
  374. <<    programs for music, fine arts, and the humanities
  375. << 
  376. <<    facilitating technical support of nontraditional areas
  377. << 
  378. <<    serving the computing beginner who wants to do
  379. <<    sophisticated tasks
  380. << 
  381. << 
  382. <<Consulting, Training, and Documentation
  383. << 
  384. <<Supporting those who use the computing resources that we provide re-
  385. <<mains an important responsibility of user services organizations.  Topics
  386. <<of particular interest include:
  387. << 
  388. <<    new approaches to training
  389. << 
  390. <<    providing distributed consulting
  391. << 
  392. <<    documentation distribution services
  393. << 
  394. << 
  395. <<and/or other topics that would be of interest to your national
  396. <<and international colleagues
  397. << 
  398. << 
  399. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  400. << 
  401. <<Submitting Proposals
  402. << 
  403. << 
  404. <<Submit proposals via electronic mail to:
  405. << 
  406. <<    SIGPAPER@OHSTVMA.BITNET or
  407. << 
  408. <<    SIGPAPER@OHSTVMA.IRCC.OHIO-STATE.EDU
  409. << 
  410. <<If you do not have access to electronic mail, send a printed copy to:
  411. << 
  412. <<        Susan Jenkins Saari
  413. <<        Instruction and Research
  414. <<        Computer Center
  415. <<        The Ohio State University
  416. <<        1971 Neil Avenue
  417. <<        Columbus, OH 43210
  418. << 
  419. <<        phone:      (614) 292-4843
  420. <<        fax:      (614) 292-7081
  421. << 
  422. << 
  423. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  424. << 
  425. <<Accepted Proposals
  426. << 
  427. << 
  428. <<Proposals must be received by March 1, 1990.  Any submisson received
  429. <<after this date will not be considered by the Program Committee.  You will
  430. <<be notified of the Program CommitteeUs decision by April 1, 1990.  If your
  431. <<proposal is accepted, you will be asked to submit a full paper by May 1,
  432. <<1990.  Any papers received after this date will not be considered.  You will
  433. <<be notified of the Program CommitteeUs decision by June 15, 1990.
  434. << 
  435. <<If your presentation is accepted, SIGUCCS is depending on you.  If you are
  436. <<ker to make your presentation (not a substitute presentation).
  437. << 
  438. << 
  439. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  440. << 
  441. << 
  442. <<How to Participate
  443. << 
  444. << 
  445. <<Proposals
  446. << 
  447. <<For each proposal, include your name, title, affiliation, mailing ad-
  448. <<type of  proposal (presentation or panel discussion) and its topic area.
  449. <<In addition, you must enclose the proper materials from the following
  450. <<requirements list:
  451. << 
  452. <<Description
  453. << 
  454. <<Papers        Papers will be presented in 20-minute ntervals, with
  455. <<        three papers scheduled per 90-minute session. Speakers'
  456. <<        papers will be published in the conference proceedings.
  457. << 
  458. <<Panels        Panels will be in-depth treatments of a single topic by
  459. <<        two to four speakers from at least two different schools,
  460. <<        coordinated by a moderator.  Allow ample time for audience
  461. <<        discussion.  Abstracts for panels should be submitted
  462. <<        as a unit by the person who wishes to act as a moderator.
  463. <<        Panelists' papers will be published in the conference
  464. <<        proceedings.
  465. << 
  466. <<Quick Workshops    Quick workshops provide 90-minute overviews of new technolo-
  467. <<        gies, innovative applications, and creative strategies
  468. <<        for addressing the needs of computer users on campus.
  469. << 
  470. << 
  471. <<Requirements
  472. << 
  473. <<Papers        A 250- to 300-word abstract of the paper.  Acceptance of
  474. <<        a proposal does not automatically ensure acceptance
  475. <<        of a paper for presentation; you must submit a full
  476. <<        paper to be considered for the conference program.
  477. << 
  478. <<Panels        A 250- to 300-word description of the panel, including
  479. <<        each panelist's name, title, affiliation, and presentation
  480. <<        topic.  Acceptance of a panel description does not
  481. <<        automatically ensure acceptance of the panel for
  482. <<        presentation; each panelist must submit a full paper
  483. <<        to be considered for the conference program.
  484. << 
  485. <<Quick Workshops    A one- to two-page outline of the presentation and a
  486. <<        10-minute videotape excerpt from the proposed presentation.
  487. <<        Acceptance of a proposal does not automatically ensure
  488. <<        acceptance of a workshop for presentation; you must
  489. <<        submit a full paper to be considered for the conference
  490. <<        program.  Only three or four presentations will be a
  491. <<        ccepted in this category because it is highly competiive.
  492. << 
  493. << 
  494. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  495. << 
  496. << 
  497. <<Other Ways to Participate
  498. << 
  499. <<Education and Training Materials Competition
  500. << 
  501. <<Interest in and the importance of user education and training have grown
  502. <<with each SIGUCCS conference.  The 1990 SIGUCCS Conference offers,
  503. <<for the first time, competition for user education and training materials for
  504. <<colleges and universities.*  We invite you to submit no more than two
  505. <<entries in any or all of the following categories: curriculum catalog, class-
  506. <<room printed materials, or self-contained printed tutorials.  Although the
  507. <<first year of this competition includes only printed materials, we would like
  508. <<to know if there is an interest in expanding our future competitions to
  509. <<include video, audio, and computer-based tutorials.  Deadline for entry is
  510. <<June 1, 1990.  For more details and an entry form, or to address the issue
  511. <<of future competition categories, contact:
  512. << 
  513. <<        Diane Jung-Gribble
  514. <<        Indiana University
  515. <<        750 North State Road 46 Bypass
  516. <<        Bloomington, IN  47405
  517. << 
  518. <<        (812) 855-0962
  519. << 
  520. << 
  521. <<        JUNG@IUBACS.BITNET
  522. <<        JUNG@JADE.BACS.INDIANA.EDU
  523. << 
  524. <<*NOTE:  this competition is not open to commercial materials
  525. << 
  526. <<Newsletter Competition
  527. << 
  528. <<Winning an award in the SIGUCCS Newsletter Competition is a mark of
  529. <<distinction for your institution, and for your editors, writers,artists,and
  530. <<designers.  You will be asked to submit two consecutive issues published
  531. <<between June 1989 and May 1990.  Deadline for entry is June 1, 1990.
  532. <<For more details and an entry form, contact:
  533. << 
  534. <<        Jess Anderson
  535. <<        Madison Academic Computing Center
  536. <<        University of Wisconsin-Madison
  537. <<        1210 West Dayton Street
  538. <<        Madison, WI   53706
  539. << 
  540. <<        (608) 263-6988
  541. << 
  542. <<        ANDERSON@MACC.WISC.EDU
  543. <<        ANDERSON@WISCMACC.BITNET
  544. << 
  545. << 
  546. <<Technical Writing Competition
  547. << 
  548. <<If you have written or published a particularly good article in a computing
  549. <<newsletter, enter it in the Technical Writing Competition.  Each computing
  550. <<center may enter one article.  Deadline for entry is June 1,1990.  To obtain
  551. <<entry forms and more details, contact:
  552. << 
  553. <<        Donald J. Montabana
  554. <<        University of Pennsylvania
  555. <<        Computing Resources Center
  556. <<        1202 Blockley Hall
  557. <<        Philadelphia, PA  19104-6021
  558. << 
  559. <<        (215) 898-9085
  560. << 
  561. <<        MONTABANA@A1.RELAY.UPENN.EDU
  562. << 
  563. << 
  564. << 
  565. <<Documentation Display
  566. << 
  567. <<The documentation room will feature an online system for submitted
  568. <<documentation.  Conference attendees who have BITNET or INTERNET
  569. <<access will be able to email documentation to their university or college.
  570. <<Documentation may be submitted electronically to DOCUMENT@MIAMIU,
  571. <<by hardcopy, or diskette (IBM or Mac formatted) and must be received
  572. <<before September 1, 1990.  Direct inquries to:
  573. << 
  574. <<        Al Kaled
  575. <<        Academic Computing Services
  576. <<        Miami University
  577. <<        Oxford, OH  45056
  578. << 
  579. <<        (513) 529-6226
  580. << 
  581. <<        AK75STAF@MIAMIU
  582. << 
  583. << 
  584. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  585. << 
  586. << 
  587. <<More Information
  588. << 
  589. << 
  590. <<General Information
  591. <
  592. <<Amin Shafie, Conference Chair
  593. <<University of Cincinnati
  594. << 
  595. << 
  596. <<        e-mail:        SHAFIE@UCBEH.BITNET
  597. << 
  598. <<        phone:        (513) 556-9001
  599. << 
  600. <<        fax:        (513) 556-0035
  601. << 
  602. << 
  603. <<Call for Participation
  604. <<Susan Jenkins Saari, Program Chair
  605. <<The Ohio State University
  606. << 
  607. <<        e-mail:        SIGPAPER@OHSTVMA.BITNET
  608. << 
  609. <<        phone:        (614) 292-4843
  610. << 
  611. <<        fax:        (614) 292-7081
  612. << 
  613. << 
  614. <<Registration
  615. <<Ken Maccarone, Registration Chair
  616. <<University of Cincinnati
  617. << 
  618. <<        e-mail:        MACCARON@UCBEH.BITNET
  619. << 
  620. << 
  621. <<        phone:        (513) 556-9098
  622. <<        fax:        (513) 556-0035
  623. << 
  624. << 
  625. <<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  626. << 
  627. << 
  628. <<ACM SIGUCCS
  629. << 
  630. <<The Association of Computing Machinery's (ACM) Special Interest Group
  631. <<for University and College Computing (SIGUCCS) is one of ACM's
  632. <<organizational units devoted to the technical activities of its members.
  633. <<SIGUCCS provides a link for guidance and the interchange of ideas among
  634. <<computing professionals in the full range of small to large institutions.
  635. <<Its newsletter, annual conferences, and workshops promote the discussion
  636. <<of mutual problems. networks, user services, and computer center management.
  637. <<This SIGUCCS conference emphasizes practical ways to improve services for
  638. <<those who use university and college computing centers.
  639.  
  640.  
  641. Amin Shafie
  642. Assistant Director
  643. Academic Computing Services                UCBEH::SHAFIE
  644. University of Cincinnati                   SHAFIE@UCBEH.SAN.UC.EDU
  645. ML 088                                     SHAFIE@UCBEH.BITNET
  646. Cincinnati, Ohio  45221
  647. (513) 556-9022
  648.  
  649. From ASRRM@asuacad.bitnet  Fri Jan 12 13:47:46 1990
  650. Message-Id: <9001122047.AA20569@megaron>
  651. Received: from rvax.ccit.arizona.edu by megaron (5.59-1.7/15) via SMTP
  652.     id AA20569; Fri, 12 Jan 90 13:47:46 MST
  653. Received: from ASUACAD.BITNET by rvax.ccit.arizona.edu; Fri, 12 Jan 90 13:43 MST
  654. Received: by ASUACAD (Mailer R2.05) id 9455; Fri, 12 Jan 90 13:37:55 MST
  655. Date: Fri, 12 Jan 90 13:37:11 MST
  656. From: mannem ravinder reddy <ASRRM@asuacad.bitnet>
  657. Subject: unsubscribe
  658. To: icon-group <icon-group@cs.arizona.edu>
  659. Status: O
  660.  
  661. unsubscribe icon-group
  662.  
  663. From PRONK@HROEUR5.BITNET  Thu Jan 18 16:01:25 1990
  664. Message-Id: <9001182301.AA18292@megaron.arizona.edu>
  665. Received: from rvax.ccit.arizona.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  666.     id AA18292; Thu, 18 Jan 90 16:01:25 MST
  667. Received: from HROEUR5.BITNET by rvax.ccit.arizona.edu; Thu, 18 Jan 90 15:44 MST
  668. Date: Thu, 18 Jan 90 13:06 N
  669. From: PRONK@HROEUR5.BITNET
  670. Subject: unsubscribe
  671. To: icon-group@cs.arizona.edu
  672. X-Original-To:  icon-group@cs.arizona.edu, PRONK
  673. Status: O
  674.  
  675. unsubscribe
  676.  
  677. From icon-group-request@arizona.edu  Fri Jan 19 06:50:55 1990
  678. Received: from ucbvax.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  679.     id AA01143; Fri, 19 Jan 90 06:50:55 MST
  680. Received: by ucbvax.Berkeley.EDU (5.61/1.41)
  681.     id AA29135; Fri, 19 Jan 90 05:40:50 -0800
  682. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  683.     for icon-group@arizona.edu (icon-group@arizona.edu)
  684.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  685. Date: 18 Jan 90 22:00:00 GMT
  686. From: amdahl!ntmtv!hildum@apple.com  (Eric Hildum)
  687. Organization: Northern Telecom (Mountain View, CA)
  688. Subject: Installing Icon 7.5 on Sun 4
  689. Message-Id: <679@ntmtv.UUCP>
  690. References: <678@ntmtv.UUCP>
  691. Sender: icon-group-request@arizona.edu
  692. To: icon-group@arizona.edu
  693. Status: O
  694.  
  695.  
  696. I have installed Icon 7.5 on a Sun 4 workstation, and run into some
  697. problems. The operating system is SunOS 4.0.3c, the installation was
  698. done by Bill Mitchell on November 22, 1988. 
  699.  
  700. After the installation, I ran the full test suite, and the gc2 and
  701. checking tests apparently did not pass.  In addition, this port does
  702. not support overflow checking or co-expressions.
  703.  
  704. Are these known problems, and is there a more recent port to the Sun 4
  705. which supports overflow checking and co-expressions?
  706.  
  707.             Thanks,
  708.                 Eric
  709.  
  710. replies to:
  711.  
  712.             ntmtv!hildum@ames.com
  713.             hildum@iris.ucdavis.edu
  714.  
  715. From icon-group-request@arizona.edu  Fri Jan 19 06:51:00 1990
  716. Received: from ucbvax.Berkeley.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  717.     id AA01158; Fri, 19 Jan 90 06:51:00 MST
  718. Received: by ucbvax.Berkeley.EDU (5.61/1.41)
  719.     id AA29153; Fri, 19 Jan 90 05:41:00 -0800
  720. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  721.     for icon-group@arizona.edu (icon-group@arizona.edu)
  722.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  723. Date: 18 Jan 90 21:53:30 GMT
  724. From: amdahl!ntmtv!hildum@apple.com  (Eric Hildum)
  725. Organization: Northern Telecom (Mountain View, CA)
  726. Subject: Installing Icon on Sun3 with SunOS 4.0.3
  727. Message-Id: <678@ntmtv.UUCP>
  728. Sender: icon-group-request@arizona.edu
  729. To: icon-group@arizona.edu
  730. Status: O
  731.  
  732.  
  733. I have just installed Icon 7.5 on a Sun 3/60 with SunOS 4.0.3 and have a
  734. couple of issues.
  735.  
  736. First, I have to change the -m68020 switch to -sun3 to get correct
  737. compiliation.  This seems to work just fine; is this change going to
  738. be made to the installation available on arizona.edu?
  739.  
  740. The new default for the cc compiler is to use software floating point,
  741. rather than the switch option.  Would it be reasonable to change the
  742. default sun3 installation to include the -fswitch option?
  743.  
  744. The Header file now requires almost 12000 bytes. Is this reasonable?
  745.  
  746.  
  747. Other than these issues, everything went well, and all the tests
  748. passed.
  749.  
  750. From cargo@tardis.cray.com  Fri Jan 19 07:39:42 1990
  751. Received: from uc.msc.umn.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  752.     id AA02802; Fri, 19 Jan 90 07:39:42 MST
  753. Received: from hall.cray.com by uc.msc.umn.edu (5.59/1.14)
  754.     id AA19081; Fri, 19 Jan 90 08:37:55 CST
  755. Received: from zk.cray.com by hall.cray.com
  756.     id AA04437; 3.2/CRI-3.12; Fri, 19 Jan 90 08:39:39 CST
  757. Received: by zk.cray.com
  758.     id AA00765; 3.2/CRI-3.12; Fri, 19 Jan 90 08:39:35 CST
  759. Date: Fri, 19 Jan 90 08:39:35 CST
  760. From: cargo@tardis.cray.com (David S. Cargo)
  761. Message-Id: <9001191439.AA00765@zk.cray.com>
  762. To: icon-group@cs.arizona.edu
  763. Subject: concat with blank and a question
  764. Status: O
  765.  
  766. I recently purchased a product called HyperPAD for the PC.  It is intended
  767. to be a HyperCard-like product for the PC.  What I found interesting was
  768. something in its list of operators.  To concatenate two strings there is
  769. the concatenation operator &.  However, there is an operator to concatenate
  770. two strings with a space in between them, the && operator.  I realized that
  771. this one little feature was a a nice convenience.  I know I have often used
  772. something like  a || " " || b because I needed to put a space between two
  773. strings I was combining.  Maybe from an overall language viewpoint this isn't
  774. a significant improvement, but I thought it was an interesting addition to
  775. a language with string processing.
  776.  
  777. The question I have is:  What is the best way to elminate spaces (or, to
  778. generalize, members of a particular cset) from a string while still preserving
  779. the order of the remaining characters?  I'm going to be performing some comparisons
  780. where certain characters are very likely to not be significant.  I'm looking for
  781. an efficient way of doing preprocessing to remove the insignificant characters.
  782.  
  783.                          o       o
  784.                           \_____/
  785.                           /-o-o-\     _______
  786. DDDD      SSSS   CCCC    /   ^   \   /\\\\\\\\
  787. D   D    S      C        \ \___/ /  /\   ___  \
  788. D   D     SSS   C         \_   _/  /\   /\\\\  \
  789. D   D        S  C           \  \__/\   /\ @_/  /
  790. DDDDavid SSSS.   CCCCargo    \____\____\______/ CARGO@TARDIS.CRAY.COM
  791.  
  792. From goer@sophist.uchicago.edu  Fri Jan 19 09:17:22 1990
  793. Received: from tank.uchicago.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  794.     id AA09664; Fri, 19 Jan 90 09:17:22 MST
  795. Received: from sophist.uchicago.edu by tank.uchicago.edu Fri, 19 Jan 90 10:17:26 CST
  796. Return-Path: <goer@sophist.uchicago.edu>
  797. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  798.     id AA22197; Fri, 19 Jan 90 10:13:19 CST
  799. Date: Fri, 19 Jan 90 10:13:19 CST
  800. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  801. Message-Id: <9001191613.AA22197@sophist.uchicago.edu>
  802. To: icon-group@arizona.edu
  803. Subject: strip?
  804. Status: O
  805.  
  806. A snail asked:
  807.  
  808. The question I have is:  What is the best way to elminate spaces (or, to
  809. generalize, members of a particular cset) from a string while still preserving
  810. the order of the remaining characters?
  811.  
  812. I wonder if you are referring to a stripping routine?
  813.  
  814. procedure Strip(s,c)
  815.   s2 := ""
  816.   s ? {
  817.     while s2 ||:= tab(upto(c))
  818.     do tab(many(c))
  819.     s2 ||:= tab(0)
  820.     }
  821.   return s2
  822. end
  823.  
  824. This will work with strings, and I suppose that type conversion
  825. will make it work with csets, too.  For operations specifically
  826. having to do with csets, you can of course say
  827.  
  828.      c1 --:= c2
  829.  
  830. where c1 is the cset you are trying to strip down, and c2 is the
  831. cset containing the characters to be removed from it.  The trouble
  832. here, though, is that, unlike strings, csets are not an ordered
  833. sequence of characters (you did say something about "original or-
  834. der," didn't you?).
  835.  
  836. I guess I'm confused.  If the original order is important, use 
  837. Strip(s,c), and feed it strings.  Does this help?
  838.  
  839.                                         -Richard L. Goerwitz
  840.                                         goer@sophist.uchicago.edu
  841.                                         goer%sophist@uchicago.bitnet
  842.                                         rutgers!oddjob!gide!sophist!goer
  843.  
  844. From tenaglia@fps.mcw.edu  Fri Jan 19 10:20:36 1990
  845. Received: from RUTGERS.EDU by megaron.arizona.edu (5.59-1.7/15) via SMTP
  846.     id AA13085; Fri, 19 Jan 90 10:20:36 MST
  847. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  848.     id AA25922; Fri, 19 Jan 90 12:18:26 EST
  849. Received: by uwm.edu; id AA26075; Fri, 19 Jan 90 11:17:22 -0600
  850. Message-Id: <9001191717.AA26075@uwm.edu>
  851. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  852.           Fri, 19 Jan 90 11:15:03 CDT
  853. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  854.           Fri, 19 Jan 90 11:08:11 CDT
  855. Date: Fri, 19 Jan 90 11:08:11 CDT
  856. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  857. To: icon-group@cs.arizona.edu
  858. Subject: RE: concat with blank and a question
  859. X-Vms-Mail-To: UUCP%"cargo@tardis.cray.com"
  860. Status: O
  861.  
  862. In reply to the concat,...
  863.  
  864. If you are running ICON under unix, and are adventurous, you can build
  865. in your own concat with the 'Personal Interpretor' or 'Variant Translator'.
  866. I've built a personal code library of icon software chips which I just
  867. include using the editor when I use them.
  868.  
  869. Having an operator $ for example may accomplish :
  870.  
  871.   both := first $ second   (rather then both := first || " " || second)     
  872.  
  873. But it still not as flexible as a procedure :
  874.  
  875.   procedure cat(s1,s2,s3)
  876.     /s3 := " "             # where an optional string may or may not appear.
  877.     return s1 || s3 || s2
  878.     end
  879.  
  880. ---------------------------------------------------
  881.  
  882. Concerning Character Elimination in a String
  883.  
  884. This is best done with the string scanning feature of ICON. I'll present
  885. a little procedure. Others may approach the problem differently.
  886.  
  887.   procedure strip(str,chrs)
  888.     local text,chars
  889.     /chrs := ' '
  890.     chars := &cset -- chrs
  891.     text  := ""
  892.     str ? while tab(upto(chars)) do text ||:= tab(many(chars))
  893.     return text
  894.     end
  895.  
  896. Yours truly,
  897.  
  898. Chris Tenaglia (System Manager)
  899. Medical College of Wisconsin
  900. 8701 W. Watertown Plank Rd.
  901. Milwaukee, WI 53226
  902. (414)257-8765
  903. tenaglia@mis.mcw.edu
  904.  
  905.  
  906. From cargo@tardis.cray.com  Fri Jan 19 16:03:37 1990
  907. Received: from uc.msc.umn.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  908.     id AA09993; Fri, 19 Jan 90 16:03:37 MST
  909. Received: from hall.cray.com by uc.msc.umn.edu (5.59/1.14)
  910.     id AA01870; Fri, 19 Jan 90 17:01:37 CST
  911. Received: from zk.cray.com by hall.cray.com
  912.     id AA16178; 3.2/CRI-3.12; Fri, 19 Jan 90 17:03:22 CST
  913. Received: by zk.cray.com
  914.     id AA01299; 3.2/CRI-3.12; Fri, 19 Jan 90 17:03:16 CST
  915. Date: Fri, 19 Jan 90 17:03:16 CST
  916. From: cargo@tardis.cray.com (David S. Cargo)
  917. Message-Id: <9001192303.AA01299@zk.cray.com>
  918. To: icon-group@cs.arizona.edu
  919. Subject: deleting characters
  920. Status: O
  921.  
  922. After sending out my mail about deleting or stripping characters out of a
  923. string I received a couple of responses from kindly Iconists.  I later was
  924. showing off Icon to a friend when I notices a "delete" function in
  925. strutil.icn.  Upon closer examination I found that delete also did what I
  926. wanted.  The next step for me was to write a little benchmarking program so
  927. I could see how the different methods compared speedwise.  It turns out
  928. that the IPL delete routine was the slowest, although the fastest was only
  929. 15 percent faster.
  930.  
  931. Here is the test program:
  932.  
  933. procedure main()
  934.     test_string :=
  935.         "    str ? while tab(upto(chars)) do text ||:= tab(many(chars))"
  936.     remove := &cset -- &lcase
  937.     time1 := &time
  938.     limit := 1000
  939.     every 1 to limit do result1 := delete(test_string, remove)
  940.     time2 := &time
  941.     every 1 to limit do result2 := strip1(test_string, remove)
  942.     time3 := &time
  943.     every 1 to limit do result3 := strip2(test_string, remove)
  944.     time4 := &time
  945.     write(time1)
  946.     write(time2-time1, " ", result1)
  947.     write(time3-time2, " ", result2)
  948.     write(time4-time3, " ", result3)
  949.     return
  950. end
  951.  
  952. #  from IPL strutil.icn
  953. #  delete characters
  954. #
  955. procedure delete(s,c)
  956.     local i
  957.     while i := upto(c,s) do
  958.         s[i:many(c,s,i)] := ""
  959.     return s
  960. end
  961.  
  962. #From: Richard Goerwitz <goer@sophist.uchicago.edu>
  963. procedure strip1(s,c)
  964.     s2 := ""
  965.     s ? {
  966.         while s2 ||:= tab(upto(c)) do
  967.             tab(many(c))
  968.         s2 ||:= tab(0)
  969.         }
  970.   return s2
  971. end
  972.  
  973.  
  974. #From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  975. procedure strip2(str,chrs)
  976.     local text,chars
  977. #    /chrs := ' '
  978. #   (I commmented this out because the others don't do such checks.)
  979.     chars := &cset -- chrs
  980.     text  := ""
  981.     str ? while tab(upto(chars)) do text ||:= tab(many(chars))
  982.     return text
  983. end
  984.  
  985. And the output (first column is time, second column is the result string
  986. which is always supposed to be the same).  Initial time is 0, other times
  987. are in milliseconds.
  988.  
  989. 0
  990. 21033 strwhiletabuptocharsdotexttabmanychars
  991. 20350 strwhiletabuptocharsdotexttabmanychars
  992. 17717 strwhiletabuptocharsdotexttabmanychars
  993.  
  994. All three are reasonable, but the differences in approach are educational.
  995.                          o       o
  996.                           \_____/
  997.                           /-o-o-\     _______
  998. DDDD      SSSS   CCCC    /   ^   \   /\\\\\\\\
  999. D   D    S      C        \ \___/ /  /\   ___  \
  1000. D   D     SSS   C         \_   _/  /\   /\\\\  \
  1001. D   D        S  C           \  \__/\   /\ @_/  /
  1002. DDDDavid SSSS.   CCCCargo    \____\____\______/ CARGO@TARDIS.CRAY.COM
  1003.  
  1004. From flee@shire.cs.psu.edu  Fri Jan 19 17:07:13 1990
  1005. Received: from shire.cs.psu.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1006.     id AA15092; Fri, 19 Jan 90 17:07:13 MST
  1007. Received: from localhost by shire.cs.psu.edu with SMTP 
  1008.     (5.61/PSUCS-1.0) id AA02947; Fri, 19 Jan 90 19:07:42 -0500
  1009. Message-Id: <9001200007.AA02947@shire.cs.psu.edu>
  1010. To: cargo@tardis.cray.com (David S. Cargo)
  1011. Cc: icon-group@cs.arizona.edu
  1012. Subject: Re: deleting characters 
  1013. In-Reply-To: Your message of Fri, 19 Jan 90 17:03:16 CST.
  1014.              <9001192303.AA01299@zk.cray.com> 
  1015. Date: Fri, 19 Jan 90 19:07:40 EST
  1016. From: Felix Lee <flee@shire.cs.psu.edu>
  1017. Status: O
  1018.  
  1019. > It turns out that the IPL delete routine was the slowest, although
  1020. > the fastest was only 15 percent faster.
  1021.  
  1022. On pathological cases, the delete routine can be much slower.  Try
  1023. removing spaces from repl("a   ", 1000).
  1024.  
  1025. The delete routine is quadratic wrt the length of the source string,
  1026. while the strip routines are quadratic wrt the result.  This is due
  1027. to the terrible amount of copying involved in manipulating Icon
  1028. strings: delete has to copy 3997 + 3994 + ... + 1000 characters,
  1029. while the other procedures need only copy 1 + 2 + ... + 1000.
  1030.  
  1031. You can get linear performance if you do it in C.
  1032. --
  1033. Felix Lee    flee@shire.cs.psu.edu    *!psuvax1!flee
  1034.  
  1035. From gmt  Fri Jan 19 17:48:05 1990
  1036. Date: Fri, 19 Jan 90 17:48:05 MST
  1037. From: "Gregg Townsend" <gmt>
  1038. Message-Id: <9001200048.AA16501@megaron.arizona.edu>
  1039. Received: by megaron.arizona.edu (5.59-1.7/15)
  1040.     id AA16501; Fri, 19 Jan 90 17:48:05 MST
  1041. In-Reply-To: <9001200007.AA02947@shire.cs.psu.edu>
  1042. To: icon-group
  1043. Subject: Re: deleting characters
  1044. Cc: cargo@tardis.cray.com, flee@shire.cs.psu.edu
  1045. Status: O
  1046.  
  1047.     Felix Lee (flee@shire.cs.psu.edu) writes:
  1048.  
  1049.     On pathological cases, the delete routine can be much slower.
  1050.  
  1051. True.
  1052.     
  1053.     ...You can get linear performance if you do it in C.
  1054.  
  1055. You get it in Icon, too.  Both Goerwitz's and Tenaglia's procedures are linear.
  1056.  
  1057. Building strings by successive concatenation is sufficiently common that it was
  1058. worth optimizing the implementation.  If no other concurrent activity disrupts
  1059. things, only the new characters (those added at the end) are copied.
  1060.  
  1061.     Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  1062.     +1 602 621 4325     gmt@cs.arizona.edu     110 57 16 W / 32 13 45 N / +758m
  1063.  
  1064. From wgg@cs.washington.edu  Fri Jan 19 18:13:02 1990
  1065. Received: from june.cs.washington.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1066.     id AA17870; Fri, 19 Jan 90 18:13:02 MST
  1067. Received: by june.cs.washington.edu (5.61/7.0jh)
  1068.     id AA16921; Fri, 19 Jan 90 17:11:14 -0800
  1069. Date: Fri, 19 Jan 90 17:11:14 -0800
  1070. From: wgg@cs.washington.edu (William Griswold)
  1071. Return-Path: <wgg@cs.washington.edu>
  1072. Message-Id: <9001200111.AA16921@june.cs.washington.edu>
  1073. To: cargo@tardis.cray.com, flee@shire.cs.psu.edu
  1074. Subject: Re: deleting characters
  1075. Cc: icon-group@cs.arizona.edu
  1076. Status: O
  1077.  
  1078.  
  1079. > The delete routine is quadratic wrt the length of the source string,
  1080. > while the strip routines are quadratic wrt the result.
  1081.  
  1082. I may be wrong, but I believe you will find that in modern implementations 
  1083. of Icon that the strip routines are linear in time.  Icon is smart enough 
  1084. to know that a string is located at the end of the string memory region 
  1085. (in this case the value of the variable holding the accumulating result 
  1086. string), and can just add to the end of it to concatenate.  Any other 
  1087. *modification* of a string requires copying--substring creation does not
  1088. require copying, since it is implemented as a pointer and an index. 
  1089.  
  1090. > You can get linear performance if you do it in C.
  1091.  
  1092. Many common operations in Icon require *more* time to perform in C--using
  1093. available abstractions--such as computing the length of a string.  Also
  1094. note that string concatentation in C in the standard way (using strcat)
  1095. takes linear time.  It also requires knowing the destination string is
  1096. long enough to hold the longer result.  Thus making strip as ``fast'' as
  1097. Icon's requires a little effort. 
  1098.  
  1099.                     Bill Griswold
  1100.  
  1101. From flee@shire.cs.psu.edu  Fri Jan 19 19:50:23 1990
  1102. Received: from shire.cs.psu.edu by megaron.arizona.edu (5.59-1.7/15) via SMTP
  1103.     id AA21917; Fri, 19 Jan 90 19:50:23 MST
  1104. Received: from localhost by shire.cs.psu.edu with SMTP 
  1105.     (5.61/PSUCS-1.0) id AA04238; Fri, 19 Jan 90 21:51:28 -0500
  1106. Message-Id: <9001200251.AA04238@shire.cs.psu.edu>
  1107. To: "Gregg Townsend" <gmt@cs.arizona.edu>
  1108. Cc: icon-group@cs.arizona.edu
  1109. Subject: Re: deleting characters 
  1110. In-Reply-To: Your message of Fri, 19 Jan 90 17:48:05 MST.
  1111.              <9001200048.AA16501@megaron.arizona.edu> 
  1112. Date: Fri, 19 Jan 90 21:51:27 EST
  1113. From: Felix Lee <flee@shire.cs.psu.edu>
  1114. Status: O
  1115.  
  1116. > If no other concurrent activity disrupts things, only the new characters
  1117. > (those added at the end) are copied.
  1118.  
  1119. Ah, I forgot about that optimization.
  1120. --
  1121. Felix
  1122.  
  1123. From icon-group-request@arizona.edu  Sun Jan 21 20:52:21 1990
  1124. Received: from ucbvax.Berkeley.EDU by megaron (5.59-1.7/15) via SMTP
  1125.     id AA12560; Sun, 21 Jan 90 20:52:21 MST
  1126. Received: by ucbvax.Berkeley.EDU (5.61/1.41)
  1127.     id AA06366; Sun, 21 Jan 90 19:47:56 -0800
  1128. Received: from USENET by ucbvax.Berkeley.EDU with netnews
  1129.     for icon-group@arizona.edu (icon-group@arizona.edu)
  1130.     (contact usenet@ucbvax.Berkeley.EDU if you have questions)
  1131. Date: 22 Jan 90 03:24:46 GMT
  1132. From: aramis.rutgers.edu!paul.rutgers.edu!jac@rutgers.edu  (Jonathan A. Chandross)
  1133. Organization: Rutgers Univ., New Brunswick, N.J.
  1134. Subject: Re: deleting characters
  1135. Message-Id: <Jan.21.22.24.44.1990.9958@paul.rutgers.edu>
  1136. References: <9001200111.AA16921@june.cs.washington.edu>
  1137. Sender: icon-group-request@arizona.edu
  1138. To: icon-group@arizona.edu
  1139. Status: O
  1140.  
  1141.  
  1142. wgg@CS.WASHINGTON.EDU (William Griswold)
  1143. > Many common operations in Icon require *more* time to perform in C--using
  1144. > available abstractions--such as computing the length of a string.  Also
  1145. > note that string concatentation in C in the standard way (using strcat)
  1146. > takes linear time.  It also requires knowing the destination string is
  1147. > long enough to hold the longer result.  Thus making strip as ``fast'' as
  1148. > Icon's requires a little effort. 
  1149.  
  1150. I don't know if your statement is totally fair.  There is nothing to
  1151. prevent one from using BCPL style strings (i.e. also store a length
  1152. with the string) in a C program.
  1153.  
  1154. In fact, this is done.  The MESA language (XEROX) generates C code
  1155. which is then compiled normally.  Strings in MESA are stored with
  1156. a length, and are word aligned.  This allows strcpy, strcmp, et al
  1157. to work on word quantities,  producing much faster string routines. 
  1158. I see no reason (aside from inertia) for why this has not been done
  1159. to C.  (Well, one would have to write routines to convert from the
  1160. library function's notion of a character string to the new one with
  1161. a length.)
  1162.  
  1163. A while back I needed to derive the name from a file pointer.  Since
  1164. stdio does not support this I had to write a piece of code like:
  1165.     struct N_FILE {
  1166.         char    *name;
  1167.         FILE    *file;
  1168.         };
  1169. and the associated front-end routines for stdio.  This was not hard
  1170. to do, and did not take all that much time.
  1171.  
  1172. Of course, one could say that the pattern matching, associative
  1173. table features, etc. that make Icon so popular could also be added
  1174. to C using the argument I give above.  I won't (and can't) defend
  1175. such a statement.  My point is that condemning C for a shortcoming
  1176. in the library routines is not really fair.  Especially when that
  1177. problem could be fixed in a few days hacking.
  1178.  
  1179.  
  1180. Jonathan A. Chandross
  1181. Internet: jac@paul.rutgers.edu
  1182. UUCP: rutgers!paul.rutgers.edu!jac
  1183.  
  1184. From goer@sophist.uchicago.edu  Sun Jan 21 22:18:57 1990
  1185. Received: from tank.uchicago.edu by megaron (5.59-1.7/15) via SMTP
  1186.     id AA16449; Sun, 21 Jan 90 22:18:57 MST
  1187. Received: from sophist.uchicago.edu by tank.uchicago.edu Sun, 21 Jan 90 23:19:04 CST
  1188. Return-Path: <goer@sophist.uchicago.edu>
  1189. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  1190.     id AA24968; Sun, 21 Jan 90 23:14:57 CST
  1191. Date: Sun, 21 Jan 90 23:14:57 CST
  1192. From: Richard Goerwitz <goer@sophist.uchicago.edu>
  1193. Message-Id: <9001220514.AA24968@sophist.uchicago.edu>
  1194. To: icon-group@arizona.edu
  1195. Subject: condemning
  1196. Status: O
  1197.  
  1198. Recent point:
  1199.  
  1200. > My point is that condemning C for a shortcoming in the library
  1201. > routines is not really fair.  Especially when the problem could
  1202. > be fixed in a few days hacking.
  1203.  
  1204. I never got the impression that anyone was condemning C.  Aren't
  1205. you overreacting a bit?  Whether or not the poster was correct in
  1206. this instance, it does seem that making C behave like Icon often
  1207. does result in very poor performance.  Granted, you can often go
  1208. down some by-way, and come up with a new Iconish library routine
  1209. that will outperform Icon itself.  But this is the very sort of in-
  1210. convenience that Icon was intended to help us avoid.  It's a trade-
  1211. off.  Name your poison.
  1212. -Richard
  1213.  
  1214. From wgg@cs.washington.edu  Mon Jan 22 01:57:26 1990
  1215. Received: from june.cs.washington.edu by megaron (5.59-1.7/15) via SMTP
  1216.     id AA00782; Mon, 22 Jan 90 01:57:26 MST
  1217. Received: by june.cs.washington.edu (5.61/7.0jh)
  1218.     id AA15833; Sun, 21 Jan 90 23:59:00 -0800
  1219. Date: Sun, 21 Jan 90 23:59:00 -0800
  1220. From: wgg@cs.washington.edu (William Griswold)
  1221. Return-Path: <wgg>
  1222. Message-Id: <9001220759.AA15833@june.cs.washington.edu>
  1223. To: @rutgers.edu:paul.rutgers.edu!jac@aramis.rutgers.edu
  1224. Subject: Re: deleting characters
  1225. Cc: icon-group@cs.arizona.edu
  1226. Status: O
  1227.  
  1228. >Date: 22 Jan 90 03:24:46 GMT
  1229. >From: aramis.rutgers.edu!paul.rutgers.edu!jac@rutgers.edu  (Jonathan A. Chandross)
  1230. >Organization: Rutgers Univ., New Brunswick, N.J.
  1231. >Subject: Re: deleting characters
  1232. >To: icon-group@arizona.edu
  1233. >
  1234. >
  1235. >wgg@CS.WASHINGTON.EDU (William Griswold)
  1236. >> Many common operations in Icon require *more* time to perform in C--using
  1237. >> available abstractions--such as computing the length of a string.  Also
  1238. >> note that string concatentation in C in the standard way (using strcat)
  1239. >> takes linear time.  It also requires knowing the destination string is
  1240. >> long enough to hold the longer result.  Thus making strip as ``fast'' as
  1241. >> Icon's requires a little effort. 
  1242. >
  1243. >I don't know if your statement is totally fair.  There is nothing to
  1244. >prevent one from using BCPL style strings (i.e. also store a length
  1245. >with the string) in a C program.
  1246. >
  1247. >In fact, this is done.  The MESA language (XEROX) generates C code
  1248. >which is then compiled normally.  Strings in MESA are stored with
  1249. >a length, and are word aligned.  This allows strcpy, strcmp, et al
  1250. >to work on word quantities,  producing much faster string routines. 
  1251. >I see no reason (aside from inertia) for why this has not been done
  1252. >to C.  (Well, one would have to write routines to convert from the
  1253. >library function's notion of a character string to the new one with
  1254. >a length.)
  1255. >
  1256. ...
  1257. >
  1258. >Of course, one could say that the pattern matching, associative
  1259. >table features, etc. that make Icon so popular could also be added
  1260. >to C using the argument I give above.  I won't (and can't) defend
  1261. >such a statement.  My point is that condemning C for a shortcoming
  1262. >in the library routines is not really fair.  Especially when that
  1263. >problem could be fixed in a few days hacking.
  1264. >
  1265. >
  1266. >Jonathan A. Chandross
  1267. >Internet: jac@paul.rutgers.edu
  1268. >UUCP: rutgers!paul.rutgers.edu!jac
  1269. >
  1270.  
  1271. Looks like I've got my foot stuck in the Turing Tar Pit.  I'm aware that I 
  1272. can do (almost) anything I want in any programming language at (close to) 
  1273. the performance the theoreticians tell me.  As indicated at the end of 
  1274. your message, it is not possibility, but reality that counts.  The reality 
  1275. is that C translates a string literal into a fixed-sized null-terminated 
  1276. character array.  For a programmer to reimplement strings has to work
  1277. pretty hard (The folks at Xerox and Arizona are good examples) 
  1278. particularly if that includes dynamically sized string management.  Only
  1279. with the encapsulation provided by C++ can we get close to what you claim,
  1280. which, with care, can even handle C string literals correctly. 
  1281.  
  1282. I will readily confess that there are many problems that I would rather
  1283. code in C than Icon--each is suited to a special set of tasks.
  1284.  
  1285.                     Bill Griswold
  1286.  
  1287. From tenaglia@fps.mcw.edu  Tue Jan 23 15:54:03 1990
  1288. Received: from RUTGERS.EDU by megaron (5.59-1.7/15) via SMTP
  1289.     id AA19233; Tue, 23 Jan 90 15:54:03 MST
  1290. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  1291.     id AA28358; Tue, 23 Jan 90 17:52:43 EST
  1292. Received: by uwm.edu; id AA03553; Tue, 23 Jan 90 16:28:55 -0600
  1293. Message-Id: <9001232228.AA03553@uwm.edu>
  1294. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  1295.           Tue, 23 Jan 90 16:12:14 CDT
  1296. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  1297.           Tue, 23 Jan 90 13:56:10 CDT
  1298. Date: Tue, 23 Jan 90 13:56:10 CDT
  1299. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  1300. To: icon-group@cs.arizona.edu
  1301. Subject: Correction to packed decimal converter
  1302. Status: O
  1303.  
  1304.  
  1305. Several weeks ago I posted procedures for converting integers to and
  1306. from packed format. After perfecting an application using them, a flaw
  1307. became apparent in the procedure unpack(). Below is the corrected version.
  1308.  
  1309. ##################################################################
  1310. #                                                                #
  1311. # THIS PROCEDURE UNPACKS A VALUE INTO AN INTEGER.                #
  1312. #                                                                #
  1313. ##################################################################
  1314. procedure unpack(val,width)         # REQUIRES LINK RADCON !
  1315.   local tmp,number,tens,ones,sign
  1316.   tmp  := ""
  1317.   sign := 1
  1318.   every number := ord(!val) do
  1319.     tmp ||:= right(map(radcon(number,10,16),&lcase,&ucase),2,"0") #this line changed
  1320.   if tmp[-1] == ("B" | "D") then sign := -1
  1321.   tmp[-1] := ""
  1322.   tmp    *:= sign
  1323.   /width  := *tmp
  1324.   return right(tmp,width)
  1325.   end
  1326.  
  1327. Yours truly,
  1328.  
  1329. Chris Tenaglia (System Manager)
  1330. Medical College of Wisconsin
  1331. 8701 W. Watertown Plank Rd.
  1332. Milwaukee, WI 53226
  1333. (414)257-8765
  1334. tenaglia@mis.mcw.edu
  1335.  
  1336.  
  1337. From cargo@tardis.cray.com  Wed Jan 24 14:31:32 1990
  1338. Received: from uc.msc.umn.edu by megaron (5.59-1.7/15) via SMTP
  1339.     id AA18152; Wed, 24 Jan 90 14:31:32 MST
  1340. Received: from hall.cray.com by uc.msc.umn.edu (5.59/1.14)
  1341.     id AA23656; Wed, 24 Jan 90 15:29:38 CST
  1342. Received: from zk.cray.com by hall.cray.com
  1343.     id AA12949; 3.2/CRI-3.12; Wed, 24 Jan 90 15:31:27 CST
  1344. Received: by zk.cray.com
  1345.     id AA05119; 3.2/CRI-3.12; Wed, 24 Jan 90 15:31:21 CST
  1346. Date: Wed, 24 Jan 90 15:31:21 CST
  1347. From: cargo@tardis.cray.com (David S. Cargo)
  1348. Message-Id: <9001242131.AA05119@zk.cray.com>
  1349. To: icon-group@cs.arizona.edu
  1350. Subject: questions about records
  1351. Status: O
  1352.  
  1353. I happened to be looking at an application for rsg.icn from the IPL,
  1354. when I happened to be looking at the beginning of the program and saw:
  1355.  
  1356. record nonterm(name)
  1357. record charset(chars)
  1358. record query(name)
  1359.  
  1360. I observed that two records had the same field name ("name").  This
  1361. prompted a couple of questions that I couldn't find answers to in any
  1362. of the Icon programming language documentation I looked at (including
  1363. the book).
  1364.  
  1365. What are the restrictions on reusing field names from record declarations?
  1366. For example, you can clearly use the same field name in two different
  1367. record declarations.  You can also use the same field name in two different
  1368. ordinal locations in two different record declarations.  The field names
  1369. can also be the same as names of local variables (surprise!).  That was
  1370. not what I would have expected.
  1371.  
  1372. What seems most confusing is from page 222 of the Icon book:
  1373.  
  1374. record-declaration:
  1375.        record identifier ( field-list )
  1376.  
  1377. where the field-list is subscripted with "opt" (meaning optional).
  1378. The syntax says you can have a declaration like
  1379.  
  1380. record weird()
  1381.  
  1382. and I tried that in a test program and it translated without
  1383. complaint.  But what can you use it for?
  1384.  
  1385. A very puzzled snail,    o       o
  1386.                           \_____/
  1387.                           /-o-o-\     _______
  1388. DDDD      SSSS   CCCC    /   ^   \   /\\\\\\\\
  1389. D   D    S      C        \ \___/ /  /\   ___  \
  1390. D   D     SSS   C         \_   _/  /\   /\\\\  \
  1391. D   D        S  C           \  \__/\   /\ @_/  /
  1392. DDDDavid SSSS.   CCCCargo    \____\____\______/ cargo@tardis.cray.com
  1393.  
  1394. From ralph  Wed Jan 24 15:13:41 1990
  1395. Date: Wed, 24 Jan 90 15:13:41 MST
  1396. From: "Ralph Griswold" <ralph>
  1397. Message-Id: <9001242213.AA21470@megaron.cs.arizona.edu>
  1398. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  1399.     id AA21470; Wed, 24 Jan 90 15:13:41 MST
  1400. To: cargo@tardis.cray.com, icon-group@cs.arizona.edu
  1401. Subject: Re:  questions about records
  1402. In-Reply-To: <9001242131.AA05119@zk.cray.com>
  1403. Status: O
  1404.  
  1405. Yes, you can have the same field name in different records, and the
  1406. positions need not be the same, as in
  1407.  
  1408.     record foo(a,b,c)
  1409.     record baz(c,b,a)
  1410.  
  1411. Icon will handle this properly.
  1412.  
  1413. Also, as you've observed, the "name spaces" for identifiers and field
  1414. names are disjoint, so you can, for example, have a local identifier
  1415. named b and do something like
  1416.  
  1417.     b := foo()
  1418.        .
  1419.        .
  1420.        .
  1421.     b.b := 1
  1422.  
  1423. (Not recommended, of course.)
  1424.  
  1425. And a record need not have any fields, as in
  1426.  
  1427.     record nil()
  1428.  
  1429. Useful if you need objects of an identifiable type, but the objects have
  1430. no attributes.
  1431.  
  1432.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  1433.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  1434.  
  1435. From @um.cc.umich.EDU:Paul_Abrahams@Wayne-MTS  Wed Jan 24 17:17:07 1990
  1436. Resent-From: @um.cc.umich.EDU:Paul_Abrahams@Wayne-MTS
  1437. Received: from maggie.telcom.arizona.edu by megaron (5.59-1.7/15) via SMTP
  1438.     id AA01355; Wed, 24 Jan 90 17:17:07 MST
  1439. Received: from megaron (megaron.cs.arizona.edu) by Arizona.EDU; Wed, 24 Jan 90
  1440.  02:22 MST
  1441. Received: from sharkey.cc.umich.edu by megaron (5.59-1.7/15) via SMTP id
  1442.  AA04923; Wed, 24 Jan 90 02:25:00 MST
  1443. Received: from ummts.cc.umich.edu by sharkey.cc.umich.edu (5.61/1123-1.0) id
  1444.  AA14554; Wed, 24 Jan 90 04:21:59 -0500
  1445. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 24 Jan 90
  1446.  04:23:14 EST
  1447. Resent-Date: Wed, 24 Jan 90 02:23 MST
  1448. Date: Tue, 23 Jan 90 23:55:38 EST
  1449. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.EDU
  1450. Subject: Strings in C
  1451. Resent-To: icon-group@cs.arizona.edu
  1452. To: icon-group@arizona.edu
  1453. Resent-Message-Id: <EC2682F3055F203C1C@Arizona.EDU>
  1454. Message-Id: <195450@Wayne-MTS>
  1455. X-Envelope-To: icon-group@CS.Arizona.EDU
  1456. X-Vms-To: icon-group@arizona.edu
  1457. Status: O
  1458.  
  1459. This forum isn't about C, but anyway---
  1460.  
  1461. The problem with C is not just that it's a high-level machine language--
  1462. it's a high-level machine language for the PDP11.  But even given that,
  1463. the decision to null-terminate strings was a dreadful mistake (see my
  1464. article on the subject in SIGPLAN Notices, Oct 88 I think).
  1465.  
  1466. Paul Abrahams
  1467.  
  1468. From icon-group-request@arizona.edu  Thu Jan 25 11:08:40 1990
  1469. Resent-From: icon-group-request@arizona.edu
  1470. Received: from maggie.telcom.arizona.edu by megaron (5.59-1.7/15) via SMTP
  1471.     id AA27922; Thu, 25 Jan 90 11:08:40 MST
  1472. Received: from megaron (megaron.cs.arizona.edu) by Arizona.EDU; Thu, 25 Jan 90
  1473.  11:03 MST
  1474. Received: from ucbvax.Berkeley.EDU by megaron (5.59-1.7/15) via SMTP id
  1475.  AA27812; Thu, 25 Jan 90 11:06:29 MST
  1476. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA05008; Thu, 25 Jan 90
  1477.  09:55:56 -0800
  1478. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  1479.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  1480.  usenet@ucbvax.Berkeley.EDU if you have questions)
  1481. Resent-Date: Thu, 25 Jan 90 11:04 MST
  1482. Date: 25 Jan 90 06:01:11 GMT
  1483. From: tellab5!wheaton!johnh@uunet.uu.NET
  1484. Subject: installing icon 5.7 on ultrix 3.0
  1485. Sender: icon-group-request@arizona.edu
  1486. Resent-To: icon-group@cs.arizona.edu
  1487. To: icon-group@arizona.edu
  1488. Organization: Wheaton College, Wheaton Il
  1489. Resent-Message-Id: <EB149124BC3F20405B@Arizona.EDU>
  1490. Message-Id: <1786@wheaton.UUCP>
  1491. X-Envelope-To: icon-group@CS.Arizona.EDU
  1492. X-Vms-To: icon-group@arizona.edu
  1493. Status: O
  1494.  
  1495.  
  1496. This may have been discussed before but:
  1497.  
  1498. I have (I think) installed icon 5.7 on ultrix 3.0.  I could not do it
  1499. without using the BSD4.2 sources.  There were three problems.
  1500.  
  1501. 1) Apparently in BSD4.2 a C program allocates a fixed number of slots
  1502.    for files inside of the users area (below &end).  The Icon
  1503.    compiler/translator uses that fact along with setbuf calls to
  1504.    have complete control of memory allocation above &end.
  1505.    Apparently in ultrix 3.0 space for files are allocated at runtime
  1506.    above the &end symbol.  Since the Icon compiler/intepreter assumes
  1507.    that the limit of memory starts at &end the memory initialization
  1508.    routines walk over the file slots.
  1509.    The result is that the distributed (unsupported) binarys will not run on 
  1510.    ultrix 3.0. (In our case compiles and intrepets hits eof immeadiatly).
  1511.    Changes to the sources from BSD4.2 were minmal (3 files - fgrep for brk
  1512.    and &end replace code using sbrk)
  1513.  
  1514. 2) The manual of execve which include a description of "intepreter" files
  1515.    where the first line of a file start with #! intrepeter
  1516.    I could not get to work on ultrix 3.0.  I remember a problem with 
  1517.    pascal pi object files not working with some ultrix releases.  The
  1518.    pi object files on ultrix 3.0 do not use this facility.  There
  1519.    is a reasonable discussion of the issue in doc/install and the solution
  1520.    is to not use the -directex flag when running icon-setup.
  1521.  
  1522. 3) There was seemed to be a small problem in the Makefile for icont.  It
  1523.    refered to a object mon.o.  There is no mon.c but there was a mon.o 
  1524.    file in one of the libraries included in the link step.  I removed
  1525.    the mon.o entry in the Makefile.
  1526.  
  1527.    johnh...
  1528. -- 
  1529. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1530. UUCP: (obdient spl1)!wheaton!johnh           telephone: (312) 260-3871 (office)
  1531. Mail: John Hayward Math/Computer Science Dept. Wheaton College Wheaton Il 60187
  1532.        Act justly, love mercy and walk humbly with your God. Micah 6:8b
  1533.  
  1534. From cargo@tardis.cray.com  Mon Jan 29 14:39:51 1990
  1535. Received: from timbuk.cray.com by megaron (5.59-1.7/15) via SMTP
  1536.     id AA26026; Mon, 29 Jan 90 14:39:51 MST
  1537. Received: from hall.cray.com by timbuk.CRAY.COM (4.1/CRI-1.34)
  1538.     id AA05890; Mon, 29 Jan 90 15:39:40 CST
  1539. Received: from zk.cray.com by hall.cray.com
  1540.     id AA01356; 3.2/CRI-3.12; Mon, 29 Jan 90 15:39:37 CST
  1541. Received: by zk.cray.com
  1542.     id AA00300; 3.2/CRI-3.12; Mon, 29 Jan 90 15:39:34 CST
  1543. Date: Mon, 29 Jan 90 15:39:34 CST
  1544. From: cargo@tardis.cray.com (David S. Cargo)
  1545. Message-Id: <9001292139.AA00300@zk.cray.com>
  1546. To: icon-group@cs.arizona.edu
  1547. Subject: comparing csets
  1548. Status: O
  1549.  
  1550. I got my hardcopy Icon news in the mail and saw my name mentioned.
  1551. I thought I'd furnish an update on the way I eventually solved my
  1552. cset comparison problem.  I eventually started using the following
  1553. procedure:
  1554.  
  1555. procedure overlap(c1, c2)
  1556.     return '' ~=== c1 ** c2
  1557. end
  1558.  
  1559. The main feature that I exploit with this procedure is that when I have
  1560. tracing turned on, I can see the result of the comparison. Approaches
  1561. like
  1562.  
  1563. 0 ~= *(c1 ** c2)
  1564.  
  1565. are probably more efficient (though I haven't checked), but not as
  1566. informative when I'm testing.
  1567.  
  1568.                          o       o
  1569.                           \_____/
  1570.                           /-o-o-\     _______
  1571. DDDD      SSSS   CCCC    /   ^   \   /\\\\\\\\
  1572. D   D    S      C        \ \___/ /  /\   ___  \
  1573. D   D     SSS   C         \_   _/  /\   /\\\\  \
  1574. D   D        S  C           \  \__/\   /\ @_/  /
  1575. DDDDavid SSSS.   CCCCargo    \____\____\______/ cargo@tardis.cray.com
  1576.  
  1577. From cargo@tardis.cray.com  Thu Feb  1 13:52:05 1990
  1578. Received: from timbuk.cray.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  1579.     id AA17936; Thu, 1 Feb 90 13:52:05 MST
  1580. Received: from hall.cray.com by timbuk.CRAY.COM (4.1/CRI-1.34)
  1581.     id AA12869; Thu, 1 Feb 90 14:52:00 CST
  1582. Received: from zk.cray.com by hall.cray.com
  1583.     id AA10468; 3.2/CRI-3.12; Thu, 1 Feb 90 14:51:57 CST
  1584. Received: by zk.cray.com
  1585.     id AA03270; 3.2/CRI-3.12; Thu, 1 Feb 90 14:52:14 CST
  1586. Date: Thu, 1 Feb 90 14:52:14 CST
  1587. From: cargo@tardis.cray.com (David S. Cargo)
  1588. Message-Id: <9002012052.AA03270@zk.cray.com>
  1589. To: icon-group@cs.arizona.edu
  1590. Subject: table initialization
  1591. Status: O
  1592.  
  1593. I was looking at implementing some Icon code to initialize font width
  1594. tables.  Naturally I thought about using tables to do this.  I then
  1595. realized that while most other structures can be initialized with
  1596. constants, there doesn't seem to be a convenient way to do this with
  1597. tables.  Or is there something I'm missing.
  1598.  
  1599. What I will probably wind up doing is either using lists indexed by
  1600. character values (using ord(s)) or using two constant lists to
  1601. initialize a table, char_val and char_width are the two lists:
  1602.  
  1603. every i := 1 to n do width[char_val[i]] := char_width[i]
  1604.  
  1605. Eventually I'll probably want to know which is faster to use, a
  1606. character width table or and array indexed using ord(s))
  1607.  
  1608. string_width := 0 # for either case
  1609. every string_width +:= char_width[ord(!s)] # for a list
  1610. every string_width +:= char_width[!s] # for a table
  1611.  
  1612. It would seem to be a trade between ease of access and creation
  1613. of temporaries.
  1614.  
  1615. Has anybody tried anything like this already and found an answer
  1616. to which is better speed-wise?
  1617.  
  1618. From wgg@cs.washington.edu  Thu Feb  1 15:27:59 1990
  1619. Received: from june.cs.washington.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  1620.     id AA27918; Thu, 1 Feb 90 15:27:59 MST
  1621. Received: by june.cs.washington.edu (5.61/7.0jh)
  1622.     id AA27239; Thu, 1 Feb 90 14:26:50 -0800
  1623. Date: Thu, 1 Feb 90 14:26:50 -0800
  1624. From: wgg@cs.washington.edu (William Griswold)
  1625. Return-Path: <wgg@cs.washington.edu>
  1626. Message-Id: <9002012226.AA27239@june.cs.washington.edu>
  1627. To: cargo@tardis.cray.com, icon-group@cs.arizona.edu
  1628. Subject: Re:  table initialization
  1629. Status: O
  1630.  
  1631. >From: cargo@tardis.cray.com (David S. Cargo)
  1632. >To: icon-group@cs.arizona.edu
  1633. >Subject: table initialization
  1634. >
  1635. >I was looking at implementing some Icon code to initialize font width
  1636. >tables.  Naturally I thought about using tables to do this.  I then
  1637. >realized that while most other structures can be initialized with
  1638. >constants, there doesn't seem to be a convenient way to do this with
  1639. >tables.  Or is there something I'm missing.
  1640. >
  1641. >What I will probably wind up doing is either using lists indexed by
  1642. >character values (using ord(s)) or using two constant lists to
  1643. >initialize a table, char_val and char_width are the two lists:
  1644. >
  1645. >every i := 1 to n do width[char_val[i]] := char_width[i]
  1646. >
  1647. >Eventually I'll probably want to know which is faster to use, a
  1648. >character width table or and array indexed using ord(s))
  1649. >
  1650. >string_width := 0 # for either case
  1651. >every string_width +:= char_width[ord(!s)] # for a list
  1652. >every string_width +:= char_width[!s] # for a table
  1653. >
  1654. >It would seem to be a trade between ease of access and creation
  1655. >of temporaries.
  1656. >
  1657. >Has anybody tried anything like this already and found an answer
  1658. >to which is better speed-wise?
  1659. >
  1660.  
  1661. You might want to think about storing your character set and font widths
  1662. in an external file, so that if the values (i.e., font) change, you won't
  1663. have to change your program.  Then the code for tables vs. lists is not
  1664. so different:
  1665.  
  1666. Your input:
  1667.  
  1668. a    5
  1669. b    5
  1670. ...
  1671. m       8
  1672. ...
  1673. z       6
  1674.  
  1675. the processing code:
  1676.  
  1677. # e.g., for tables
  1678. table := width()
  1679. while line := read(font-file) do 
  1680.     line ? width[move(1)] := integer((tab(many(' \t')) & tab(0)))
  1681.  
  1682.  
  1683. As for performance, there are several things you can try.  It is likely
  1684. that the ord(s) function will be faster, since the hashing and chaining
  1685. used to implement tables will be avoided.
  1686.  
  1687. If you want to hide which type you are using, use a procedure.  Procedure
  1688. call is pretty cheap, so you don't have to worry much about the cost: 
  1689.  
  1690. # for tables
  1691. procedure width(char)
  1692. static width-table
  1693. initial width-table := table()
  1694.  
  1695.     return width-table[char]
  1696. end
  1697.  
  1698.  
  1699. # for lists
  1700. procedure width(char)
  1701. static width-list
  1702. initial width-list := list(256)
  1703.  
  1704.     return width-list[ord(char)]
  1705. end
  1706.  
  1707. Note that since I didn't dereference the return variable, they can be
  1708. assigned to by the input function:
  1709.  
  1710.     while line := read(font-file) do 
  1711.     line ? width(move(1)) := integer((tab(many(' \t')) & tab(0)))
  1712.  
  1713. Thus even the font width reader doesn't need to know the representation
  1714. you are using.
  1715.  
  1716. One thing that just occurred to me is that with the table representation
  1717. (or some hybrid enscapsulated in a procedure) you could look-up word
  1718. widths as well as character widths, probably at little extra effort (say,
  1719. if you stored the widths of the 2000 most commonly used words) and some
  1720. performance benefit.  You could even use a history scheme, in which you
  1721. remember the widths of words already computed in the current document.  It 
  1722. seems like overkill, but it gives you some idea of the flexibility of Icon. 
  1723.  
  1724.                     Bill Griswold
  1725.  
  1726.  
  1727. From cargo@tardis.cray.com  Thu Feb  1 15:47:09 1990
  1728. Received: from timbuk.cray.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  1729.     id AA29364; Thu, 1 Feb 90 15:47:09 MST
  1730. Received: from hall.cray.com by timbuk.CRAY.COM (4.1/CRI-1.34)
  1731.     id AA14604; Thu, 1 Feb 90 16:47:02 CST
  1732. Received: from zk.cray.com by hall.cray.com
  1733.     id AA12124; 3.2/CRI-3.12; Thu, 1 Feb 90 16:46:59 CST
  1734. Received: by zk.cray.com
  1735.     id AA03421; 3.2/CRI-3.12; Thu, 1 Feb 90 16:47:18 CST
  1736. Date: Thu, 1 Feb 90 16:47:18 CST
  1737. From: cargo@tardis.cray.com (David S. Cargo)
  1738. Message-Id: <9002012247.AA03421@zk.cray.com>
  1739. To: icon-group@cs.arizona.edu
  1740. Subject: Re:  table initialization
  1741. Status: O
  1742.  
  1743. "You might want to think about storing your character set and font widths
  1744. in an external file, so that if the values (i.e., font) change, you won't
  1745. have to change your program."
  1746.  
  1747. As a matter of fact, I will start by reading the Adobe Font Metrics file
  1748. to get the initial values.  I could either use them directly, or have
  1749. the program write initialization code to be used by another program.
  1750. It's a matter of early or late binding in effect.  If you think that
  1751. ord(s) is fast relative to hashing, I'll probably go that way.
  1752.  
  1753. david snail
  1754.  
  1755. From @mirsa.inria.fr:ol@cerisi.cerisi.Fr  Mon Feb  5 13:28:51 1990
  1756. Received: from mirsa.inria.fr by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  1757.     id AA02205; Mon, 5 Feb 90 13:28:51 MST
  1758. Received: from cerisi.cerisi.fr by mirsa.inria.fr with SMTP
  1759.     (5.59++/IDA-1.2.8) id AA23439; Mon, 5 Feb 90 21:26:06 +0100
  1760. Message-Id: <9002052026.AA23439@mirsa.inria.fr>
  1761. Date: Mon, 5 Feb 90 21:26:48 -0100
  1762. Posted-Date: Mon, 5 Feb 90 21:26:48 -0100
  1763. From: Lecarme Olivier <ol@cerisi.cerisi.Fr>
  1764. To: icon-group@cs.arizona.edu
  1765. Subject: Icon on RISC machines
  1766. Status: O
  1767.  
  1768. Our laboratory and computing center are just buying brand new RISC
  1769. machines made by DEC (or more precisely, sold by DEC). On these
  1770. machines, Unix or something like this is supposed to work, but most
  1771. programming languages have been forgotten: after all, C is enough for
  1772. everything, or is it not enough after all? Thus, I'm missing Pascal,
  1773. Modula-2... and Icon!
  1774.  
  1775. Being naturally optimistic, I tried to pretend to the Icon installation
  1776. that this machine is in fact a Vax with Ultrix. Something went wrong
  1777. during "make Icon", in program rlocal.c of src/iconx. I could try to
  1778. figure what happened, but it's somewhat late for working, and I
  1779. preferred to ask the Icon community whether anybody has already made the
  1780. job. Maybe I made a mistake when copying the whole Icon distribution, or
  1781. maybe something more serious is happening.
  1782.  
  1783. Can anybody help me?
  1784.  
  1785.  
  1786.                 Olivier Lecarme
  1787.  
  1788. From cargo@tardis.cray.com  Wed Feb  7 08:58:08 1990
  1789. Received: from timbuk.cray.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  1790.     id AA11797; Wed, 7 Feb 90 08:58:08 MST
  1791. Received: from hall.cray.com by timbuk.CRAY.COM (4.1/CRI-1.34)
  1792.     id AA09246; Wed, 7 Feb 90 09:57:51 CST
  1793. Received: from zk.cray.com by hall.cray.com
  1794.     id AA29474; 3.2/CRI-3.12; Wed, 7 Feb 90 09:57:48 CST
  1795. Received: by zk.cray.com
  1796.     id AA01397; 3.2/CRI-3.12; Wed, 7 Feb 90 09:57:47 CST
  1797. Date: Wed, 7 Feb 90 09:57:47 CST
  1798. From: cargo@tardis.cray.com (David S. Cargo)
  1799. Message-Id: <9002071557.AA01397@zk.cray.com>
  1800. To: icon-group@cs.arizona.edu
  1801. Subject: generation of procedures
  1802. Status: O
  1803.  
  1804. I was looking at the code for RSG (part of the Icon Program Library),
  1805. noticing how one part of the code takes advantage of the order of a
  1806. list of procedure variables to successively try evaluating a line of
  1807. input until one of the procedures succeeds.   My first reaction was
  1808. that this reminded me of searching an object hierarchy looking for a
  1809. handler for a particular type of message.  If a particular object
  1810. can't handle the message, it fails and lets the object next higher
  1811. in the hierarchy have a crack at it.  It sort of reminded me of
  1812. message passing, but with a distinctively Icon flavor to it.
  1813.  
  1814. My real question is that I can't figure out how to decide what the
  1815. symantics of the operation really are.  Normally I would expect to
  1816. say the !plist comes as element generation, which should succeed
  1817. when the first element is generated.  But then it is followed by
  1818. a parameter list and surrounded by parentheses.  This seems to
  1819. combine to make it an alternation expression equivelent to:
  1820.  
  1821.    (define | generate | grammar | source | comment | prompter | error)(line)
  1822.  
  1823.  
  1824.    plist := [define,generate,grammar,source,comment,prompter,error]
  1825.    :
  1826.    :
  1827.    while in := pop(ifile) do {        # process all files
  1828.       repeat {
  1829.          writes(\prompt)
  1830.          line := read(in) | break
  1831.          while line[-1] == "\\" do line := line[1:-1] || read(in) | break
  1832.          (!plist)(line)
  1833. # the line above is the interesting one!
  1834.          }
  1835.       close(in)
  1836.       }
  1837.  
  1838.  
  1839. I can't seem to find anything in the Icon book that spells out what is really
  1840. happening here.  It looked at first like !plist wasn't in a context that required
  1841. generation of all the list elements, but clearly that is not the case.
  1842.  
  1843. The confused snail,      o       o
  1844.                           \_____/
  1845.                           /-o-o-\     _______
  1846. DDDD      SSSS   CCCC    /   ^   \   /\\\\\\\\
  1847. D   D    S      C        \ \___/ /  /\   ___  \
  1848. D   D     SSS   C         \_   _/  /\   /\\\\  \
  1849. D   D        S  C           \  \__/\   /\ @_/  /
  1850. DDDDavid SSSS.   CCCCargo    \____\____\______/ cargo@tardis.cray.com
  1851.  
  1852. From ralph  Wed Feb  7 09:11:17 1990
  1853. Date: Wed, 7 Feb 90 09:11:17 MST
  1854. From: "Ralph Griswold" <ralph>
  1855. Message-Id: <9002071611.AA13262@megaron.cs.arizona.edu>
  1856. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  1857.     id AA13262; Wed, 7 Feb 90 09:11:17 MST
  1858. To: cargo@tardis.cray.com, icon-group@cs.arizona.edu
  1859. Subject: Re:  generation of procedures
  1860. In-Reply-To: <9002071557.AA01397@zk.cray.com>
  1861. Status: O
  1862.  
  1863. The procedures are generated by !plist as you surmised.  The first one
  1864. is then applied to the argument list, resulting in a procedure call.
  1865. If that call fails, !plist is resumed to produce another procedure.
  1866.  
  1867. Think of a procedure call as
  1868.  
  1869.     e0(e1, e2, ..., en)
  1870.  
  1871. The order of evaluation is e0, e1, e2, ..., en.  If all succeed, the value of e0
  1872. is applied to the values of e1, e2, ..., en. If the resulting procedure call
  1873. fails, en, ..., e2, e1, e0 are resumed in that order (assuming they suspended).
  1874. If any produces a new result, evaluation starts to the right again. In the
  1875. case you cite, only e0 is a generator, so failure of the procedure call
  1876. causes e0 to produce another procedure, which is then applied to the
  1877. arguments.  If any of the procedure calls fails, the process stops, since
  1878. there is nothing to drive further generation.  The effect is to apply the
  1879. procedures in plist until one succeeds.
  1880.  
  1881.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  1882.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  1883.  
  1884. From wgg@cs.washington.edu  Wed Feb  7 09:50:43 1990
  1885. Received: from june.cs.washington.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  1886.     id AA17139; Wed, 7 Feb 90 09:50:43 MST
  1887. Received: by june.cs.washington.edu (5.61/7.0jh)
  1888.     id AA00868; Wed, 7 Feb 90 08:49:37 -0800
  1889. Date: Wed, 7 Feb 90 08:49:37 -0800
  1890. From: wgg@cs.washington.edu (William Griswold)
  1891. Return-Path: <wgg@cs.washington.edu>
  1892. Message-Id: <9002071649.AA00868@june.cs.washington.edu>
  1893. To: cargo@tardis.cray.com, icon-group@cs.arizona.edu
  1894. Subject: Re:  generation of procedures
  1895. Status: O
  1896.  
  1897. >Date: Wed, 7 Feb 90 09:57:47 CST
  1898. >From: cargo@tardis.cray.com (David S. Cargo)
  1899. >To: icon-group@cs.arizona.edu
  1900. >Subject: generation of procedures
  1901. >Errors-To: icon-group-errors@cs.arizona.edu
  1902. >
  1903. >I was looking at the code for RSG (part of the Icon Program Library),
  1904. >noticing how one part of the code takes advantage of the order of a
  1905. >list of procedure variables to successively try evaluating a line of
  1906. >input until one of the procedures succeeds.   My first reaction was
  1907. >that this reminded me of searching an object hierarchy looking for a
  1908. >handler for a particular type of message.  If a particular object
  1909. >can't handle the message, it fails and lets the object next higher
  1910. >in the hierarchy have a crack at it.  It sort of reminded me of
  1911. >message passing, but with a distinctively Icon flavor to it.
  1912. >
  1913.  
  1914.   I like your analogy to searching for a handler in an object hierarchy--
  1915.   it looks a lot like delegation.  I'll think about this one some more.
  1916.   Perhaps one could use PDCOs or a Variant Translator to make such a
  1917.   scheme syntactically papable.
  1918.  
  1919. >My real question is that I can't figure out how to decide what the
  1920. >symantics of the operation really are.  Normally I would expect to
  1921. >say the !plist comes as element generation, which should succeed
  1922. >when the first element is generated.  But then it is followed by
  1923. >a parameter list and surrounded by parentheses.  This seems to
  1924. >combine to make it an alternation expression equivelent to:
  1925. >
  1926. >   (define | generate | grammar | source | comment | prompter | error)(line)
  1927. >
  1928. >
  1929. >   plist := [define,generate,grammar,source,comment,prompter,error]
  1930. >   :
  1931. >   :
  1932. >   while in := pop(ifile) do {        # process all files
  1933. >      repeat {
  1934. >         writes(\prompt)
  1935. >         line := read(in) | break
  1936. >         while line[-1] == "\\" do line := line[1:-1] || read(in) | break
  1937. >         (!plist)(line)
  1938. ># the line above is the interesting one!
  1939. >         }
  1940. >      close(in)
  1941. >      }
  1942. >
  1943. >
  1944. >I can't seem to find anything in the Icon book that spells out what is really
  1945. >happening here.  It looked at first like !plist wasn't in a context that required
  1946. >generation of all the list elements, but clearly that is not the case.
  1947. >
  1948.  
  1949.  
  1950.   Element generation in normal expression context evaluates the expression 
  1951.   in an attempt to produce a single result.  So this code will try list
  1952.   elements until one invocation succeeds.  Thus error(line) gets executed
  1953.   only if none of the other alternatives succeed.  It is trying to parse the 
  1954.   line, using each of the parsing procedures as a possible syntactic 
  1955.   alternative.  As is usual with parsing, you want only one result, and in
  1956.   this case we take the first one that comes, assuming that it is preferred
  1957.   or unique.
  1958.  
  1959.  
  1960.                     Bill Griswold
  1961.  
  1962.  
  1963. From icon-group-request@arizona.edu  Thu Feb  8 09:53:28 1990
  1964. Resent-From: icon-group-request@arizona.edu
  1965. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  1966.     id AA13028; Thu, 8 Feb 90 09:53:28 MST
  1967. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 8 Feb 90 09:53 MST
  1968. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA06835; Thu, 8 Feb 90 08:47:22
  1969.  -0800
  1970. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  1971.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  1972.  usenet@ucbvax.Berkeley.EDU if you have questions)
  1973. Resent-Date: Thu, 8 Feb 90 09:55 MST
  1974. Date: 8 Feb 90 16:43:27 GMT
  1975. From: tank!iitmax!chien@handies.ucar.EDU
  1976. Subject: icon source wanted
  1977. Sender: icon-group-request@arizona.edu
  1978. Resent-To: icon-group@cs.arizona.edu
  1979. To: icon-group@arizona.edu
  1980. Resent-Message-Id: <E01DF8A10AFF401F39@Arizona.EDU>
  1981. Message-Id: <3348@iitmax.IIT.EDU>
  1982. Organization: Illinois Institute of Technology, Chicago
  1983. X-Envelope-To: icon-group@CS.Arizona.EDU
  1984. X-Vms-To: icon-group@Arizona.edu
  1985. Status: O
  1986.  
  1987. Is icon source for UN*X machines available for ftp?  Thanks for the info.
  1988.  
  1989. Greg Chien
  1990. Manager, Design Processes Laboratory
  1991. Institute of Design
  1992. Illinois Institute of Technology
  1993. Internet: chien@iitmax.iit.edu
  1994.  
  1995. From icon-group-request@arizona.edu  Mon Feb 12 23:42:25 1990
  1996. Resent-From: icon-group-request@arizona.edu
  1997. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  1998.     id AA14475; Mon, 12 Feb 90 23:42:25 MST
  1999. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Mon, 12 Feb 90 23:40 MST
  2000. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA12563; Mon, 12 Feb 90
  2001.  22:23:00 -0800
  2002. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2003.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2004.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2005. Resent-Date: Mon, 12 Feb 90 23:42 MST
  2006. Date: 12 Feb 90 14:42:17 GMT
  2007. From: van-bc!ubc-cs!alberta!myrias!dragos!wally@ucbvax.Berkeley.EDU
  2008. Subject: compiler, compiler, where art thou?
  2009. Sender: icon-group-request@arizona.edu
  2010. Resent-To: icon-group@cs.arizona.edu
  2011. To: icon-group@arizona.edu
  2012. Resent-Message-Id: <DC85C6C540FFC01060@Arizona.EDU>
  2013. Message-Id: <1990Feb12.144217.17097@dragos.uucp>
  2014. Organization: Orbital Mind Control Lasers, Inc.
  2015. X-Envelope-To: icon-group@CS.Arizona.EDU
  2016. X-Vms-To: icon-group@Arizona.edu
  2017. Status: O
  2018.  
  2019.  
  2020.  
  2021.    So, the question of the day is:
  2022.  
  2023.    Where does one find a compiler for our wonderful Icon that runs
  2024.  on the Atari ST? 
  2025.  
  2026.   We`ve found icont, and iconx, but is there to be found an iconc?
  2027.  
  2028.  
  2029. -- 
  2030.   O o          Wallace Harshaw
  2031.  (   )         somewhere around here...
  2032.  "] ["   <you don't have to understand it, just look at it...>
  2033.  
  2034. From goer@sophist.uchicago.EDU  Tue Feb 13 01:31:14 1990
  2035. Resent-From: goer@sophist.uchicago.EDU
  2036. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2037.     id AA18977; Tue, 13 Feb 90 01:31:14 MST
  2038. Return-Path: goer@sophist.uchicago.EDU
  2039. Received: from tank.uchicago.edu by Arizona.EDU; Tue, 13 Feb 90 01:30 MST
  2040. Received: from sophist.uchicago.edu by tank.uchicago.edu Tue, 13 Feb 90
  2041.  02:28:40 CST
  2042. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA29016; Tue, 13 Feb 90
  2043.  02:24:10 CST
  2044. Resent-Date: Tue, 13 Feb 90 01:32 MST
  2045. Date: Tue, 13 Feb 90 02:24:10 CST
  2046. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  2047. Subject: compiler, compiler
  2048. Resent-To: icon-group@cs.arizona.edu
  2049. To: icon-group@arizona.edu
  2050. Resent-Message-Id: <DC7674F83C5FC010CA@Arizona.EDU>
  2051. Message-Id: <9002130824.AA29016@sophist.uchicago.edu>
  2052. X-Envelope-To: icon-group@CS.Arizona.EDU
  2053. X-Vms-To: icon-group@Arizona.edu
  2054. Status: O
  2055.  
  2056.       We`ve found icont, and iconx, but is there to be found an iconc?
  2057.  
  2058. Just about everyone would like to see a compiler, but it's a whole dif-
  2059. ferent ball game than an interpreter.  The most recent Icon newsletter
  2060. mentioned that research in this are was going on.  With all the work the
  2061. icon-project members put in right now, though, it might not be fitting
  2062. for us to press them on this subject.
  2063.  
  2064. The "Icon book," as everyone affectionately calls it, speaks of a com-
  2065. piler (version 5 is it?).  Compilers haven't been implemented since
  2066. then, though you can save an image of the executing program under Unix,
  2067. chmod it so that it is an executable file, and then pretend it is a
  2068. compiled program.  You're working on an Atari, though, so you're out
  2069. of luck.  Sorry.
  2070.  
  2071.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  2072.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  2073.  
  2074. From icon-group-request@arizona.edu  Tue Feb 13 02:54:27 1990
  2075. Resent-From: icon-group-request@arizona.edu
  2076. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2077.     id AA21988; Tue, 13 Feb 90 02:54:27 MST
  2078. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 13 Feb 90 02:55 MST
  2079. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA25510; Tue, 13 Feb 90
  2080.  01:46:31 -0800
  2081. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2082.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2083.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2084. Resent-Date: Tue, 13 Feb 90 02:55 MST
  2085. Date: 13 Feb 90 04:32:21 GMT
  2086. From: ssbell!mcmi!unocss!dent@uunet.uu.NET
  2087. Subject: Anyone using Idol..?
  2088. Sender: icon-group-request@arizona.edu
  2089. Resent-To: icon-group@cs.arizona.edu
  2090. To: icon-group@arizona.edu
  2091. Resent-Message-Id: <DC6AD3378C5FC00B17@Arizona.EDU>
  2092. Message-Id: <1996@unocss..unl.edu>
  2093. Organization: U. of Nebraska at Omaha
  2094. X-Envelope-To: icon-group@CS.Arizona.EDU
  2095. X-Vms-To: icon-group@Arizona.edu
  2096. Status: O
  2097.  
  2098. Is anyone out there using Idol for anything?  I've got it running in tandem
  2099. with Icon 7.5 on a UNIX (DYNIX really) machine here, and I think it's very
  2100. interesting, but I have no background in "object orientedness" at all, so
  2101. I was curious to see if there were some slightly more complex examples of
  2102. Idol use around.
  2103.  
  2104. Thanks for any pointers you might want to give.. :-)
  2105.  
  2106. -/ Dave Caplinger /---------------------------------------------------------
  2107.  Microcomputer Specialist,   Campus Computing,   Univ. of Nebraska at Omaha
  2108.  dent@zeus.unl.edu         ...!uunet!unocss!dent                DENT@UNOMA1
  2109.  
  2110. From ralph  Tue Feb 13 06:27:50 1990
  2111. Date: Tue, 13 Feb 90 06:27:50 MST
  2112. From: "Ralph Griswold" <ralph>
  2113. Message-Id: <9002131327.AA00802@megaron.cs.arizona.edu>
  2114. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  2115.     id AA00802; Tue, 13 Feb 90 06:27:50 MST
  2116. To: van-bc!ubc-cs!alberta!myrias!dragos!wally@ucbvax.Berkeley.EDU
  2117. Subject: Re:  compiler, compiler, where art thou?
  2118. Cc: icon-group
  2119. In-Reply-To: <1990Feb12.144217.17097@dragos.uucp>
  2120. Status: O
  2121.  
  2122. The so-called Icon compiler, iconc, has not been supported for any
  2123. version of Icon for many years, and there never hsa been one for the
  2124. Atari ST.
  2125.  
  2126. The term compiler in this context is somewhat misleading.  The iconc
  2127. you refer to compiled Icon mostly into subroutine calls and was only
  2128. 5-10% faster than the interpreter.  Granted there are other advantages
  2129. to iconc, like being able to link C functions.
  2130.  
  2131. However, iconc was not portable and we did not have the resources to
  2132. maintain it as a separate program.
  2133.  
  2134.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  2135.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  2136.  
  2137. From icon-group-request@arizona.edu  Wed Feb 14 22:53:35 1990
  2138. Resent-From: icon-group-request@arizona.edu
  2139. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2140.     id AA26458; Wed, 14 Feb 90 22:53:35 MST
  2141. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 14 Feb 90 22:48 MST
  2142. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA00866; Wed, 14 Feb 90
  2143.  21:36:58 -0800
  2144. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  2145.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  2146.  usenet@ucbvax.Berkeley.EDU if you have questions)
  2147. Resent-Date: Wed, 14 Feb 90 22:54 MST
  2148. Date: 14 Feb 90 21:06:57 GMT
  2149. From: esquire!yost@nyu.EDU
  2150. Subject: a reads() bug
  2151. Sender: icon-group-request@arizona.edu
  2152. Resent-To: icon-group@cs.arizona.edu
  2153. To: icon-group@arizona.edu
  2154. Resent-Message-Id: <DAFA10C2BD5FC01C2F@Arizona.EDU>
  2155. Message-Id: <1785@esquire.UUCP>
  2156. Organization: DP&W, New York, NY
  2157. X-Envelope-To: icon-group@CS.Arizona.EDU
  2158. X-Vms-To: icon-group@Arizona.edu
  2159. Status: O
  2160.  
  2161. #!/bin/sh
  2162.  
  2163. # Demonstrate Icon reads() bug on Sun4
  2164. # Reading more characters than available on a pipe can cause trouble
  2165. # Don't know if it is a system bug or an Icon bug
  2166. # May also be a problem if reading from a device.
  2167. # Works OK on the Pyramid
  2168. # Icon version 7.5
  2169. # Moral of the story, reads(,4096) at a time, max
  2170.  
  2171. # 2/14/90 Dave Yost, DP&W <yost@DPW.COM>
  2172.  
  2173. pipebufsize=4096
  2174. just_big_enough_for_trouble1=`expr $pipebufsize + 1`
  2175. just_big_enough_for_trouble2=`expr $pipebufsize + 1`
  2176.  
  2177. tmp=xxx
  2178. bigfile=/etc/termcap
  2179.  
  2180. dd ibs=$just_big_enough_for_trouble1 count=1 < $bigfile > $tmp
  2181.  
  2182. cat << END > pipebug.icn
  2183.  
  2184. procedure
  2185. main (args)
  2186.     while writes(reads(&input, $just_big_enough_for_trouble2))
  2187.     return
  2188. end
  2189.  
  2190. END
  2191.  
  2192. icont pipebug.icn
  2193.  
  2194. echo ">> Both of these commands should succeed, but for the bug
  2195. "
  2196. echo ">> ./pipebug < $tmp | cmp - $tmp"
  2197.      ./pipebug < $tmp | cmp - $tmp
  2198.  
  2199. echo ">> cat $tmp | ./pipebug | cmp - $tmp"
  2200.      cat $tmp | ./pipebug | cmp - $tmp
  2201.  
  2202. rm -f pipebug.icn $tmp
  2203.  
  2204. ality of the underlying UNIX system call.
  2205.  
  2206.  --dave yost
  2207.    yost@dpw.com or uunet!esquire!yost
  2208.  
  2209. From kelvin@astro.cs.iastate.EDU  Thu Feb 15 08:31:44 1990
  2210. Resent-From: kelvin@astro.cs.iastate.EDU
  2211. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2212.     id AA20024; Thu, 15 Feb 90 08:31:44 MST
  2213. Received: from megaron.cs.arizona.edu by Arizona.EDU; Thu, 15 Feb 90 08:31 MST
  2214. Received: from atanasoff.cs.iastate.edu by megaron.cs.arizona.edu (5.59-1.7/15)
  2215.  via SMTP id AA19794; Thu, 15 Feb 90 08:28:47 MST
  2216. Received: from astro.cs.iastate.edu by atanasoff (99.99) id AA10782; Thu, 15
  2217.  Feb 90 09:26:21 -0600
  2218. Received: by astro.cs.iastate.edu (3.24) id AA28956; Thu, 15 Feb 90 09:27:11 CST
  2219. Resent-Date: Thu, 15 Feb 90 08:33 MST
  2220. Date: Thu, 15 Feb 90 09:27:11 CST
  2221. From: kelvin@astro.cs.iastate.EDU
  2222. Subject: reads() considered weak
  2223. Resent-To: icon-group@cs.arizona.edu
  2224. To: esquire!yost@nyu.EDU
  2225. Cc: icon-group@arizona.edu
  2226. Resent-Message-Id: <DAA94B00E15FC02730@Arizona.EDU>
  2227. Message-Id: <9002151527.AA28956@astro.cs.iastate.edu>
  2228. In-Reply-To: esquire!yost@nyu.EDU's message of 14 Feb 90 22:00:14 GMT
  2229.  <1786@esquire.UUCP>
  2230. X-Envelope-To: icon-group@CS.Arizona.EDU
  2231. X-Vms-To: esquire!yost@nyu.EDU
  2232. X-Vms-Cc: icon-group@Arizona.edu
  2233. Status: O
  2234.  
  2235.  
  2236. you might want to look at:
  2237.  
  2238.   A Stream Data Type that Supports Goal-Directed Pattern Matching on 
  2239.     Unbounded Sequences of Values, in Computer Languages, Vol. 15, No. 1
  2240.     (jan 1990) by Kelvin Nilsen
  2241.  
  2242. this describes one proposed solution to the sort of problems you mentioned.
  2243.  
  2244. unfortunately, i haven't yet gathered enough external funding and/or 
  2245.  academic rank to spend much time on development and distribution of
  2246.  my real-time derivative of Icon, Conicon.
  2247.  
  2248.  
  2249. Kelvin Nilsen/Dept. of Computer Science/Iowa State University/Ames, IA  50011 
  2250.  (515) 294-2259   kelvin@atanasoff.cs.iastate.edu  uunet!atanasoff!kelvin
  2251.  
  2252.  
  2253. From goer@sophist.uchicago.EDU  Thu Feb 15 09:47:27 1990
  2254. Resent-From: goer@sophist.uchicago.EDU
  2255. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2256.     id AA27427; Thu, 15 Feb 90 09:47:27 MST
  2257. Return-Path: goer@sophist.uchicago.EDU
  2258. Received: from tank.uchicago.edu by Arizona.EDU; Thu, 15 Feb 90 09:45 MST
  2259. Received: from sophist.uchicago.edu by tank.uchicago.edu Thu, 15 Feb 90
  2260.  10:44:22 CST
  2261. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA01848; Thu, 15 Feb 90
  2262.  10:39:46 CST
  2263. Resent-Date: Thu, 15 Feb 90 09:49 MST
  2264. Date: Thu, 15 Feb 90 10:39:46 CST
  2265. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  2266. Subject: Conicon - What?!!
  2267. Resent-To: icon-group@cs.arizona.edu
  2268. To: icon-group@arizona.edu
  2269. Resent-Message-Id: <DA9EA6FE623FC026D5@Arizona.EDU>
  2270. Message-Id: <9002151639.AA01848@sophist.uchicago.edu>
  2271. X-Envelope-To: icon-group@CS.Arizona.EDU
  2272. X-Vms-To: icon-group@Arizona.edu
  2273. Status: O
  2274.  
  2275. > unfortunately, i haven't yet gathered enough external funding and/or 
  2276. > academic rank to spend much time on development and distribution of
  2277. > my real-time derivative of Icon, Conicon.
  2278.                                     ^^^^^
  2279.  
  2280. Did you really think you could toss this one off without being asked
  2281. for more information? :-)  What is Conicon?
  2282.  
  2283.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  2284.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  2285.  
  2286. From kelvin@astro.cs.iastate.EDU  Thu Feb 15 13:15:02 1990
  2287. Resent-From: kelvin@astro.cs.iastate.EDU
  2288. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2289.     id AA14373; Thu, 15 Feb 90 13:15:02 MST
  2290. Received: from megaron.cs.arizona.edu by Arizona.EDU; Thu, 15 Feb 90 13:09 MST
  2291. Received: from atanasoff.cs.iastate.edu by megaron.cs.arizona.edu (5.59-1.7/15)
  2292.  via SMTP id AA13788; Thu, 15 Feb 90 13:06:45 MST
  2293. Received: from astro.cs.iastate.edu by atanasoff (99.99) id AA15938; Thu, 15
  2294.  Feb 90 14:04:15 -0600
  2295. Received: by astro.cs.iastate.edu (3.24) id AA29215; Thu, 15 Feb 90 14:05:04 CST
  2296. Resent-Date: Thu, 15 Feb 90 13:14 MST
  2297. Date: Thu, 15 Feb 90 14:05:04 CST
  2298. From: kelvin@astro.cs.iastate.EDU
  2299. Subject: Conicon - What?!!
  2300. Resent-To: icon-group@cs.arizona.edu
  2301. To: goer@sophist.uchicago.EDU
  2302. Cc: icon-group@arizona.edu
  2303. Resent-Message-Id: <DA81EBA7C51FC029B3@Arizona.EDU>
  2304. Message-Id: <9002152005.AA29215@astro.cs.iastate.edu>
  2305. In-Reply-To: Richard Goerwitz's message of Thu, 15 Feb 90 10:39:46 CST
  2306.  <9002151639.AA01848@sophist.uchicago.edu>
  2307. X-Envelope-To: icon-group@CS.Arizona.EDU
  2308. X-Vms-To: goer@sophist.uchicago.EDU
  2309. X-Vms-Cc: icon-group@Arizona.edu
  2310. Status: O
  2311.  
  2312.  
  2313. Conicon is a contraction for concurrent Icon.  Conicon is designed to
  2314.  provide the high-level power of Icon to real-time programmers.  The
  2315.  implementation of Conicon differs somewhat from that of Icon.  In particular,
  2316.  we use a special real-time garbage collection algorithm designed in part
  2317.  by me, and a different virtual machine encoding which allows real-time
  2318.  response to interrupts (certain machine instructions in Icon's virtual
  2319.  machine represent potentially unbounded amounts of computation.  Since
  2320.  it is not possible to switch contexts in the middle of executing a particular
  2321.  instruction, the worst-case time required to execute a virtual machine
  2322.  instruction represents a lower bound on the time required to respond to
  2323.  a high-priority interrupt.)
  2324.  
  2325. Also, Conicon provides several new (and different) programming paradigms:
  2326.  
  2327.   1) The stream data type represents an unbounded sequence of values.
  2328.      Generally, you can treat this like a pipe from a concurrent process,
  2329.      or as an I/O connection to the outside world (to A/D converters,
  2330.      keyboards, terminals, modems, etc...).  In Conicon, string scanning
  2331.      is replaced with stream scanning.  The integration is, I think, fairly
  2332.      clean and natural.  Streams are described more thoroughly in the
  2333.      paper mentioned in my earlier mail:
  2334.  
  2335.         A Stream Data Type that Supports Goal-Directed Pattern Matching on
  2336.           Unbounded Sequences of Values - Kelvin Nilsen
  2337.            Computer Languages, Vol. 15, No. 1, Jan. 90.
  2338.  
  2339.      I can provide reprints to anyone who is interested in this.
  2340.  
  2341.   2) Conicon supports concurrent processes.  These processes are
  2342.      spawned in one of two ways.  First, Icon's create operator serves
  2343.      in Conicon to create a concurrent process instead of creating
  2344.      a coexpression.  A stream which represents the sequence of values
  2345.      generated by the spawned expression is automatically created when
  2346.      the process is spawned.  Second, Conicon introduces yet another
  2347.      operator: binary !, which is interpreted as "concurrent alternation."
  2348.      For example,
  2349.  
  2350.     every write(1 to 3 ! 5 to 7)
  2351.  
  2352.      might output the sequence:
  2353.  
  2354.     5, 6, 1, 2, 3, 7
  2355.  
  2356.      There are a variety of useful programming techniques that can be
  2357.      based on the concurrent alternation operator.  These techniques,
  2358.      and other aspects of concurrency in Conicon are discussed more
  2359.      thoroughly in a paper submitted to Software -- Practice & Experience.
  2360.      We have not yet heard back from the referees.  If anyone would like
  2361.      to see a draft, please send me mail...
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367. From root@fergvax.unl.edu  Fri Feb 16 07:22:53 1990
  2368. Received: from fergvax.unl.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2369.     id AA10598; Fri, 16 Feb 90 07:22:53 MST
  2370. Received: by fergvax.unl.edu (5.57/Ultrix2.4-C)
  2371.     id AA09632; Fri, 16 Feb 90 08:20:06 CST
  2372. Date: Fri, 16 Feb 90 08:20:06 CST
  2373. From: root@fergvax.unl.edu (System PRIVILEGED Account)
  2374. Message-Id: <9002161420.AA09632@fergvax.unl.edu>
  2375. To: icon-group@cs.arizona.edu
  2376. Subject: unocss.unl.edu
  2377. Cc: mkb@fergvax.unl.edu
  2378. Status: O
  2379.  
  2380. Dear Icon-Group List Manager:
  2381.  
  2382. The network that host unocss is currently on is in the process of being changed
  2383. over from a class C network to a class B network.  No mail can get through to 
  2384. it.  Messages that are currently being routed through fergvax.unl.edu are unable
  2385. to get through and are spooling up here. 
  2386.  
  2387. I would appreciate it if you would remove them from the mailing list until they
  2388. get their network problems straightened out.  When they do, you will need
  2389. to send all icon-group mail to unocss directly.  You will need to change the 
  2390. mailing address of 
  2391.         payne%unocss.unl.edu@fergvax.unl.edu
  2392. to be        payne@unocss.unomaha.edu
  2393.  
  2394. I do not know what the IP# will be for unocss.  But if you are running
  2395. named, you should not need it.
  2396.  
  2397. Thank you.
  2398.  
  2399. Sincerely,
  2400.  
  2401. FERGVAX System Manager
  2402.  
  2403. P.S.    For your information:
  2404.  
  2405.         Mail Queue (6 requests)
  2406. --QID-- --Size-- -----Q-Time----- ------------Sender/Recipient------------
  2407. AA27250     2562 Thu Feb 15 14:42 <icon-group-sender@cs.arizona.edu>
  2408.          (Deferred: Connection timed out during user open with unocss.)
  2409.                   <payne%unocss.unl.edu@fergvax.unl.edu>
  2410. AA24126      481 Thu Feb 15 11:26 <icon-group-sender@cs.arizona.edu>
  2411.          (Deferred: Connection timed out during user open with unocss.)
  2412.                   <payne%unocss.unl.edu@fergvax.unl.edu>
  2413. AA23032      620 Thu Feb 15 10:31 <icon-group-sender@cs.arizona.edu>
  2414.          (Deferred: Connection timed out during user open with unocss.)
  2415.                   <payne%unocss.unl.edu@fergvax.unl.edu>
  2416. AA19377      969 Thu Feb 15 00:34 <icon-group-sender@cs.arizona.edu>
  2417.          (Deferred: Connection timed out during user open with unocss.)
  2418.                   <payne%unocss.unl.edu@fergvax.unl.edu>
  2419. AA19373     1054 Thu Feb 15 00:33 <icon-group-sender@cs.arizona.edu>
  2420.          (Deferred: Connection timed out during user open with unocss.)
  2421.                   <payne%unocss.unl.edu@fergvax.unl.edu>
  2422. AA17854      652 Tue Feb 13 10:12 <icon-group-sender@cs.arizona.edu>
  2423.          (Deferred: Connection timed out during user open with unocss.)
  2424.                   <payne%unocss.unl.edu@fergvax.unl.edu>
  2425.  
  2426. From goer@sophist.uchicago.EDU  Thu Feb 22 20:06:32 1990
  2427. Resent-From: goer@sophist.uchicago.EDU
  2428. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2429.     id AA18569; Thu, 22 Feb 90 20:06:32 MST
  2430. Return-Path: goer@sophist.uchicago.EDU
  2431. Received: from tank.uchicago.edu by Arizona.EDU; Thu, 22 Feb 90 20:08 MST
  2432. Received: from sophist.uchicago.edu by tank.uchicago.edu Thu, 22 Feb 90
  2433.  21:06:43 CST
  2434. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA03453; Thu, 22 Feb 90
  2435.  21:02:03 CST
  2436. Resent-Date: Thu, 22 Feb 90 20:08 MST
  2437. Date: Thu, 22 Feb 90 21:02:03 CST
  2438. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  2439. Subject: BSD -> SYSV filename mapper (reformats entire tar archive)
  2440. Resent-To: icon-group@cs.arizona.edu
  2441. To: icon-group@arizona.edu
  2442. Resent-Message-Id: <D4C7FAE1B7DFE01F25@Arizona.EDU>
  2443. Message-Id: <9002230302.AA03453@sophist.uchicago.edu>
  2444. X-Envelope-To: icon-group@CS.Arizona.EDU
  2445. X-Vms-To: icon-group@Arizona.edu
  2446. Status: O
  2447.  
  2448.  
  2449. Recently I had occasion to install a number of BSD archives on my
  2450. home (SysV) machine, and I got fed up with having to rename all the
  2451. directories, and altering all the source to recognize the new and
  2452. shorter names.  It seemed better to create a filter that would take
  2453. a tar archive and map everything all at once.
  2454.  
  2455. I started writing the program in C, but I soon realized that doing
  2456. the job in C would take a couple of evenings.  The Icon program took
  2457. just part of one evening.  It's not meant to be pretty, but since it
  2458. is probably something others would find useful, I'm posting it.  It
  2459. works here at my site.  Naturally, I don't guarantee that it will
  2460. work anywhere else.
  2461.  
  2462. ----------------------------------------------------------------------
  2463. global filenametbl, chunkset, short_chunkset        # see procedure mappiece(s)
  2464. record hblock(name,junk,size,mtime,chksum,
  2465.               linkflag,linkname,therest)            # see readtarhdr(s)
  2466.  
  2467.  
  2468. procedure main(a)
  2469.  
  2470.     usage := "usage:  maptarfile inputfile      # output goes to stdout"
  2471.     0 < *a < 2 | stop("Bad arg count.\n",usage)
  2472.     intext := open(a[1],"r") |
  2473.     stop("maptarfile:  can't open ",a[1])
  2474.  
  2475.     # run through all the headers in the input file, filling
  2476.     # (global) filenametbl with the names of overlong files;
  2477.     # make_table_of_filenames fails if there are no such files
  2478.     make_table_of_filenames(intext) |
  2479.     stop("maptarfile:  no overlong path names to map")
  2480.   
  2481.     # now that a table of overlong filenames exists, go back
  2482.     # through the text, remapping all occurrences of these names
  2483.     # to new, 14-char values; also, reset header checksums, and
  2484.     # reformat text into correctly padded 512-byte blocks
  2485.     seek(intext,1)
  2486.     output_mapped_headers_and_texts(intext) |
  2487.     stop("maptarfile:  error reformatting text")
  2488.  
  2489.     close(intext)
  2490.     write_report()
  2491.     exit(0)
  2492.     
  2493. end
  2494.  
  2495.  
  2496.  
  2497. procedure make_table_of_filenames(intext)
  2498.  
  2499.     # global chunkset (set of overlong filenames)
  2500.     local header
  2501.  
  2502.     # read headers for overlong filenames; for now
  2503.     # ignore everything else
  2504.     while header := readtarhdr(reads(intext,512)) do {
  2505.     tab_nxt_hdr(intext,trim_str(header.size))
  2506.     fixpath(trim_str(header.name))
  2507.     }
  2508.     *chunkset = 0 & fail
  2509.     return &null
  2510.  
  2511. end
  2512.  
  2513.  
  2514.  
  2515. procedure output_mapped_headers_and_texts(intext)
  2516.  
  2517.     # remember that filenametbl, chunkset, and short_chunkset
  2518.     # (which are used by various procedures below) are GLOBAL
  2519.     local header, newtext, full_block 
  2520.  
  2521.     # read in headers, one at a time
  2522.     while header := readtarhdr(reads(intext,512)) do {
  2523.  
  2524.     # replace overlong filenames with shorter ones, according to
  2525.     # the conversions specified in the global hash table filenametbl
  2526.           header.name := left(map_filenams(header.name),100,"\x00")
  2527.     header.linkname := left(map_filenams(header.linkname),100,"\x00")
  2528.  
  2529.     # use header.size field to read in and map the subsequent text
  2530.     newtext := trim(
  2531.         map_filenams(tab_nxt_hdr(intext,trim_str(header.size))),'\x00'
  2532.         )
  2533.  
  2534.     # now, find the length of newtext, and insert it into the size field
  2535.     header.size := right(exbase10(*newtext,8) || " ",12," ")
  2536.  
  2537.     # calculate the checksum of the newly retouched header
  2538.     header.chksum := right(exbase10(get_checksum(header),8)||"\x00 ",8," ")
  2539.  
  2540.     # finally, join all the header fields into a new block and write it out
  2541.     full_block := ""; every full_block ||:= !header
  2542.     writes(left(full_block,512,"\x00"))
  2543.  
  2544.     # now we're ready to write out the text, padding the final block
  2545.     # out to an even 512 bytes if necessary; the next header must start
  2546.     # right at the beginning of a 512 byte block
  2547.     newtext ? {
  2548.         while writes(move(512))
  2549.         if not pos(0)
  2550.         then writes(left(tab(0),512,"\x00")) | fail
  2551.     }
  2552.     }
  2553.     writes(repl("\x00",512))
  2554.     return &null
  2555.  
  2556. end
  2557.  
  2558.  
  2559.  
  2560. procedure trim_str(s)
  2561.     # knock out spaces, nulls
  2562.     return s ? {
  2563.     (tab(many(' ')) | &null) &
  2564.         trim(tab(find("\x00")|0))
  2565.     } \ 1
  2566. end 
  2567.  
  2568.  
  2569.  
  2570. procedure tab_nxt_hdr(f,size_str)
  2571.  
  2572.     hs := integer("8r" || size_str)
  2573.     next_header_offset := (hs / 512) * 512
  2574.     hs % 512 ~= 0 & next_header_offset +:= 512
  2575.     if 0 = next_header_offset then return ""
  2576.     return reads(f,next_header_offset) |
  2577.     stop("maptarfile:  error reading in ",
  2578.          string(next_header_offset)," bytes.")
  2579.  
  2580. end
  2581.  
  2582.  
  2583.  
  2584. procedure fixpath(s)
  2585.  
  2586.     # fixpath is a misnomer of sorts, since it is used on
  2587.     # the first pass only, and merely examines each filename
  2588.     # in a path, using the procedure mappiece to record any
  2589.     # overlong ones in the global table filenametbl and in
  2590.     # the global sets chunkset and short_chunkset; no fixing
  2591.     # is actually done here
  2592.     s2 := ""
  2593.     s ? {
  2594.     while piece := tab(find("/")+1)
  2595.     do s2 ||:= mappiece(piece) 
  2596.     s2 ||:= mappiece(tab(0))
  2597.     }
  2598.     return s2
  2599.  
  2600. end
  2601.  
  2602.  
  2603.  
  2604. procedure mappiece(s)
  2605.     
  2606.     # global filenametbl, chunkset short_chunkset
  2607.     initial {
  2608.     filenametbl := table()
  2609.     chunkset := set()
  2610.     short_chunkset := set()
  2611.     }
  2612.     
  2613.     chunk := trim(s,'/')
  2614.     if *chunk > 14 then {
  2615.     i := 0
  2616.     repeat {
  2617.     # if the file has already been looked at, continue
  2618.         if \filenametbl[chunk] then next
  2619.     # else find a new unique 14-character name for it
  2620.         lchunk := chunk[1:12] || right(string(i+:=1),3,"0")
  2621.         if lchunk == !filenametbl
  2622.         then next else break
  2623.     }
  2624.     # record filename in various global sets and tables
  2625.     filenametbl[chunk] := lchunk
  2626.     insert(chunkset,chunk)
  2627.     insert(short_chunkset,chunk[1:16])
  2628.     }
  2629.     else lchunk := chunk
  2630.  
  2631.     lchunk ||:= (s[-1] == "/")
  2632.     return lchunk
  2633.  
  2634. end
  2635.  
  2636.  
  2637.  
  2638. procedure readtarhdr(s)
  2639.     this_block := hblock()
  2640.     s ? {
  2641.     this_block.name     := move(100)    # <- to be looked at later
  2642.     this_block.junk     := move(8+8+8)  # skip the permissions, uid, etc.
  2643.     this_block.size     := move(12)     # <- to be looked at later
  2644.     this_block.mtime    := move(12)
  2645.     this_block.chksum   := move(8)      # <- to be looked at later
  2646.     this_block.linkflag := move(1)
  2647.     this_block.linkname := move(100)    # <- to be looked at later
  2648.     this_block.therest  := tab(0)
  2649.     }
  2650.     integer(this_block.size) | fail
  2651.     return this_block
  2652. end
  2653.  
  2654.  
  2655.  
  2656. procedure map_filenams(s)
  2657.  
  2658.     # chunkset is global, and contains all the overlong filenames
  2659.     # found in the first pass through the input file; here the aim
  2660.     # is to map the filenames to the shortened variants as stored
  2661.     # in filenametbl (which happens to be GLOBAL)
  2662.  
  2663.     local s2
  2664.  
  2665.     s2 := ""
  2666.     s ? {
  2667.     until pos(0) do {
  2668.         # first narrow the possibilities, then try to map;
  2669.         # short_chunkset, chunkset & filenametbl are global
  2670.         if member(short_chunkset,&subject[&pos:&pos+15])
  2671.         then s2 ||:= filenametbl[=!chunkset]
  2672.         else s2 ||:= move(1)
  2673.     }
  2674.     }
  2675.     return s2
  2676.  
  2677. end
  2678.  
  2679.  
  2680.  
  2681. #  Author:  Ralph E. Griswold
  2682. #  Date:  June 10, 1988
  2683. #  exbase10(i,j) convert base-10 integer i to base j
  2684. #  The maximum base allowed is 36.
  2685.  
  2686. procedure exbase10(i,j)
  2687.    static digits
  2688.    local s, d, sign
  2689.    initial digits := &digits || &lcase
  2690.    if i = 0 then return 0
  2691.    if i < 0 then {
  2692.       sign := "-"
  2693.       i := -i
  2694.       }
  2695.    else sign := ""
  2696.    s := ""
  2697.    while i > 0 do {
  2698.       d := i % j
  2699.       if d > 9 then d := digits[d + 1]
  2700.       s := d || s
  2701.       i /:= j
  2702.       }
  2703.    return sign || s
  2704. end
  2705.  
  2706.  
  2707.  
  2708. procedure get_checksum(r)
  2709.     sum := 0
  2710.     r.chksum := "        "
  2711.     every field := !r
  2712.     do every sum +:= ord(!field)
  2713.     return sum
  2714. end
  2715.  
  2716.  
  2717.  
  2718. procedure write_report()
  2719.  
  2720.     # this procedure writes out a list of filenames which were
  2721.     # remapped (because they exceeded the SysV 14-char limit)
  2722.  
  2723.     local outtext, stbl, i
  2724.  
  2725.     (outtext := open(fname := "mapping.report","w")) |
  2726.     open(fname := "/tmp/mapping.report","w") |
  2727.          stop("maptarfile:  Can't find a place to put mapping.report!")
  2728.     stbl := sort(filenametbl,3)
  2729.     every i := 1 to *stbl -1 by 2 do {
  2730.     write(outtext,left(stbl[i],35," ")," ",stbl[i+1])
  2731.     }
  2732.     write(&errout,"maptarfile:  ",fname," contains the list of changes")
  2733.     close(outtext)
  2734.     return &null
  2735.  
  2736. end
  2737.  
  2738. From CELEX@HNYMPI52.BITNET  Sat Feb 24 19:16:52 1990
  2739. Resent-From: CELEX@HNYMPI52.BITNET
  2740. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2741.     id AA00779; Sat, 24 Feb 90 19:16:52 MST
  2742. Received: from rvax.ccit.arizona.edu by Arizona.EDU; Sat, 24 Feb 90 19:16 MST
  2743. Received: from HNYMPI52.BITNET by rvax.ccit.arizona.edu; Sat, 24 Feb 90 19:12
  2744.  MST
  2745. Resent-Date: Sat, 24 Feb 90 19:18 MST
  2746. Date: Sat, 24 Feb 90 20:03 N
  2747. From: CELEX@HNYMPI52.BITNET
  2748. Subject: strip
  2749. Resent-To: icon-group@cs.arizona.edu
  2750. To: icon-group@arizona.edu
  2751. Resent-Message-Id: <D33CB1465D1FE01ACE@Arizona.EDU>
  2752. Message-Id: <D33D74193DDF2053C7@rvax.ccit.arizona.edu>
  2753. X-Original-To:  icon-group@arizona.edu, CELEX
  2754. X-Envelope-To: icon-group@CS.Arizona.EDU
  2755. X-Vms-To: icon-group@Arizona.edu
  2756. Status: O
  2757.  
  2758.  
  2759. We use for removing unwanted characters from a string the following
  2760. method:
  2761.  
  2762. (&unwanchar is the set of the unwanted characters)
  2763.  
  2764. while string[upto(&unwanchar,string)+:1] :== ""
  2765.  
  2766.                                             Hope this helps,
  2767.                                             Marcel Bingley
  2768.  
  2769.                                                         C
  2770.  
  2771.                                                               C
  2772.    --   C E L E X   --                            C        C      C
  2773.                                                        C
  2774.  University of Nijmegen                                          C    CCCCCC
  2775.  Wundtlaan 1                                                C     CCCCCCCCCCCCC
  2776.  6525 XD  NIJMEGEN                       C           C    C     CCCCCCCCCCCCCCCC
  2777.  The Netherlands                                            CCCCCCCCCC        CC
  2778.                                                       C    CCCCCCCC
  2779.                                                           CCCCCCCC
  2780.  Tel: (+31) (0)80 - 512117                                CCCCCCCC
  2781.                   - 515797                               CCCCCCCC
  2782.                                                          CCCCCCCC
  2783.  EARN/BITNET:   celex@hnympi52                           CCCCCCCC
  2784.  Internet:    celexmail@celex.surfnet.nl                  CCCCCCCC
  2785.  SURFNET:  celex::celexmail                               CCCCCCCC
  2786.  JANET:  celex%hnympi52@earn-relay                         CCCCCCCCC
  2787.  PSI:  020418802007380::celexmail                            CCCCCCCCCCC
  2788.  
  2789. From goer@sophist.uchicago.EDU  Wed Feb 28 02:40:39 1990
  2790. Resent-From: goer@sophist.uchicago.EDU
  2791. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  2792.     id AA01623; Wed, 28 Feb 90 02:40:39 MST
  2793. Return-Path: goer@sophist.uchicago.EDU
  2794. Received: from tank.uchicago.edu by Arizona.EDU; Wed, 28 Feb 90 02:38 MST
  2795. Received: from sophist.uchicago.edu by tank.uchicago.edu Wed, 28 Feb 90
  2796.  03:37:08 CST
  2797. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA10175; Wed, 28 Feb 90
  2798.  03:32:21 CST
  2799. Resent-Date: Wed, 28 Feb 90 02:40 MST
  2800. Date: Wed, 28 Feb 90 03:32:21 CST
  2801. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  2802. Subject: in situ filename truncator for tar files
  2803. Resent-To: icon-group@cs.arizona.edu
  2804. To: icon-group@arizona.edu
  2805. Resent-Message-Id: <D0A356C4AEFF400C10@Arizona.EDU>
  2806. Message-Id: <9002280932.AA10175@sophist.uchicago.edu>
  2807. X-Envelope-To: icon-group@CS.Arizona.EDU
  2808. X-Vms-To: icon-group@Arizona.edu
  2809. Status: O
  2810.  
  2811. Having received a number of requests for this thing from a number
  2812. of places, it seemed prudent to clean it up, comment it, fix the
  2813. bugs, and repost.
  2814.  
  2815. I had no idea that anyone would really _use_ it.
  2816.  
  2817.  
  2818. #-------------------------------------------------------------------
  2819. #
  2820. #    MAPTARFILE 
  2821. #    
  2822. #    Map 15+ char. filenames in a tar archive to 14 chars.
  2823. #    Handles both the header blocks and the source itself.
  2824. #    Obviates the need for renaming files and directories
  2825. #    by hand, and for altering source and docs to refer to
  2826. #    the new file and directory names.
  2827. #
  2828. #    Richard L. Goerwitz, III
  2829. #
  2830. #    Last modified 2/27/90
  2831. #
  2832. #-------------------------------------------------------------------
  2833.  
  2834.  
  2835. global filenametbl, chunkset, short_chunkset   # see procedure mappiece(s)
  2836. record hblock(name,junk,size,mtime,chksum,
  2837.               linkflag,linkname,therest)       # see readtarhdr(s)
  2838.  
  2839.  
  2840. procedure main(a)
  2841.  
  2842.     usage := "usage:  maptarfile inputfile      # output goes to stdout"
  2843.     0 < *a < 2 | stop("Bad arg count.\n",usage)
  2844.     intext := open(a[1],"r") |
  2845.     stop("maptarfile:  can't open ",a[1])
  2846.  
  2847.     # Run through all the headers in the input file, filling
  2848.     # (global) filenametbl with the names of overlong files;
  2849.     # make_table_of_filenames fails if there are no such files.
  2850.     make_table_of_filenames(intext) |
  2851.     stop("maptarfile:  no overlong path names to map")
  2852.   
  2853.     # Now that a table of overlong filenames exists, go back
  2854.     # through the text, remapping all occurrences of these names
  2855.     # to new, 14-char values; also, reset header checksums, and
  2856.     # reformat text into correctly padded 512-byte blocks.  Ter-
  2857.     # minate output with 512 nulls.
  2858.     seek(intext,1)
  2859.     every writes(output_mapped_headers_and_texts(intext))
  2860.  
  2861.     close(intext)
  2862.     write_report()   # Record mapped file and dir names for future ref.
  2863.     exit(0)
  2864.     
  2865. end
  2866.  
  2867.  
  2868.  
  2869. procedure make_table_of_filenames(intext)
  2870.  
  2871.     local header # chunkset is global
  2872.  
  2873.     # search headers for overlong filenames; for now
  2874.     # ignore everything else
  2875.     while header := readtarhdr(reads(intext,512)) do {
  2876.     # tab upto the next header block
  2877.     tab_nxt_hdr(intext,trim_str(header.size),1)
  2878.     # record overlong filenames in several global tables, sets
  2879.     fixpath(trim_str(header.name))
  2880.     }
  2881.     *chunkset = 0 & fail
  2882.     return &null
  2883.  
  2884. end
  2885.  
  2886.  
  2887.  
  2888. procedure output_mapped_headers_and_texts(intext)
  2889.  
  2890.     # Remember that filenametbl, chunkset, and short_chunkset
  2891.     # (which are used by various procedures below) are global.
  2892.     local header, newtext, full_block, block, lastblock
  2893.  
  2894.     # Read in headers, one at a time.
  2895.     while header := readtarhdr(reads(intext,512)) do {
  2896.  
  2897.     # Replace overlong filenames with shorter ones, according to
  2898.     # the conversions specified in the global hash table filenametbl
  2899.     # (which were generated by fixpath() on the first pass).
  2900.           header.name := left(map_filenams(header.name),100,"\x00")
  2901.     header.linkname := left(map_filenams(header.linkname),100,"\x00")
  2902.  
  2903.     # Use header.size field to determine the size of the subsequent text.
  2904.     # Read in the text as one string.  Map overlong filenames found in it
  2905.      # to shorter names as specified in the global hash table filenamtbl.
  2906.     newtext := map_filenams(tab_nxt_hdr(intext,trim_str(header.size)))
  2907.  
  2908.     # Now, find the length of newtext, and insert it into the size field.
  2909.     header.size := right(exbase10(*newtext,8) || " ",12," ")
  2910.  
  2911.     # Calculate the checksum of the newly retouched header.
  2912.     header.chksum := right(exbase10(get_checksum(header),8)||"\x00 ",8," ")
  2913.  
  2914.     # Finally, join all the header fields into a new block and write it out
  2915.     full_block := ""; every full_block ||:= !header
  2916.     suspend left(full_block,512,"\x00")
  2917.  
  2918.     # Now we're ready to write out the text, padding the final block
  2919.     # out to an even 512 bytes if necessary; the next header must start
  2920.     # right at the beginning of a 512-byte block.
  2921.     newtext ? {
  2922.         while block := move(512)
  2923.         do suspend block
  2924.         pos(0) & next
  2925.             lastblock := left(tab(0),512,"\x00")
  2926.         suspend lastblock
  2927.     }
  2928.     }
  2929.     # Write out a final null-filled block.  Some tar programs will write
  2930.     # out 1024 nulls at the end.  Dunno why.
  2931.     return repl("\x00",512)
  2932.  
  2933. end
  2934.  
  2935.  
  2936.  
  2937. procedure trim_str(s)
  2938.  
  2939.     # Knock out spaces, nulls from those crazy tar header
  2940.     # block fields (some of which end in a space and a null,
  2941.     # some just a space, and some just a null [anyone know
  2942.     # why?]).
  2943.     return s ? {
  2944.     (tab(many(' ')) | &null) &
  2945.         trim(tab(find("\x00")|0))
  2946.     } \ 1
  2947.  
  2948. end 
  2949.  
  2950.  
  2951.  
  2952. procedure tab_nxt_hdr(f,size_str,firstpass)
  2953.  
  2954.     # Tab upto the next header block.  Return the bypassed text
  2955.     # as a string (this value is not always used).
  2956.  
  2957.     local hs, next_header_offset
  2958.  
  2959.     hs := integer("8r" || size_str)
  2960.     next_header_offset := (hs / 512) * 512
  2961.     hs % 512 ~= 0 & next_header_offset +:= 512
  2962.     if 0 = next_header_offset then return ""
  2963.     else {
  2964.     # if this is pass no. 1 don't bother returning a value; we're
  2965.     # just collecting long filenames;
  2966.     if \firstpass then {
  2967.         seek(f,where(f)+next_header_offset)
  2968.         return
  2969.     }
  2970.     else {
  2971.         return reads(f,next_header_offset)[1:hs+1] |
  2972.         stop("maptarfile:  error reading in ",
  2973.              string(next_header_offset)," bytes.")
  2974.     }
  2975.     }
  2976.  
  2977. end
  2978.  
  2979.  
  2980.  
  2981. procedure fixpath(s)
  2982.  
  2983.     # Fixpath is a misnomer of sorts, since it is used on
  2984.     # the first pass only, and merely examines each filename
  2985.     # in a path, using the procedure mappiece to record any
  2986.     # overlong ones in the global table filenametbl and in
  2987.     # the global sets chunkset and short_chunkset; no fixing
  2988.     # is actually done here.
  2989.  
  2990.     s2 := ""
  2991.     s ? {
  2992.     while piece := tab(find("/")+1)
  2993.     do s2 ||:= mappiece(piece) 
  2994.     s2 ||:= mappiece(tab(0))
  2995.     }
  2996.     return s2
  2997.  
  2998. end
  2999.  
  3000.  
  3001.  
  3002. procedure mappiece(s)
  3003.  
  3004.     # Check s (the name of a file or dir as recorded in the tar header
  3005.     # being examined) to see if it is over 14 chars long.  If so,
  3006.     # generate a unique 14-char version of the name, and store
  3007.     # both values in the global hashtable filenametbl.  Also store
  3008.     # the original (overlong) file name in chunkset.  Store the
  3009.     # first fifteen chars of the original file name in short_chunkset.
  3010.     # Sorry about all of the tables and sets.  It actually makes for
  3011.     # a reasonably efficient program.  Doing away with both sets,
  3012.     # while possible, causes a tenfold drop in execution speed!
  3013.     
  3014.     # global filenametbl, chunkset, short_chunkset
  3015.     local j, ending
  3016.  
  3017.     initial {
  3018.     filenametbl := table()
  3019.     chunkset := set()
  3020.     short_chunkset := set()
  3021.     }
  3022.     
  3023.     chunk := trim(s,'/')
  3024.     if *chunk > 14 then {
  3025.     i := 0
  3026.     repeat {
  3027.     # if the file has already been looked at, continue
  3028.         if \filenametbl[chunk] then next
  3029.     # else find a new unique 14-character name for it
  3030.     # preserve important suffixes like ".Z," ".c," etc.
  3031.         if chunk ?
  3032.            (tab(find(".")), ending := move(1) || tab(any(&ascii)), pos(0))
  3033.         then lchunk := chunk[1:11] || right(string(i+:=1),2,"0") || ending
  3034.         else lchunk := chunk[1:12] || right(string(i+:=1),3,"0")
  3035.         if lchunk == !filenametbl
  3036.         then next else break
  3037.     }
  3038.     # record filename in various global sets and tables
  3039.     filenametbl[chunk] := lchunk
  3040.     insert(chunkset,chunk)
  3041.     insert(short_chunkset,chunk[1:16])
  3042.     }
  3043.     else lchunk := chunk
  3044.  
  3045.     lchunk ||:= (s[-1] == "/")
  3046.     return lchunk
  3047.  
  3048. end
  3049.  
  3050.  
  3051.  
  3052. procedure readtarhdr(s)
  3053.  
  3054.     # Read the silly tar header into a record.  Note that, as was
  3055.     # complained about above, some of the fields end in a null, some
  3056.     # in a space, and some in a space and a null.  The procedure
  3057.     # trim_str() may (and in fact often _is_) used to remove this
  3058.     # extra garbage.
  3059.  
  3060.     this_block := hblock()
  3061.     s ? {
  3062.     this_block.name     := move(100)    # <- to be looked at later
  3063.     this_block.junk     := move(8+8+8)  # skip the permissions, uid, etc.
  3064.     this_block.size     := move(12)     # <- to be looked at later
  3065.     this_block.mtime    := move(12)
  3066.     this_block.chksum   := move(8)      # <- to be looked at later
  3067.     this_block.linkflag := move(1)
  3068.     this_block.linkname := move(100)    # <- to be looked at later
  3069.     this_block.therest  := tab(0)
  3070.     }
  3071.     integer(this_block.size) | fail  # If it's not an integer, we've hit
  3072.                                      # the final (null-filled) block.
  3073.     return this_block
  3074.  
  3075. end
  3076.  
  3077.  
  3078.  
  3079. procedure map_filenams(s)
  3080.  
  3081.     # Chunkset is global, and contains all the overlong filenames
  3082.     # found in the first pass through the input file; here the aim
  3083.     # is to map these filenames to the shortened variants as stored
  3084.     # in filenametbl (GLOBAL).
  3085.  
  3086.     local s2
  3087.  
  3088.     s2 := ""
  3089.     s ? {
  3090.     until pos(0) do {
  3091.         # first narrow the possibilities, using short_chunkset
  3092.         if member(short_chunkset,&subject[&pos:&pos+15])
  3093.             # then try to map from a long to a shorter 14-char filename
  3094.         then s2 ||:= (filenametbl[=!chunkset] | move(1))
  3095.         else s2 ||:= move(1)
  3096.     }
  3097.     }
  3098.     return s2
  3099.  
  3100. end
  3101.  
  3102.  
  3103. #  From the IPL.  Thanks, Ralph -
  3104. #  Author:  Ralph E. Griswold
  3105. #  Date:  June 10, 1988
  3106. #  exbase10(i,j) convert base-10 integer i to base j
  3107. #  The maximum base allowed is 36.
  3108.  
  3109. procedure exbase10(i,j)
  3110.  
  3111.    static digits
  3112.    local s, d, sign
  3113.    initial digits := &digits || &lcase
  3114.    if i = 0 then return 0
  3115.    if i < 0 then {
  3116.       sign := "-"
  3117.       i := -i
  3118.       }
  3119.    else sign := ""
  3120.    s := ""
  3121.    while i > 0 do {
  3122.       d := i % j
  3123.       if d > 9 then d := digits[d + 1]
  3124.       s := d || s
  3125.       i /:= j
  3126.       }
  3127.    return sign || s
  3128.  
  3129. end
  3130.  
  3131. # end IPL material
  3132.  
  3133.  
  3134. procedure get_checksum(r)
  3135.  
  3136.     # Calculates the new value of the checksum field for the
  3137.     # current header block.  Note that the specification say
  3138.     # that, when calculating this value, the chksum field must
  3139.     # be blank-filled.
  3140.  
  3141.     sum := 0
  3142.     r.chksum := "        "
  3143.     every field := !r
  3144.     do every sum +:= ord(!field)
  3145.     return sum
  3146.  
  3147. end
  3148.  
  3149.  
  3150.  
  3151. procedure write_report()
  3152.  
  3153.     # This procedure writes out a list of filenames which were
  3154.     # remapped (because they exceeded the SysV 14-char limit),
  3155.     # and then notifies the user of the existence of this file.
  3156.  
  3157.     local outtext, stbl, i
  3158.  
  3159.     (outtext := open(fname := "mapping.report","w")) |
  3160.     open(fname := "/tmp/mapping.report","w") |
  3161.          stop("maptarfile:  Can't find a place to put mapping.report!")
  3162.     stbl := sort(filenametbl,3)
  3163.     every i := 1 to *stbl -1 by 2 do {
  3164.     write(outtext,left(stbl[i],35," ")," ",stbl[i+1])
  3165.     }
  3166.     write(&errout,"maptarfile:  ",fname," contains the list of changes")
  3167.     close(outtext)
  3168.     return &null
  3169.  
  3170. end
  3171.  
  3172. From tenaglia@fps.mcw.edu  Wed Feb 28 08:20:02 1990
  3173. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3174.     id AA12588; Wed, 28 Feb 90 08:20:02 MST
  3175. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  3176.     id AA19229; Wed, 28 Feb 90 10:17:25 EST
  3177. Received: by uwm.edu; id AA23161; Wed, 28 Feb 90 09:08:35 -0600
  3178. Message-Id: <9002281508.AA23161@uwm.edu>
  3179. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  3180.           Wed, 28 Feb 90 08:29:52 CDT
  3181. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  3182.           Wed, 28 Feb 90 08:29:37 CDT
  3183. Date: Wed, 28 Feb 90 08:29:37 CDT
  3184. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  3185. To: icon-group@cs.arizona.edu
  3186. Subject: And now something useless
  3187. Status: O
  3188.  
  3189.  
  3190. Icon is a great language for recreational programming as well. I recently
  3191. read a Scientific American where someone described a program that takes a
  3192. known text and scrambles it in a most bizaare fashion. The output is not
  3193. unlike a Max Headroom monolog. Also they interfaced it with a rhyming
  3194. engine to generate bizaare poetry. Well I thought it would be fun to try
  3195. doing it in icon. Below is the scrambler. I guess I was lazy not to do the
  3196. rhyming engine. It chooses subsequent words based on the likelyhood of them
  3197. occuring after the current word. This icon program accomplishes that. I
  3198. find it rather amusing what it does to my own documentation. Perhaps someone
  3199. has a more clever method, or perhaps someone would want to post a rhyming
  3200. engine?
  3201.  
  3202. ##################### 80 lines follow ############################
  3203. #                                                                #
  3204. # Poet.Icn               02/28/90          BY TENAGLIA           #
  3205. #                                                                #
  3206. # THIS PROGRAM TAKES A DOCUMENT AND RE-OUTPUTS IT IN A CLEVERLY  #
  3207. # SCRAMBLED FASHION. IT USES THE NEXT TWO MOST LIKELY WORDS TO   #
  3208. # TO FOLLOW. USAGE : ICONX POET INPUT_FILE [OUTPUT_FILE]         #
  3209. # IF NO OUTPUT FILE IS SPECIFIED, THE GIBBERISH IS SENT TO TTY   #
  3210. # THE CONCEPT WAS FOUND IN A RECENT SCIENTIFIC AMERICAN AND ICON #
  3211. # SEEMED TO OFFER THE BEST IMPLEMENTATION.                       #
  3212. #                                                                #
  3213. ##################################################################
  3214. global vocab,index
  3215. procedure main(param)
  3216.   source := param[1]        | input("_Source:")
  3217.   target := param[2]        | "tt:"
  3218.   (in  := open(source))     | stop("Can't open ",source)
  3219.   (out := open(target,"w")) | stop("Can't open ",target)
  3220.   vocab:= []
  3221.   index:= table([])
  3222.   write("Loading vocabulary")
  3223.   while line := read(in) do
  3224.     {
  3225.     vocab |||:= parse(line,' ')
  3226.     writes(".")
  3227.     }
  3228.   close(in)
  3229.  
  3230.   write("\nindexing...\n")
  3231.   every i := 1 to *vocab-2 do index[vocab[i]] |||:= [i]
  3232.   index[vocab[-2]] |||:= [-2]    # wrap end to front in order to
  3233.   index[vocab[-1]] |||:= [-1]    # prevent stuck loop if last word chosen
  3234.  
  3235.   n := -1 ; &random := map(&clock,":","0") ; line := ""
  3236.   write("\n")
  3237.   every 1 to *vocab/2 do
  3238.     {
  3239.     (n > 1) | (n := ?(*vocab-2))
  3240.     word    := vocab[n]
  3241.     follows := vocab[(?(index[word]))+1]
  3242.     n       := (?(index[follows])) + 1
  3243.     if (*line + *word + *follows + 2) > 80 then
  3244.       {
  3245.       write(out,line)
  3246.       line := ""
  3247.       }
  3248.     line ||:= word || " " || follows || " "
  3249.     }
  3250.   write(out,line,".")
  3251.   close(out)
  3252.   end
  3253.  
  3254. ##################################################################
  3255. #                                                                #
  3256. # THIS PROCEDURE PULLS ALL THE ELEMENTS (TOKENS) OUT OF A LINE   #
  3257. # BUFFER AND RETURNS THEM IN A LIST. A VARIABLE NAMED 'CHARS'    #
  3258. # CAN BE STATICALLY DEFINED HERE OR GLOBAL. IT IS A CSET THAT    #
  3259. # CONTAINS THE VALID CHARACTERS THAT CAN COMPOSE THE ELEMENTS    #
  3260. # ONE WISHES TO EXTRACT.                                         #
  3261. #                                                                #
  3262. ##################################################################
  3263. procedure parse(line,delims)
  3264.   static chars
  3265.   chars  := &cset -- delims
  3266.   tokens := []
  3267.   line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
  3268.   return tokens
  3269.   end
  3270.  
  3271. ##################################################################
  3272. #                                                                #
  3273. # THIS PROCEDURE IS TERRIBLY HANDY IN PROMPTING AND GETTING      #
  3274. # AN INPUT STRING                                                #
  3275. #                                                                #
  3276. ##################################################################
  3277. procedure input(prompt)
  3278.   writes(prompt)
  3279.   return read()
  3280.   end
  3281.  
  3282. Yours truly,
  3283.  
  3284. Chris Tenaglia (System Manager)
  3285. Medical College of Wisconsin
  3286. 8701 W. Watertown Plank Rd.
  3287. Milwaukee, WI 53226
  3288. (414)257-8765
  3289. tenaglia@mis.mcw.edu
  3290.  
  3291. From icon-group-request@arizona.edu  Wed Feb 28 18:13:45 1990
  3292. Resent-From: icon-group-request@arizona.edu
  3293. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3294.     id AA27832; Wed, 28 Feb 90 18:13:45 MST
  3295. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 28 Feb 90 18:13 MST
  3296. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AB00291; Tue, 27 Feb 90
  3297.  20:19:27 -0800
  3298. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3299.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3300.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3301. Resent-Date: Wed, 28 Feb 90 18:14 MST
  3302. Date: 27 Feb 90 18:20:53 GMT
  3303. From: esquire!yost@nyu.EDU
  3304. Subject: Icon instead of shell scripts or C code
  3305. Sender: icon-group-request@arizona.edu
  3306. Resent-To: icon-group@cs.arizona.edu
  3307. To: icon-group@arizona.edu
  3308. Resent-Message-Id: <D020FA1A957F401151@Arizona.EDU>
  3309. Message-Id: <1806@esquire.UUCP>
  3310. Organization: DP&W, New York, NY
  3311. X-Envelope-To: icon-group@CS.Arizona.EDU
  3312. X-Vms-To: icon-group@Arizona.edu
  3313. Status: O
  3314.  
  3315. There world is divided into two kinds of programs:
  3316.   1.  Simple data manipulation batch programs (e.g. grep)
  3317.   2.  All other programs.
  3318.  
  3319. Unfortunately, Icon doesn't reach much beyond Class 1.
  3320. It would be great to be able to use Icon for all programs.
  3321.  
  3322. There are many reasons write programs on unix in Icon instead
  3323. of the shell or C, and I'm sure we all know what those are.
  3324. Unfortunately, those reasons don't stand a chance against
  3325. the reason why you can't use Icon:
  3326.  
  3327.    The vast majority of unix system calls are not supported.
  3328.  
  3329. As a result, Icon has these deficiencies, among others:
  3330.  
  3331.    Lack of sophistication in the running of subprocesses:
  3332.     Keyboard interrupt while a system() command is ignored
  3333.     No way to run a unix command and capture its output in a variable
  3334.     You can't run a program in the background and get its process (group)
  3335.          id for a later kill
  3336.     No fork, exec, wait, etc.
  3337.    No trapping of signals, and therefore no cleanup on forced exit,
  3338.     no timeouts
  3339.  
  3340. Has anyone implemented more of the unix system calls?
  3341. Would you please tell us about it?
  3342.  
  3343. Icon is so nice.  It's a shame it can't be used for more things.
  3344.  
  3345.  --dave yost
  3346.    yost@dpw.com or uunet!esquire!yost
  3347.    Please ignore the From or Reply-To fields above, if different.
  3348.  
  3349. P.S.
  3350.  
  3351. Here is a routine that adds a little to Icon's capability to replace
  3352. shell scripts:
  3353.  
  3354. # Run a command with the contents of an Icon string variable as input
  3355. # Note: If the string is not newline-terminated, it will appear to the
  3356. # command as if it were.  There are workarounds for this
  3357. procedure
  3358. tosystem (inputstring, command)
  3359.  
  3360.     return system ("<<'**END**' " || command || "\n" ||
  3361.            inputstring || if inputstring[-1] ~== "\n" then "\n" else "" ||
  3362.            "**END**\n")
  3363. end
  3364.  
  3365. From jeffc@osf.ORG  Mon Mar  5 09:14:07 1990
  3366. Resent-From: jeffc@osf.ORG
  3367. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3368.     id AA25244; Mon, 5 Mar 90 09:14:07 MST
  3369. Received: from osf.osf.org by Arizona.EDU; Mon, 5 Mar 90 09:06 MST
  3370. Received: from soba.osf.org by osf.osf.org (5.61/OSF 0.9) id AA16654; Mon, 5
  3371.  Mar 90 11:02:30 -0500
  3372. Resent-Date: Mon, 5 Mar 90 09:11 MST
  3373. Date: Mon, 05 Mar 90 11:02:29 -0500
  3374. From: Jeff Carter <jeffc@osf.ORG>
  3375. Subject: Porting Icon 7.5 to a new and Unique UNIX machine
  3376. Resent-To: icon-group@cs.arizona.edu
  3377. To: icon-group@arizona.edu
  3378. Resent-Message-Id: <CC7EE79266DF4033BE@Arizona.EDU>
  3379. Message-Id: <9533.636652949@soba>
  3380. X-Envelope-To: icon-group@CS.Arizona.EDU
  3381. X-Vms-To: icon-group@Arizona.edu
  3382. Status: O
  3383.  
  3384. I recently began porting (a reasonably simple task) Icon to a 
  3385. DECstation 3100 (MIPS RISC chipset, runs Ultrix. aka PMAX). I have run
  3386. in to a couple of things that hopefully someone else out there has a 
  3387. solution for, or suggestions how to debug:
  3388.  
  3389. (1) There are numurous calls to fopen() with "rb" and "wb" modes that
  3390. are _not_ surrounded by OS-specific #ifdef's. This leads me to believe
  3391. (unfortunately) that maybe the particular version I have hasn't been
  3392. run on a wide variety of UNIX machines. Any comments? Are other versions
  3393. of UNIX more forgiving than ULTRIX 3.0?
  3394.  
  3395. (2) Floating-point conversions. I get numerous failures of the "eval"
  3396. and "fncs" tests that seem to stem from a problem with the conversion of
  3397. real numbers to their string representations. For example, from the
  3398. "eval" test:
  3399.  
  3400. 3c3
  3401. < 2.0 === +2.0 ----> 9.018482111602407e-O4
  3402. ---
  3403. > 2.0 === +2.0 ----> 2.0
  3404.  
  3405. And from the "fncs" test:
  3406.  
  3407. 3c3
  3408. < copy(1.0) ----> 9.017964046223754e-O4
  3409. ---
  3410. > copy(1.0) ----> 1.0
  3411.  
  3412. There are numerous other examples, but almost all of the reported errors 
  3413. are similar to these.
  3414.  
  3415. (3) Memory allocation. Early the startup, the executable calls fopen() in 
  3416. order to get the code file. This, unfortunately, causes fopen() to call
  3417. malloc(), which immediately fails because initalloc() hasn't been 
  3418. called. And initalloc doesn't get called until after the header is read
  3419. from the code file. This forces me to use the static allocation versions
  3420. of the memory management routines. The first application that I want to use
  3421. this for wants to use a _lot_ of string space. I keep getting "out
  3422. of space in string region" errors, and having to restart with larger and
  3423. larger values. This is a royal pain. Has anyone looked at making the code
  3424. region be allocated out of the static memory region, or some other technique
  3425. that would let me initialize the memory allocation routine earlier? 
  3426. Is there a particular reason why this _won't_ work (so I don't waste my
  3427. time on it, only to dicover the fatal flaw.)
  3428.  
  3429.     jeff carter
  3430.     jeffc@osf.org
  3431.  
  3432. From ralph  Mon Mar  5 09:29:18 1990
  3433. Resent-From: "Ralph Griswold" <ralph>
  3434. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3435.     id AA26537; Mon, 5 Mar 90 09:29:18 MST
  3436. Received: from megaron.cs.arizona.edu by Arizona.EDU; Mon, 5 Mar 90 09:26 MST
  3437. Received: by megaron.cs.arizona.edu (5.59-1.7/15) id AA26252; Mon, 5 Mar 90
  3438.  09:26:10 MST
  3439. Resent-Date: Mon, 5 Mar 90 09:27 MST
  3440. Date: Mon, 5 Mar 90 09:26:10 MST
  3441. From: Ralph Griswold <ralph@cs.arizona.edu>
  3442. Subject: RE:  Porting Icon 7.5 to a new and Unique UNIX machine
  3443. Resent-To: icon-group@cs.arizona.edu
  3444. To: icon-group@arizona.edu, jeffc@osf.ORG
  3445. Resent-Message-Id: <CC7CC173687F4035D1@Arizona.EDU>
  3446. Message-Id: <9003051626.AA26252@megaron.cs.arizona.edu>
  3447. In-Reply-To: <9533.636652949@soba>
  3448. X-Envelope-To: icon-group@CS.Arizona.EDU
  3449. X-Vms-To: icon-group@Arizona.edu, jeffc@osf.ORG
  3450. Status: O
  3451.  
  3452. Version 8 of Icon, to be out shortly, will support the DECstation and
  3453. several other newer workstations, including the Sun SPARCstation and
  3454. the NeXT machine.  (All of the problems noted in earlier mail are
  3455. corrected in Version 8.)
  3456.  
  3457.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  3458.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  3459.  
  3460. From tenaglia@fps.mcw.edu  Wed Mar 14 16:18:58 1990
  3461. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3462.     id AA26299; Wed, 14 Mar 90 16:18:58 MST
  3463. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  3464.     id AA18368; Wed, 14 Mar 90 18:17:58 EST
  3465. Received: by uwm.edu; id AA22806; Wed, 14 Mar 90 16:49:13 -0600
  3466. Message-Id: <9003142249.AA22806@uwm.edu>
  3467. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  3468.           Wed, 14 Mar 90 16:02:34 CDT
  3469. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  3470.           Wed, 14 Mar 90 15:05:15 CDT
  3471. Date: Wed, 14 Mar 90 15:05:15 CDT
  3472. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  3473. To: icon-group@cs.arizona.edu
  3474. Subject: Handy Icon Procedure for Reports
  3475. Status: O
  3476.  
  3477. Dear Icon Group :
  3478.  
  3479. I am including a handy procedure that can reformat strings. It's
  3480. fairly intuitive as far as usage is concerned. My implementaion
  3481. is pretty plain. Perhaps someone has a more elegant expression
  3482. that makes use of string scanning or co-expressions? Enjoy!
  3483.  
  3484. ########################################################################
  3485. #                                                                      #
  3486. # THIS PROCEDURE IS A HANDY STRING REMAPPER/FORMATTER AND IT'S         #
  3487. # VERY HANDY FOR REPORT GENERATION. USAGE PATCH(VARIABLE,MASK)         #
  3488. # WHERE VARIABLE IS A STRING AND MASK IS A STRING. MASK CONTAINS       #
  3489. # A SEQUENCE THAT TRANSFORMS VARIABLE. THE # CHARACTER MEANS TO        #
  3490. # COPY THE CHARACTER AT THAT POSITION. THE $ CHARACTER MEANS TO        #
  3491. # DELETE THE CURRENT CHARACTER AT THAT POSITION. ANY OTHER BYTES       #
  3492. # GET INSERTED INTO THE VARIABLE AT THEIR RESPECTIVE POSITIONS.        #
  3493. # EXAMPLES : patch("12/03/89","##$##$##") returns 120389               #
  3494. #            patch("120389","##/##/19##") returns 12/03/1989           #
  3495. #            patch("12/03/1989","##$")    returns 12                   #
  3496. #                                                                      #
  3497. ########################################################################
  3498. procedure patch(var,mask)
  3499.   text := ""
  3500.   i    := 0
  3501.   every mark := !mask do
  3502.     {
  3503.     case mark of
  3504.       {
  3505.       "#" : {
  3506.             text ||:= var[(i+:=1)]
  3507.             next
  3508.             }
  3509.       "$" : {
  3510.             i +:= 1
  3511.             next
  3512.             }
  3513.   default : text ||:= mark
  3514.       }
  3515.     }
  3516.   return text
  3517.   end
  3518.  
  3519. #############################################################
  3520. Chris Tenaglia (System Manager)
  3521. Medical College of Wisconsin
  3522. 8701 W. Watertown Plank Rd.
  3523. Milwaukee, WI 53226
  3524. (414)257-8765
  3525. tenaglia@mis.mcw.edu
  3526.  
  3527.  
  3528.  
  3529. From wgg@cs.washington.edu  Wed Mar 14 17:54:59 1990
  3530. Received: from june.cs.washington.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3531.     id AA02804; Wed, 14 Mar 90 17:54:59 MST
  3532. Received: by june.cs.washington.edu (5.61/7.0jh)
  3533.     id AA20769; Wed, 14 Mar 90 16:54:34 -0800
  3534. Date: Wed, 14 Mar 90 16:54:34 -0800
  3535. From: wgg@cs.washington.edu (William Griswold)
  3536. Return-Path: <wgg@cs.washington.edu>
  3537. Message-Id: <9003150054.AA20769@june.cs.washington.edu>
  3538. To: icon-group@cs.arizona.edu, tenaglia@mis.mcw.edu
  3539. Subject: Re:  Handy Icon Procedure for Reports
  3540. Status: O
  3541.  
  3542. An Icon programmer writes...
  3543.  
  3544. >Date: Wed, 14 Mar 90 15:05:15 CDT
  3545. >From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  3546. >To: icon-group@cs.arizona.edu
  3547. >Subject: Handy Icon Procedure for Reports
  3548. >Errors-To: icon-group-errors@cs.arizona.edu
  3549. >Status: R
  3550. >
  3551. >Dear Icon Group :
  3552. >
  3553. >I am including a handy procedure that can reformat strings. It's
  3554. >fairly intuitive as far as usage is concerned. My implementaion
  3555. >is pretty plain. Perhaps someone has a more elegant expression
  3556. >that makes use of string scanning or co-expressions? Enjoy!
  3557. >
  3558.  
  3559. Although the paradigm is a little different, there are a whole class of
  3560. problems like this that can be cleverly implemented in one line with the
  3561. map() function.  In one of the later chapters of the Icon book there are
  3562. several examples.  Perhaps someone would like to submit some....
  3563.  
  3564.                     Bill Griswold
  3565.  
  3566.  
  3567. From goer@sophist.uchicago.EDU  Wed Mar 14 18:04:23 1990
  3568. Resent-From: goer@sophist.uchicago.EDU
  3569. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3570.     id AA03325; Wed, 14 Mar 90 18:04:23 MST
  3571. Return-Path: goer@Arizona.edu
  3572. Received: from tank.uchicago.edu by Arizona.EDU; Wed, 14 Mar 90 17:55 MST
  3573. Received: from sophist.uchicago.edu by tank.uchicago.edu Wed, 14 Mar 90
  3574.  18:54:59 CST
  3575. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA03952; Wed, 14 Mar 90
  3576.  18:26:35 CST
  3577. Resent-Date: Wed, 14 Mar 90 18:02 MST
  3578. Date: Wed, 14 Mar 90 18:26:35 CST
  3579. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  3580. Subject: patch; using string scanning
  3581. Resent-To: icon-group@cs.arizona.edu
  3582. To: icon-group@arizona.edu
  3583. Resent-Message-Id: <C52255ED54FFC05ACC@Arizona.EDU>
  3584. Message-Id: <9003150026.AA03952@sophist.uchicago.edu>
  3585. X-Envelope-To: icon-group@CS.Arizona.EDU
  3586. X-Vms-To: icon-group@Arizona.edu
  3587. Status: O
  3588.  
  3589.  
  3590. I liked the previous posting, and I don't think there was anything
  3591. wrong with it.  String scanning just seems a bit clearer to me than
  3592. the i/j stuff.  This is how I would have done it:
  3593.  
  3594. procedure patch(var,mask)
  3595.   text := ""
  3596.   var ? {
  3597.     every chr := !mask do {
  3598.       case chr of {
  3599.         "#" : text ||:= move(1)
  3600.         "$" : move(1)
  3601.         default : text ||:= chr
  3602.         }
  3603.       }
  3604.     }
  3605.   return text
  3606. end
  3607.  
  3608. Warning, warning:  This code fragment has not been tested (though
  3609. with Icon it's pretty hard to screw up something of this sort).
  3610.  
  3611.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  3612.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  3613.  
  3614. From icon-group-request@arizona.edu  Fri Mar 16 15:06:10 1990
  3615. Resent-From: icon-group-request@arizona.edu
  3616. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3617.     id AA01622; Fri, 16 Mar 90 15:06:10 MST
  3618. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Fri, 16 Mar 90 13:52 MST
  3619. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA29091; Fri, 16 Mar 90
  3620.  12:43:34 -0800
  3621. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3622.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3623.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3624. Resent-Date: Fri, 16 Mar 90 14:06 MST
  3625. Date: 16 Mar 90 15:58:20 GMT
  3626. From: mcsun!ukc!dcl-cs!se@uunet.uu.NET
  3627. Subject: icon on a PC
  3628. Sender: icon-group-request@arizona.edu
  3629. Resent-To: icon-group@cs.arizona.edu
  3630. To: icon-group@arizona.edu
  3631. Resent-Message-Id: <C3B0EE8559BFE00341@Arizona.EDU>
  3632. Message-Id: <891@dcl-vitus.comp.lancs.ac.uk>
  3633. Organization: Department of Computing at Lancaster University, UK.
  3634. X-Envelope-To: icon-group@CS.Arizona.EDU
  3635. X-Vms-To: icon-group@Arizona.edu
  3636. Status: O
  3637.  
  3638. I recently helped to install Icon on the University's Sequent Symmetry S81
  3639. and then put on some workshops to 'educate the masses'.
  3640. I'm now being inundated with questions from people who were so impressed
  3641. they got a copy to run on their PCs. They're now coming to me with questions
  3642. about the implementation that I cannot answer. Anyone care to help?
  3643.  
  3644. 1) Is there a PC version of icon which creates an executable file
  3645.    instead of having to run the ICONCX program every time?
  3646.  
  3647. 2) Text files which I want to process using icon involve home-made
  3648.    fonts created in Pascal. What is the possibility of processing such
  3649.    fonts in icon?
  3650.  
  3651. 3) I keep getting an error message 'inadequate space in block region'.
  3652.    Is there an environment variable that can be set to stop this? This 
  3653.    happens with long files.
  3654.  
  3655. Thanks in advance for any light shed on these problems.
  3656.  
  3657. Steve
  3658.  
  3659.  
  3660.  
  3661. -- 
  3662. NAME:    Steve Elliott            WORK PHONE: +44 524 65201 ext 3783
  3663. EMAIL:    se@uk.ac.lancs.comp
  3664. POST:    University of Lancaster, Department of Computing,
  3665.     Engineering Building, Bailrigg, Lancaster, LA1 4YR, UK.
  3666.  
  3667. From nowlin@iwtqg.att.COM  Fri Mar 16 17:23:41 1990
  3668. Resent-From: nowlin@iwtqg.att.COM
  3669. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3670.     id AA12143; Fri, 16 Mar 90 17:23:41 MST
  3671. Received: from att-in.att.com by Arizona.EDU; Fri, 16 Mar 90 15:47 MST
  3672. Resent-Date: Fri, 16 Mar 90 16:38 MST
  3673. Date: Fri, 16 Mar 90 16:41 CST
  3674. From: nowlin@iwtqg.att.COM
  3675. Subject: RE: icon on a PC
  3676. Resent-To: icon-group@cs.arizona.edu
  3677. To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  3678. Resent-Message-Id: <C39BA908DB1FE003CD@Arizona.EDU>
  3679. Message-Id: <C3A2DF4FF35FE003B5@Arizona.EDU>
  3680. >From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  3681. X-Envelope-To: icon-group@CS.Arizona.EDU
  3682. X-Vms-To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  3683. Status: O
  3684.  
  3685. > 1) Is there a PC version of icon which creates an executable file
  3686. >    instead of having to run the ICONCX program every time?
  3687.  
  3688. No.
  3689.  
  3690. > 2) Text files which I want to process using icon involve home-made
  3691. >    fonts created in Pascal. What is the possibility of processing such
  3692. >    fonts in icon?
  3693.  
  3694. That's up to you to implement but Icon should be up to it.
  3695.  
  3696. > 3) I keep getting an error message 'inadequate space in block region'.
  3697. >    Is there an environment variable that can be set to stop this? This 
  3698. >    happens with long files.
  3699.  
  3700. The third one I'm familiar with on a number of systems.  Define HEAPSIZE to
  3701. be larger than the default for your system to get rid of that problem.  The
  3702. default on the system I use (3B2) is 51,200 so I use 100,000 when I start
  3703. to get the block region warning.
  3704.  
  3705. Jerry Nowlin
  3706.  
  3707. From cjeffery  Fri Mar 16 17:41:50 1990
  3708. Received: from caslon.cs.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3709.     id AA13199; Fri, 16 Mar 90 17:41:50 MST
  3710. Date: Fri, 16 Mar 90 17:41:48 mst
  3711. From: "Clinton Jeffery" <cjeffery>
  3712. Message-Id: <9003170041.AA14968@caslon>
  3713. Received: by caslon; Fri, 16 Mar 90 17:41:48 mst
  3714. To: icon-group
  3715. In-Reply-To: nowlin@iwtqg.att.COM's message of Fri, 16 Mar 90 16:41 CST <C3A2DF4FF35FE003B5@Arizona.EDU>
  3716. Subject: icon on a PC
  3717. Status: O
  3718.  
  3719. >> 3) I keep getting an error message 'inadequate space in block region'.
  3720. >>    Is there an environment variable that can be set to stop this? This 
  3721. >>    happens with long files.
  3722.  
  3723. >The third one I'm familiar with on a number of systems.  Define HEAPSIZE to
  3724. >be larger than the default for your system to get rid of that problem.  The
  3725. >default on the system I use (3B2) is 51,200 so I use 100,000 when I start
  3726. >to get the block region warning.
  3727.  
  3728. This is the correct answer.  Unfortunately, I have my doubts as to whether
  3729. most MS-DOS Icon implementations can support HEAPSIZE values larger than
  3730. 64K due to the segmentation of the 8086 architecture.  Large Icon programs
  3731. have to be designed well in order to run under MS-DOS.  Version 8.0 of
  3732. Icon is more space-efficient in its use of the block region.
  3733.  
  3734. From icon-group-request@arizona.edu  Tue Mar 20 05:56:18 1990
  3735. Resent-From: icon-group-request@arizona.edu
  3736. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3737.     id AA05939; Tue, 20 Mar 90 05:56:18 MST
  3738. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 20 Mar 90 05:46 MST
  3739. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20684; Tue, 20 Mar 90
  3740.  04:33:00 -0800
  3741. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3742.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3743.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3744. Resent-Date: Tue, 20 Mar 90 05:48 MST
  3745. Date: 18 Mar 90 22:36:53 GMT
  3746. From: cs.utexas.edu!news-server.csri.toronto.edu!qucdn!walmslec@tut.cis.ohio-state.EDU
  3747. Subject: RE: icon on a PC
  3748. Sender: icon-group-request@arizona.edu
  3749. Resent-To: icon-group@cs.arizona.edu
  3750. To: icon-group@arizona.edu
  3751. Resent-Message-Id: <C0D1CFD280BFE00F37@Arizona.EDU>
  3752. Message-Id: <90077.173653WALMSLEC@QUCDN.BITNET>
  3753. Organization: Queen's University at Kingston
  3754. X-Envelope-To: icon-group@CS.Arizona.EDU
  3755. X-Vms-To: icon-group@Arizona.edu
  3756. References: <C3A2DF4FF35FE003B5@Arizona.EDU>, <9003170041.AA14968@caslon>
  3757. Status: O
  3758.  
  3759. Regarding Icon version 8.0.
  3760.  
  3761. Is it available yet, if not then when, and what new features, fixes will it
  3762. provide?
  3763.  
  3764. thanks
  3765. chris
  3766. -------
  3767. |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~|
  3768. | Christopher J. M. Walmsley                 |  Queen's University     |
  3769. | BITNET:  WALMSLEC@QUCDN                    |  Kingston, Ontario      |
  3770. | X.400:   Christopher.Walmsley@QueensU.CA   |  Canada                 |
  3771. |                                            |                         |
  3772. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3773.  
  3774. From ralph  Tue Mar 20 06:26:57 1990
  3775. Resent-From: "Ralph Griswold" <ralph>
  3776. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3777.     id AA07059; Tue, 20 Mar 90 06:26:57 MST
  3778. Received: from megaron.cs.arizona.edu by Arizona.EDU; Tue, 20 Mar 90 06:07 MST
  3779. Received: by megaron.cs.arizona.edu (5.59-1.7/15) id AA06718; Tue, 20 Mar 90
  3780.  06:06:58 MST
  3781. Resent-Date: Tue, 20 Mar 90 06:18 MST
  3782. Date: Tue, 20 Mar 90 06:06:58 MST
  3783. From: Ralph Griswold <ralph@cs.arizona.edu>
  3784. Subject: RE: icon on a PC
  3785. Resent-To: icon-group@cs.arizona.edu
  3786. To: cs.utexas.edu!news-server.csri.toronto.edu!qucdn!walmslec@tut.cis.ohio-state.EDU,
  3787.         icon-group@arizona.edu
  3788. Resent-Message-Id: <C0CDA5E3797FE00A45@Arizona.EDU>
  3789. Message-Id: <9003201306.AA06718@megaron.cs.arizona.edu>
  3790. In-Reply-To: <90077.173653WALMSLEC@QUCDN.BITNET>
  3791. X-Envelope-To: icon-group@CS.Arizona.EDU
  3792. X-Vms-To: 
  3793.  cs.utexas.edu!news-server.csri.toronto.edu!qucdn!walmslec@tut.cis.ohio-state.EDU,
  3794.  icon-group@Arizona.edu
  3795. Status: O
  3796.  
  3797. Version 8 of Icon will be released on a system-by-system basis as we
  3798. get individual implementations and documentation done.
  3799.  
  3800. We expect to release Version 8 for UNIX and VMS in a few weeks.  Others
  3801. will follow as time and resources permit.
  3802.  
  3803. We'll provide a summary of new features and other relevant information
  3804. when the first release is announced.
  3805.  
  3806.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  3807.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  3808.  
  3809. From tenaglia@fps.mcw.edu  Wed Mar 21 11:26:58 1990
  3810. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3811.     id AA24446; Wed, 21 Mar 90 11:26:58 MST
  3812. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  3813.     id AA14178; Wed, 21 Mar 90 13:26:47 EST
  3814. Received: by uwm.edu; id AA06632; Wed, 21 Mar 90 12:25:18 -0600
  3815. Message-Id: <9003211825.AA06632@uwm.edu>
  3816. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  3817.           Wed, 21 Mar 90 11:54:37 CDT
  3818. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  3819.           Wed, 21 Mar 90 11:54:14 CDT
  3820. Date: Wed, 21 Mar 90 11:54:14 CDT
  3821. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  3822. To: icon-group@cs.arizona.edu
  3823. Subject: Icon Ideas ?
  3824. Status: O
  3825.  
  3826.  
  3827. I've noticed in the Icon Newsletter discussion of an object oriented version
  3828. of Icon (IDOL?). It makes use of the $ character. Somehow I can never quite
  3829. seem to comprehend this 'object oriented' stuff. It looks like kloojed
  3830. terminology.
  3831.  
  3832. But back to the $.
  3833.  
  3834. I wonder about the use of the $ to create user define operators. For example:
  3835.  
  3836. operation("$+",lst)
  3837.   case *lst of
  3838.     {
  3839.     1 : return &null                    # unary form not defined
  3840.     2 : return lst[1] || " " || lst[2]  # binary form ok
  3841.     }
  3842.   end
  3843.  
  3844. Later ...
  3845.  
  3846. a := b $+ c     # 'a' is 'b' appended with a space and then 'c'
  3847. d := $+e        # unary form should fail or be &null
  3848. x $+:= z        # augmented form appends blank and 'z' to 'x'
  3849.  
  3850. Is this a desirable 'feature' for Icon 8.2 or 9.0? Or would it be impractical?
  3851.  
  3852. Chris Tenaglia (System Manager)
  3853. Medical College of Wisconsin
  3854. 8701 W. Watertown Plank Rd.
  3855. Milwaukee, WI 53226
  3856. (414)257-8765
  3857. tenaglia@mis.mcw.edu
  3858.  
  3859.  
  3860. From icon-group-request@arizona.edu  Thu Mar 22 22:36:35 1990
  3861. Resent-From: icon-group-request@arizona.edu
  3862. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3863.     id AA09424; Thu, 22 Mar 90 22:36:35 MST
  3864. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 22 Mar 90 22:31 MST
  3865. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA18719; Thu, 22 Mar 90
  3866.  21:27:49 -0800
  3867. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3868.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3869.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3870. Resent-Date: Thu, 22 Mar 90 22:34 MST
  3871. Date: 23 Mar 90 05:27:19 GMT
  3872. From: zaphod.mps.ohio-state.edu!uwm.edu!csd4.csd.uwm.edu!corre@tut.cis.ohio-state.EDU
  3873. Subject: RE: icon on a PC
  3874. Sender: icon-group-request@arizona.edu
  3875. Resent-To: icon-group@cs.arizona.edu
  3876. To: icon-group@arizona.edu
  3877. Resent-Message-Id: <BEB2F93CF23FE01986@Arizona.EDU>
  3878. Message-Id: <3028@uwm.edu>
  3879. Organization: University of Wisconsin-Milwaukee
  3880. X-Envelope-To: icon-group@CS.Arizona.EDU
  3881. X-Vms-To: icon-group@Arizona.edu
  3882. References: <891@dcl-vitus.comp.lancs.ac.uk>
  3883. Status: O
  3884.  
  3885.  
  3886.  
  3887. I use custom made characters on my Zenith by loading a table of
  3888. chars 128-255 into memory, then going to the graphics screen with
  3889. writes("\e[=6h")
  3890. I first install the ANSI.SYS terminal driver by including the
  3891. relevant command in the CONFIG.SYS file.
  3892. --
  3893. Alan D. Corre
  3894. Department of Hebrew Studies
  3895. University of Wisconsin-Milwaukee                     (414) 229-4245
  3896. PO Box 413, Milwaukee, WI 53201               corre@csd4.csd.uwm.edu
  3897.  
  3898. From icon-group-request@arizona.edu  Mon Mar 26 09:07:23 1990
  3899. Resent-From: icon-group-request@arizona.edu
  3900. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3901.     id AA01386; Mon, 26 Mar 90 09:07:23 MST
  3902. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Mon, 26 Mar 90 09:02 MST
  3903. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA07097; Mon, 26 Mar 90
  3904.  07:53:56 -0800
  3905. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  3906.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  3907.  usenet@ucbvax.Berkeley.EDU if you have questions)
  3908. Resent-Date: Mon, 26 Mar 90 09:05 MST
  3909. Date: 26 Mar 90 15:39:54 GMT
  3910. From: consp22@bingvaxu.cc.binghamton.EDU
  3911. Subject: Need general Info
  3912. Sender: icon-group-request@arizona.edu
  3913. Resent-To: icon-group@cs.arizona.edu
  3914. To: icon-group@arizona.edu
  3915. Resent-Message-Id: <BBFF54C3DDFFE03131@Arizona.EDU>
  3916. Message-Id: <3210@bingvaxu.cc.binghamton.edu>
  3917. Organization: SUNY Binghamton POD consultants
  3918. X-Envelope-To: icon-group@CS.Arizona.EDU
  3919. X-Vms-To: icon-group@Arizona.edu
  3920. Status: O
  3921.  
  3922.  
  3923.     I was asked to do some 'poking' around to see what I could
  3924. find out about icon.  We are looking into using it to pre-process some
  3925. information before moving the data down to a micro.  If somebody would
  3926. to be so kind as to give me or direct me to information on the language.
  3927.  
  3928.                         Thank you,
  3929.  
  3930. -------------------------------------------------------------------------------
  3931. |  Consp22@Bingsuns.pod.binghamton.edu  |  SUNY-B Computer Consultants -      |
  3932. |  Consp22@Bingvaxu.cc.binghamton.edu   |  Trying to keep the world safe from |
  3933. |---------------------------------------|  the SUNY-B Computer users.         |
  3934. |  Consultant/Techie - World Computers  |-------------------------------------|
  3935. |  Computer Cons. - SUNY Binghamton     |     Darren `Mac Hack' Handler       |
  3936. |-----------------------------------------------------------------------------|
  3937. I don't know if I am going to heaven or hell, I just hope God grades on a curve
  3938.  
  3939. From tenaglia@fps.mcw.edu  Mon Mar 26 18:29:53 1990
  3940. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  3941.     id AA03233; Mon, 26 Mar 90 18:29:53 MST
  3942. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  3943.     id AA16891; Mon, 26 Mar 90 19:19:10 EST
  3944. Received: by uwm.edu; id AA06342; Mon, 26 Mar 90 14:43:35 -0600
  3945. Message-Id: <9003262043.AA06342@uwm.edu>
  3946. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  3947.           Mon, 26 Mar 90 14:04:18 CDT
  3948. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  3949.           Mon, 26 Mar 90 13:31:24 CDT
  3950. Date: Mon, 26 Mar 90 13:31:24 CDT
  3951. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  3952. To: icon-group@cs.arizona.edu
  3953. Subject: Re: Icon Ideas ?
  3954. X-Vms-Mail-To: UUCP%"langley@DG-RTP.DG.COM"
  3955. Status: O
  3956.  
  3957. In response to a response to my posting,....
  3958.  
  3959. > > But back to the $.
  3960. > >
  3961. > > I wonder about the use of the $ to create user define operators. For example:
  3962. > >
  3963. > > operation("$+",lst)
  3964. > >   case *lst of
  3965. > >     {
  3966. > >     1 : return &null                    # unary form not defined
  3967. > >     2 : return lst[1] || " " || lst[2]  # binary form ok
  3968. > >     }
  3969. > >   end
  3970. > >
  3971. > > Later ...
  3972. > >
  3973. > > a := b $+ c     # 'a' is 'b' appended with a space and then 'c'
  3974. > > d := $+e        # unary form should fail or be &null
  3975. > > x $+:= z        # augmented form appends blank and 'z' to 'x'
  3976. > >
  3977. > > Is this a desirable 'feature' for Icon 8.2 or 9.0? Or would it be impractical?
  3978. >
  3979. > Wouldn't general operator overloading in Icon be better?
  3980.  
  3981. Yes, I gave some thought to overloading some of the existing Icon operators.
  3982.  
  3983. I had had some classes in ADA language which permits this. However, as a
  3984. group of programmers (40 of us) discussed it. The thought that + could be
  3985. * or - made us nervous. A language such as ADA is very strict about DATA TYPES,
  3986. and for it NOT to be strict with the OPERATORS seemed sort of inconsistent.
  3987.  
  3988. My icon background gives me the philosophy of typed operators as well as
  3989. (loosely) typed data/procedures. It seems more natural to keep the user
  3990. defined objects (operators, procedures, variables) separated from the built
  3991. in ones. This is only my opinion, and it may not line up with the goals
  3992. of the Icon project in the long run.
  3993.  
  3994. Chris Tenaglia (System Manager)
  3995. Medical College of Wisconsin
  3996. 8701 W. Watertown Plank Rd.
  3997. Milwaukee, WI 53226
  3998. (414)257-8765
  3999. tenaglia@mis.mcw.edu
  4000.  
  4001.  
  4002. From nowlin@iwtqg.att.COM  Tue Mar 27 00:16:50 1990
  4003. Resent-From: nowlin@iwtqg.att.COM
  4004. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4005.     id AA21961; Tue, 27 Mar 90 00:16:50 MST
  4006. Received: from att-in.att.com by Arizona.EDU; Tue, 27 Mar 90 00:05 MST
  4007. Resent-Date: Tue, 27 Mar 90 00:14 MST
  4008. Date: Mon, 26 Mar 90 23:15 CST
  4009. From: nowlin@iwtqg.att.COM
  4010. Subject: RE: Icon Ideas? (operators)
  4011. Resent-To: icon-group@cs.arizona.edu
  4012. To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  4013. Resent-Message-Id: <BB805174307FE036D9@Arizona.EDU>
  4014. Message-Id: <BB818785EF9FE037D8@Arizona.EDU>
  4015. >From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  4016. X-Envelope-To: icon-group@CS.Arizona.EDU
  4017. X-Vms-To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  4018. Status: O
  4019.  
  4020. > In response to a response to my posting,....
  4021. > > > But back to the $.
  4022. > > >
  4023. > > > I wonder about the use of the $ to create user define operators.
  4024. > >
  4025. > > Wouldn't general operator overloading in Icon be better?
  4026. > Yes, I gave some thought to overloading some of the existing Icon operators.
  4027. > ...
  4028. >
  4029. > My icon background gives me the philosophy of typed operators as well as
  4030. > (loosely) typed data/procedures. It seems more natural to keep the user
  4031. > defined objects (operators, procedures, variables) separated from the built
  4032. > in ones. This is only my opinion, and it may not line up with the goals
  4033. > of the Icon project in the long run.
  4034. > Chris Tenaglia (System Manager)
  4035.  
  4036. I can't remember if Bill's object oriented Icon has operator and function
  4037. overloading or not.  This is my two cents worth and if I've got it all
  4038. wrong I trust someone will let me know.
  4039.  
  4040. The language that has overloaded operators that I'm most familiar with is
  4041. C++.  It discriminates between overloaded operators (functions) by
  4042. enforcing strict typing of operands (arguments).  This is how the compiler
  4043. determines which operation to perform on the operands.  Operators can
  4044. appear to take on almost any type for the programmer working with well
  4045. defined C++ classes.
  4046.  
  4047. Icon, on the other hand, has operands or variables that can be any type.
  4048. To discriminate between different types of operands Icon uses fairly
  4049. strongly typed operators (and functions).  There are exceptions
  4050. (assignment) but for the most part the operators in Icon are type specific.
  4051. I know this because of all the run time errors I generate.  You get a great
  4052. deal of automatic type conversion in Icon but it's driven by the operators
  4053. more than the types of the operands.
  4054.  
  4055. You can add two strings of digits in Icon with the "+" operator but you get
  4056. a numeric result, not a longer string of digits.  You can also concatenate
  4057. two numbers into a string of digits with the "||" operator.  To allow
  4058. overloaded operators would violate this scheme.  How would Icon know
  4059. whether to do automatic type conversion or try for another version of the
  4060. operator that was a better fit to the given operands?  Someone with
  4061. experience in the implementation could shed more light on this.
  4062.  
  4063. User defined operators that are distinguished from built-in operators by an
  4064. explicit syntax are the best compromise but there are an awful lot of
  4065. operators in Icon already.  Procedure names can be very descriptive. (hint)
  4066.  
  4067. Jerry Nowlin
  4068. (...!att!iwtqg!nowlin)
  4069.  
  4070. From kwalker  Tue Mar 27 09:45:16 1990
  4071. Date: Tue, 27 Mar 90 09:45:16 MST
  4072. From: "Kenneth Walker" <kwalker>
  4073. Message-Id: <9003271645.AA17945@megaron.cs.arizona.edu>
  4074. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  4075.     id AA17945; Tue, 27 Mar 90 09:45:16 MST
  4076. In-Reply-To: <BB818785EF9FE037D8@Arizona.EDU>
  4077. To: icon-group
  4078. Subject: RE: Icon Ideas? (operators)
  4079. Status: O
  4080.  
  4081. > Date: Mon, 26 Mar 90 23:15 CST
  4082. > From: nowlin@iwtqg.att.COM
  4083. > You can add two strings of digits in Icon with the "+" operator but you get
  4084. > a numeric result, not a longer string of digits.  You can also concatenate
  4085. > two numbers into a string of digits with the "||" operator.  To allow
  4086. > overloaded operators would violate this scheme.  How would Icon know
  4087. > whether to do automatic type conversion or try for another version of the
  4088. > operator that was a better fit to the given operands?  Someone with
  4089. > experience in the implementation could shed more light on this.
  4090.  
  4091. "+" does give a numeric result, but numeric is either integer or real.
  4092. The decision about whether to do integer arithmetic or real arithmetic
  4093. is made at run-time. If you could replace "+" with with your own operation
  4094. and somehow invoke the old "+" within your operation, you could get the
  4095. effect of overloading. Assuming the function old_op() gets you the built-in
  4096. version, the following operation would enhance "+" to do pair wise addition
  4097. of lists.
  4098.  
  4099. operator +(a,b)
  4100.    if type(a) == type(b) == "list" then {
  4101.       r := []
  4102.       every i := 1 to *a do
  4103.          put(r, old_op(a[i], b[i]))
  4104.       return r
  4105.       }
  4106.    else
  4107.       return old_op(a,b)
  4108. end
  4109.       
  4110. I don't necessarily think being able to arbitrarily redefine operators
  4111. is a good idea. It leaves you with too few features in the language
  4112. whose meaning you can "trust" while reading a program. The idea of
  4113. being able to add new operators does not have this problem. However,
  4114. no one has brought up the problems of precedence and associtivity.
  4115. Does a $- b - c mean (a $- b) - c or a $- (b - c)? You need something
  4116. in your definition of an operator to deal with this.
  4117.  
  4118. Currently, the organization of icont does not allow you to add new
  4119. operators. With the tools we use to make icont, it is possible to
  4120. organize a translator so that adding new operators can be done, but
  4121. you must decide on a fixed set of precedences. If you decide "+"
  4122. is at precedence 12 and "*" is at precedence 13, you will not be
  4123. able to add operators with intermediate precedences. If you fix
  4124. them at 12 and 15, you are limited to 2 levels of precedence between
  4125. them. To get around these problems (which are not particularly
  4126. serious), you would need a different kind of parser within icont.
  4127.  
  4128.   Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  4129.   +1 602 621 2858  kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker
  4130.  
  4131. From tenaglia@fps.mcw.edu  Tue Mar 27 10:22:43 1990
  4132. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4133.     id AA20477; Tue, 27 Mar 90 10:22:43 MST
  4134. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  4135.     id AA23876; Tue, 27 Mar 90 11:18:50 EST
  4136. Received: by uwm.edu; id AA23916; Tue, 27 Mar 90 09:22:38 -0600
  4137. Message-Id: <9003271522.AA23916@uwm.edu>
  4138. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  4139.           Tue, 27 Mar 90 09:13:57 CDT
  4140. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  4141.           Tue, 27 Mar 90 08:46:42 CDT
  4142. Date: Tue, 27 Mar 90 08:46:42 CDT
  4143. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  4144. To: icon-group@cs.arizona.edu
  4145. Subject: VMS Icon 7.0 process cleanup
  4146. Status: O
  4147.  
  4148. I'm running Icon 7.0 on a VAX with VMS 5.2. I've noticed a little problem.
  4149.  
  4150. With files this code fragment works as expected :
  4151.  
  4152.           (inf := open(file)) | stop("Can't open ",file)
  4153.           while line := read(inf) do
  4154.             if find(target,line) then break
  4155.           close(inf)
  4156.           return line
  4157.  
  4158. But with processes something goes wrong
  4159.  
  4160.           (inf := open(cmd,"pr") | stop("Can't run ",cmd)
  4161.           while line := read(inf) do
  4162.             if find(target,line) then break
  4163.           close(inf)
  4164.           return line
  4165.  
  4166. The close(inf) doesn't work here. The process stays open. Shouldn't it just
  4167. be killed? Eventually ones process quota is reached and the open fails if
  4168. the fragment is in a loop. Is this fixed in Icon 8? I think the unix versions
  4169. work properly (do they?).
  4170.  
  4171.           (inf := open(cmd,"pr") | stop("Can't run ",cmd)
  4172.           while line := read(inf) do
  4173.             if find(target,line) then temp := line
  4174.           close(inf)
  4175.           return temp
  4176.  
  4177. is my current work-around. But if it generates thousands of lines of output,
  4178. and I'm only interested in the first 10, it's rather wasteful.
  4179.  
  4180. Thanx,
  4181.  
  4182. Chris Tenaglia (System Manager)
  4183. Medical College of Wisconsin
  4184. 8701 W. Watertown Plank Rd.
  4185. Milwaukee, WI 53226
  4186. (414)257-8765
  4187. tenaglia@mis.mcw.edu
  4188.  
  4189.  
  4190. From gudeman  Tue Mar 27 12:19:21 1990
  4191. Date: Tue, 27 Mar 90 12:19:21 MST
  4192. From: "David Gudeman" <gudeman>
  4193. Message-Id: <9003271919.AA00259@megaron.cs.arizona.edu>
  4194. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  4195.     id AA00259; Tue, 27 Mar 90 12:19:21 MST
  4196. To: icon-group
  4197. In-Reply-To: "Kenneth Walker"'s message of Tue, 27 Mar 90 09:45:16 MST <9003271645.AA17945@megaron.cs.arizona.edu>
  4198. Subject: Icon Ideas? (operators)
  4199. Status: O
  4200.  
  4201. Date: Tue, 27 Mar 90 09:45:16 MST
  4202. From: "Kenneth Walker" <kwalker>
  4203.  
  4204. ]I don't necessarily think being able to arbitrarily redefine operators
  4205. ]is a good idea. It leaves you with too few features in the language
  4206. ]whose meaning you can "trust" while reading a program.
  4207.  
  4208. Ken is doing research that involves optimization of Icon programs by
  4209. doing static analysis of the programs.  Obviously this gets harder as
  4210. more things become dependent on run-time conditions.  Perhaps this is
  4211. slightly effecting his opinion? ;-)
  4212.  
  4213. There is an important advantage to overloading operators, though.
  4214. Suppose you write a calculator program.  Of course, inside this
  4215. program you use mathematical operators.  Now suppose you decide to
  4216. upgrade the program to use complex numbers.  You can't just define a
  4217. new type and write functions to operate on complex numbers, you have
  4218. to go through the entire program and replace every arithmetic
  4219. expression such as ``a + b'' with ``add(a,b)'' (if it is in a position
  4220. to take complex values for ``a'' and/or ``b'').  Ick.
  4221.  
  4222. If you could overload Icon's built-in operators, all you would have to
  4223. do is overload the arithmetic operators so that they understood
  4224. complex numbers.  I can think of similar examples for non-numeric
  4225. applications.
  4226.  
  4227. Someone objected that this lets you do strange things like define + to
  4228. do subtraction.  True enough.  But honestly, if a programmer is that
  4229. determined to make write an unreadable program, he can do it just as
  4230. easily without operator overloading.  There is nothing the language
  4231. designer can do about obtuseness of programmers, and it seems
  4232. pointless to try.
  4233.  
  4234. From icon-group-request@arizona.edu  Tue Mar 27 20:15:21 1990
  4235. Resent-From: icon-group-request@arizona.edu
  4236. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4237.     id AA03298; Tue, 27 Mar 90 20:15:21 MST
  4238. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 27 Mar 90 20:17 MST
  4239. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20957; Tue, 27 Mar 90
  4240.  19:03:35 -0800
  4241. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4242.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4243.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4244. Resent-Date: Tue, 27 Mar 90 20:17 MST
  4245. Date: 28 Mar 90 02:30:09 GMT
  4246. From: shelby!csli!poser@decwrl.dec.COM
  4247. Subject: RE: Icon Ideas? (operators)
  4248. Sender: icon-group-request@arizona.edu
  4249. Resent-To: icon-group@cs.arizona.edu
  4250. To: icon-group@arizona.edu
  4251. Resent-Message-Id: <BAD84AEEF71FE032CF@Arizona.EDU>
  4252. Message-Id: <12860@csli.Stanford.EDU>
  4253. Organization: Center for the Study of Language and Information, Stanford U.
  4254. X-Envelope-To: icon-group@CS.Arizona.EDU
  4255. X-Vms-To: icon-group@Arizona.edu
  4256. References: <9003271645.AA17945@megaron.cs.arizona.edu>,
  4257.  <9003271919.AA00259@megaron.cs.arizona.edu>
  4258. Status: O
  4259.  
  4260. In article <9003271919.AA00259@megaron.cs.arizona.edu> gudeman@CS.ARIZONA.EDU ("David Gudeman") writes:
  4261. >
  4262. >If you could overload Icon's built-in operators, all you would have to
  4263. >do is overload the arithmetic operators so that they understood
  4264. >complex numbers.  I can think of similar examples for non-numeric
  4265. >applications.
  4266. >
  4267. >Someone objected that this lets you do strange things like define + to
  4268. >do subtraction.
  4269.  
  4270. There is an intermediate approach available in object-oriented languages
  4271. as well as in languages like ML that provide disjunctive procedure
  4272. definitions. Implement operator overloading as ADDITION of methods for
  4273. new data types, but don't allow pre-defined methods (i.e. the built-in
  4274. operators) to be removed. This guarantees that an operator will have
  4275. the expected semantics when applied to built-in data types and reduces the
  4276. uncertainty to derived types.
  4277.  
  4278. From goer@sophist.uchicago.EDU  Wed Mar 28 11:36:57 1990
  4279. Resent-From: goer@sophist.uchicago.EDU
  4280. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4281.     id AA24195; Wed, 28 Mar 90 11:36:57 MST
  4282. Return-Path: goer@sophist.uchicago.EDU
  4283. Received: from tank.uchicago.edu by Arizona.EDU; Wed, 28 Mar 90 11:38 MST
  4284. Received: from sophist.uchicago.edu by tank.uchicago.edu Wed, 28 Mar 90
  4285.  12:38:40 CST
  4286. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA18812; Wed, 28 Mar 90
  4287.  12:33:15 CST
  4288. Resent-Date: Wed, 28 Mar 90 11:38 MST
  4289. Date: Wed, 28 Mar 90 12:33:15 CST
  4290. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  4291. Subject: icon & prolog
  4292. Resent-To: icon-group@cs.arizona.edu
  4293. To: icon-group@arizona.edu
  4294. Resent-Message-Id: <BA578B75D7DFE0384F@Arizona.EDU>
  4295. Message-Id: <9003281833.AA18812@sophist.uchicago.edu>
  4296. X-Envelope-To: icon-group@CS.Arizona.EDU
  4297. X-Vms-To: icon-group@Arizona.edu
  4298. Status: O
  4299.  
  4300. Just an idle question:  Has anyone thought of implementing
  4301. Prolog in Icon, either as a Prolog -> Icon translator, or
  4302. as a Prolog interpreter written in Icon?  I'm not a Prolog
  4303. expert, but it occurs to me that Icon might offer facili-
  4304. ties to make such a project much easier than it might be
  4305. for most other languages.
  4306.  
  4307. Just curious.
  4308.  
  4309.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  4310.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  4311.  
  4312. From gudeman  Wed Mar 28 13:15:06 1990
  4313. Resent-From: "David Gudeman" <gudeman>
  4314. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4315.     id AA01233; Wed, 28 Mar 90 13:15:06 MST
  4316. Received: from megaron.cs.arizona.edu by Arizona.EDU; Wed, 28 Mar 90 13:15 MST
  4317. Received: by megaron.cs.arizona.edu (5.59-1.7/15) id AA01095; Wed, 28 Mar 90
  4318.  13:12:49 MST
  4319. Resent-Date: Wed, 28 Mar 90 13:16 MST
  4320. Date: Wed, 28 Mar 90 13:12:49 MST
  4321. From: David Gudeman <gudeman@cs.arizona.edu>
  4322. Subject: icon & prolog
  4323. Resent-To: icon-group@cs.arizona.edu
  4324. To: icon-group@arizona.edu
  4325. Resent-Message-Id: <BA49E0F5B17FE0433E@Arizona.EDU>
  4326. Message-Id: <9003282012.AA01095@megaron.cs.arizona.edu>
  4327. In-Reply-To: Richard Goerwitz's message of Wed, 28 Mar 90 12:33:15 CST
  4328.  <9003281833.AA18812@sophist.uchicago.edu>
  4329. X-Envelope-To: icon-group@CS.Arizona.EDU
  4330. X-Vms-To: icon-group@Arizona.edu
  4331. Status: O
  4332.  
  4333.    From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  4334.  
  4335.    Just an idle question:  Has anyone thought of implementing
  4336.    Prolog in Icon, either as a Prolog -> Icon translator, or
  4337.    as a Prolog interpreter written in Icon?  I'm not a Prolog
  4338.    expert, but it occurs to me that Icon might offer facili-
  4339.    ties to make such a project much easier than it might be
  4340.    for most other languages.
  4341.  
  4342. I wrote an interpreter for a small logic language in Icon, not much
  4343. like Prolog, but it did do goal-directed unification with backtracking
  4344. like Prolog does.  Your intuition is correct that Icon makes this
  4345. easy, at least for an interpreter.  I was able to use Icon's
  4346. goal-directed evaluation to do all the goal-directed evualation of the
  4347. logic language, so I didn't have to keep track of states or anything
  4348. like that.
  4349.  
  4350. I just looked for the code I wrote, and it seems to have disapeared.
  4351. Oh well.
  4352.  
  4353. From icon-group-request@arizona.edu  Thu Mar 29 04:47:01 1990
  4354. Resent-From: icon-group-request@arizona.edu
  4355. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4356.     id AA01727; Thu, 29 Mar 90 04:47:01 MST
  4357. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 29 Mar 90 04:46 MST
  4358. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20318; Thu, 29 Mar 90
  4359.  03:42:50 -0800
  4360. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4361.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4362.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4363. Resent-Date: Thu, 29 Mar 90 04:47 MST
  4364. Date: 29 Mar 90 10:54:12 GMT
  4365. From: zaphod.mps.ohio-state.edu!usc!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  4366. Subject: RE: icon & prolog
  4367. Sender: icon-group-request@arizona.edu
  4368. Resent-To: icon-group@cs.arizona.edu
  4369. To: icon-group@arizona.edu
  4370. Resent-Message-Id: <B9C7EB4F5BDFE04741@Arizona.EDU>
  4371. Message-Id: <1996@bruce.OZ>
  4372. Organization: Monash Uni. Computer Science, Australia
  4373. X-Envelope-To: icon-group@CS.Arizona.EDU
  4374. X-Vms-To: icon-group@Arizona.edu
  4375. References: <9003281833.AA18812@sophist.uchicago.edu>
  4376. Status: O
  4377.  
  4378. In article <9003281833.AA18812@sophist.uchicago.edu>, goer@SOPHIST.UCHICAGO.EDU (Richard Goerwitz) writes:
  4379. > Just an idle question:  Has anyone thought of implementing
  4380. > Prolog in Icon, either as a Prolog -> Icon translator, or
  4381. > as a Prolog interpreter written in Icon?  I'm not a Prolog ...
  4382.  
  4383. I wrote a Prolog interpreter in Icon some time ago.  I never got
  4384. around to doing anything with it (i.e. publishing wise).  I was
  4385. in the process of writing the converse (Icon interpreter in Prolog)
  4386. when I got sidetracked.  I will post the sources and documentation.
  4387. There were four versions in increasing order of complexity.  I only got
  4388. around to documentation for versions 1 and 2.  The versions appear to
  4389. have implemented the following incrementally:
  4390.     1. Basic pure Prolog with negation by failure,
  4391.     2. List notation added (syntactic sugar),
  4392.     3. Assert and Retract,
  4393.     4. Cut.
  4394.  
  4395. The program documentation files *.doc are in troff format.  They're still
  4396. readable however.  The user guides *.usr are just plain text.  The source
  4397. is copyright in the sense that it can be used anywhere for any purpose 
  4398. provided the copyright is maintained and I get credit for my work.
  4399.  
  4400. I would be interested in any comments about the code.  I was trying to get
  4401. as succinct a source file as possible without sacrificing clarity (but its
  4402. always tempting to save a line here and there!).
  4403.  
  4404. From icon-group-request@arizona.edu  Thu Mar 29 05:02:47 1990
  4405. Resent-From: icon-group-request@arizona.edu
  4406. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4407.     id AA02405; Thu, 29 Mar 90 05:02:47 MST
  4408. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 29 Mar 90 05:02 MST
  4409. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20510; Thu, 29 Mar 90
  4410.  03:47:58 -0800
  4411. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4412.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4413.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4414. Resent-Date: Thu, 29 Mar 90 05:04 MST
  4415. Date: 29 Mar 90 11:10:30 GMT
  4416. From: zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  4417. Subject: Prolog in Icon (version 1)
  4418. Sender: icon-group-request@arizona.edu
  4419. Resent-To: icon-group@cs.arizona.edu
  4420. To: icon-group@arizona.edu
  4421. Resent-Message-Id: <B9C573061FDFE04C55@Arizona.EDU>
  4422. Message-Id: <1997@bruce.OZ>
  4423. Organization: Monash Uni. Computer Science, Australia
  4424. X-Envelope-To: icon-group@CS.Arizona.EDU
  4425. X-Vms-To: icon-group@Arizona.edu
  4426. Status: O
  4427.  
  4428.  
  4429. ########################## global variables and types ######################
  4430.  
  4431. record ctxt(env,subst)    # integer[string] * ((integer | struct | null) list)
  4432. record struct(name,args)  # string * ((integer | struct) list)
  4433. record rule(ids,head,body)# string list * predicate * predicate list \
  4434. record all(ids,body)      # string list * predicate list              } clauses
  4435. record one(ids,body)      # string list * predicate list             /
  4436. record fun(name,args)     # string * predicate list        \ types of 
  4437. record var(name)          # string                         / predicates
  4438. global dbase              # table of clauses indexed by head name
  4439. global consult            # stack of files being consulted
  4440. global query              # top level query
  4441.  
  4442. ################################## driver ##################################
  4443.  
  4444. procedure main()
  4445.    dbase:=table([]); consult:=[&input] # empty dbase; standard input
  4446.    while \query | *consult>0 do { # more queries possible
  4447.       prog() # parse clauses, possibly setting query as a side effect
  4448.       if \query then case type(query) of {
  4449.          "all" : {every printsoln(query); write("no more solutions")}
  4450.          "one" : if not printsoln(query) then write("no")}
  4451.       else pop(consult)}
  4452. end
  4453.  
  4454. procedure printsoln(qry) # print first or next solution to qry 
  4455.    local ans,v
  4456.    every ans:=resolve(qry.body,1,*qry.body,newctxt(qry.ids,[])) do { 
  4457.       writes("yes")
  4458.       every v:=!qry.ids do writes(", ",v,"=",trmstr(ans.env[v],ans.subst))
  4459.       suspend write()}
  4460. end
  4461.  
  4462. ########################### Prolog interpreter #############################
  4463.  
  4464. procedure resolve(qry,hd,tl,ctext) # generates all solutions of qry[hd:tl]
  4465.    local sub,q                     # in given context, returns updated context
  4466.    if hd>tl then return ctext
  4467.    if (q:=qry[hd]).name=="~" then # negation by failure
  4468.       {if not resolve(q.args,1,1,ctext) then suspend resolve(qry,hd+1,tl,ctext)}
  4469.    else every sub:=tryclause(scanpred(q,ctext),!dbase[q.name],ctext.subst) do
  4470.            suspend resolve(qry,hd+1,tl,ctxt(ctext.env,sub))
  4471. end
  4472.  
  4473. procedure tryclause(term,cls,sub) # resolves term using given clause or fails
  4474.    local ctext                    # a copy of sub is used so no side effects
  4475.    ctext:=newctxt(cls.ids,copy(sub)) # preallocate context for whole clause
  4476.    if unify(term,scanpred(cls.head,ctext),ctext.subst) then 
  4477.       suspend resolve(cls.body,1,*cls.body,ctext).subst
  4478. end
  4479.  
  4480. procedure scanpred(prd,ctext) # converts predicate to structure 
  4481.    local args; args:=[] 
  4482.    if type(prd)=="var" then return ctext.env[prd.name]
  4483.    every put(args,scanpred(!prd.args,ctext))
  4484.    return struct(prd.name,args) 
  4485. end
  4486.  
  4487. ######################## primitive domain operations ########################
  4488.  
  4489. procedure unify(t1,t2,sub) # (integer | struct),(integer | struct),sub 
  4490.    local v,i,num           # side effect: sub is updated
  4491.    if type(t1)=="integer" then {
  4492.       while type(v:=sub[t1])=="integer" do t1:=v # apply sub to t1
  4493.       return if type(v)=="struct" then unify(v,t2,sub) else sub[t1]:=t2}
  4494.    if type(t2)=="integer" then return unify(t2,t1,sub)
  4495.    if (t1.name==t2.name) & ((num:=*t1.args)=*t2.args) then {
  4496.       every i:=1 to num do if not unify(t1.args[i],t2.args[i],sub) then fail
  4497.       return}
  4498. end
  4499.  
  4500. procedure newctxt(ids,sub)       # forms a new context by extending sub
  4501.    local env; env:=table(&null)  # to accommodate the unbound identifiers
  4502.    every env[!ids]:=*put(sub,&null)
  4503.    return ctxt(env,sub)
  4504. end
  4505.    
  4506. procedure trmstr(str,sub) # converts a term to a string suitable for output
  4507.    local s; s:=""
  4508.    case type(str) of {
  4509.       "integer" : return trmstr(sub[str],sub)
  4510.       "struct" : {every s:=s||trmstr(!str.args,sub)||","
  4511.                   return str.name||(if *s=0 then "" else "("||s[1:-1]||")")}
  4512.       "null" : return "undefined"}
  4513. end
  4514.  
  4515. ############################## Prolog parser ###############################
  4516.  
  4517. procedure prog() # parses consult[1] until query found or end of file
  4518.    query:=&null
  4519.    while write(read(consult[1])) ? clause() 
  4520.    if /query & consult[1]~===&input then close(consult[1])
  4521. end
  4522.  
  4523. procedure clause() # adds a clause to the dbase or fails when query set
  4524.    local p,b,ids,t; b:=[]; ids:=[]
  4525.    if =":-" then query:=all(ids,b:=body())
  4526.    else if ="?-" then query:=one(ids,b:=body())
  4527.    else {p:=pred(); if =":-" then b:=body()}
  4528.    if (t:=trim(tab(0)))~=="." then # syntax error
  4529.       return write("syntax error: ",t,if *t=0 then "." else " not"," expected")
  4530.    every extractids(ids,\p|!b) # list of variable identifiers
  4531.    if (\p).name=="consult" then every push(consult,open((!p.args).name))
  4532.    return dbase[(\p).name]:=dbase[p.name]|||[rule(ids,p,b)]
  4533. end
  4534.  
  4535. procedure body() # list of predicates
  4536.    local b; b:=[]
  4537.    if put(b,pred()) then while ="," & put(b,pred())
  4538.    return b
  4539. end
  4540.  
  4541. procedure pred() # ~pred | name(body) | uc_name | lc_name()
  4542.    local name,args; args:=[]
  4543.    if ="~" then return fun("~",[pred()])
  4544.    if not (name:=tab(many(&ucase++&lcase++'0123456789._'))) then fail
  4545.    if any(&ucase,name) then return var(name)
  4546.    if ="(" & args:=body() then # arguments parsed
  4547.       if  not =")" then write("syntax error: \")\" expected before ",tab(0))
  4548.    return fun(name,args)
  4549. end
  4550.  
  4551. procedure extractids(ids,pred)
  4552.    if type(pred)=="fun" then every extractids(ids,!pred.args)
  4553.    else if not (pred.name==!ids) then put(ids,pred.name)
  4554.    return
  4555. end
  4556.  
  4557. From icon-group-request@arizona.edu  Thu Mar 29 05:02:53 1990
  4558. Resent-From: icon-group-request@arizona.edu
  4559. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4560.     id AA02430; Thu, 29 Mar 90 05:02:53 MST
  4561. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 29 Mar 90 05:03 MST
  4562. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20775; Thu, 29 Mar 90
  4563.  03:53:51 -0800
  4564. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4565.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4566.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4567. Resent-Date: Thu, 29 Mar 90 05:04 MST
  4568. Date: 29 Mar 90 11:20:55 GMT
  4569. From: zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  4570. Subject: prolog2.usr
  4571. Sender: icon-group-request@arizona.edu
  4572. Resent-To: icon-group@cs.arizona.edu
  4573. To: icon-group@arizona.edu
  4574. Resent-Message-Id: <B9C577C4B95FE04C55@Arizona.EDU>
  4575. Message-Id: <2000@bruce.OZ>
  4576. Organization: Monash Uni. Computer Science, Australia
  4577. X-Envelope-To: icon-group@CS.Arizona.EDU
  4578. X-Vms-To: icon-group@Arizona.edu
  4579. Status: O
  4580.  
  4581.  
  4582.                           Prolog in Icon (version 2)
  4583.                           --------------------------
  4584.                         Alan Finlay, Monash University.
  4585.  
  4586. The Prolog interpretor associated with this file is written in Icon for  a  very
  4587. simple  version  of  pure Prolog.  Cuts, arithmetic, assert and retract are  not
  4588. implemented.   There  is  only  one  non  logical  primitive "consult"  which is
  4589. used as if it were a fact with one argument.  The argument to consult is used as
  4590. a file name and the file is consulted  for  clauses  and queries.   Negation  is
  4591. implemented as negation by failure.  Version two includes list notation.
  4592.  
  4593. Acceptable Prolog programs consist of a list of clauses and queries,   one   per
  4594. line.  The clauses are either facts or rules:
  4595.  
  4596.         predicate.
  4597.         predicate:-predicate,...,predicate.
  4598.  
  4599. A fact is a predicate followed by a full stop.  The syntax of a  predicate  will
  4600. be   described   later.   A rule has a "head" on the left of the turnstile ":-",
  4601. and a "body" on the right.  The body is a  list  of  one  or   more   predicates
  4602. separated   by  commas and terminated by a full stop.  The predicates are simple
  4603. identifiers, identifiers parameterised by one or more  arguments,   or   negated
  4604. predicates:
  4605.  
  4606.         identifier
  4607.         identifier(argument,...,argument)
  4608.         ~predicate
  4609.  
  4610. An identifier is a string of letters, digits,  underline  or  full   stop.    An
  4611. identifier   which   starts  with  an  upper  case  letter  and has no arguments
  4612. associated with it is interpreted as a variable identifier.  The  arguments  are
  4613. syntactically   identical   to  predicates  but  interpreted differently.  Those
  4614. arguments with arguments of their own are called structures, those  without  are
  4615. called   constants   if  not starting with an upper case letter and variables if
  4616. they do.
  4617.  
  4618. A query is like a rule without a head:
  4619.  
  4620.         :-predicate,...,predicate.
  4621.         ?-predicate,...,predicate.
  4622.  
  4623. The first form causes the interpreter to find all solutions to the  query.   The
  4624. second   form   only  asks  for  one  solution.   The interpreter reports values
  4625. assigned to free variables in the  query  and  this  is  the  way   answers   to
  4626. questions more complex than yes/no are obtained.
  4627.  
  4628. As a simple example here is a traditional inference test program
  4629.  
  4630.         mortal(X):-man(X).
  4631.         man(X):-greek(X).
  4632.         greek(socrates).
  4633.         ?-mortal(socrates).
  4634.  
  4635. Try typing in this example after starting the interpreter with the command
  4636.  
  4637.         iconx prolog
  4638.  
  4639. and the response is
  4640.  
  4641.         yes
  4642.  
  4643. After this the interpreter will be waiting for another clause or query   to   be
  4644. entered.  Try entering another query for example
  4645.  
  4646.         ?-mortal(Socrates).
  4647.  
  4648. which produces the strange response
  4649.  
  4650.         yes, Socrates = socrates
  4651.  
  4652. This is because the upper case S indicates a  free  variable.    To   experiment
  4653. with negation try
  4654.  
  4655.         being(X):-man(X).
  4656.         being(X):-god(X).
  4657.         god(apollo).
  4658.         :-being(X),~mortal(X).
  4659.  
  4660. which produces the response
  4661.  
  4662.         yes, X = apollo
  4663.         no more solutions
  4664.  
  4665. Note that negation should only be applied to ground terms (terms with  all   the
  4666. variables bound) or strange behaviour may result.  For example the query
  4667.  
  4668.         :-~mortal(X),being(X).
  4669.  
  4670. which fails with no solutions.
  4671.  
  4672. Finaly send an end of file  to  finish  interpreting  Prolog   commands.    More
  4673. examples   can   be  found  in files "test1.plg", "test2.plg", . . .  To run the
  4674. first of these enter the fact
  4675.  
  4676.         consult(test?.plg).
  4677.  
  4678. etc, after starting the interpreter.
  4679.  
  4680. The list notation is simply  a  set  of  convenient  abbreviations.   Lists  are
  4681. assumed to be represented by using the binary dot constructor "." and "nil". The
  4682. dot constructor should  only  be  applied  to  (element,list)  pairs  and  "nil"
  4683. represents  an  empty list.  An infix version of the dot constructor "|" is also
  4684. provided and is useful for pattern matching.  Some examples follow.
  4685.  
  4686.         abbreviation                    represents
  4687.         []                              nil
  4688.         [1]                             .(1,nil)
  4689.         1|nil                           .(1,nil)
  4690.         [1,2]                           .(1,.(2,nil))
  4691.         [1,2,3,4]                       .(1,.(2,.(3,.(4,nil))))
  4692.         1|2|3|4|nil                     .(1,.(2,.(3,.(4,nil))))
  4693.         [[1,2],[3,4]]                   .(.(1,.(2,nil)),.(.(3,.(4,nil)),nil))
  4694.         1|2                             .(1,2)
  4695.  
  4696. The last example is not a proper list since  the  second  argument  of  the  dot
  4697. constuctor  is  not  a list.  The list [A,B,C,D] must have exactly four elements
  4698. whereas the list A|B|C|D has three or more depending upon the length of the list
  4699. bound to D.  The following two versions of naive reverse are exactly equivalent.
  4700.  
  4701. reverse([],[]).
  4702. reverse(X|Y,Z):-reverse(Y,W),append(W,[X],Z).
  4703. append(X,[],X).
  4704. append([],X,X).
  4705. append(X|Y,Z,X|W):-append(Y,Z,W).
  4706.  
  4707. reverse(nil,nil).
  4708. reverse(.(X,Y),Z):-reverse(Y,W),append(W,.(X,nil),Z).
  4709. append(X,nil,X).
  4710. append(nil,X,X).
  4711. append(.(X,Y),Z,.(X,W)):-append(Y,Z,W).
  4712.  
  4713. From icon-group-request@arizona.edu  Thu Mar 29 05:02:57 1990
  4714. Resent-From: icon-group-request@arizona.edu
  4715. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4716.     id AA02452; Thu, 29 Mar 90 05:02:57 MST
  4717. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 29 Mar 90 05:03 MST
  4718. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20539; Thu, 29 Mar 90
  4719.  03:48:27 -0800
  4720. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4721.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4722.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4723. Resent-Date: Thu, 29 Mar 90 05:04 MST
  4724. Date: 29 Mar 90 11:14:23 GMT
  4725. From: cs.utexas.edu!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  4726. Subject: Prolog in Icon (version 2)
  4727. Sender: icon-group-request@arizona.edu
  4728. Resent-To: icon-group@cs.arizona.edu
  4729. To: icon-group@arizona.edu
  4730. Resent-Message-Id: <B9C57CFA579FE04C55@Arizona.EDU>
  4731. Message-Id: <1998@bruce.OZ>
  4732. Organization: Monash Uni. Computer Science, Australia
  4733. X-Envelope-To: icon-group@CS.Arizona.EDU
  4734. X-Vms-To: icon-group@Arizona.edu
  4735. Status: O
  4736.  
  4737.  
  4738. # Prolog in Icon, version 2, (C) Alan Finlay, Monash University.
  4739. ########################## global variables and types ######################
  4740.  
  4741. record ctxt(env,subst)    # integer[string] * ((integer | struct | null) list)
  4742. record struct(name,args)  # string * ((integer | struct) list)
  4743. record rule(ids,head,body)# string list * predicate * predicate list \
  4744. record all(ids,body)      # string list * predicate list              } clauses
  4745. record one(ids,body)      # string list * predicate list             /
  4746. record fun(name,args)     # string * predicate list        \ types of 
  4747. record var(name)          # string                         / predicates
  4748. global dbase              # table of clauses indexed by head name
  4749. global consult            # stack of files being consulted
  4750. global query              # top level query
  4751.  
  4752. ################################## driver ##################################
  4753.  
  4754. procedure main()
  4755.    dbase:=table([]); consult:=[&input] # empty dbase; standard input
  4756.    while \query | *consult>0 do { # more queries possible
  4757.       prog() # parse clauses, possibly setting query as a side effect
  4758.       if \query then case type(query) of {
  4759.          "all" : {every printsoln(query); write("no more solutions")}
  4760.          "one" : if not printsoln(query) then write("no")}
  4761.       else pop(consult)}
  4762. end
  4763.  
  4764. procedure printsoln(qry) # print first or next solution to qry 
  4765.    local ans,v
  4766.    every ans:=resolve(qry.body,1,*qry.body,newctxt(qry.ids,[])) do { 
  4767.       writes("yes")
  4768.       every v:=!qry.ids do writes(", ",v,"=",trmstr(ans.env[v],ans.subst))
  4769.       suspend write()}
  4770. end
  4771.  
  4772. ########################### Prolog interpreter #############################
  4773.  
  4774. procedure resolve(qry,hd,tl,ctext) # generates all solutions of qry[hd:tl]
  4775.    local sub,q                     # in given context, returns updated context
  4776.    if hd>tl then return ctext
  4777.    if (q:=qry[hd]).name=="~" then # negation by failure
  4778.       {if not resolve(q.args,1,1,ctext) then suspend resolve(qry,hd+1,tl,ctext)}
  4779.    else every sub:=tryclause(scanpred(q,ctext),!dbase[q.name],ctext.subst) do
  4780.            suspend resolve(qry,hd+1,tl,ctxt(ctext.env,sub))
  4781. end
  4782.  
  4783. procedure tryclause(term,cls,sub) # resolves term using given clause or fails
  4784.    local ctext                    # a copy of sub is used so no side effects
  4785.    ctext:=newctxt(cls.ids,copy(sub)) # preallocate context for whole clause
  4786.    if unify(term,scanpred(cls.head,ctext),ctext.subst) then 
  4787.       suspend resolve(cls.body,1,*cls.body,ctext).subst
  4788. end
  4789.  
  4790. procedure scanpred(prd,ctext) # converts predicate to structure 
  4791.    local args; args:=[] 
  4792.    if type(prd)=="var" then return ctext.env[prd.name]
  4793.    every put(args,scanpred(!prd.args,ctext))
  4794.    return struct(prd.name,args) 
  4795. end
  4796.  
  4797. ######################## primitive domain operations ########################
  4798.  
  4799. procedure unify(t1,t2,sub) # (integer | struct),(integer | struct),sub 
  4800.    local v,i,num           # side effect: sub is updated
  4801.    if type(t1)=="integer" then {
  4802.       while type(v:=sub[t1])=="integer" do t1:=v # apply sub to t1
  4803.       return if type(v)=="struct" then unify(v,t2,sub) else sub[t1]:=t2}
  4804.    if type(t2)=="integer" then return unify(t2,t1,sub)
  4805.    if (t1.name==t2.name) & ((num:=*t1.args)=*t2.args) then {
  4806.       every i:=1 to num do if not unify(t1.args[i],t2.args[i],sub) then fail
  4807.       return}
  4808. end
  4809.  
  4810. procedure newctxt(ids,sub)       # forms a new context by extending sub
  4811.    local env; env:=table(&null)  # to accommodate the unbound identifiers
  4812.    every env[!ids]:=*put(sub,&null)
  4813.    return ctxt(env,sub)
  4814. end
  4815.    
  4816. procedure trmstr(trm,sub) # converts a term to a string suitable for output
  4817.    local s; s:=""
  4818.    case type(trm) of {
  4819.       "integer" : return trmstr(sub[trm],sub)
  4820.       "struct" : if s:=lstr(trm,sub) then return "["||s||"]" # non-empty list 
  4821.                  else {every s:=s||trmstr(!trm.args,sub)||","
  4822.                       return trm.name||(if *s=0 then "" else "("||s[1:-1]||")")}
  4823.       "null" : return "undefined"}
  4824. end
  4825.  
  4826. procedure lstr(l,sub) # succeeds if l is a proper non-empty list and
  4827.    local hd,tl        # converts l to string suitable for output
  4828.    if l.name=="." & *l.args=2 then {
  4829.       hd:=trmstr(l.args[1],sub); tl:=l.args[2]
  4830.       while type(tl)=="integer" do tl:=sub[tl] # apply sub to tl
  4831.       case type(tl) of {
  4832.          "struct" : {if tl.name=="nil" & *tl.args=0 then return hd # nil
  4833.                      return hd||","||lstr(tl,sub)}                 # cons
  4834.          "null" : return "undefined"}}
  4835. end
  4836.  
  4837. ############################## Prolog parser ###############################
  4838.  
  4839. procedure prog() # parses consult[1] until query found or end of file
  4840.    query:=&null
  4841.    while write(read(consult[1])) ? clause() 
  4842.    if /query & consult[1]~===&input then close(consult[1])
  4843. end
  4844.  
  4845. procedure clause() # adds a clause to the dbase or fails when query set
  4846.    local p,b,ids,t; b:=[]; ids:=[]
  4847.    if =":-" then query:=all(ids,b:=body())
  4848.    else if ="?-" then query:=one(ids,b:=body())
  4849.    else {p:=pred(); if =":-" then b:=body()}
  4850.    if (t:=trim(tab(0)))~=="." then # syntax error
  4851.       return write("syntax error: ",t,if *t=0 then "." else " not"," expected")
  4852.    every extractids(ids,\p|!b) # list of variable identifiers
  4853.    if (\p).name=="consult" then every push(consult,open((!p.args).name))
  4854.    return dbase[(\p).name]:=dbase[p.name]|||[rule(ids,p,b)]
  4855. end
  4856.  
  4857. procedure body() # list of predicates (may be empty)
  4858.    local b; b:=[]
  4859.    if put(b,pred()) then while ="," & put(b,pred())
  4860.    return b
  4861. end
  4862.  
  4863. procedure dots() # converts non-empty body of list to cons cells
  4864.    local p
  4865.    if p:=pred() then if ="," then return fun(".",[p,dots()])
  4866.                      else return fun (".",[p,fun("nil",[])])
  4867. end
  4868.  
  4869. procedure pred() # ~pred , name(body) , uc_name , lc_name , [body] , pred|pred
  4870.    local name,args,d,p,pp; args:=[]
  4871.    if ="~" then p:=fun("~",[pred()])
  4872.    else if name:=tab(many(&ucase++&lcase++'0123456789._')) then {
  4873.       if any(&ucase,name) then p:=var(name)
  4874.       else {if ="(" & args:=body() then check(")"); p:=fun(name,args)}}
  4875.    else if ="[]" then p:=fun("nil",[]) # empty list abbreviation
  4876.    else if ="[" then {p:=dots(); check("]")} # non-empty list abbreviation
  4877.    if ="|" then if pp:=pred() then return fun(".",[p,pp]) # infix cons
  4878.                 else write("syntax error: missing second argument to \"|\"")
  4879.    return \p # n.b. fails if predicate invalid
  4880. end
  4881.  
  4882. procedure check(s) # report error if s not present or skip over it
  4883.    if not =s then write("syntax error: ",s," expected before ",tab(0))
  4884. end
  4885.  
  4886. procedure extractids(ids,pred) # build the set of variable identifiers 
  4887.    if type(pred)=="fun" then every extractids(ids,!pred.args)
  4888.    else if not (pred.name==!ids) then put(ids,pred.name)
  4889.    return # the identifiers have been appended to reference parameter ids
  4890. end
  4891.  
  4892. From icon-group-request@arizona.edu  Thu Mar 29 05:03:05 1990
  4893. Resent-From: icon-group-request@arizona.edu
  4894. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  4895.     id AA02469; Thu, 29 Mar 90 05:03:05 MST
  4896. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 29 Mar 90 05:03 MST
  4897. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20789; Thu, 29 Mar 90
  4898.  03:54:04 -0800
  4899. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  4900.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  4901.  usenet@ucbvax.Berkeley.EDU if you have questions)
  4902. Resent-Date: Thu, 29 Mar 90 05:04 MST
  4903. Date: 29 Mar 90 11:22:14 GMT
  4904. From: zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  4905. Subject: prolog3.icn
  4906. Sender: icon-group-request@arizona.edu
  4907. Resent-To: icon-group@cs.arizona.edu
  4908. To: icon-group@arizona.edu
  4909. Resent-Message-Id: <B9C583A4465FE04C55@Arizona.EDU>
  4910. Message-Id: <2001@bruce.OZ>
  4911. Organization: Monash Uni. Computer Science, Australia
  4912. X-Envelope-To: icon-group@CS.Arizona.EDU
  4913. X-Vms-To: icon-group@Arizona.edu
  4914. Status: O
  4915.  
  4916.  
  4917.  
  4918.  
  4919. # Prolog in Icon, version 3, (C) Alan Finlay, Monash University.
  4920. ########################## global variables and types ######################
  4921.  
  4922. record ctxt(env,subst)    # integer[string] * ((integer | struct | null) list)
  4923. record struct(name,args)  # string * ((integer | struct) list)
  4924. record rule(ids,head,body)# string list * predicate * predicate list \
  4925. record all(ids,body)      # string list * predicate list              } clauses
  4926. record one(ids,body)      # string list * predicate list             /
  4927. record fun(name,args)     # string * predicate list        \ types of 
  4928. record var(name)          # string                         / predicates
  4929. global dbase              # table of clauses indexed by head name
  4930. global consult            # stack of files being consulted
  4931. global query              # top level query
  4932.  
  4933. ################################## driver ##################################
  4934.  
  4935. procedure main()
  4936.    dbase:=table([]); consult:=[&input] # empty dbase; standard input
  4937.    while \query | *consult>0 do { # more queries possible
  4938.       prog() # parse clauses, possibly setting query as a side effect
  4939.       if \query then case type(query) of {
  4940.          "all" : {every printsoln(query); write("no more solutions")}
  4941.          "one" : if not printsoln(query) then write("no")}
  4942.       else pop(consult)}
  4943. end
  4944.  
  4945. procedure printsoln(qry) # print first or next solution to qry 
  4946.    local ans,v
  4947.    every ans:=resolve(qry.body,1,*qry.body,newctxt(qry.ids,[])) do { 
  4948.       writes("yes")
  4949.       every v:=!qry.ids do writes(", ",v,"=",trmstr(ans.env[v],ans.subst))
  4950.       suspend write()}
  4951. end
  4952.  
  4953. ########################### Prolog interpreter #############################
  4954.  
  4955. procedure resolve(qry,hd,tl,ctext) # generates all solutions of qry[hd:tl]
  4956.    local sub,q,cls,r               # and returns updated context
  4957.    if hd>tl then return ctext
  4958.    case (q:=qry[hd]).name of {
  4959.       "assert"  : {r:=rule([],q.args[1],q.args[2:0])
  4960.                    every extractids(r.ids,!q.args)
  4961.                    dbase[q.args[1].name]:=dbase[q.args[1].name]|||[r]
  4962.                    suspend resolve(qry,hd+1,tl,ctext)} # always succeeds
  4963.       "retract" : suspend retract(q.args[1],ctext) & resolve(qry,hd+1,tl,ctext)
  4964.       "~"       : {if not resolve(q.args,1,1,ctext) then 
  4965.                       suspend resolve(qry,hd+1,tl,ctext)} # negation by failure
  4966.       default   : {goal:=scanpred(q,ctext)
  4967.                    every cls := !dbase[q.name] do
  4968.                       every sub:=tryclause(goal,cls,ctext.subst) do
  4969.                          suspend resolve(qry,hd+1,tl,ctxt(ctext.env,sub))}
  4970.       }
  4971. end
  4972.  
  4973. procedure retract(pred,ctext) # removes a clause matching pred from dbase 
  4974. local cand,goal,entry,i; i:=1 # fails when no more matching clauses to remove
  4975.    goal:=scanpred(pred,ctext)
  4976.    every entry:=!dbase[goal.name] do { # check for matching clause
  4977.       cand:=scanpred(entry.head,newctxt(entry.ids,ctext.subst))
  4978.       if unify(goal,cand,copy(ctext.subst)) then { # found one so remove it
  4979.          dbase[goal.name]:=extract(dbase[goal.name],i) 
  4980.          suspend} # on backtracking more retractions can occur
  4981.       else i+:=1 # i keeps track of the entry number even with extractions
  4982.       }
  4983. end
  4984.  
  4985. procedure tryclause(term,cls,sub) # resolves term using given clause or fails
  4986.    local ctext                    # a copy of sub is used so no side effects
  4987.    ctext:=newctxt(cls.ids,copy(sub)) # preallocate context for whole clause
  4988.    if unify(term,scanpred(cls.head,ctext),ctext.subst) then 
  4989.       suspend resolve(cls.body,1,*cls.body,ctext).subst
  4990. end
  4991.  
  4992. procedure scanpred(prd,ctext) # converts predicate to structure 
  4993.    local args; args:=[] 
  4994.    if type(prd)=="var" then return ctext.env[prd.name]
  4995.    every put(args,scanpred(!prd.args,ctext))
  4996.    return struct(prd.name,args) 
  4997. end
  4998.  
  4999. ######################## primitive domain operations ########################
  5000.  
  5001. procedure unify(t1,t2,sub) # (integer | struct),(integer | struct),sub 
  5002.    local v,i,num           # side effect: sub is updated
  5003.    if type(t1)=="integer" then {
  5004.       while type(v:=sub[t1])=="integer" do t1:=v # apply sub to t1
  5005.       return if type(v)=="struct" then unify(v,t2,sub) else sub[t1]:=t2}
  5006.    if type(t2)=="integer" then return unify(t2,t1,sub)
  5007.    if (t1.name==t2.name) & ((num:=*t1.args)=*t2.args) then {
  5008.       every i:=1 to num do if not unify(t1.args[i],t2.args[i],sub) then fail
  5009.       return}
  5010. end
  5011.  
  5012. procedure newctxt(ids,sub)       # forms a new context by extending sub
  5013.    local env; env:=table(&null)  # to accommodate the unbound identifiers
  5014.    every env[!ids]:=*put(sub,&null)
  5015.    return ctxt(env,sub)
  5016. end
  5017.    
  5018. procedure trmstr(trm,sub) # converts a term to a string suitable for output
  5019.    local s; s:=""
  5020.    case type(trm) of {
  5021.       "integer" : return trmstr(sub[trm],sub)
  5022.       "struct" : if s:=lstr(trm,sub) then return "["||s||"]" # non-empty list 
  5023.                  else {every s:=s||trmstr(!trm.args,sub)||","
  5024.                       return trm.name||(if *s=0 then "" else "("||s[1:-1]||")")}
  5025.       "null" : return "undefined"}
  5026. end
  5027.  
  5028. procedure lstr(l,sub) # succeeds if l is a proper non-empty list and
  5029.    local hd,tl        # converts l to string suitable for output
  5030.    if l.name=="." & *l.args=2 then {
  5031.       hd:=trmstr(l.args[1],sub); tl:=l.args[2]
  5032.       while type(tl)=="integer" do tl:=sub[tl] # apply sub to tl
  5033.       case type(tl) of {
  5034.          "struct" : {if tl.name=="nil" & *tl.args=0 then return hd # nil
  5035.                      return hd||","||lstr(tl,sub)}                 # cons
  5036.          "null" : return "undefined"}}
  5037. end
  5038.  
  5039. procedure extract(list,el) # extract list element in position [el:el+1]
  5040.    return list:=list[1:el]|||list[el+1:0]
  5041. end
  5042.  
  5043. ############################## Prolog parser ###############################
  5044.  
  5045. procedure prog() # parses consult[1] until query found or end of file
  5046.    query:=&null
  5047.    while write(read(consult[1])) ? clause() 
  5048.    if /query & consult[1]~===&input then close(consult[1])
  5049. end
  5050.  
  5051. procedure clause() # adds a clause to the dbase or fails when query set
  5052.    local p,b,ids,t; b:=[]; ids:=[]
  5053.    if =":-" then query:=all(ids,b:=body())
  5054.    else if ="?-" then query:=one(ids,b:=body())
  5055.    else {p:=pred(); if =":-" then b:=body()}
  5056.    if (t:=trim(tab(0)))~=="." then # syntax error
  5057.       return write("syntax error: ",t,if *t=0 then "." else " not"," expected")
  5058.    every extractids(ids,\p|!b) # list of variable identifiers
  5059.    if (\p).name=="consult" then every push(consult,open((!p.args).name))
  5060.    return dbase[(\p).name]:=dbase[p.name]|||[rule(ids,p,b)]
  5061. end
  5062.  
  5063. procedure body() # list of predicates (may be empty)
  5064.    local b; b:=[]
  5065.    if put(b,pred()) then while ="," & put(b,pred())
  5066.    return b
  5067. end
  5068.  
  5069. procedure dots() # converts non-empty body of list to cons cells
  5070.    local p
  5071.    if p:=pred() then if ="," then return fun(".",[p,dots()])
  5072.                      else return fun (".",[p,fun("nil",[])])
  5073. end
  5074.  
  5075. procedure pred() # ~pred , name(body) , uc_name , lc_name , [body] , pred|pred
  5076.    local name,args,d,p,pp; args:=[]
  5077.    if ="~" then p:=fun("~",[pred()])
  5078.    else if name:=tab(many(&ucase++&lcase++'0123456789._')) then {
  5079.       if any(&ucase,name) then p:=var(name)
  5080.       else {if ="(" & args:=body() then check(")"); p:=fun(name,args)}}
  5081.    else if ="[]" then p:=fun("nil",[]) # empty list abbreviation
  5082.    else if ="[" then {p:=dots(); check("]")} # non-empty list abbreviation
  5083.    if ="|" then if pp:=pred() then return fun(".",[p,pp]) # infix cons
  5084.                 else write("syntax error: missing second argument to \"|\"")
  5085.    return \p # n.b. fails if predicate invalid
  5086. end
  5087.  
  5088. procedure check(s) # report error if s not present or skip over it
  5089.    if not =s then write("syntax error: ",s," expected before ",tab(0))
  5090. end
  5091.  
  5092. procedure extractids(ids,pred) # build the set of variable identifiers 
  5093.    if type(pred)=="fun" then every extractids(ids,!pred.args)
  5094.    else if not (pred.name==!ids) then put(ids,pred.name)
  5095.    return # the identifiers have been appended to reference parameter ids
  5096. end
  5097.  
  5098. From icon-group-request@arizona.edu  Thu Mar 29 05:03:09 1990
  5099. Resent-From: icon-group-request@arizona.edu
  5100. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  5101.     id AA02479; Thu, 29 Mar 90 05:03:09 MST
  5102. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 29 Mar 90 05:03 MST
  5103. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20977; Thu, 29 Mar 90
  5104.  03:58:01 -0800
  5105. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  5106.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  5107.  usenet@ucbvax.Berkeley.EDU if you have questions)
  5108. Resent-Date: Thu, 29 Mar 90 05:04 MST
  5109. Date: 29 Mar 90 11:23:34 GMT
  5110. From: zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  5111. Subject: prolog4.icn
  5112. Sender: icon-group-request@arizona.edu
  5113. Resent-To: icon-group@cs.arizona.edu
  5114. To: icon-group@arizona.edu
  5115. Resent-Message-Id: <B9C58C73861FE04C55@Arizona.EDU>
  5116. Message-Id: <2002@bruce.OZ>
  5117. Organization: Monash Uni. Computer Science, Australia
  5118. X-Envelope-To: icon-group@CS.Arizona.EDU
  5119. X-Vms-To: icon-group@Arizona.edu
  5120. Status: O
  5121.  
  5122.  
  5123. # Prolog in Icon, version 4, (C) Alan Finlay, Monash University.
  5124. ########################## global variables and types ######################
  5125.  
  5126. record ctxt(env,subst)    # integer[string] * ((integer | struct | null) list)
  5127. record struct(name,args)  # string * ((integer | struct) list)
  5128. record rule(ids,head,body)# string list * predicate * predicate list \
  5129. record all(ids,body)      # string list * predicate list              } clauses
  5130. record one(ids,body)      # string list * predicate list             /
  5131. record fun(name,args)     # string * predicate list        \ types of 
  5132. record var(name)          # string                         / predicates
  5133. global dbase              # table of clauses indexed by head name
  5134. global consult            # stack of files being consulted
  5135. global query              # top level query
  5136.  
  5137. ################################## driver ##################################
  5138.  
  5139. procedure main()
  5140.    dbase:=table([]); consult:=[&input] # empty dbase; standard input
  5141.    while \query | *consult>0 do { # more queries possible
  5142.       prog() # parse clauses, possibly setting query as a side effect
  5143.       if \query then case type(query) of {
  5144.          "all" : {every printsoln(query); write("no more solutions")}
  5145.          "one" : if not printsoln(query) then write("no")}
  5146.       else pop(consult)}
  5147. end
  5148.  
  5149. procedure printsoln(qry) # print first or next solution to qry 
  5150.    local ans,v
  5151.    every ans:=resolve(qry.body,1,*qry.body,newctxt(qry.ids,[])) do {
  5152.       if (type(ans)=="string") & (ans=="cut") then fail # cut query
  5153.       writes("yes")
  5154.       every v:=!qry.ids do writes(", ",v,"=",trmstr(ans.env[v],ans.subst))
  5155.       suspend write()}
  5156. end
  5157.  
  5158. ########################### Prolog interpreter #############################
  5159.  
  5160. procedure resolve(qry,hd,tl,ctext) # generates all solutions of qry[hd:tl]
  5161.    local sub,q,cls,r               # and returns updated context
  5162.    if hd>tl then return ctext # terminate linear recursion
  5163.    case (q:=qry[hd]).name of {
  5164.       "assert"  : {r:=rule([],q.args[1],q.args[2:0])
  5165.                    every extractids(r.ids,!q.args)
  5166.                    dbase[q.args[1].name]:=dbase[q.args[1].name]|||[r]
  5167.                    suspend resolve(qry,hd+1,tl,ctext)} # always succeeds
  5168.       "retract" : suspend retract(q.args[1],ctext) & resolve(qry,hd+1,tl,ctext)
  5169.       "~"       : {if not (sub:=resolve(q.args,1,1,ctext).subst) |
  5170.                          (type(sub)=="string" & sub=="cut") then 
  5171.                       suspend resolve(qry,hd+1,tl,ctext)} # negation by failure
  5172.       "!"       : {suspend resolve(qry,hd+1,tl,ctext)
  5173.                    return "cut"} # causes failure of parent clause
  5174.       default   : {goal:=scanpred(q,ctext)
  5175.                    every cls := !dbase[q.name] do
  5176.                       every sub:=tryclause(goal,cls,ctext.subst) do {
  5177.                          if type(sub)=="string" & sub=="cut" then fail
  5178.                          else suspend resolve(qry,hd+1,tl,ctxt(ctext.env,sub))}
  5179.                   }
  5180.       }
  5181. end
  5182.  
  5183. procedure retract(pred,ctext) # removes a clause matching pred from dbase 
  5184. local cand,goal,entry,i; i:=1 # fails when no more matching clauses to remove
  5185.    goal:=scanpred(pred,ctext)
  5186.    every entry:=!dbase[goal.name] do { # check for matching clause
  5187.       cand:=scanpred(entry.head,newctxt(entry.ids,ctext.subst))
  5188.       if unify(goal,cand,copy(ctext.subst)) then { # found one so remove it
  5189.          dbase[goal.name]:=extract(dbase[goal.name],i) 
  5190.          suspend} # on backtracking more retractions can occur
  5191.       else i+:=1 # i keeps track of the entry number even with extractions
  5192.       } # n.b. this is a primitive retract since only the head is matched
  5193. end
  5194.  
  5195. procedure tryclause(term,cls,sub) # resolves term using given clause or fails
  5196.    local ctext,res                # a copy of sub is used so no side effects
  5197.    ctext:=newctxt(cls.ids,copy(sub)) # preallocate context for whole clause
  5198.    if unify(term,scanpred(cls.head,ctext),ctext.subst) then 
  5199.       every res:=resolve(cls.body,1,*cls.body,ctext) do {
  5200.           if (type(res)=="string") & (res=="cut") then suspend "cut"
  5201.           else suspend res.subst} 
  5202. end
  5203.  
  5204. ######################## primitive domain operations ########################
  5205.  
  5206. procedure scanpred(prd,ctext) # converts predicate to structure 
  5207.    local args; args:=[] 
  5208.    if type(prd)=="var" then return ctext.env[prd.name]
  5209.    every put(args,scanpred(!prd.args,ctext))
  5210.    return struct(prd.name,args) 
  5211. end
  5212.  
  5213. procedure unify(t1,t2,sub) # (integer | struct),(integer | struct),sub 
  5214.    local v,i,num           # side effect: sub is updated
  5215.    if type(t1)=="integer" then {
  5216.       while type(v:=sub[t1])=="integer" do t1:=v # apply sub to t1
  5217.       return if type(v)=="struct" then unify(v,t2,sub) else sub[t1]:=t2}
  5218.    if type(t2)=="integer" then return unify(t2,t1,sub)
  5219.    if (t1.name==t2.name) & ((num:=*t1.args)=*t2.args) then {
  5220.       every i:=1 to num do if not unify(t1.args[i],t2.args[i],sub) then fail
  5221.       return}
  5222. end
  5223.  
  5224. procedure newctxt(ids,sub)       # forms a new context by extending sub
  5225.    local env; env:=table(&null)  # to accommodate the unbound identifiers
  5226.    every env[!ids]:=*put(sub,&null)
  5227.    return ctxt(env,sub)
  5228. end
  5229.    
  5230. procedure trmstr(trm,sub) # converts a term to a string suitable for output
  5231.    local s; s:=""
  5232.    case type(trm) of {
  5233.       "integer" : return trmstr(sub[trm],sub)
  5234.       "struct" : if s:=lstr(trm,sub) then return "["||s||"]" # non-empty list 
  5235.                  else {every s:=s||trmstr(!trm.args,sub)||","
  5236.                       return trm.name||(if *s=0 then "" else "("||s[1:-1]||")")}
  5237.       "null" : return "undefined"}
  5238. end
  5239.  
  5240. procedure lstr(l,sub) # succeeds if l is a proper non-empty list and
  5241.    local hd,tl        # converts l to string suitable for output
  5242.    if l.name=="." & *l.args=2 then {
  5243.       hd:=trmstr(l.args[1],sub); tl:=l.args[2]
  5244.       while type(tl)=="integer" do tl:=sub[tl] # apply sub to tl
  5245.       case type(tl) of {
  5246.          "struct" : {if tl.name=="nil" & *tl.args=0 then return hd # nil
  5247.                      return hd||","||lstr(tl,sub)}                 # cons
  5248.          "null" : return "undefined"}}
  5249. end
  5250.  
  5251. procedure extract(list,el) # extract list element in position [el:el+1]
  5252.    return list:=list[1:el]|||list[el+1:0]
  5253. end
  5254.  
  5255. ############################## Prolog parser ###############################
  5256.  
  5257. procedure prog() # parses consult[1] until query found or end of file
  5258.    query:=&null
  5259.    while write(read(consult[1])) ? clause() 
  5260.    if /query & consult[1]~===&input then close(consult[1])
  5261. end
  5262.  
  5263. procedure clause() # adds a clause to the dbase or fails when query set
  5264.    local p,b,ids,t; b:=[]; ids:=[]
  5265.    if =":-" then query:=all(ids,b:=body())
  5266.    else if ="?-" then query:=one(ids,b:=body())
  5267.    else {p:=pred(); if =":-" then b:=body()}
  5268.    if (t:=trim(tab(0)))~=="." then # syntax error
  5269.       return write("syntax error: ",t,if *t=0 then "." else " not"," expected")
  5270.    every extractids(ids,\p|!b) # list of variable identifiers
  5271.    if (\p).name=="consult" then every push(consult,open((!p.args).name))
  5272.    return dbase[(\p).name]:=dbase[p.name]|||[rule(ids,p,b)]
  5273. end
  5274.  
  5275. procedure body() # list of predicates (may be empty)
  5276.    local b; b:=[]
  5277.    if put(b,pred()) then while ="," & put(b,pred())
  5278.    return b
  5279. end
  5280.  
  5281. procedure dots() # converts non-empty body of list to cons cells
  5282.    local p
  5283.    if p:=pred() then if ="," then return fun(".",[p,dots()])
  5284.                      else return fun (".",[p,fun("nil",[])])
  5285. end
  5286.  
  5287. procedure pred() # ~pred , name(body) , uc_name , lc_name , [body] , pred|pred
  5288.    local name,args,d,p,pp; args:=[]
  5289.    if ="~" then p:=fun("~",[pred()])
  5290.    else if ="!" then p:=fun("!",[])
  5291.    else if name:=tab(many(&ucase++&lcase++'0123456789._')) then {
  5292.       if any(&ucase,name) then p:=var(name)
  5293.       else {if ="(" & args:=body() then check(")"); p:=fun(name,args)}}
  5294.    else if ="[]" then p:=fun("nil",[]) # empty list abbreviation
  5295.    else if ="[" then {p:=dots(); check("]")} # non-empty list abbreviation
  5296.    if ="|" then if pp:=pred() then return fun(".",[p,pp]) # infix cons
  5297.                 else write("syntax error: missing second argument to \"|\"")
  5298.    return \p # n.b. fails if predicate invalid
  5299. end
  5300.  
  5301. procedure check(s) # report error if s not present or skip over it
  5302.    if not =s then write("syntax error: ",s," expected before ",tab(0))
  5303. end
  5304.  
  5305. procedure extractids(ids,pred) # build the set of variable identifiers 
  5306.    if type(pred)=="fun" then every extractids(ids,!pred.args)
  5307.    else if not (pred.name==!ids) then put(ids,pred.name)
  5308.    return # the identifiers have been appended to reference parameter ids
  5309. end
  5310.  
  5311. From icon-group-request@arizona.edu  Thu Mar 29 05:03:45 1990
  5312. Resent-From: icon-group-request@arizona.edu
  5313. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  5314.     id AA02493; Thu, 29 Mar 90 05:03:45 MST
  5315. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 29 Mar 90 05:04 MST
  5316. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA20764; Thu, 29 Mar 90
  5317.  03:53:34 -0800
  5318. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  5319.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  5320.  usenet@ucbvax.Berkeley.EDU if you have questions)
  5321. Resent-Date: Thu, 29 Mar 90 05:05 MST
  5322. Date: 29 Mar 90 11:17:51 GMT
  5323. From: zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  5324. Subject: prolog2.doc
  5325. Sender: icon-group-request@arizona.edu
  5326. Resent-To: icon-group@cs.arizona.edu
  5327. To: icon-group@arizona.edu
  5328. Resent-Message-Id: <B9C5526D17BFE04BD8@Arizona.EDU>
  5329. Message-Id: <1999@bruce.OZ>
  5330. Organization: Monash Uni. Computer Science, Australia
  5331. X-Envelope-To: icon-group@CS.Arizona.EDU
  5332. X-Vms-To: icon-group@Arizona.edu
  5333. Status: O
  5334.  
  5335.  
  5336. .ce
  5337. .uh "Prolog in Icon version 2 : Program documentation"
  5338. .ce
  5339. Alan Finlay, Monash University, March 1990.
  5340.  
  5341. This version of Prolog is loosely based upon the various denotational
  5342. semantics for Prolog with which I have been acquainted\*[*\*]
  5343. .(f
  5344. * In particular: T. Nicholson and N. Foo. "A Denotational Semantics for Prolog",
  5345. to appear in ACM TOPLAS.
  5346. .)f
  5347. and discussion with colleagues at Monash University.
  5348. The motivation was to gain experience with Icon and to see if there was any
  5349. truth to the claim "It should only take about half a page of Icon to implement
  5350. a Prolog interpreter."
  5351.  
  5352. .sh1 "Data structures"
  5353.  
  5354. .ftCW
  5355. ########################## global variables and types ######################
  5356.  
  5357. .nf
  5358. record ctxt(env,subst)    # integer[string] * ((integer | struct | null) list)
  5359. record struct(name,args)  # string * ((integer | struct) list)
  5360. record rule(ids,head,body)# string list * predicate * predicate list \\
  5361. record all(ids,body)      # string list * predicate list              } clauses
  5362. record one(ids,body)      # string list * predicate list             /
  5363. record fun(name,args)     # string * predicate list        \\ types of 
  5364. record var(name)          # string                         / predicates
  5365. global dbase              # table of clauses indexed by head name
  5366. global consult            # stack of files being consulted
  5367. global query              # top level query
  5368. .ft
  5369. .fi
  5370.  
  5371. Despite the lack of enforced type discipline in Icon I have used some 
  5372. self discipline.  The record and global declarations above indicate types
  5373. using "|" for disjoint sum and shared field names to get a degree of type
  5374. inheritance.
  5375. Type "ctxt" is a context for goal resolution and consists of an environment
  5376. and a substitution.  The environment is a table which maps variable identifiers
  5377. to variables.  A variable is represented by an integer which is its position
  5378. in the substitution list.  A substitution then effectively maps variables
  5379. to terms or unbound.  The null value is used to represent an unbound variable. 
  5380. A term is either another variable or a structure.
  5381. Type "struct" is used to represent structures which are either functors or
  5382. constants.  Functors have a name and a list of arguments which are terms.
  5383. Constants are represented as functors with zero arguments.
  5384.  
  5385. The types for clauses and predicates are used to represent the syntax of
  5386. Prolog.  I will use the words predicate and functor more or less
  5387. interchangeably since the interpreter doesn't distinguish between them
  5388. structurally.  A consequence of this is that a variable may be used as
  5389. a goal.
  5390. The use of separate domains for syntactic predicates and their run time
  5391. equivalents (called structures above) is required because the syntax is
  5392. independent of any context whereas the "terms" referred to above are only
  5393. meaningful when considered together with an appropriate context.  At various
  5394. stages in a computation a given clause or predicate will have to be used
  5395. in different contexts.  There are a few idiosyncrasies of the syntactic 
  5396. domains worth mentioning.  Clauses have the redundant field "ids" which is a
  5397. list of all the variable identifiers used in the clause.  This saves a lot
  5398. of recalculation during execution.  The types "all" and "one" are respectively
  5399. queries where all or one solution are requested.  Syntactically this is
  5400. signaled by using the turnstile ":-" for all solutions and "?-" for one.
  5401. As before type "fun" can be used with no arguments to indicate constants.
  5402. Facts are represented as rules with empty bodies.  
  5403.  
  5404. The database is global and consists of a table of clause lists indexed
  5405. by the name of the predicate at the head.  The index is used for efficiency
  5406. reasons only.  The global "consult" is a stack of files being consulted,
  5407. used for nesting of consult commands.  The top level query is global simply 
  5408. to simplify the parser and could have been passed to the driver as a parameter
  5409. via procedure "prog".
  5410.  
  5411. .ne7
  5412. .sh1 "The driver"
  5413.  
  5414. .ftCW
  5415. ################################## driver ##################################
  5416.  
  5417. procedure main()
  5418.    dbase:=table([]); consult:=[&input] # empty dbase; standard input
  5419.    while \\query | *consult>0 do { # more queries possible
  5420.       prog() # parse clauses, possibly setting query as a side effect
  5421.       if \\query then case type(query) of {
  5422.          "all" : {every printsoln(query); write("no more solutions")}
  5423.          "one" : if not printsoln(query) then write("no")}
  5424.       else pop(consult)}
  5425. end
  5426.  
  5427. procedure printsoln(qry) # print first or next solution to qry 
  5428.    local ans,v
  5429.    every ans:=resolve(qry.body,1,*qry.body,newctxt(qry.ids,[])) do { 
  5430.       writes("yes")
  5431.       every v:=!qry.ids do writes(", ",v,"=",trmstr(ans.env[v],ans.subst))
  5432.       suspend write()}
  5433. end
  5434. .ft
  5435.  
  5436. Most of procedure "main" is concerned with providing a usable interactive
  5437. interface and the details are of little interest.  The parser is called
  5438. until a query is encountered and "printsoln" is used to resolve it and display
  5439. the answer substitution.  The separate
  5440. procedure "printsoln" is required because it can generate all solutions and
  5441. may be activated once only or resumed until it fails depending on the type
  5442. of query.
  5443. The procedure "printsoln" simply uses procedure "resolve" to generate solution
  5444. contexts from an initial context determined by the query.  This initial 
  5445. context has an environment with all and only the free variables in the query
  5446. and a substitution in which they are unbound.  This context is created by
  5447. calling procedure "newctxt" which will be described later.
  5448.  
  5449. .ne7
  5450. .sh1 "The interpreter proper"
  5451.  
  5452. .ftCW
  5453. ########################### Prolog interpreter #############################
  5454.  
  5455. procedure resolve(qry,hd,tl,ctext) # generates all solutions of qry[hd:tl]
  5456.    local sub,q                     # in given context, returns updated context
  5457.    if hd>tl then return ctext
  5458.    if (q:=qry[hd]).name=="~" then # negation by failure
  5459.       {if not resolve(q.args,1,1,ctext) then suspend resolve(qry,hd+1,tl,ctext)}
  5460.    else every sub:=tryclause(scanpred(q,ctext),!dbase[q.name],ctext.subst) do
  5461.            suspend resolve(qry,hd+1,tl,ctxt(ctext.env,sub))
  5462. end
  5463.  
  5464. procedure tryclause(term,cls,sub) # resolves term using given clause or fails
  5465.    local ctext                    # a copy of sub is used so no side effects
  5466.    ctext:=newctxt(cls.ids,copy(sub)) # preallocate context for whole clause
  5467.    if unify(term,scanpred(cls.head,ctext),ctext.subst) then 
  5468.       suspend resolve(cls.body,1,*cls.body,ctext).subst
  5469. end
  5470.  
  5471. procedure scanpred(prd,ctext) # converts predicate to structure 
  5472.    local args; args:=[] 
  5473.    if type(prd)=="var" then return ctext.env[prd.name]
  5474.    every put(args,scanpred(!prd.args,ctext))
  5475.    return struct(prd.name,args) 
  5476. end
  5477. .ft
  5478.  
  5479. The procedure "resolve" is a generator which produces all solutions to a sublist
  5480. of the supplied goal list "qry".  This sublist is from element "hd" to element
  5481. .(f
  5482. * Lisp's variety of lists can be implemented in Icon but lack the useful
  5483. operators the inbuilt lists have.  On the other hand the inbuilt list type
  5484. in Icon does not have a non copying "tail" or "cdr" operation.
  5485. .)f
  5486. "tl" and is passed in this way to save copying sublists\*[*\*].  The
  5487. resolution takes place with respect to the supplied context and
  5488. an updated context is returned as the answer.  
  5489. Ignoring negation for the moment, "resolve" proceeds by resolving
  5490. the first goal in the list and for each solution uses a recursive call
  5491. to satisfy the rest of the goal list if possible and generates a result
  5492. for every case.  The first goal is resolved by resuming "tryclause" for
  5493. each clause in the database matching the goal and "tryclause" itself being
  5494. a generator can be resumed several times for each clause.  For those not
  5495. accustomed to Icon's procedure resumption conventions this is more clearly
  5496. expressed
  5497.  
  5498. .ftCW
  5499.    q:=qry[hd]
  5500.    every cls:=!dbase[q.name] do
  5501.       every sub:=tryclause(scanpred(q,ctext),cls,ctext.subst) do
  5502.          suspend resolve(qry,hd+1,tl,ctxt(ctext.env,sub))
  5503. .ft
  5504.  
  5505. Notice that the updated substitution return by "tryclause" is supplied
  5506. to "resolve" for the rest of the list hence the effects of goal resolution
  5507. within a clause body are cumulative.  Another important point is to note that
  5508. the recursion bottoms out when the sublist of goals is empty and succeeds in
  5509. this case.  It is tempting to try to use a goal generator instead of a goal
  5510. list as in
  5511.  
  5512. .ftCW
  5513.    sub:=ctext.subst
  5514.    every q:=!qry do
  5515.       every sub:=tryclause(scanpred(q,ctext),!dbase[q.name],sub)
  5516.    return ctxt(ctext.env,sub)
  5517. .ft
  5518.  
  5519. This appears to save an explicit test for the end of the list but suffers
  5520. from a fatal flaw.  Apart from only being able to generate one solution this
  5521. scheme finds the first solution provided there is one but otherwise
  5522. succeeds anyway with a partial solution.  
  5523.  
  5524. Negation is simply handled as "negation as failure" by using Icon's "not"
  5525. operator which succeeds if and only if its argument fails.  Since when
  5526. a negated goal
  5527. succeeds the substitution cannot be updated the original substitution is
  5528. passed to the remaining goals in this case.
  5529.  
  5530. The procedure "tryclause" first creates a context for resolving the supplied
  5531. term against the supplied clause.  This context is based upon the supplied 
  5532. substitution and all the free identifiers in the clause.  The free identifiers
  5533. and the a copy of the substitution are used by "newctxt" to create a context
  5534. which has an environment for the identifiers as new variables and the
  5535. substitution extended with these new variables unbound.  Denotational
  5536. semantics for Prolog may perform this task on the fly as a clause is
  5537. interpreted and this corresponds operationally to a great deal of recomputation.
  5538. Here the syntax parser generates a list of free variable identifiers (without
  5539. repetitions) only once and combined with the "newctxt" this avoids extending
  5540. the context in a piecemeal fashion.
  5541.  
  5542. The substitution passed to "newctxt" is a copy since "newctxt" and "unify"
  5543. cause side effects upon their substitution parameter.  If these side effects
  5544. were eliminated it would require two copying operations to be performed on
  5545. very similar substitutions where only one is required.  The unifier returns
  5546. only success or failure of the attempted unification but in the case of
  5547. success the supplied substitution is updated as a side effect.
  5548.  
  5549. The procedure "scanpred" simply converts a predicate from its syntactic form
  5550. into a term according to some relevant context.  There are no side effects.
  5551.  
  5552. .ne7
  5553. .sh1 "Primitive domain operations and the parser"
  5554.  
  5555. .ftCW
  5556. ######################## primitive domain operations ########################
  5557.  
  5558. procedure unify(t1,t2,sub) # (integer | struct),(integer | struct),sub 
  5559.    local v,i,num           # side effect: sub is updated
  5560.    if type(t1)=="integer" then {
  5561.       while type(v:=sub[t1])=="integer" do t1:=v # apply sub to t1
  5562.       return if type(v)=="struct" then unify(v,t2,sub) else sub[t1]:=t2}
  5563.    if type(t2)=="integer" then return unify(t2,t1,sub)
  5564.    if (t1.name==t2.name) & ((num:=*t1.args)=*t2.args) then {
  5565.       every i:=1 to num do if not unify(t1.args[i],t2.args[i],sub) then fail
  5566.       return}
  5567. end
  5568.  
  5569. procedure newctxt(ids,sub)       # forms a new context by extending sub
  5570.    local env; env:=table(&null)  # to accommodate the unbound identifiers
  5571.    every env[!ids]:=*put(sub,&null)
  5572.    return ctxt(env,sub)
  5573. end
  5574.    
  5575. procedure trmstr(trm,sub) # converts a term to a string suitable for output
  5576.    local s; s:=""
  5577.    case type(trm) of {
  5578.       "integer" : return trmstr(sub[trm],sub)
  5579.       "struct" : if s:=lstr(trm,sub) then return "["||s||"]" # non-empty list 
  5580.                  else {every s:=s||trmstr(!trm.args,sub)||","
  5581.                       return trm.name||(if *s=0 then "" else "("||s[1:-1]||")")}
  5582.       "null" : return "undefined"}
  5583. end
  5584.  
  5585. procedure lstr(l,sub) # succeeds if l is a proper non-empty list and
  5586.    local hd,tl        # converts l to string suitable for output
  5587.    if l.name=="." & *l.args=2 then {
  5588.       hd:=trmstr(l.args[1],sub); tl:=l.args[2]
  5589.       while type(tl)=="integer" do tl:=sub[tl] # apply sub to tl
  5590.       case type(tl) of {
  5591.          "struct" : {if tl.name=="nil" & *tl.args=0 then return hd # nil
  5592.                      return hd||","||lstr(tl,sub)}                 # cons
  5593.          "null" : return "undefined"}}
  5594. end
  5595.  
  5596. ############################## Prolog parser ###############################
  5597.  
  5598. procedure prog() # parses consult[1] until query found or end of file
  5599.    query:=&null
  5600.    while write(read(consult[1])) ? clause() 
  5601.    if /query & consult[1]~===&input then close(consult[1])
  5602. end
  5603.  
  5604. procedure clause() # adds a clause to the dbase or fails when query set
  5605.    local p,b,ids,t; b:=[]; ids:=[]
  5606.    if =":-" then query:=all(ids,b:=body())
  5607.    else if ="?-" then query:=one(ids,b:=body())
  5608.    else {p:=pred(); if =":-" then b:=body()}
  5609.    if (t:=trim(tab(0)))~=="." then # syntax error
  5610.       return write("syntax error: ",t,if *t=0 then "." else " not"," expected")
  5611.    every extractids(ids,\\p|!b) # list of variable identifiers
  5612.    if (\\p).name=="consult" then every push(consult,open((!p.args).name))
  5613.    return dbase[(\\p).name]:=dbase[p.name]|||[rule(ids,p,b)]
  5614. end
  5615.  
  5616. procedure body() # list of predicates (may be empty)
  5617.    local b; b:=[]
  5618.    if put(b,pred()) then while ="," & put(b,pred())
  5619.    return b
  5620. end
  5621.  
  5622. procedure dots() # converts non-empty body of list to cons cells
  5623.    local p
  5624.    if p:=pred() then if ="," then return fun(".",[p,dots()])
  5625.                      else return fun (".",[p,fun("nil",[])])
  5626. end
  5627.  
  5628. procedure pred() # ~pred , name(body) , uc_name , lc_name , [body] , pred|pred
  5629.    local name,args,d,p,pp; args:=[]
  5630.    if ="~" then p:=fun("~",[pred()])
  5631.    else if name:=tab(many(&ucase++&lcase++'0123456789._')) then {
  5632.       if any(&ucase,name) then p:=var(name)
  5633.       else {if ="(" & args:=body() then check(")"); p:=fun(name,args)}}
  5634.    else if ="[]" then p:=fun("nil",[]) # empty list abbreviation
  5635.    else if ="[" then {p:=dots(); check("]")} # non-empty list abbreviation
  5636.    if ="|" then if pp:=pred() then return fun(".",[p,pp]) # infix cons
  5637.                 else write("syntax error: missing second argument to \\"|\\"")
  5638.    return \\p # n.b. fails if predicate invalid
  5639. end
  5640.  
  5641. procedure check(s) # report error if s not present or skip over it
  5642.    if not =s then write("syntax error: ",s," expected before ",tab(0))
  5643. end
  5644.  
  5645. procedure extractids(ids,pred) # build the set of variable identifiers 
  5646.    if type(pred)=="fun" then every extractids(ids,!pred.args)
  5647.    else if not (pred.name==!ids) then put(ids,pred.name)
  5648.    return # the identifiers have been appended to reference parameter ids
  5649. end
  5650. .ft
  5651.  
  5652. The rest of the interpreter is supplied for completeness but is of little
  5653. intrinsic interest.  
  5654.  
  5655. The unifier updates the supplied substitution.  It is natural to consider 
  5656. using the backtrackable assignment and hence avoid the need to copy
  5657. substitutions altogether.  A preliminary investigation indicates that this
  5658. is feasible but space inefficient.  This may be due to poor implementation
  5659. of backtrackable assignment in the particular Icon interpreter used\*[*\*].
  5660. .(f
  5661. * &version = "Icon Version 6.0.  July 7, 1986." (University of Arizona)
  5662. .)f
  5663.  
  5664. The parser uses procedures which return parse trees except that "clause"
  5665. uses a global variable to return a top level query and fails when it
  5666. encounters one.  This causes termination of string scanning in "prog".
  5667. The behaviour of the user interface is described in the user manual.
  5668.  
  5669. From kwalker  Thu Mar 29 12:27:32 1990
  5670. Date: Thu, 29 Mar 90 12:27:32 MST
  5671. From: "Kenneth Walker" <kwalker>
  5672. Message-Id: <9003291927.AA00336@megaron.cs.arizona.edu>
  5673. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  5674.     id AA00336; Thu, 29 Mar 90 12:27:32 MST
  5675. In-Reply-To: <9003281833.AA18812@sophist.uchicago.edu>
  5676. To: icon-group
  5677. Subject: Re:  icon & prolog
  5678. Status: O
  5679.  
  5680. > Date: Wed, 28 Mar 90 12:33:15 CST
  5681. > From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  5682. > Just an idle question:  Has anyone thought of implementing
  5683. > Prolog in Icon, either as a Prolog -> Icon translator, or
  5684. > as a Prolog interpreter written in Icon?
  5685.  
  5686. You might want to check out "Logicon: an Integration of Prolog into
  5687. Icon" by Guy Lapalme and Suzanne Chapleau, Software Practice and
  5688. Experience, Oct 1986. They implement a Prolog interpreter in Icon
  5689. which lets you call back and forth between the two languages.
  5690.  
  5691.   Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  5692.   +1 602 621 2858  kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker
  5693.  
  5694. From ralph  Sat Mar 31 05:07:38 1990
  5695. Date: Sat, 31 Mar 90 05:07:38 MST
  5696. From: "Ralph Griswold" <ralph>
  5697. Message-Id: <9003311207.AA17346@megaron.cs.arizona.edu>
  5698. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  5699.     id AA17346; Sat, 31 Mar 90 05:07:38 MST
  5700. To: icon-group
  5701. Subject: Version 8 of Icon
  5702. Status: O
  5703.  
  5704. Version 8 of Icon is complete and implementations will be available
  5705. for most computer systems soon.
  5706.  
  5707. Version 8 has both new features and improvements to the implementation.
  5708.  
  5709. New language features:
  5710.  
  5711.     Math functions:  sin(), cos(), ..., exp(), log(), etc.
  5712.  
  5713.     Keyboard functions:  getch(), getche(), kbhit(); PC implementations
  5714.        only.
  5715.  
  5716.     key(T) to generate the keys in table T.
  5717.  
  5718.     name(v) and variable(s) to produce string name of variable v and
  5719.        vice versa.
  5720.  
  5721.     p!L to invoke p with arguments in list L.
  5722.  
  5723.     &letters, cset of all letters.
  5724.  
  5725.     Arbitrary-precision integer arithmetic (not supported on all PCs).
  5726.  
  5727.     Serial numbers for structures.
  5728.  
  5729.     An interface for calling C functions from Icon and vice versa.
  5730.  
  5731. Implementation changes:
  5732.  
  5733.     Smaller structures.
  5734.  
  5735.     Dynamic hashing for sets and tables.
  5736.  
  5737.     Instrumentation of storage management.
  5738.  
  5739. Implementations of Version 8 will be announced as they become available.
  5740.  
  5741. Please direct any questions to me, not to icon-group or icon-project.
  5742.  
  5743.  
  5744.  
  5745.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  5746.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  5747.  
  5748. From ralph  Sat Mar 31 05:50:35 1990
  5749. Date: Sat, 31 Mar 90 05:50:35 MST
  5750. From: "Ralph Griswold" <ralph>
  5751. Message-Id: <9003311250.AA18283@megaron.cs.arizona.edu>
  5752. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  5753.     id AA18283; Sat, 31 Mar 90 05:50:35 MST
  5754. To: icon-group
  5755. Subject: Version 8 of Icon for UNIX
  5756. Status: O
  5757.  
  5758. Version 8 of Icon for UNIX systems is now available. This implementation
  5759. can be configured for a wide variety of UNIX systems. Configuration
  5760. information is provided for 56 different systems, including the Sun
  5761. Sparcstation, the DecStation, the NeXT, the DG AViiON, and the Cray-2.
  5762.  
  5763. Configurations for new systems can be added with relative ease.
  5764.  
  5765. The UNIX distribution includes source code, configuration files,
  5766. documentation, the Icon program library (new in Version 8), and
  5767. several auxiliary components of Icon.
  5768.  
  5769. Version 8 of Icon for UNIX systems can be obtained by anonymous FTP
  5770. to cs.arizona.edu. After connecting, cd /icon/v8.  Get READ.ME
  5771. there for more information.
  5772.  
  5773. If you do not have FTP access or prefer to obtain a magnetic tape
  5774. and printed documentation, Version 8 of Icon for UNIX can be ordered
  5775. from:
  5776.  
  5777.     Icon Project
  5778.     Department of Computer Science
  5779.     Gould-Simpson Building
  5780.     The University of Arizona
  5781.     Tucson, AZ   85721
  5782.  
  5783.     602 621-2018 (voice)
  5784.     602 621-4246 (FAX)
  5785.  
  5786. The price is $30, payable in US dollars with a check written on a bank
  5787. in the United States.  Orders also can be charged to MasterCard or Visa.
  5788. This price includes shipping by parcel post in the United States, Canada,
  5789. and Mexico. Add $10 for air mail delivery to other countries.
  5790.  
  5791. Please direct any questions to me, not to icon-project or icon-group.
  5792.  
  5793.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  5794.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  5795.  
  5796. From goer@sophist.uchicago.EDU  Sat Mar 31 16:32:35 1990
  5797. Resent-From: goer@sophist.uchicago.EDU
  5798. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  5799.     id AA21928; Sat, 31 Mar 90 16:32:35 MST
  5800. Return-Path: goer@sophist.uchicago.EDU
  5801. Received: from tank.uchicago.edu by Arizona.EDU; Sat, 31 Mar 90 16:33 MST
  5802. Received: from sophist.uchicago.edu by tank.uchicago.edu Sat, 31 Mar 90
  5803.  17:33:50 CST
  5804. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA24215; Sat, 31 Mar 90
  5805.  17:28:19 CST
  5806. Resent-Date: Sat, 31 Mar 90 16:34 MST
  5807. Date: Sat, 31 Mar 90 17:28:19 CST
  5808. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  5809. Subject: more help w/ BSD->SysV filename conversion
  5810. Resent-To: icon-group@cs.arizona.edu
  5811. To: icon-group@arizona.edu
  5812. Resent-Message-Id: <B7D2D2117EBFE0252D@Arizona.EDU>
  5813. Message-Id: <9003312328.AA24215@sophist.uchicago.edu>
  5814. X-Envelope-To: icon-group@CS.Arizona.EDU
  5815. X-Vms-To: icon-group@Arizona.edu
  5816. Status: O
  5817.  
  5818. Yet another version of the BSD->SysV tar file mapping aid.
  5819.  
  5820. The chore of renaming files is time-consuming, and any automation that
  5821. can be introduced into the process is certainly of use to me.  I hope
  5822. that this succession of mapping programs I'm posting will be as useful
  5823. to others, too.  This one has been used on more platforms than the one
  5824. I posted before, and has a few more error checks.  It also prevents the
  5825. user from fooling with nested tar archives, and permits preservation of
  5826. an arbitrary number of extensions of any length (e.g. .dvi.Z, .pxl,
  5827. etc.)
  5828.  
  5829.  
  5830. #-------------------------------------------------------------------
  5831. #
  5832. #    PROGNAME:  mtf (stands for "map tar file")
  5833. #    
  5834. #    PURPOSE:  Maps 15+ char. filenames in a tar archive to 14
  5835. #    chars.  Handles both header blocks and the archive itself.
  5836. #
  5837. #    USAGE:  mtf inputfile .extensions     # (writes to stdout)
  5838. #
  5839. #       Inputfile is a tar archive; "extensions" is a sequence of
  5840. #       strings which denote .extensions to be preserved in mapped
  5841. #       filenames.  One-char extensions are automatically preserved.
  5842. #       Writes a "mapped" tar archive to the stdout.
  5843. #
  5844. #       BUGS:  Mtf only maps filenames found in the main tar headers.
  5845. #       Because of this, mtf cannot accept nested tar archives.  Mtf
  5846. #       also obviously cannot know about conflicts with filenames in
  5847. #       use outside the archive.  Check before you extract!
  5848. #
  5849. #    Richard L. Goerwitz, III
  5850. #    Last modified 3/29/90
  5851. #
  5852. #-------------------------------------------------------------------
  5853.  
  5854.  
  5855. global filenametbl, chunkset, short_chunkset   # see procedure mappiece(s)
  5856. global extensions                              # ditto
  5857. record hblock(name,junk,size,mtime,chksum,
  5858.               linkflag,linkname,therest)       # see readtarhdr(s)
  5859.  
  5860.  
  5861. procedure main(a)
  5862.  
  5863.     usage := "usage:  mtf inputfile extensions  # output goes to stdout\n" ||
  5864.              "        useful extensions include .tar.Z .pxl .cpi, etc."
  5865.     0 < *a | stop(usage)
  5866.     intext := open(a[1],"r") |
  5867.     stop("mtf:  can't open ",a[1])
  5868.     a[1][-2:0] == ".Z" &
  5869.         stop("mtf:  sorry, can't accept compressed files")
  5870.     extensions := a[2:0]
  5871.     every i := 1 to *extensions
  5872.     do extensions[i] ?:= (=".", tab(0))
  5873.  
  5874.     # Run through all the headers in the input file, filling
  5875.     # (global) filenametbl with the names of overlong files;
  5876.     # make_table_of_filenames fails if there are no such files.
  5877.     make_table_of_filenames(intext) | {
  5878.     write(&errout,"mtf:  no overlong path names to map") 
  5879.     a[1] ? (tab(find(".tar")+4), pos(0)) |
  5880.       write(&errout,"(Is ",a[1]," even a tar archive?)")
  5881.      exit(1)
  5882.     } 
  5883.  
  5884.     # Now that a table of overlong filenames exists, go back
  5885.     # through the text, remapping all occurrences of these names
  5886.     # to new, 14-char values; also, reset header checksums, and
  5887.     # reformat text into correctly padded 512-byte blocks.  Ter-
  5888.     # minate output with 512 nulls.
  5889.     seek(intext,1)
  5890.     every writes(output_mapped_headers_and_texts(intext))
  5891.  
  5892.     close(intext)
  5893.     write_report()   # Record mapped file and dir names for future ref.
  5894.     exit(0)
  5895.     
  5896. end
  5897.  
  5898.  
  5899.  
  5900. procedure make_table_of_filenames(intext)
  5901.  
  5902.     local header # chunkset is global
  5903.  
  5904.     # search headers for overlong filenames; for now
  5905.     # ignore everything else
  5906.     while header := readtarhdr(reads(intext,512)) do {
  5907.     # tab upto the next header block
  5908.     tab_nxt_hdr(intext,trim_str(header.size),1)
  5909.     # record overlong filenames in several global tables, sets
  5910.     fixpath(trim_str(header.name))
  5911.     }
  5912.     *\chunkset ~= 0 | fail
  5913.     return &null
  5914.  
  5915. end
  5916.  
  5917.  
  5918.  
  5919. procedure output_mapped_headers_and_texts(intext)
  5920.  
  5921.     # Remember that filenametbl, chunkset, and short_chunkset
  5922.     # (which are used by various procedures below) are global.
  5923.     local header, newtext, full_block, block, lastblock
  5924.  
  5925.     # Read in headers, one at a time.
  5926.     while header := readtarhdr(reads(intext,512)) do {
  5927.  
  5928.     # Replace overlong filenames with shorter ones, according to
  5929.     # the conversions specified in the global hash table filenametbl
  5930.     # (which were generated by fixpath() on the first pass).
  5931.           header.name := left(map_filenams(header.name),100,"\x00")
  5932.     header.linkname := left(map_filenams(header.linkname),100,"\x00")
  5933.  
  5934.     # Use header.size field to determine the size of the subsequent text.
  5935.     # Read in the text as one string.  Map overlong filenames found in it
  5936.      # to shorter names as specified in the global hash table filenamtbl.
  5937.     newtext := map_filenams(tab_nxt_hdr(intext,trim_str(header.size)))
  5938.  
  5939.     # Now, find the length of newtext, and insert it into the size field.
  5940.     header.size := right(exbase10(*newtext,8) || " ",12," ")
  5941.  
  5942.     # Calculate the checksum of the newly retouched header.
  5943.     header.chksum := right(exbase10(get_checksum(header),8)||"\x00 ",8," ")
  5944.  
  5945.     # Finally, join all the header fields into a new block and write it out
  5946.     full_block := ""; every full_block ||:= !header
  5947.     suspend left(full_block,512,"\x00")
  5948.  
  5949.     # Now we're ready to write out the text, padding the final block
  5950.     # out to an even 512 bytes if necessary; the next header must start
  5951.     # right at the beginning of a 512-byte block.
  5952.     newtext ? {
  5953.         while block := move(512)
  5954.         do suspend block
  5955.         pos(0) & next
  5956.             lastblock := left(tab(0),512,"\x00")
  5957.         suspend lastblock
  5958.     }
  5959.     }
  5960.     # Write out a final null-filled block.  Some tar programs will write
  5961.     # out 1024 nulls at the end.  Dunno why.
  5962.     return repl("\x00",512)
  5963.  
  5964. end
  5965.  
  5966.  
  5967.  
  5968. procedure trim_str(s)
  5969.  
  5970.     # Knock out spaces, nulls from those crazy tar header
  5971.     # block fields (some of which end in a space and a null,
  5972.     # some just a space, and some just a null [anyone know
  5973.     # why?]).
  5974.     return s ? {
  5975.     (tab(many(' ')) | &null) &
  5976.         trim(tab(find("\x00")|0))
  5977.     } \ 1
  5978.  
  5979. end 
  5980.  
  5981.  
  5982.  
  5983. procedure tab_nxt_hdr(f,size_str,firstpass)
  5984.  
  5985.     # Tab upto the next header block.  Return the bypassed text
  5986.     # as a string if not the first pass.
  5987.  
  5988.     local hs, next_header_offset
  5989.  
  5990.     hs := integer("8r" || size_str)
  5991.     next_header_offset := (hs / 512) * 512
  5992.     hs % 512 ~= 0 & next_header_offset +:= 512
  5993.     if 0 = next_header_offset then return ""
  5994.     else {
  5995.     # if this is pass no. 1 don't bother returning a value; we're
  5996.     # just collecting long filenames;
  5997.     if \firstpass then {
  5998.         seek(f,where(f)+next_header_offset)
  5999.         return
  6000.     }
  6001.     else {
  6002.         return reads(f,next_header_offset)[1:hs+1] |
  6003.         stop("mtf:  error reading in ",
  6004.              string(next_header_offset)," bytes.")
  6005.     }
  6006.     }
  6007.  
  6008. end
  6009.  
  6010.  
  6011.  
  6012. procedure fixpath(s)
  6013.  
  6014.     # Fixpath is a misnomer of sorts, since it is used on
  6015.     # the first pass only, and merely examines each filename
  6016.     # in a path, using the procedure mappiece to record any
  6017.     # overlong ones in the global table filenametbl and in
  6018.     # the global sets chunkset and short_chunkset; no fixing
  6019.     # is actually done here.
  6020.  
  6021.     s2 := ""
  6022.     s ? {
  6023.     while piece := tab(find("/")+1)
  6024.     do s2 ||:= mappiece(piece) 
  6025.     s2 ||:= mappiece(tab(0))
  6026.     }
  6027.     return s2
  6028.  
  6029. end
  6030.  
  6031.  
  6032.  
  6033. procedure mappiece(s)
  6034.  
  6035.     # Check s (the name of a file or dir as recorded in the tar header
  6036.     # being examined) to see if it is over 14 chars long.  If so,
  6037.     # generate a unique 14-char version of the name, and store
  6038.     # both values in the global hashtable filenametbl.  Also store
  6039.     # the original (overlong) file name in chunkset.  Store the
  6040.     # first fifteen chars of the original file name in short_chunkset.
  6041.     # Sorry about all of the tables and sets.  It actually makes for
  6042.     # a reasonably efficient program.  Doing away with both sets,
  6043.     # while possible, causes a tenfold drop in execution speed!
  6044.     
  6045.     # global filenametbl, chunkset, short_chunkset, extensions
  6046.     local j, ending
  6047.  
  6048.     initial {
  6049.     filenametbl := table()
  6050.     chunkset := set()
  6051.     short_chunkset := set()
  6052.     }
  6053.    
  6054.     chunk := trim(s,'/')
  6055.     if chunk ? (tab(find(".tar")+4), pos(0)) then {
  6056.     write(&errout, "mtf:  Sorry, I can't let you do this.\n",
  6057.                    "      You've nested a tar archive within\n",
  6058.                    "      another tar archive, which makes it\n",
  6059.                    "      likely I'll f your filenames ubar.")
  6060.     exit(2)
  6061.     }
  6062.     if *chunk > 14 then {
  6063.     i := 0
  6064.  
  6065.     if /filenametbl[chunk] then {
  6066.     # if we have not seen this file, then...
  6067.         repeat {
  6068.         # ...find a new unique 14-character name for it;
  6069.         # preserve important suffixes like ".Z," ".c," etc.
  6070.         # First, check to see if the original filename (chunk)
  6071.         # ends in an important extension...
  6072.         if chunk ?
  6073.             (tab(find(".")),
  6074.              ending := move(1) || tab(match(!\extensions)|any(&ascii)),
  6075.              pos(0)
  6076.              )
  6077.         # ...If so, then leave the extension alone; mess with the
  6078.         # middle part of the filename (e.g. file.with.extension.c ->
  6079.         # file.with001.c).
  6080.         then {
  6081.             j := (15 - *ending - 3)
  6082.             lchunk:= chunk[1:j] || right(string(i+:=1),3,"0") || ending
  6083.         }
  6084.         # If no important extension is present, then reformat the
  6085.         # end of the file (e.g. too.long.file.name -> too.long.fi01).
  6086.         else lchunk := chunk[1:13] || right(string(i+:=1),2,"0")
  6087.  
  6088.         # If the resulting shorter file name has already been used...
  6089.         if lchunk == !filenametbl
  6090.         # ...then go back and find another (i.e. increment i & try
  6091.         # again; else break from the repeat loop, and...
  6092.         then next else break
  6093.         }
  6094.             # ...record both the old filename (chunk) and its new,
  6095.         # mapped name (lchunk) in filenametbl.  Also record the
  6096.         # mapped names in chunkset and short_chunkset.
  6097.         filenametbl[chunk] := lchunk
  6098.         insert(chunkset,chunk)
  6099.         insert(short_chunkset,chunk[1:16])
  6100.     }
  6101.     }
  6102.  
  6103.     # If the filename is overlong, return lchunk (the shortened
  6104.     # name), else return the original name (chunk).  If the name,
  6105.     # as passed to the current function, contained a trailing /
  6106.     # (i.e. if s[-1]=="/"), then put the / back.  This could be
  6107.     # done more elegantly.
  6108.     return (\lchunk | chunk) || ((s[-1] == "/") | "")
  6109.  
  6110. end
  6111.  
  6112.  
  6113.  
  6114. procedure readtarhdr(s)
  6115.  
  6116.     # Read the silly tar header into a record.  Note that, as was
  6117.     # complained about above, some of the fields end in a null, some
  6118.     # in a space, and some in a space and a null.  The procedure
  6119.     # trim_str() may (and in fact often _is_) used to remove this
  6120.     # extra garbage.
  6121.  
  6122.     this_block := hblock()
  6123.     s ? {
  6124.     this_block.name     := move(100)    # <- to be looked at later
  6125.     this_block.junk     := move(8+8+8)  # skip the permissions, uid, etc.
  6126.     this_block.size     := move(12)     # <- to be looked at later
  6127.     this_block.mtime    := move(12)
  6128.     this_block.chksum   := move(8)      # <- to be looked at later
  6129.     this_block.linkflag := move(1)
  6130.     this_block.linkname := move(100)    # <- to be looked at later
  6131.     this_block.therest  := tab(0)
  6132.     }
  6133.     integer(this_block.size) | fail  # If it's not an integer, we've hit
  6134.                                      # the final (null-filled) block.
  6135.     return this_block
  6136.  
  6137. end
  6138.  
  6139.  
  6140.  
  6141. procedure map_filenams(s)
  6142.  
  6143.     # Chunkset is global, and contains all the overlong filenames
  6144.     # found in the first pass through the input file; here the aim
  6145.     # is to map these filenames to the shortened variants as stored
  6146.     # in filenametbl (GLOBAL).
  6147.  
  6148.     local s2
  6149.  
  6150.     s2 := ""
  6151.     s ? {
  6152.     until pos(0) do {
  6153.         # first narrow the possibilities, using short_chunkset
  6154.         if member(short_chunkset,&subject[&pos:&pos+15])
  6155.             # then try to map from a long to a shorter 14-char filename
  6156.         then s2 ||:= (filenametbl[=!chunkset] | move(1))
  6157.         else s2 ||:= move(1)
  6158.     }
  6159.     }
  6160.     return s2
  6161.  
  6162. end
  6163.  
  6164.  
  6165. #  From the IPL.  Thanks, Ralph -
  6166. #  Author:  Ralph E. Griswold
  6167. #  Date:  June 10, 1988
  6168. #  exbase10(i,j) convert base-10 integer i to base j
  6169. #  The maximum base allowed is 36.
  6170.  
  6171. procedure exbase10(i,j)
  6172.  
  6173.    static digits
  6174.    local s, d, sign
  6175.    initial digits := &digits || &lcase
  6176.    if i = 0 then return 0
  6177.    if i < 0 then {
  6178.       sign := "-"
  6179.       i := -i
  6180.       }
  6181.    else sign := ""
  6182.    s := ""
  6183.    while i > 0 do {
  6184.       d := i % j
  6185.       if d > 9 then d := digits[d + 1]
  6186.       s := d || s
  6187.       i /:= j
  6188.       }
  6189.    return sign || s
  6190.  
  6191. end
  6192.  
  6193. # end IPL material
  6194.  
  6195.  
  6196. procedure get_checksum(r)
  6197.  
  6198.     # Calculates the new value of the checksum field for the
  6199.     # current header block.  Note that the specification say
  6200.     # that, when calculating this value, the chksum field must
  6201.     # be blank-filled.
  6202.  
  6203.     sum := 0
  6204.     r.chksum := "        "
  6205.     every field := !r
  6206.     do every sum +:= ord(!field)
  6207.     return sum
  6208.  
  6209. end
  6210.  
  6211.  
  6212.  
  6213. procedure write_report()
  6214.  
  6215.     # This procedure writes out a list of filenames which were
  6216.     # remapped (because they exceeded the SysV 14-char limit),
  6217.     # and then notifies the user of the existence of this file.
  6218.  
  6219.     local outtext, stbl, i
  6220.  
  6221.     (outtext := open(fname := "mapping.report","w")) |
  6222.     open(fname := "/tmp/mapping.report","w") |
  6223.          stop("mtf:  Can't find a place to put mapping.report!")
  6224.     stbl := sort(filenametbl,3)
  6225.     every i := 1 to *stbl -1 by 2 do {
  6226.     write(outtext,left(stbl[i],35," ")," ",stbl[i+1])
  6227.     }
  6228.     write(&errout,"mtf:  ",fname," contains the list of changes")
  6229.     close(outtext)
  6230.     return &null
  6231.  
  6232. end
  6233.  
  6234. From goer@sophist.uchicago.EDU  Sat Mar 31 16:59:29 1990
  6235. Resent-From: goer@sophist.uchicago.EDU
  6236. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6237.     id AA22736; Sat, 31 Mar 90 16:59:29 MST
  6238. Return-Path: goer@sophist.uchicago.EDU
  6239. Received: from tank.uchicago.edu by Arizona.EDU; Sat, 31 Mar 90 17:00 MST
  6240. Received: from sophist.uchicago.edu by tank.uchicago.edu Sat, 31 Mar 90
  6241.  18:00:26 CST
  6242. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA24270; Sat, 31 Mar 90
  6243.  17:54:54 CST
  6244. Resent-Date: Sat, 31 Mar 90 17:01 MST
  6245. Date: Sat, 31 Mar 90 17:54:54 CST
  6246. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  6247. Subject: help with MS-DOS files
  6248. Resent-To: icon-group@cs.arizona.edu
  6249. To: icon-group@arizona.edu
  6250. Resent-Message-Id: <B7CF0D1F6EDFE058C0@Arizona.EDU>
  6251. Message-Id: <9003312354.AA24270@sophist.uchicago.edu>
  6252. X-Envelope-To: icon-group@CS.Arizona.EDU
  6253. X-Vms-To: icon-group@Arizona.edu
  6254. Status: O
  6255.  
  6256. Appended below are two short programs for converting MSDOS
  6257. text files to Unix format and vice-versa.  I use them all
  6258. the time.  I hope someone else finds them helpful.
  6259.  
  6260. #-------------------------------------------------------------------
  6261. #
  6262. #     PROGRAM:  nocr (stands for "no carriage return")
  6263. #
  6264. #     usage:  nocr [file1 [file2 [etc.]]]
  6265. #
  6266. #     PURPOSE:  Nocr simply removes carriage returns from the
  6267. #     files whose names are given as arguments to the program.
  6268. #     I use it to import MS-DOS files.
  6269. #
  6270. #     BUGS:  None known.
  6271. #
  6272. #     Richard L. Goerwitz, III
  6273. #     last modified 1/20/90
  6274. #
  6275. #-------------------------------------------------------------------
  6276.  
  6277. procedure main(a)
  6278.  
  6279.   local fname, infile, outfile
  6280.  
  6281.   *a = 0 & stop("usage:  nocr file1 file2...")
  6282.   while fname := pop(a) do {
  6283.     infile := open(fname,"r") | (er(), next)
  6284.     outfile := open(fname || ".xM","w") | (er(), next)
  6285.     while line := !infile do {
  6286.       if line[-1] == "\x0D"
  6287.       then write(outfile,line[1:-1])
  6288.       else write(outfile,line)
  6289.       }
  6290.     close(infile) | stop("nocr:  cannot close, ",fname)
  6291.     remove(fname) | stop("nocr:  cannot remove ",fname)
  6292.     rename(fname || ".xM",fname)
  6293.     }
  6294.  
  6295. end
  6296.  
  6297. procedure er()
  6298.   write(&errout,"nocr:  cannot open ",fname," for reading")
  6299.   return
  6300. end
  6301.  
  6302.  
  6303. #-------------------------------------------------------------------
  6304. #
  6305. #     PROGRAM:  yescr
  6306. #
  6307. #     usage:  yescr [file1 [file2 [etc.]]]
  6308. #
  6309. #     PURPOSE:  Yescr simply adds a CR after each newlines in the
  6310. #     files whose names are given as arguments to the program.
  6311. #     I use it to export MS-DOS files.
  6312. #
  6313. #     BUGS:  None known.
  6314. #
  6315. #     Richard L. Goerwitz, III
  6316. #     last modified 1/20/90
  6317. #
  6318. #-------------------------------------------------------------------
  6319.  
  6320. procedure main(a)
  6321.  
  6322.   local fname, infile, outfile
  6323.  
  6324.   *a = 0 & stop("usage:  yescr file1 file2...")
  6325.   while fname := pop(a) do {
  6326.     infile := open(fname,"r") | (er(), next)
  6327.     outfile := open(fname || ".xM","w") | (er(), next)
  6328.     while line := !infile do {
  6329.       if line[-1] ~== "\x0D" | line == ""
  6330.       then write(outfile,line || "\x0D")
  6331.       else write(outfile,line)
  6332.       }
  6333.     close(infile) | stop("yescr:  cannot close, ",fname)
  6334.     remove(fname) | stop("yescr:  cannot remove ",fname)
  6335.     rename(fname || ".xM",fname)
  6336.     }
  6337.  
  6338. end
  6339.  
  6340. procedure er()
  6341.   write(&errout,"yescr:  cannot open ",fname," for reading")
  6342.   return
  6343. end
  6344.  
  6345.  
  6346.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  6347.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  6348.  
  6349. From ralph  Mon Apr  2 18:35:07 1990
  6350. Date: Mon, 2 Apr 90 18:35:07 MST
  6351. From: "Ralph Griswold" <ralph>
  6352. Message-Id: <9004030135.AA24469@megaron.cs.arizona.edu>
  6353. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  6354.     id AA24469; Mon, 2 Apr 90 18:35:07 MST
  6355. To: icon-group
  6356. Subject: Version 8 of Icon for VMS
  6357. Status: O
  6358.  
  6359. Version 8 of Icon for VAX/VMS is now available.
  6360.  
  6361. The VMS distribution includes source code, object code, executable binaries,
  6362. documentation, and the Icon program library (new in Version 8).
  6363.  
  6364. Version 8 of Icon for VMS systems can be obtained by anonymous FTP
  6365. to cs.arizona.edu. After connecting, cd /icon/v8.  Get READ.ME
  6366. there for more information.  See vmsfix.com in that directory for
  6367. information about patching up VMS BACKUP tapes after FTP.
  6368.  
  6369. If you do not have FTP access or prefer to obtain a magnetic tape
  6370. and printed documentation, Version 8 of Icon for VMS can be ordered
  6371. from:
  6372.  
  6373.     Icon Project
  6374.     Department of Computer Science
  6375.     Gould-Simpson Building
  6376.     The University of Arizona
  6377.     Tucson, AZ   85721
  6378.  
  6379.     602 621-2018 (voice)
  6380.     602 621-4246 (FAX)
  6381.  
  6382. The price is $30, payable in US dollars with a check written on a bank
  6383. in the United States.  Orders also can be charged to MasterCard or Visa.
  6384. This price includes shipping by parcel post in the United States, Canada,
  6385. and Mexico. Add $10 for air mail delivery to other countries.
  6386.  
  6387. Please direct any questions to me, not to icon-project or icon-group.
  6388.  
  6389.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  6390.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  6391.  
  6392.  
  6393. From cjeffery  Mon Apr  2 20:52:45 1990
  6394. Resent-From: "Clinton Jeffery" <cjeffery>
  6395. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6396.     id AA01383; Mon, 2 Apr 90 20:52:45 MST
  6397. Received: from megaron.cs.arizona.edu by Arizona.EDU; Mon, 2 Apr 90 20:54 MST
  6398. Received: from caslon.cs.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15)
  6399.  via SMTP id AA01306; Mon, 2 Apr 90 20:52:11 MST
  6400. Received: by caslon; Mon, 2 Apr 90 20:52:10 mst
  6401. Resent-Date: Mon, 2 Apr 90 20:54 MST
  6402. Date: Mon, 2 Apr 90 20:52:10 mst
  6403. From: Clinton Jeffery <cjeffery@cs.arizona.edu>
  6404. Subject: Icon Ideas? (operator overloading)
  6405. Resent-To: icon-group@cs.arizona.edu
  6406. To: icon-group@arizona.edu
  6407. Resent-Message-Id: <B61C186D9FFFE06CE1@Arizona.EDU>
  6408. Message-Id: <9004030352.AA03647@caslon>
  6409. In-Reply-To: shelby!csli!poser@decwrl.dec.COM's message of 28 Mar 90 02:30:09
  6410.  GMT <12860@csli.Stanford.EDU>
  6411. X-Envelope-To: icon-group@CS.Arizona.EDU
  6412. X-Vms-To: icon-group@Arizona.edu
  6413. Status: O
  6414.  
  6415. > There is an intermediate approach...Implement operator overloading as
  6416. > ADDITION of methods for new data types, but don't allow pre-defined
  6417. > methods (i.e. the built-in operators) to be removed. This guarantees 
  6418. > that an operator will have the expected semantics when applied to 
  6419. > built-in data types and reduces the uncertainty to derived types.
  6420.  
  6421. I like this a lot.  For Icon, though, I am not sure operator overloading
  6422. makes sense, since Icon does not support the addition of new data types
  6423. (other than records).  It makes great sense in the object-oriented
  6424. Icon-derivatives (what a mouthful!), but none of them do operator
  6425. overloading so far as I know.  No one is willing to translate + into an
  6426. Icon procedure call.  Neither is anyone willing to make extensive
  6427. additions to the Icon interpreter to support this feature which "normal"
  6428. Icon programs couldn't use.  In the absence of type information, are there
  6429. any other alternatives?
  6430.  
  6431. From icon-group-request@arizona.edu  Tue Apr  3 10:44:53 1990
  6432. Resent-From: icon-group-request@arizona.edu
  6433. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6434.     id AA13687; Tue, 3 Apr 90 10:44:53 MST
  6435. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 3 Apr 90 10:21 MST
  6436. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA10428; Tue, 3 Apr 90 09:20:00
  6437.  -0700
  6438. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6439.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6440.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6441. Resent-Date: Tue, 3 Apr 90 10:22 MST
  6442. Date: 3 Apr 90 15:02:32 GMT
  6443. From: esquire!yost@nyu.EDU
  6444. Subject: The Splash programming language
  6445. Sender: icon-group-request@arizona.edu
  6446. Resent-To: icon-group@cs.arizona.edu
  6447. To: icon-group@arizona.edu
  6448. Resent-Message-Id: <B5AB4B25657FC000D2@Arizona.EDU>
  6449. Message-Id: <1909@esquire.UUCP>
  6450. Organization: DP&W, New York, NY
  6451. X-Envelope-To: icon-group@CS.Arizona.EDU
  6452. X-Vms-To: icon-group@Arizona.edu
  6453. Status: O
  6454.  
  6455. A friend at the IBM Watson Research Center saw a talk
  6456. last week by Paul Abrahams on a language he is designing
  6457. called Splash, that is supposed to derive to some extent
  6458. on Icon.  Does anyone know how to find out more about
  6459. this language?
  6460.  
  6461. Thanks
  6462.  
  6463.  --dave yost
  6464.    yost@dpw.com or uunet!esquire!yost
  6465.    Please ignore the From or Reply-To fields above, if different.
  6466.  
  6467. From icon-group-request@arizona.edu  Tue Apr  3 16:33:39 1990
  6468. Resent-From: icon-group-request@arizona.edu
  6469. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6470.     id AA13536; Tue, 3 Apr 90 16:33:39 MST
  6471. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 3 Apr 90 16:33 MST
  6472. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA10493; Tue, 3 Apr 90 16:30:24
  6473.  -0700
  6474. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6475.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6476.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6477. Resent-Date: Tue, 3 Apr 90 16:35 MST
  6478. Date: 3 Apr 90 23:30:14 GMT
  6479. From: usenet@arizona.edu
  6480. Subject: Can Icon be ftp'd from anywhere? Any icon for the Mac?
  6481. Sender: icon-group-request@arizona.edu
  6482. Resent-To: icon-group@cs.arizona.edu
  6483. To: icon-group@arizona.edu
  6484. Resent-Message-Id: <B5771EFA9FDFC00452@Arizona.EDU>
  6485. Message-Id: <35270@ucbvax.BERKELEY.EDU>
  6486. Organization: School of Education, UC-Berkeley
  6487. X-Envelope-To: icon-group@CS.Arizona.EDU
  6488. X-Vms-To: icon-group@Arizona.edu
  6489. Status: O
  6490.  
  6491. around? For the Mac would be great. Any help much appreciated. Thanks
  6492. From: thom@dewey.soe.berkeley.edu (Thom Gillespie)
  6493. Path: dewey.soe.berkeley.edu!thom
  6494.  
  6495. --Thom
  6496.  
  6497.  
  6498.  
  6499. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Tue Apr  3 19:28:26 1990
  6500. Received: from umich.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6501.     id AA07078; Tue, 3 Apr 90 19:28:26 MST
  6502. Received: from ummts.cc.umich.edu by umich.edu (5.61/1123-1.0)
  6503.     id AA05905; Tue, 3 Apr 90 22:28:21 -0400
  6504. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Tue, 3 Apr 90 22:28:14 EDT
  6505. Date: Tue, 3 Apr 90 20:31:14 EDT
  6506. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  6507. To: icon-group@cs.arizona.edu
  6508. Message-Id: <214949@Wayne-MTS>
  6509. Subject: The SPLASH Programming Language
  6510. Status: O
  6511.  
  6512.  
  6513. Re Dave Yost's inquiry: here's the abstract of the talk that I've been
  6514. giving on SPLASH:
  6515.  
  6516. ========================================================
  6517.  
  6518. SPLASH: A Systems Programming Language for Software Hackers
  6519.  
  6520. SPLASH is a programming language designed for programmers who delight in
  6521. their tools.  SPLASH supports programming at a high level of expression,
  6522. yet it enables its user to understand how the code he writes is actually
  6523. executed and to maintain precise control, where it is wanted, over what the
  6524. computer is actually doing.  Its high-level facilities include the ability
  6525. to define container types and iterators; inheritance of operations and
  6526. polymorphism in the object-oriented style; generators that provide most of
  6527. the facilities of coroutines but at far less cost; tuple types; and a great
  6528. many syntactic niceties that encourage elegance and transparency of
  6529. expression.  Although the ideas in SPLASH are not radically new, they are
  6530. combined and integrated in a new way.  Major sources of inspiration for
  6531. SPLASH are Icon, C++, and SEDL, a Software Engineering Design Language
  6532. developed at IBM that is an extension of Ada.  SPLASH is still a paper
  6533. language, but the ideas in it are of interest independently of any
  6534. particular implementation.  The talk will describe the features of SPLASH
  6535. and give some examples of its use. 
  6536. =============================================================
  6537.  
  6538. I still don't have a formal report on it, but I hope to have that by early
  6539. summer.  Meanwhile I'll be happy to answer questions about SPLASH and its
  6540. status.  There are a lot of things in it that are directly taken from
  6541. ICON (for which I give full credit).  Two major differences (which are
  6542. related): SPLASH is strongly typed, and it is designed to be compiled rather
  6543. than interpreted.  The strong typing also makes operator overloading possible
  6544. (re the recent discussions in the ICON group).
  6545.  
  6546. Paul Abrahams
  6547. Abrahams%wayne-mts@um.cc.umich.edu
  6548. 214 River Road
  6549. Deerfield  MA  01342
  6550. (413) 774-5500
  6551.  
  6552. From R.J.Hare@EDINBURGH.AC.UK  Wed Apr  4 11:19:43 1990
  6553. Received: from rvax.ccit.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6554.     id AA26454; Wed, 4 Apr 90 11:19:43 MST
  6555. Received: from UKACRL.BITNET by rvax.ccit.arizona.edu; Wed, 4 Apr 90 11:18 MST
  6556. Received: from RL.IB by UKACRL.BITNET (Mailer X1.25) with BSMTP id 2221; Tue,
  6557.  03 Apr 90 10:04:13 BST
  6558. Date: 03 Apr 90  10:04:40 bst
  6559. From: R.J.Hare@EDINBURGH.AC.UK
  6560. Subject: Prolog documentation
  6561. To: icon-group@cs.arizona.edu
  6562. Message-Id: <03 Apr 90  10:04:40 bst  340539@EMAS-A>
  6563. Via:        UK.AC.ED.EMAS-A;  3 APR 90 10:04:10 BST
  6564. X-Envelope-To: icon-group@CS.ARIZONA.EDU
  6565. Status: O
  6566.  
  6567. Someone put a short document file on this board the other day, which contained
  6568. instructions for running the prolog interpreter. I have foolishly lost this.
  6569. Could it please be re-posted on the board.
  6570.  
  6571. Thanks.
  6572.  
  6573. Roger Hare.
  6574.  
  6575. From icon-group-request@arizona.edu  Wed Apr  4 19:00:49 1990
  6576. Resent-From: icon-group-request@arizona.edu
  6577. Received: from maggie.telcom.arizona.edu by megaron (5.59-1.7/15) via SMTP
  6578.     id AA17274; Wed, 4 Apr 90 19:00:49 MST
  6579. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 4 Apr 90 17:48 MST
  6580. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA10800; Wed, 4 Apr 90 17:44:52
  6581.  -0700
  6582. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6583.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6584.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6585. Resent-Date: Wed, 4 Apr 90 17:55 MST
  6586. Date: 4 Apr 90 23:23:06 GMT
  6587. From: motcid!henley@uunet.uu.NET
  6588. Subject: RE: Can Icon be ftp'd from anywhere? Any icon for the Mac?
  6589. Sender: icon-group-request@arizona.edu
  6590. Resent-To: icon-group@cs.arizona.edu
  6591. To: icon-group@arizona.edu
  6592. Resent-Message-Id: <B4A2C0FF959FC00F03@Arizona.EDU>
  6593. Message-Id: <2074@mica6.UUCP>
  6594. Organization: Motorola Inc., Cellular Infrastructure Div., Arlington Heights, IL
  6595. X-Envelope-To: icon-group@CS.Arizona.EDU
  6596. X-Vms-To: icon-group@Arizona.edu
  6597. References: <35270@ucbvax.BERKELEY.EDU>
  6598. Status: O
  6599.  
  6600. usenet@ucbvax.BERKELEY.EDU (USENET News Administration) writes:
  6601.  
  6602. >around? For the Mac would be great. Any help much appreciated. Thanks
  6603. >From: thom@dewey.soe.berkeley.edu (Thom Gillespie)
  6604. >Path: dewey.soe.berkeley.edu!thom
  6605.  
  6606. >--Thom
  6607.  
  6608. All questions, Yes!
  6609.     1) ICON is available from the university of Arizona(version 7.5 and 7.0):
  6610.  
  6611.         BBS:  (602) 621-2283
  6612.  
  6613.         FTP:  arizona.edu (/icon)
  6614.               (128.196.128.118 or 192.12.69.1)
  6615.  
  6616.     2) There is a version available for the Mac!
  6617.  
  6618.  -------------------------------------------------
  6619. |    Aaron Henley (uunet!motcid!henley)           |
  6620. |    Motorola Cellular Infrastructure Division    |
  6621.  -------------------------------------------------
  6622.  
  6623. From icon-group-request@arizona.edu  Wed Apr  4 19:01:22 1990
  6624. Resent-From: icon-group-request@arizona.edu
  6625. Received: from maggie.telcom.arizona.edu by megaron (5.59-1.7/15) via SMTP
  6626.     id AA17414; Wed, 4 Apr 90 19:01:22 MST
  6627. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 4 Apr 90 17:33 MST
  6628. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA09534; Wed, 4 Apr 90 17:24:54
  6629.  -0700
  6630. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6631.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6632.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6633. Resent-Date: Wed, 4 Apr 90 17:37 MST
  6634. Date: 5 Apr 90 00:01:01 GMT
  6635. From: bullwinkle!ccsam@ucdavis.ucdavis.EDU
  6636. Subject: Icon on the IBM RS/6000
  6637. Sender: icon-group-request@arizona.edu
  6638. Resent-To: icon-group@cs.arizona.edu
  6639. To: icon-group@arizona.edu
  6640. Resent-Message-Id: <B4A541F67F9FC00ED5@Arizona.EDU>
  6641. Message-Id: <7033@aggie.ucdavis.edu>
  6642. Organization: Computing Services, UC Davis
  6643. X-Envelope-To: icon-group@CS.Arizona.EDU
  6644. X-Vms-To: icon-group@Arizona.edu
  6645. Status: O
  6646.  
  6647. the subject says it all - has someone ported it yet?
  6648.  
  6649. (please respond via mail; and, if you've got a 6000 and want
  6650.  to hear what responses i get, please send me a note).
  6651.  
  6652. -sam
  6653.  
  6654. From icon-group-request@arizona.edu  Wed Apr  4 21:49:29 1990
  6655. Resent-From: icon-group-request@arizona.edu
  6656. Received: from maggie.telcom.arizona.edu by megaron (5.59-1.7/15) via SMTP
  6657.     id AA26942; Wed, 4 Apr 90 21:49:29 MST
  6658. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 4 Apr 90 21:50 MST
  6659. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA23834; Wed, 4 Apr 90 21:38:24
  6660.  -0700
  6661. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6662.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6663.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6664. Resent-Date: Wed, 4 Apr 90 21:51 MST
  6665. Date: 4 Apr 90 16:05:44 GMT
  6666. From: esquire!yost@nyu.EDU
  6667. Subject: RE: Any Icon (programming language) for the Mac?
  6668. Sender: icon-group-request@arizona.edu
  6669. Resent-To: icon-group@cs.arizona.edu
  6670. To: icon-group@arizona.edu
  6671. Resent-Message-Id: <B481DF6F09FFC01061@Arizona.EDU>
  6672. Message-Id: <1913@esquire.UUCP>
  6673. Organization: DP&W, New York, NY
  6674. X-Envelope-To: icon-group@CS.Arizona.EDU
  6675. X-Vms-To: icon-group@Arizona.edu
  6676. References: <35270@ucbvax.BERKELEY.EDU>
  6677. Status: O
  6678.  
  6679. In article <35270@ucbvax.BERKELEY.EDU> thom@dewey.soe.berkeley.edu.UUCP (Thom Gillespie) writes.
  6680.  
  6681. ProIcon for the Mac looks from its manual to be
  6682. extremely well done.  I haven't used it or seen
  6683. it used yet, but it has nicely-accessible online
  6684. language reference documentation, power assist for
  6685. writing code, some support for Mac windows, and
  6686. tracing has been extended to include calls to builtin
  6687. functions, and other goodies.
  6688.  
  6689. ProIcon was developed by Mark Emmer and Ralph Griswold
  6690. and is available mail order for $175 from their company
  6691. called Bright Forest at 303-539-3884.
  6692.  
  6693. It would be nice if someone who uses ProIcon
  6694. would tell us if it really is as good as it looks.
  6695.  
  6696. There is also more unix-like batch-oriented version
  6697. for MPW available from icon-project@cs.arizona.edu.
  6698.  
  6699.  --dave yost
  6700.    yost@dpw.com or uunet!esquire!yost
  6701.    Please ignore the From or Reply-To fields above, if different.
  6702.  
  6703. From shafto@eos.arc.nasa.GOV  Thu Apr  5 08:20:36 1990
  6704. Resent-From: shafto@eos.arc.nasa.GOV
  6705. Received: from maggie.telcom.arizona.edu by megaron (5.59-1.7/15) via SMTP
  6706.     id AA29876; Thu, 5 Apr 90 08:20:36 MST
  6707. Received: from eos.arc.nasa.gov by Arizona.EDU; Thu, 5 Apr 90 08:19 MST
  6708. Received: Thu, 5 Apr 90 08:16:57 PST by eos.arc.nasa.gov (5.59/1.2)
  6709. Resent-Date: Thu, 5 Apr 90 08:21 MST
  6710. Date: Thu, 5 Apr 90 08:16:57 PST
  6711. From: Michael Shafto <shafto@eos.arc.nasa.GOV>
  6712. Subject: RE: Any Icon (programming language) for the Mac?
  6713. Resent-To: icon-group@cs.arizona.edu
  6714. To: esquire!yost@nyu.EDU, icon-group@arizona.edu
  6715. Cc: shafto@EOS.ARC.NASA.GOV
  6716. Resent-Message-Id: <B429D55CA3DFC0132C@Arizona.EDU>
  6717. Message-Id: <9004051616.AA23858@eos.arc.nasa.gov>
  6718. X-Envelope-To: icon-group@CS.Arizona.EDU
  6719. X-Vms-To: esquire!yost@nyu.EDU, icon-group@Arizona.edu
  6720. X-Vms-Cc: shafto@EOS.ARC.NASA.GOV
  6721. Status: O
  6722.  
  6723. Well, I've used ProIcon quite a bit, as well as other symbol-processing
  6724. languages on the Mac -- Allegro Common Lisp and MaxSpitbol.  I uncovered
  6725. a bug regarding coroutines, which Mark & Ralph patched up right away --
  6726. they're a lot more responsive than the MPW folks, in my experience.
  6727.  
  6728. I found the ProIcon environment significantly more comfortable than
  6729. the ACL environment, even though I had sort of adapted to ACL before
  6730. getting ProIcon.  As a general high-level language that gives access
  6731. to the Mac qua Mac, I strongly recommend ProIcon.
  6732.  
  6733. (Can't comment much on MaxSpitbol due to less experience with it,
  6734. though it looks to have many of the same good environmental
  6735. features as ProIcon.)
  6736.  
  6737. Mike
  6738.  
  6739. From goer@sophist.uchicago.EDU  Thu Apr  5 15:51:15 1990
  6740. Resent-From: goer@sophist.uchicago.EDU
  6741. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6742.     id AA00754; Thu, 5 Apr 90 15:51:15 MST
  6743. Return-Path: goer@sophist.uchicago.EDU
  6744. Received: from tank.uchicago.edu by Arizona.EDU; Thu, 5 Apr 90 14:55 MST
  6745. Received: from sophist.uchicago.edu by tank.uchicago.edu Thu, 5 Apr 90 16:54:03
  6746.  CDT
  6747. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA00373; Thu, 5 Apr 90
  6748.  16:50:21 CDT
  6749. Resent-Date: Thu, 5 Apr 90 15:03 MST
  6750. Date: Thu, 5 Apr 90 16:50:21 CDT
  6751. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  6752. Subject: benchmarks for v8, Xenix
  6753. Resent-To: icon-group@cs.arizona.edu
  6754. To: icon-group@arizona.edu
  6755. Resent-Message-Id: <B3F1A7D705FFC014BD@Arizona.EDU>
  6756. Message-Id: <9004052150.AA00373@sophist.uchicago.edu>
  6757. X-Envelope-To: icon-group@CS.Arizona.EDU
  6758. X-Vms-To: icon-group@Arizona.edu
  6759. Status: O
  6760.  
  6761.  
  6762. I'm just curious what sorts of benchmarks people are getting
  6763. for other machines.  For me, v8 runs just as fast (maybe even
  6764. a tad faster, but this may be due to my new compiler) than
  6765. v7.
  6766.  
  6767. I'm running a 386 box with Xenix 2.3.2, and the 2.3.0 compiler
  6768. set (with lng085 sls = MSC 5.1).  However, I actually ended up
  6769. compiling Icon with gcc (-traditional).  My results were:
  6770.  
  6771. concord.out:concord elapsed time = 17166
  6772. deal.out:deal elapsed time = 21133
  6773. ipxref.out:ipxref elapsed time = 4233
  6774. queens.out: elapsed time = 22383
  6775. rsg.out: elapsed time = 24367
  6776.  
  6777. The MSC 5.1 compiler compiled okay, but the result was unsatis-
  6778. factory (none of the builtin functions could be found by the
  6779. interpreter).  Gcc passed all the tests, except for things that
  6780. are site-specific, and a few floating point operations (for
  6781. which it gave a few digits less precision).
  6782.  
  6783. Incidentally, if anyone gets Icon compiled with MSC 5.1 under
  6784. Xenix, I'd appreciate hearing about it.  My real reason for
  6785. posting, though, isn't to gripe about the Xenix compiler, but
  6786. to find out what others are discovering about Icon v8 as far
  6787. as the benchmarks go.
  6788.  
  6789.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  6790.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  6791.  
  6792. From goer@sophist.uchicago.EDU  Thu Apr  5 17:25:06 1990
  6793. Resent-From: goer@sophist.uchicago.EDU
  6794. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6795.     id AA10199; Thu, 5 Apr 90 17:25:06 MST
  6796. Return-Path: goer@sophist.uchicago.EDU
  6797. Received: from tank.uchicago.edu by Arizona.EDU; Thu, 5 Apr 90 17:25 MST
  6798. Received: from sophist.uchicago.edu by tank.uchicago.edu Thu, 5 Apr 90 19:23:31
  6799.  CDT
  6800. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA00503; Thu, 5 Apr 90
  6801.  19:19:50 CDT
  6802. Resent-Date: Thu, 5 Apr 90 17:27 MST
  6803. Date: Thu, 5 Apr 90 19:19:50 CDT
  6804. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  6805. Subject: coexpressions for Xenix
  6806. Resent-To: icon-group@cs.arizona.edu
  6807. To: icon-group@arizona.edu
  6808. Resent-Message-Id: <B3DD96DC7EBFC01749@Arizona.EDU>
  6809. Message-Id: <9004060019.AA00503@sophist.uchicago.edu>
  6810. X-Envelope-To: icon-group@CS.Arizona.EDU
  6811. X-Vms-To: icon-group@Arizona.edu
  6812. Status: O
  6813.  
  6814.  
  6815. I just implemented coexpressions for my Xenix system.  It didn't
  6816. require rewriting a single line of code.  I just moved the Micro-
  6817. port System V file into the Xenix directory, removed the #define
  6818. NoCoexp (or whatever it is), and recompiled.  Note that I used gcc.
  6819. I'd guess it would work with MSC 5.1 if the bugs there could be
  6820. worked out.  Anyway, it passes the tests, and so I'm happy.  I just
  6821. thought someone else might like to know that it can (easily) be
  6822. done.
  6823.  
  6824.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  6825.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  6826.  
  6827. From cargo@tardis.cray.com  Fri Apr  6 06:23:21 1990
  6828. Received: from timbuk.cray.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6829.     id AA17024; Fri, 6 Apr 90 06:23:21 MST
  6830. Received: from hall.cray.com by timbuk.CRAY.COM (4.1/CRI-1.34)
  6831.     id AA14189; Fri, 6 Apr 90 08:23:54 CDT
  6832. Received: from zk.cray.com by hall.cray.com
  6833.     id AA10754; 3.2/CRI-3.12; Fri, 6 Apr 90 08:23:52 CDT
  6834. Received: by zk.cray.com
  6835.     id AA17193; 3.2/CRI-3.12; Fri, 6 Apr 90 08:23:50 CDT
  6836. Date: Fri, 6 Apr 90 08:23:50 CDT
  6837. From: cargo@tardis.cray.com (David S. Cargo)
  6838. Message-Id: <9004061323.AA17193@zk.cray.com>
  6839. To: icon-group@cs.arizona.edu
  6840. Subject: RE: Any Icon (programming language) for the Mac?
  6841. Status: O
  6842.  
  6843. I have used ProIcon for generating PostScript files for printing
  6844. on the Mac.  Just this last weekend, I wrote and tested two Icon
  6845. programs on MS-DOS and then moved the files to the Mac (via MS-DOS
  6846. 5.25" floppy to MS-DOS 720K 3.5" floppy to Mac via Apple File Exchange
  6847. with a Mac with Superdrive).
  6848.  
  6849. The same Icon programs compiled and ran with ProIcon.  For me, this
  6850. was extremely useful, since my home system is MS-DOS but my target
  6851. environment was a Mac.
  6852.  
  6853. I have also used the ProIcon features for reading and writing files
  6854. to and from windows, but not so much since maintaining portability
  6855. was high on my list for my major programs.
  6856.  
  6857. dsc
  6858.  
  6859. From ralph  Fri Apr  6 08:26:29 1990
  6860. Date: Fri, 6 Apr 90 08:26:29 MST
  6861. From: "Ralph Griswold" <ralph>
  6862. Message-Id: <9004061526.AA24992@megaron.cs.arizona.edu>
  6863. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  6864.     id AA24992; Fri, 6 Apr 90 08:26:29 MST
  6865. To: icon-group
  6866. Subject: ProIcon
  6867. Status: O
  6868.  
  6869. The contact/telephone numbers for ProIcon in recent e-mail were
  6870. not correct.
  6871.  
  6872. ProIcon is marketed by Catspaw, Inc.  Their telephone number is
  6873.  
  6874.     719-539-3884
  6875.  
  6876. The telephone number for The Bright Forest Company is
  6877.  
  6878.     602-325-3948
  6879.  
  6880.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  6881.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  6882.  
  6883. From shafto@eos.arc.nasa.gov  Fri Apr  6 10:32:01 1990
  6884. Received: from eos.arc.nasa.gov by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6885.     id AA05802; Fri, 6 Apr 90 10:32:01 MST
  6886. Received: Fri, 6 Apr 90 08:28:04 PST by eos.arc.nasa.gov (5.59/1.2)
  6887. Date: Fri, 6 Apr 90 08:28:04 PST
  6888. From: Michael Shafto <shafto@eos.arc.nasa.gov>
  6889. Message-Id: <9004061628.AA12692@eos.arc.nasa.gov>
  6890. To: cargo@tardis.cray.com, icon-group@cs.arizona.edu
  6891. Subject: RE: Any Icon (programming language) for the Mac?
  6892. Cc: shafto@EOS.ARC.NASA.GOV
  6893. Status: O
  6894.  
  6895. I have also happily ported Icon from MS-DOS to Mac (ProIcon),
  6896. which saved me a lot of time.  I've not seen a Lisp dialect
  6897. that can do the same trick, though I imagine there must be such
  6898. a path via Common Lisp.
  6899.  
  6900. Mike
  6901.  
  6902. From icon-group-request@arizona.edu  Fri Apr  6 15:26:42 1990
  6903. Resent-From: icon-group-request@arizona.edu
  6904. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6905.     id AA29636; Fri, 6 Apr 90 15:26:42 MST
  6906. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Fri, 6 Apr 90 15:26 MST
  6907. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA23944; Fri, 6 Apr 90 15:04:16
  6908.  -0700
  6909. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6910.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6911.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6912. Resent-Date: Fri, 6 Apr 90 15:26 MST
  6913. Date: 6 Apr 90 21:20:38 GMT
  6914. From: pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!suned1!zaft@tut.cis.ohio-state.EDU
  6915. Subject: RE: Can Icon be ftp'd from anywhere? Any icon for the Mac?
  6916. Sender: icon-group-request@arizona.edu
  6917. Resent-To: icon-group@cs.arizona.edu
  6918. To: icon-group@arizona.edu
  6919. Resent-Message-Id: <B3254B01E47FC02098@Arizona.EDU>
  6920. Message-Id: <3605@suned1.Navy.MIL>
  6921. Organization: NSWSES, Port Hueneme, CA
  6922. X-Envelope-To: icon-group@CS.Arizona.EDU
  6923. X-Vms-To: icon-group@Arizona.edu
  6924. References: <35270@ucbvax.BERKELEY.EDU>, <2074@mica6.UUCP>
  6925. Status: O
  6926.  
  6927. CORRECTION:  The latest Icon Newsletter says the address for U of
  6928. Arizona is changing from arizona.edu to cs.arizona.edu.
  6929.  
  6930. Gordon Zaft
  6931.  
  6932. -- 
  6933. *****************************************************************************
  6934. *     suned1!zaft@elroy.JPL.Nasa.Gov     zaft@suned1.nswses.navy.mil         *
  6935. *    Chairman, Ventura County ACM    Phone: (805) 982-0684               *
  6936. *    Any statements / opinions made here are mine, alone, not the Navy's.   *
  6937.  
  6938. From icon-group-request@arizona.edu  Mon Apr  9 16:19:18 1990
  6939. Resent-From: icon-group-request@arizona.edu
  6940. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  6941.     id AA07889; Mon, 9 Apr 90 16:19:18 MST
  6942. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Mon, 9 Apr 90 10:37 MST
  6943. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA18962; Mon, 9 Apr 90 10:26:32
  6944.  -0700
  6945. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  6946.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  6947.  usenet@ucbvax.Berkeley.EDU if you have questions)
  6948. Resent-Date: Mon, 9 Apr 90 16:03 MST
  6949. Date: 9 Apr 90 17:22:44 GMT
  6950. From: usc!zaphod.mps.ohio-state.edu!rpi!uwm.edu!csd4.csd.uwm.edu!corre@ucsd.EDU
  6951. Subject: Icon on the Mac
  6952. Sender: icon-group-request@arizona.edu
  6953. Resent-To: icon-group@cs.arizona.edu
  6954. To: icon-group@arizona.edu
  6955. Resent-Message-Id: <B0C49CFE19FFC02ACA@Arizona.EDU>
  6956. Message-Id: <3344@uwm.edu>
  6957. Organization: University of Wisconsin-Milwaukee
  6958. X-Envelope-To: icon-group@CS.Arizona.EDU
  6959. X-Vms-To: icon-group@Arizona.edu
  6960. Status: O
  6961.  
  6962. I have been using ProIcon (Icon for the Macintosh computer)
  6963. continuously for some three months, and am writing to share some
  6964. impressions at this point. I feel that one's response to ProIcon will
  6965. be largely determined by how one responds to the Macintosh. I am
  6966. currently preparing some instructional materials for modern Hebrew
  6967. reviving some ideas I tried to implement some twenty years ago using
  6968. programmed learning. Many students liked the approach, but I was
  6969. bothered by the almost inevitable clumsiness and turgidity of
  6970. programmed texts, and did not pursue my ideas too far. I feel that the
  6971. computer offers real possibilities of helping students with the
  6972. difficult task of learning natural languages, especially those which
  6973. use exotic scripts. I decided to try to implement this on the
  6974. Macintosh, because my impression is that students prefer this machine,
  6975. and when they can choose between it and the other system, they vote
  6976. with their feet. The fact is that soaps doubtless have a much greater
  6977. following than dramatic masterpieces on public tv, so one need hardly
  6978. be surprised that a bright, cheery sometimes gormless approach wins
  6979. out on the computer too. I hope I don't seem to be an intellectual
  6980. snob in saying this, because I realise that my tastes are often
  6981. low-brow, and I could not honestly criticize the individuals (my son
  6982. is one) who enjoy the Macintosh. But I don't care for the Macintosh.
  6983. Bad enough that I still have to take out the trash in real life, I
  6984. don't need to do it symbolically on the screen. These trivialities
  6985. annoy me as a Macintosh user, but, more seriously, as a programmer I
  6986. feel the lack of support of a consistent and powerful operating system
  6987. which will willingly accept my written orders. Using ProIcon is quite
  6988. pleasant; it just can't get away from the world in which it lives.
  6989. True it adds some functions presaging version 8, and it has a
  6990. development system comparable to that of Turbo Pascal, bringing you
  6991. back to the Editor when an error is detected. But there is a
  6992. trade-off; the ProIcon Editor is an Editor and, unlike the Editor in
  6993. Apple Pascal for the II+ for example, does not have an automatic fill
  6994. mode that avoids the carriage returns when writing straight text.
  6995. Accordingly I find that having more or less completed a program in
  6996. ProIcon for which I found the Editor quite satisfactory, I am now
  6997. preparing the data files which the program processes on my Zenith
  6998. using my favorite editor JOVE (Jonathan's Own Version of Emacs), and
  6999. transferring them to the Mac.
  7000.  
  7001.     There is one big addition which ProIcon has, and that is the
  7002. windows. You do not need absolutely to use these windows if you don't want
  7003. to. I transferred a lengthy Icon program which gives a visually equivalent
  7004. Jewish and Gregorian calendar for any year from MS-DOS and UNIX to the
  7005. Macintosh and only needed to remove the screen controls to make it work
  7006. nicely on the Macintosh using only the Interactive window.  But it is a
  7007. pity to waste this resource if you are working in the first instance on the
  7008. Macintosh, and portability is not important. It does however inject a new
  7009. element into one's programming. Suddenly one has to become to some extent a
  7010. graphic designer, and this, like programming, is an art, but an entirely
  7011. different one. The immense flexibility and power of the window functions of
  7012. ProIcon force the programmer to think about all kinds of esthetic issues
  7013. which were not really relevant previously. Perhaps someone could do for
  7014. ProIcon's windows what Leslie Lamport did for TeX -- take over the visual
  7015. design aspect and let the programmer concentrate on logical design. Lamport
  7016. points out that "with a visual design system, authors usually produce
  7017. aesthetically pleasing, but poorly designed documents." I have an
  7018. uncomfortable feeling that I may be doing the same thing with my windows.
  7019.  
  7020.     With this admission, I would yet suggest some tentative guidelines
  7021. for using these windows. Perhaps others will have further suggestions which
  7022. will enable us to build up a body of expertise in this area. First plan the
  7023. windows which you will need for the entire program. They can be set up at
  7024. the beginning, their size, position and fonts can be determined, and
  7025. decisions made as to how they will be connected with disk files, if at all.
  7026. They do not have to be visible at this stage, or indeed at any stage (I'll
  7027. address this later.) For example, at one stage of my program I have a setup
  7028. which looks like this:
  7029.  ------------------------------------------------------------------------
  7030. |                                   |                                   |
  7031. |                                   |                                   |
  7032. |                                   |                                   |
  7033. |                                   |                                   |
  7034. |                                   |                                   |
  7035. |        Interactive Window         |         Hebrew Window             |
  7036. |                                   |                                   |
  7037. |                                   |                                   |
  7038. |                                   |                                   |
  7039. |                                   |                                   |
  7040. |                                   |                                   |
  7041. |                                   |                                   |
  7042. |                                   |                                   |
  7043.  ------------------------------------------------------------------------
  7044. |                                                                       |
  7045. |                                                                       |
  7046. |                                                                       |
  7047. |                                                                       |
  7048. |                       Information Window                              |
  7049. |                                                                       |
  7050. |                                                                       |
  7051. |                                                                       |
  7052. |                                                                       |
  7053.  -----------------------------------------------------------------------
  7054.  
  7055. The upper left window gives information to, and gets responses from, the
  7056. user. It derives its information from a disk file, but the window itself is
  7057. not connected to a file. The upper right window is connected to an empty
  7058. file which has been opened for writing, so this window is dynamic. Items
  7059. appear there (in Hebrew script) which have been prompted by the activity in
  7060. the adjacent window. This material can be saved permanently if desired. The
  7061. bottom window is connected to a complete, previously prepared file which has
  7062. been opened for reading. This is a static window, which the user refers to
  7063. as necessary, moving back and forth at will by manipulating the bar, arrows
  7064. and thumb on the right side of the window. This might be a help screen, or a
  7065. set of relevant information which needs to be handy throughout the exercise.
  7066. In addition there is a fourth window which the program never activates. This
  7067. is connected to a file logging the user's activity, hour by hour and day by
  7068. day, and measuring success.  To this file material is constantly appended,
  7069. and is saved at the end of the program. The user can see it at any time
  7070. before the program ends by using the pull-down window menu, and clicking on
  7071. the Log entry, dismissing it after perusal by clicking on its close box in
  7072. its upper left hand corner.  This window just lurks in the background, and
  7073. some users might never activate it at all.
  7074.  
  7075.     I think this is sufficient to indicate that the permutations of the
  7076. ways in which windows can be used are vast. It is probably best to try out
  7077. the window functions in some trivial program, just to get a feel for the
  7078. manner in which they work. They really do what they are supposed to, but
  7079. often it is easier to understand what the functions do by seeing them at
  7080. work rather than trying to understand a verbal description. The
  7081. documentation does a pretty good job, and is pleasant to look at, but it 
  7082. is really hard to describe all these possibilities clearly in words.
  7083.  
  7084.  
  7085. --
  7086. Alan D. Corre
  7087. Department of Hebrew Studies
  7088. University of Wisconsin-Milwaukee                     (414) 229-4245
  7089. PO Box 413, Milwaukee, WI 53201               corre@csd4.csd.uwm.edu
  7090.  
  7091. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Mon Apr  9 19:40:44 1990
  7092. Received: from umich.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7093.     id AA22670; Mon, 9 Apr 90 19:40:44 MST
  7094. Received: from ummts.cc.umich.edu by umich.edu (5.61/1123-1.0)
  7095.     id AA16310; Mon, 9 Apr 90 22:40:38 -0400
  7096. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Mon, 9 Apr 90 22:40:25 EDT
  7097. Date: Mon, 9 Apr 90 20:16:22 EDT
  7098. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  7099. To: icon-group@cs.arizona.edu
  7100. Message-Id: <216762@Wayne-MTS>
  7101. Subject: SPLASH: A Systems Programming Language for Software Hackers
  7102. Status: O
  7103.  
  7104.  
  7105. In answer to a recent inquiry in this forum, here's the abstract of the talk
  7106. that I've been giving on SPLASH.  My apologies if you've received this twice;
  7107. I thought I transmitted it once before but I never got a copy back.   Many of
  7108. the ideas in SPLASH are derived from Icon.  The main differences are that
  7109. SPLASH is strongly typed and that it is designed to be compiled rather than
  7110. interpreted.  (That helps in providing operator overloading - a recent topic
  7111. of discussion in this forum.)  I'll be happy to answer any questions about
  7112. SPLASH either by email or otherwise.
  7113.  
  7114. ==================================================================
  7115.  
  7116. SPLASH: A Systems Programming Language for Software Hackers
  7117.  
  7118. SPLASH is a programming language for programmers who delight in
  7119. their tools.  SPLASH supports programming at a high level of
  7120. expression, yet it enables its user to understand how the code he
  7121. writes is really executed and to maintain precise control, where
  7122. it is wanted, over what the computer is actually doing.  Its
  7123. high-level facilities include the ability to define container
  7124. types and iterators; generators that provide most of the
  7125. facilities of coroutines but at far less cost; tuple types;
  7126. inheritance of operations and polymorphism in the object-oriented
  7127. style; and a great many syntactic niceties that encourage
  7128. elegance and transparency of expression.  Although the ideas in
  7129. SPLASH are not radically new, they are combined and integrated in
  7130. a new way.  Major sources of inspiration for SPLASH are Icon,
  7131. C++, and SEDL, a Software Engineering Design Language developed
  7132. at IBM that is an extension of Ada.  Although SPLASH has not yet
  7133. been implemented, the ideas in it are of interest independently
  7134. of any particular implementation.  The talk will describe the
  7135. features of SPLASH and give some examples of its use. 
  7136.  
  7137.  
  7138.  
  7139. Paul Abrahams
  7140. 214 River Road
  7141. Deerfield  MA  01342
  7142. (413) 774-5500
  7143. Abrahams%wayne-mts@um.cc.umich.edu 
  7144.  
  7145. From goer@sophist.uchicago.EDU  Mon Apr  9 23:20:36 1990
  7146. Resent-From: goer@sophist.uchicago.EDU
  7147. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7148.     id AA02894; Mon, 9 Apr 90 23:20:36 MST
  7149. Return-Path: goer@sophist.uchicago.EDU
  7150. Received: from tank.uchicago.edu by Arizona.EDU; Mon, 9 Apr 90 23:15 MST
  7151. Received: from sophist.uchicago.edu by tank.uchicago.edu Tue, 10 Apr 90
  7152.  01:13:45 CDT
  7153. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA06171; Tue, 10 Apr 90
  7154.  01:09:59 CDT
  7155. Resent-Date: Mon, 9 Apr 90 23:21 MST
  7156. Date: Tue, 10 Apr 90 01:09:59 CDT
  7157. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  7158. Subject: type conversion
  7159. Resent-To: icon-group@cs.arizona.edu
  7160. To: icon-group@arizona.edu
  7161. Resent-Message-Id: <B0875C6947DFC02FBD@Arizona.EDU>
  7162. Message-Id: <9004100609.AA06171@sophist.uchicago.edu>
  7163. X-Envelope-To: icon-group@CS.Arizona.EDU
  7164. X-Vms-To: icon-group@Arizona.edu
  7165. Status: O
  7166.  
  7167.  
  7168. I find that I don't make much use of automatic type conversion.
  7169. Even though this feature lies at the heart of the Icon implemen-
  7170. tation, I wonder how much it lies at the heart of the language's
  7171. conception.
  7172.  
  7173. Normally, if I think that a type conversion will occur, I make
  7174. the conversion explicit with a builtin function like string()
  7175. or cset() or integer().  I find that if conversions are occurring
  7176. where I don't know about them, they are *usually* indicative of
  7177. sloppy programming on my part.
  7178.  
  7179. If automatic type conversion disappeared, what sorts of ramifications
  7180. would it have?  Would some aspect of the language that I haven't
  7181. considered be radically altered?  Or would it permit greater
  7182. speed and allow for fuller implementation of things like operator
  7183. overloading (which some seem to want)?
  7184.  
  7185. What if we had optional static typing?  Would this offer the best
  7186. of both worlds?  How would such a feature be implemented and inte-
  7187. grated into the rest of the language (if in fact it is desirable
  7188. in the first place)?  Would it be hard to do?
  7189.  
  7190. I don't claim to be a theoretician.  Any discussion or clarification
  7191. would be much appreciated.  Flames as well.  I don't take this sort
  7192. of thing too personally.
  7193.  
  7194.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  7195.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  7196.  
  7197. From icon-group-request@arizona.edu  Wed Apr 11 04:04:09 1990
  7198. Resent-From: icon-group-request@arizona.edu
  7199. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7200.     id AA14471; Wed, 11 Apr 90 04:04:09 MST
  7201. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 11 Apr 90 04:05 MST
  7202. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA19478; Wed, 11 Apr 90
  7203.  03:47:54 -0700
  7204. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  7205.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  7206.  usenet@ucbvax.Berkeley.EDU if you have questions)
  7207. Resent-Date: Wed, 11 Apr 90 04:05 MST
  7208. Date: 11 Apr 90 10:22:29 GMT
  7209. From: zaphod.mps.ohio-state.edu!usc!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  7210. Subject: RE: type conversion
  7211. Sender: icon-group-request@arizona.edu
  7212. Resent-To: icon-group@cs.arizona.edu
  7213. To: icon-group@arizona.edu
  7214. Resent-Message-Id: <AF968971935FC03C84@Arizona.EDU>
  7215. Message-Id: <2035@bruce.OZ>
  7216. Organization: Monash Uni. Computer Science, Australia
  7217. X-Envelope-To: icon-group@CS.Arizona.EDU
  7218. X-Vms-To: icon-group@Arizona.edu
  7219. References: <9004100609.AA06171@sophist.uchicago.edu>
  7220. Status: O
  7221.  
  7222. In article <9004100609.AA06171@sophist.uchicago.edu>, goer@SOPHIST.UCHICAGO.EDU (Richard Goerwitz) writes:
  7223. > I find that I don't make much use of automatic type conversion.
  7224. > Even though this feature lies at the heart of the Icon implemen-
  7225. > tation, I wonder how much it lies at the heart of the language's
  7226. > conception.
  7227.  
  7228. I call this kind of type conversion "type coercion" and if I can quote from
  7229. T.W. Pratt's book (2nd Edition) "Programming Languages, Design and
  7230. Implementation", p 57:
  7231.  
  7232.     "Coercions are an important design issue in most languages.  Two
  7233.      opposed philosophies exist regarding the extent to which the
  7234.      language should provide coercions between data types."
  7235.  
  7236. The two schools of thought Pratt refers to are:
  7237.     (i) only do essential coercions like int/real (Modula-2 goes even
  7238.         further and does none!), 
  7239.     (ii) if there is a coercion that might make sense then do it (e.g.
  7240.          if a string looks like it could be a numeral then convert it).
  7241.  
  7242. > Normally, if I think that a type conversion will occur, I make
  7243. > the conversion explicit with a builtin function like string()
  7244. > or cset() or integer().  I find that if conversions are occurring
  7245. > where I don't know about them, they are *usually* indicative of
  7246. > sloppy programming on my part.
  7247.  
  7248. Your philosophy is (i) above.
  7249.  
  7250. > If automatic type conversion disappeared, what sorts of ramifications
  7251. > would it have?  Would some aspect of the language that I haven't
  7252. > considered be radically altered?  Or would it permit greater
  7253. > speed and allow for fuller implementation of things like operator
  7254. > overloading (which some seem to want)?
  7255. >
  7256.  
  7257. From the point of view of implementation it is probably easier to do
  7258. Status: O
  7259.  
  7260. no coercions.  There would be little difference in execution speed either way.
  7261. It would probably be easy to provide a flag to turn this feature on or off
  7262. when using Icon.  Unfortunately this would mean two kinds of source code
  7263. proliferating.  In the functional language community a similar controversy
  7264. surrounds the use of strict or lazy evaluation of procedure arguments.
  7265. Lazy evaluation is more powerful but can enable some very arcane programming
  7266. techniques.  The functional language ML chose to use strict evaluation.
  7267. Some people liked ML except for this one thing, hence LML was born.
  7268. Imagine what it would be like if every language design decision was made
  7269. an implementation variable!
  7270.  
  7271. > What if we had optional static typing?  Would this offer the best
  7272. > of both worlds?  How would such a feature be implemented and inte-
  7273. > grated into the rest of the language (if in fact it is desirable
  7274. > in the first place)?  Would it be hard to do?
  7275. >
  7276.  
  7277. Static type checking is not realistically possible for a language such as Icon.
  7278. Consider the expression:
  7279.     if x=0 then "small" else 1
  7280. The type of this expression may be impossible to determine until run time.
  7281. In Icon as well as such expressions as these it is possible to check the type
  7282. of a value at run time and act according to this information.  I have used
  7283. this myself to obtain the behaviour of variant types.  For example:
  7284.     if type(x)=="integer" then x+1 else 0
  7285. Expression such as this are quite foreign to languages with static type
  7286. checking.  Perhaps what you need is some kind of "lint" program like that
  7287. which the C programming language has.  For programs which can be statically
  7288. typed it could warn of any type clashes and coercions that will occur, for
  7289. other programs it could just indicate that static type checking was not
  7290. feasible.
  7291.  
  7292. From goer@sophist.uchicago.EDU  Wed Apr 11 06:12:07 1990
  7293. Resent-From: goer@sophist.uchicago.EDU
  7294. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7295.     id AA18233; Wed, 11 Apr 90 06:12:07 MST
  7296. Return-Path: goer@sophist.uchicago.EDU
  7297. Received: from tank.uchicago.edu by Arizona.EDU; Wed, 11 Apr 90 06:11 MST
  7298. Received: from sophist.uchicago.edu by tank.uchicago.edu Wed, 11 Apr 90
  7299.  08:10:07 CDT
  7300. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA07853; Wed, 11 Apr 90
  7301.  08:06:19 CDT
  7302. Resent-Date: Wed, 11 Apr 90 06:13 MST
  7303. Date: Wed, 11 Apr 90 08:06:19 CDT
  7304. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  7305. Subject: type coercion
  7306. Resent-To: icon-group@cs.arizona.edu
  7307. To: icon-group@arizona.edu
  7308. Resent-Message-Id: <AF84A9EABC9FC030C1@Arizona.EDU>
  7309. Message-Id: <9004111306.AA07853@sophist.uchicago.edu>
  7310. X-Envelope-To: icon-group@CS.Arizona.EDU
  7311. X-Vms-To: icon-group@Arizona.edu
  7312. Status: O
  7313.  
  7314. Consider the following:
  7315.  
  7316.    Static type checking is not realistically possible for a language
  7317.    such as Icon. Consider the expression:
  7318.  
  7319.     if x=0 then "small" else 1
  7320.  
  7321.    The type of this expression may be impossible to determine until
  7322.    run time.  In Icon as well as such expressions as these it is
  7323.    possible to check the type of a value at run time and act according
  7324.    to this information.  I have used this myself to obtain the
  7325.    behaviour of variant types.  For example:
  7326.  
  7327.     if type(x)=="integer" then x+1 else 0 
  7328.  
  7329.    Expressions such as this are quite foreign to languages with static
  7330.    type checking.  Perhaps what you need is some kind of "lint"
  7331.    program like that which the C programming language has.  For
  7332.    programs which can be statically typed it could warn of any type
  7333.    clashes and coercions that will occur, for other programs it could
  7334.    just indicate that static type checking was not feasible.
  7335.  
  7336. I don't disagree that expressions such as this are foreign to languages
  7337. with static type checking.  What I wonder is whether a thing like optional
  7338. static typing might be applied to variables, and not expressions.  In
  7339. this scenario,
  7340.  
  7341.     if x = 0 then "small" else 1
  7342.  
  7343. would be fine.
  7344.  
  7345. Just curious.
  7346.  
  7347.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  7348.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  7349.  
  7350. From ralph  Wed Apr 11 08:35:53 1990
  7351. Date: Wed, 11 Apr 90 08:35:53 MST
  7352. From: "Ralph Griswold" <ralph>
  7353. Message-Id: <9004111535.AA26352@megaron.cs.arizona.edu>
  7354. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  7355.     id AA26352; Wed, 11 Apr 90 08:35:53 MST
  7356. To: icon-group
  7357. Subject: Version 8 of Icon for MS-DOS
  7358. Status: O
  7359.  
  7360. Version 8 of Icon for MS-DOS is now available.
  7361.  
  7362. There are two packages -- one contains executable binary files and the
  7363. other contains source code.
  7364.  
  7365. The executable binaries support only the large memory model. Two versions
  7366. of the run-time system are provided: one that supports large-integer
  7367. arithmetic and a smaller one that does not.
  7368.  
  7369. The source code compiles under Microsoft C 5.10 (MS-DOS and OS/2), Lattice C
  7370. 6.01, and Turbo C 2.0.
  7371.  
  7372. Version 8 of Icon for MS-DOS systems can be obtained by anonymous FTP
  7373. to cs.arizona.edu. After connecting, cd /icon/v8.  Get READ.ME
  7374. there for more information.
  7375.  
  7376. If you do not have FTP access or prefer to obtain diskettes and printed
  7377. documentation, Version 8 of Icon for MS-DOS can be ordered from:
  7378.  
  7379.     Icon Project
  7380.     Department of Computer Science
  7381.     Gould-Simpson Building
  7382.     The University of Arizona
  7383.     Tucson, AZ   85721
  7384.  
  7385.     602 621-2018 (voice)
  7386.     602 621-4246 (FAX)
  7387.  
  7388. Specify whether you want executable binaries, source code, or both and the
  7389. size of diskettes you prefer (5.25" or 3.5").
  7390.  
  7391. The packages are $20 each, payable in US dollars to The University of Arizona
  7392. with a check written on a bank in the United States.  Orders also can be
  7393. charged to MasterCard or Visa.  The price includes shipping by parcel post
  7394. in the United States, Canada, and Mexico. Add $5 per package for air mail
  7395. delivery to other countries.
  7396.  
  7397. Please direct any questions to me, not to icon-project or icon-group.
  7398.  
  7399.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  7400.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  7401.  
  7402.  
  7403. From M17572@mwvm.mitre.ORG  Thu Apr 12 05:53:54 1990
  7404. Resent-From: M17572@mwvm.mitre.ORG
  7405. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7406.     id AA18999; Thu, 12 Apr 90 05:53:54 MST
  7407. Return-Path: M17572@mwvm.mitre.ORG
  7408. Received: from mwunix.mitre.org by Arizona.EDU; Thu, 12 Apr 90 05:22 MST
  7409. Received: from mwvm.mitre.org by mwunix.mitre.org (5.61/SMI-2.2) id AA00101;
  7410.  Thu, 12 Apr 90 08:19:28 -0400
  7411. Received: from MWVM by mwvm.mitre.org (IBM VM SMTP R1.2.1) with BSMTP id 7601;
  7412.  Thu, 12 Apr 90 08:20:06 EDT
  7413. Resent-Date: Thu, 12 Apr 90 05:36 MST
  7414. Date: Thursday, 12 Apr 1990 08:20:05 EST
  7415. From: m17572@mwvm.mitre.ORG
  7416. Subject: pl/i to c translator in icon
  7417. Resent-To: icon-group@cs.arizona.edu
  7418. To: icon-group%arizona.edu@mwunix.mitre.ORG
  7419. Resent-Message-Id: <AEC0BF5CB25F60009A@Arizona.EDU>
  7420. Message-Id: <9004121219.AA00101@mwunix.mitre.org>
  7421. X-Envelope-To: icon-group@CS.Arizona.EDU
  7422. X-Vms-To: icon-group%arizona.edu@mwunix.mitre.ORG
  7423. Status: O
  7424.  
  7425. I am looking for a translator from pl/i to c written in icon.  It doesn't
  7426. have to be perfect.  alternatively, a translator from any similar
  7427. language to c would be helpful.  thanks in advance.
  7428. *
  7429. *  John Artz jartz@mitre.org
  7430.  
  7431. From kwalker  Thu Apr 12 08:14:52 1990
  7432. Date: Thu, 12 Apr 90 08:14:52 MST
  7433. From: "Kenneth Walker" <kwalker>
  7434. Message-Id: <9004121514.AA25491@megaron.cs.arizona.edu>
  7435. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  7436.     id AA25491; Thu, 12 Apr 90 08:14:52 MST
  7437. In-Reply-To: <9004111306.AA07853@sophist.uchicago.edu>
  7438. To: icon-group
  7439. Subject: Re:  type coercion
  7440. Status: O
  7441.  
  7442. > Date: 11 Apr 90 10:22:29 GMT
  7443. > From: zaphod.mps.ohio-state.edu!usc!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.EDU
  7444. >Static type checking is not realistically possible for a language such as Icon.
  7445. > Consider the expression:
  7446. >     if x=0 then "small" else 1
  7447. > The type of this expression may be impossible to determine until run time.
  7448. >   ...
  7449. > Perhaps what you need is some kind of "lint" program like that
  7450. > which the C programming language has.  For programs which can be statically
  7451. > typed it could warn of any type clashes and coercions that will occur, for
  7452. > other programs it could just indicate that static type checking was not
  7453. > feasible.
  7454.  
  7455. It is possible to perform type inference on Icon programs. Type
  7456. inference assigns a type to each expression, but some types may be
  7457. of a form like "string or integer", as in the example. In addition
  7458. to assigning types which an expression might actually produce,
  7459. it is sometimes necessary for a type inferencing scheme to make
  7460. conservative estimates, so the assigned type may include types which
  7461. the expression would never take on in any possible execution. A
  7462. compiler can use information from type inferencing to eliminate
  7463. much of the run-time type checking from a program, improving
  7464. execution speed.
  7465.  
  7466. I implemented a prototype type inferencing scheme some time ago
  7467. and was able to infer unique types for about 90 percent of all
  7468. operands where type checking is normally needed. I am preparing
  7469. to implement a type inferencing scheme in an experimental
  7470. optimizing compiler for Icon. It will be interesting to see what
  7471. kind of speedups result from using the type information in the
  7472. code generator.
  7473.  
  7474. > Date: Wed, 11 Apr 90 08:06:19 CDT
  7475. > From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  7476. > What I wonder is whether a thing like optional
  7477. > static typing might be applied to variables, and not expressions. 
  7478.  
  7479. This seems like a nice idea. Adding optional type information to
  7480. declarations is quite easily. You could do something like
  7481.  
  7482.    local x:integer, y: string | record r
  7483.  
  7484. x could then be assigned only integers and y could be assigned only
  7485. strings or records of type r. Variables with no type information
  7486. would simply be "any type", allowing the current style of typeless
  7487. variables to still be used. This scheme would require some run-time
  7488. type checking at assignments (and type coercions?), but that is not
  7489. a serious problem, though it might take some thought as to how to
  7490. implement it efficiently. This scheme effectively moves type
  7491. checking from the uses of a variable to the assignments, but 
  7492. run-time checking at assignments is only needed when the type
  7493. of the value being assigned cannot be statically determined.
  7494.  
  7495. I would also like to be able to have a declaration like
  7496.  
  7497.    global x: list of integer
  7498.  
  7499. This means that any list assigned to x must be restricted to contain
  7500. only integers. It would be necessary to have some way of creating
  7501. type-restricted structures. Ideally the method would be a simple
  7502. extension of the current methods for creating structures.
  7503.  
  7504. You probably also want a way of creating named types.
  7505.  
  7506.    type foo: list of (integer | foo)
  7507.    global x: foo
  7508.  
  7509. Type equivalence would be structural. In the following example, x and
  7510. y have the same type.
  7511.  
  7512.    type str_set: set of string
  7513.    local x: str_set
  7514.    local y: set of string
  7515.    
  7516.    x := y
  7517.  
  7518. Does anyone know how this compares to other languages with flexible
  7519. type systems? Are there pitfalls I haven't anticipated?
  7520.  
  7521.   Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  7522.   +1 602 621 2858  kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker
  7523.  
  7524. From ccc!ccc.com!clemc@uunet.UU.NET  Thu Apr 12 08:49:10 1990
  7525. Resent-From: ccc!ccc.com!clemc@uunet.UU.NET
  7526. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7527.     id AA27469; Thu, 12 Apr 90 08:49:10 MST
  7528. Received: from uunet.UU.NET by Arizona.EDU; Thu, 12 Apr 90 08:48 MST
  7529. Received: from ccc.UUCP by uunet.uu.net (5.61/1.14) with UUCP id AA06191; Thu,
  7530.  12 Apr 90 11:46:45 -0400
  7531. Received: from localhost by CCC.COM.ccc.CCC.COM id aa01444; 12 Apr 90 11:00 EDT
  7532. Resent-Date: Thu, 12 Apr 90 08:50 MST
  7533. Date: Thu, 12 Apr 90 10:59:58 EDT
  7534. From: clemc@ccc.COM
  7535. Subject: RE: pl/i to c translator in icon
  7536. Resent-To: icon-group@cs.arizona.edu
  7537. To: arizona.edu!icon-group@uunet.uu.NET
  7538. Resent-Message-Id: <AEA597B3C1FF6002B9@Arizona.EDU>
  7539. Message-Id: <9004121546.AA06191@uunet.uu.net>
  7540. X-Envelope-To: icon-group@CS.Arizona.EDU
  7541. X-Vms-To: arizona.edu!icon-group@uunet.uu.NET
  7542. Status: O
  7543.  
  7544. >
  7545. >    I am looking for a translator from pl/i to c written in icon.
  7546. >    It doesn't have to be perfect.  alternatively, a translator
  7547. >    from any similar language to c would be helpful.
  7548. >    thanks in advance.
  7549. >    *
  7550. >    *  John Artz jartz@mitre.org
  7551. You might want to look into f2c the FORTRAN 77 to C converter that is
  7552. available from NETLIB at AT&T or the Pascal to C converters available
  7553. in the UUNET net news archives.
  7554.  
  7555. Good Luck,
  7556. Clem Cole
  7557. ------
  7558. Clement T. Cole
  7559. Cole Computer Consulting        uunet!ccc!clemc uucp
  7560. 255 North Road #119            clemc@ccc.com Internet
  7561. Chelmsford, MA 01824-1402        (508) 256-6967    voice
  7562.  
  7563. From wgg@cs.washington.edu  Thu Apr 12 11:24:21 1990
  7564. Received: from june.cs.washington.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7565.     id AA08442; Thu, 12 Apr 90 11:24:21 MST
  7566. Received: by june.cs.washington.edu (5.61/7.0jh)
  7567.     id AA15180; Thu, 12 Apr 90 11:24:22 -0700
  7568. Date: Thu, 12 Apr 90 11:24:22 -0700
  7569. From: wgg@cs.washington.edu (William Griswold)
  7570. Return-Path: <wgg@cs.washington.edu>
  7571. Message-Id: <9004121824.AA15180@june.cs.washington.edu>
  7572. To: icon-group@cs.arizona.edu, kwalker@cs.arizona.edu
  7573. Subject: Re:  type coercion
  7574. Status: O
  7575.  
  7576. >
  7577. >Does anyone know how this compares to other languages with flexible
  7578. >type systems? Are there pitfalls I haven't anticipated?
  7579. >
  7580.  
  7581. The problem that I can anticipate right off is that structural equivalence
  7582. when only some variables are typed could be expensive, unless you do some
  7583. precomputation and type inference.  For example if you have the 
  7584. declaration: 
  7585.  
  7586.     local L : list of list of table of (integer | real)
  7587.  
  7588. What will you have to do to check an assignment to L coming from an
  7589. untyped variable.  What about assignments to any of its subcomponents?
  7590. Are pointers to substructures of L a problem? 
  7591.  
  7592. Also, suppose you wanted to allow for typed recursive structures (there
  7593. is plenty of evidence that you want truly self-referencing structures
  7594. in Icon):
  7595.  
  7596.     type tree-node : list of (integer | tree-node)
  7597.  
  7598. Is this hard to type check?  Seems no harder than the above, but again, 
  7599. how does one check modifications to substructures with pointers running
  7600. around?  Also, what if it isn't a tree, i.e., you have a loop?  Structures
  7601. would probably have to be marked during the traversal of the check. 
  7602.  
  7603. Name equivalence would make the checking easier, but it would be far too
  7604. restrictive and meaningless in Icon.
  7605.  
  7606. I'm not knocking the idea of this flexible typing.  I would *love* to have
  7607. it.  But I see some (interesting!) problems when only some of the objects
  7608. are typed.  I think the feature could be very useful during development,
  7609. because it allows the gradual introduction of types where needed for
  7610. testing, and they can be ``turned off'' after development if they cost too
  7611. much to check all the time. 
  7612.  
  7613.  
  7614.                     Bill Griswold
  7615.  
  7616. From tenaglia@fps.mcw.edu  Fri Apr 13 05:36:01 1990
  7617. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7618.     id AA26263; Fri, 13 Apr 90 05:36:01 MST
  7619. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  7620.     id AA00396; Thu, 12 Apr 90 21:13:36 EDT
  7621. Received: by uwm.edu; id AA04499; Thu, 12 Apr 90 15:09:29 -0500
  7622. Message-Id: <9004122009.AA04499@uwm.edu>
  7623. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  7624.           Thu, 12 Apr 90 14:25:33 CDT
  7625. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  7626.           Thu, 12 Apr 90 14:06:10 CDT
  7627. Date: Thu, 12 Apr 90 14:06:10 CDT
  7628. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  7629. To: icon-group@cs.arizona.edu
  7630. Subject: RE: pl/i to c translator in icon
  7631. X-Vms-Mail-To: UUCP%"m17572@mwvm.mitre.ORG"
  7632. Status: O
  7633.  
  7634. In response to :
  7635.  
  7636. > From:    UUCP%"m17572@mwvm.mitre.ORG" 12-APR-1990 13:24:50.57
  7637. > To:    mis!tenaglia
  7638. > Subj:    pl/i to c translator in icon
  7639. >
  7640. > I am looking for a translator from pl/i to c written in icon.  It doesn't
  7641. > have to be perfect.  alternatively, a translator from any similar
  7642. > language to c would be helpful.  thanks in advance.
  7643. > *
  7644. > *  John Artz jartz@mitre.org
  7645.  
  7646. I'm not sure what the pl/i language is. But if it is something like the
  7647. PL/M language offered on Intel RMX systems there may be something. Back
  7648. a few years ago at Astronautics Corp. in Milwaukee I worked on a project
  7649. to translate PL/M to C. I no longer work there, but they may still have
  7650. the system spooled on a tape. It was designed to run under Icon 6 in a
  7651. VAX/VMS environment, and was a peculiar combination of DCL script and a
  7652. long chain (21 - 27 modules) that would run sequentially and convert
  7653. good/average/moderately bad PL/M code into plain vanilla K&R C. Perhaps
  7654. if pl/i is similar, the system could be adapted. The contact would be a
  7655. Wesley Eckles, System Manager, Engineering Computer Services,
  7656. Astronautics Corp., 4115 N. Teutonia Ave, Milwaukee 53209, (414)447-8200 X450.
  7657. I can't say if they'd sell it or give it away. Just an idea.
  7658.  
  7659. Chris Tenaglia (System Manager)
  7660. Medical College of Wisconsin
  7661. 8701 W. Watertown Plank Rd.
  7662. Milwaukee, WI 53226
  7663. (414)257-8765
  7664. tenaglia@mis.mcw.edu
  7665.  
  7666.  
  7667. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Sat Apr 14 13:01:47 1990
  7668. Received: from umich.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7669.     id AA27153; Sat, 14 Apr 90 13:01:47 MST
  7670. Received: from ummts.cc.umich.edu by umich.edu (5.61/1123-1.0)
  7671.     id AA26489; Sat, 14 Apr 90 16:01:38 -0400
  7672. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 14 Apr 90 16:01:32 EDT
  7673. Date: Sat, 14 Apr 90 15:43:44 EDT
  7674. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  7675. To: icon-group@cs.arizona.edu
  7676. Message-Id: <218276@Wayne-MTS>
  7677. Subject: Overloading of operators
  7678. Status: O
  7679.  
  7680.  
  7681. One of the major advantages of strongly typed languages is that you can
  7682. overload the operators cleanly.  This advantage may be even more important
  7683. than what you gain in protection (perhaps not that much) or efficiency.
  7684. In Icon you not only don't need to declare the types of parameters; you can't.
  7685. Declaring the types of parameters is essential to defining overloaded operators
  7686. unless you want to do the overload resolution within the operator's definition.
  7687.  
  7688. I haven't found the dynamic type conversion in Icon to be of much use.  Some
  7689. of what you get with it is what you'd get in other languages through generics,
  7690. such as the ability to write a sort procedure that works for any type of list.
  7691. (Forget for the moment that sorting is built into Icon.)  The one example I
  7692. know of where dynamic type conversion really helps is in writing print
  7693. procedures, since the form of what you print depends on the type of the
  7694. argument.
  7695.  
  7696. To me, an important principle of language design is `To thine own self be
  7697. true'.  Overloaded operators are contrary to the spirit of Icon.  If you
  7698. really want them, you should either do run-time dispatching or be using a
  7699. different language.  I think it would be a mistake to add them to Icon. 
  7700.  
  7701. Paul Abrahams 
  7702. Abrahams%wayne-mts@um.cc.umich.edu
  7703.  
  7704. From sbw@naucse.cse.nau.edu  Sat Apr 14 16:00:50 1990
  7705. Received: from naucse.cse.nau.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7706.     id AA04295; Sat, 14 Apr 90 16:00:50 MST
  7707. Received: by naucse.cse.nau.edu (5.61/1.34)
  7708.     id AA26480; Sat, 14 Apr 90 16:00:32 -0700
  7709. Message-Id: <9004142300.AA26480@naucse.cse.nau.edu>
  7710. Date: Sat, 14 Apr 90 16:00:30 MST
  7711. X-Mailer: Mail User's Shell (6.5 4/17/89)
  7712. From: sbw@naucse.cse.nau.edu (Steve Wampler)
  7713. To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu, icon-group@cs.arizona.edu
  7714. Subject: Re: Overloading of operators
  7715. Status: O
  7716.  
  7717. Hmmm,  *If* one could always get one's hands on the 'original version'
  7718. of an operator, then implementing overloaded operators would be fairly
  7719. simple in Icon - though, as you say, you would have to handle the
  7720. overloading yourself.  (I would view that as consistent with Icon, since
  7721. you have to handle your own typechecking yourself - consider writing
  7722. your own version of Icon.)
  7723.  
  7724. When I first heard of 'string invocation' - I thought that this would
  7725. be the first step in 'overloading' operators (and builtin functions).
  7726. I assumed that "+"(1,3) and "write"("hello") would access the
  7727. 'original' addition and 'write' functions.  I was wrong, of course,
  7728. but if I had been correct in my assumption, we would have overloading
  7729. now (with adding syntactic support):
  7730.  
  7731.     operator +(x,y)
  7732.            if type(x) == type(y) == "complex" then
  7733.           return complex_add(x,y)
  7734.            return "+"(x,y)
  7735.         end
  7736.  
  7737. (ignoring mixed-mode for the moment.)
  7738.  
  7739. and:
  7740.  
  7741.     procedure write(a)    # ignoring varargs for the moment...
  7742.        if type(a) == "table" then
  7743.               return write_table(a)
  7744.            else return "write"(a)
  7745.     end
  7746.  
  7747. Alas, it is not so, so it will not be.  As I said, this form, to
  7748. me, would have been in the spirit of Icon.
  7749.  
  7750. -- 
  7751.     Steve Wampler
  7752.     {....!arizona!naucse!sbw}
  7753.     {sbw@naucse.cse.nau.edu}
  7754.  
  7755. From sbw@naucse.cse.nau.edu  Sun Apr 15 06:50:14 1990
  7756. Received: from naucse.cse.nau.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7757.     id AA13890; Sun, 15 Apr 90 06:50:14 MST
  7758. Received: by naucse.cse.nau.edu (5.61/1.34)
  7759.     id AA03424; Sun, 15 Apr 90 06:49:46 -0700
  7760. Message-Id: <9004151349.AA03424@naucse.cse.nau.edu>
  7761. Date: Sun, 15 Apr 90 06:49:44 MST
  7762. X-Mailer: Mail User's Shell (6.5 4/17/89)
  7763. From: sbw@naucse.cse.nau.edu (Steve Wampler)
  7764. To: icon-group@cs.arizona.edu
  7765. Subject: Sigh...
  7766. Status: O
  7767.  
  7768. The sentence in my last posting that read in part:  "consider writing
  7769. your own version of Icon" was SUPPOSED to say: "consider writing your
  7770. own version of 'image()'".  So much for saturday postings.
  7771.  
  7772. -- 
  7773.     Steve Wampler
  7774.     {....!arizona!naucse!sbw}
  7775.     {sbw@naucse.cse.nau.edu}
  7776.  
  7777. From icon-group-request@arizona.edu  Tue Apr 17 18:34:24 1990
  7778. Resent-From: icon-group-request@arizona.edu
  7779. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7780.     id AA13815; Tue, 17 Apr 90 18:34:24 MST
  7781. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 17 Apr 90 18:35 MST
  7782. Received: by ucbvax.Berkeley.EDU (5.61/1.41) id AA02739; Tue, 17 Apr 90
  7783.  18:24:50 -0700
  7784. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  7785.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  7786.  usenet@ucbvax.Berkeley.EDU if you have questions)
  7787. Resent-Date: Tue, 17 Apr 90 18:35 MST
  7788. Date: 18 Apr 90 00:58:46 GMT
  7789. From: castor!ccs007@ucdavis.ucdavis.EDU
  7790. Subject: I/O help
  7791. Sender: icon-group-request@arizona.edu
  7792. Resent-To: icon-group@cs.arizona.edu
  7793. To: icon-group@arizona.edu
  7794. Resent-Message-Id: <AA6607BF813FA0263D@Arizona.EDU>
  7795. Message-Id: <7097@aggie.ucdavis.edu>
  7796. Organization: University of California, Davis
  7797. X-Envelope-To: icon-group@CS.Arizona.EDU
  7798. X-Vms-To: icon-group@Arizona.edu
  7799. Status: O
  7800.  
  7801.  
  7802.  
  7803. I'm writing a mini-database and would like to know how to load 
  7804. and save a table of tables to disk.  I'm using icon on a VAX 11/785 under
  7805. Ultrix-32 V3.1 (Rev. 9). Any help would be greatly appreciated.
  7806. Everything I've tried doesn't seem to work.
  7807.  
  7808. Jonathan Sims
  7809. ccs007@castor.ucdavis.edu
  7810.  
  7811. From ralph  Tue Apr 17 18:55:01 1990
  7812. Date: Tue, 17 Apr 90 18:55:01 MST
  7813. From: "Ralph Griswold" <ralph>
  7814. Message-Id: <9004180155.AA15065@megaron.cs.arizona.edu>
  7815. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  7816.     id AA15065; Tue, 17 Apr 90 18:55:01 MST
  7817. To: castor!ccs007@ucdavis.ucdavis.EDU
  7818. Subject: Re:  I/O help
  7819. Cc: icon-group
  7820. In-Reply-To: <7097@aggie.ucdavis.edu>
  7821. Status: O
  7822.  
  7823. There are two procedures in the Icon program library for encoding arbitary Icon
  7824. data as strings that can be written to files and then restored.
  7825.  
  7826. The Icon program library is available in several ways, including via
  7827. FTP.  What you want depends on the version of Icon you're running.
  7828. Version 8 is current.
  7829.  
  7830. If you need specific advice, let me know.
  7831.  
  7832.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  7833.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  7834.  
  7835. From sunquest!whm  Tue Apr 17 23:31:37 1990
  7836. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  7837.     id AA28475; Tue, 17 Apr 90 23:31:37 MST
  7838. Received: from grissom by sunquest; Tue, 17 Apr 90 23:30:25 MST
  7839. Date: Tue, 17 Apr 90 23:30:22 MST
  7840. From: "Bill Mitchell" <sunquest!whm>
  7841. Message-Id: <9004180630.AA23253@grissom>
  7842. Received: by grissom; Tue, 17 Apr 90 23:30:22 MST
  7843. To: arizona!icon-group
  7844. Subject: Another kudo for Ralph
  7845. Status: O
  7846.  
  7847. I just heard this today and thought I'd pass it along for the group.  I quote:
  7848.  
  7849. Upon recommendation of [University of Arizona] President Henry Koffler, the
  7850. Arizona Board of Regents has named Ralph E. Griswold to the rank of Regents
  7851. Professor.  This title, the highest faculty rank at the University, is reserved
  7852. for scholars whose exceptional achievements have brought them national and
  7853. international distinction, and who have made unique contributions to the
  7854. quality of the University through distinguished accomplishments in teaching,
  7855. scholarship, and creative work.
  7856.  
  7857. From M13852@mwvm.mitre.ORG  Wed Apr 18 07:57:00 1990
  7858. Resent-From: M13852@mwvm.mitre.ORG
  7859. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7860.     id AA22496; Wed, 18 Apr 90 07:57:00 MST
  7861. Return-Path: M13852@mwvm.mitre.ORG
  7862. Received: from mwunix.mitre.org by Arizona.EDU; Wed, 18 Apr 90 07:57 MST
  7863. Received: from mwvm.mitre.org by mwunix.mitre.org (5.61/SMI-2.2) id AA18834;
  7864.  Wed, 18 Apr 90 10:55:28 -0400
  7865. Received: from MWVM by mwvm.mitre.org (IBM VM SMTP R1.2.1) with BSMTP id 9527;
  7866.  Wed, 18 Apr 90 10:56:06 EDT
  7867. Resent-Date: Wed, 18 Apr 90 07:58 MST
  7868. Date: Wednesday, 18 Apr 1990 10:56:04 EST
  7869. From: m13852@mwvm.mitre.ORG
  7870. Subject: ICON GROUP
  7871. Resent-To: icon-group@cs.arizona.edu
  7872. To: icon-group%arizona.edu@mwunix.mitre.ORG
  7873. Resent-Message-Id: <A9F5E9AE033FA02A2B@Arizona.EDU>
  7874. Message-Id: <9004181455.AA18834@mwunix.mitre.org>
  7875. X-Envelope-To: icon-group@CS.Arizona.EDU
  7876. X-Vms-To: icon-group%arizona.edu@mwunix.mitre.ORG
  7877. Status: O
  7878.  
  7879. A couple of us here at MITRE are doing some programming in ICON.  We are
  7880. wondering how we can become a part of the ICON Group so that we will be able to
  7881. pick up the network broadcast messages.  Thanks in advance.
  7882.  
  7883. NJBELL@mwvm.mitre.org
  7884. *
  7885. *        Noel
  7886.  
  7887. From tenaglia@fps.mcw.edu  Thu Apr 19 01:19:41 1990
  7888. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7889.     id AA02853; Thu, 19 Apr 90 01:19:41 MST
  7890. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.05) with UUCP 
  7891.     id AA08638; Thu, 19 Apr 90 02:25:07 EDT
  7892. Received: by uwm.edu; id AA02347; Thu, 19 Apr 90 00:37:11 -0500
  7893. Message-Id: <9004190537.AA02347@uwm.edu>
  7894. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  7895.           Wed, 18 Apr 90 18:10:03 CDT
  7896. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  7897.           Wed, 18 Apr 90 16:37:54 CDT
  7898. Date: Wed, 18 Apr 90 16:37:54 CDT
  7899. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  7900. To: icon-group@cs.arizona.edu
  7901. Subject: RE: I/O help
  7902. X-Vms-Mail-To: UUCP%"castor!ccs007@ucdavis.ucdavis.EDU"
  7903. Status: O
  7904.  
  7905. In regards to :
  7906.  
  7907. > I'm writing a mini-database and would like to know how to load
  7908. > and save a table of tables to disk.  I'm using icon on a VAX 11/785 under
  7909. > Ultrix-32 V3.1 (Rev. 9). Any help would be greatly appreciated.
  7910. > Everything I've tried doesn't seem to work.
  7911. >
  7912. > Jonathan Sims
  7913. > ccs007@castor.ucdavis.edu
  7914.  
  7915. I also have written such a database. It's composed of lists of lists. It's
  7916. less efficient, but I can have duplicate keys. I store the data in a file
  7917. in the format of one record per line, and each field in the record is
  7918. delimited with char(255). The database was designed to be flexible so it
  7919. wouldn't have to be redone for each individual application. Each database
  7920. consists of two parts. The data file and the configuration file. The
  7921. configuration file points to the data file and describes it and certain
  7922. default characteristics. When run this configuration is loaded, which
  7923. tells the database how to load the file, build the screens, etc,... Many
  7924. of the settings can be changed on the fly, even the data file. So it is
  7925. conceivable to have several data files attached to a given application
  7926. model. I've implemented both under VMS and Unix. I can see some advantages
  7927. to storing tables of tables, but it sounds rather complicated. I suppose
  7928. my database might be thought of as more of a simple tuple editor.
  7929.  
  7930. Chris Tenaglia (System Manager)
  7931. Medical College of Wisconsin
  7932. 8701 W. Watertown Plank Rd.
  7933. Milwaukee, WI 53226
  7934. (414)257-8765
  7935. tenaglia@mis.mcw.edu
  7936.  
  7937.  
  7938. From goer@sophist.uchicago.EDU  Thu Apr 19 18:39:54 1990
  7939. Resent-From: goer@sophist.uchicago.EDU
  7940. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  7941.     id AA13875; Thu, 19 Apr 90 18:39:54 MST
  7942. Return-Path: goer@sophist.uchicago.EDU
  7943. Received: from tank.uchicago.edu by Arizona.EDU; Thu, 19 Apr 90 18:39 MST
  7944. Received: from sophist.uchicago.edu by tank.uchicago.edu Thu, 19 Apr 90
  7945.  20:38:52 CDT
  7946. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA21462; Thu, 19 Apr 90
  7947.  20:34:52 CDT
  7948. Resent-Date: Thu, 19 Apr 90 18:40 MST
  7949. Date: Thu, 19 Apr 90 20:34:52 CDT
  7950. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  7951. Subject: question about dereferenced functions
  7952. Resent-To: icon-group@cs.arizona.edu
  7953. To: icon-group@arizona.edu
  7954. Resent-Message-Id: <A8D304B109DFA03AAD@Arizona.EDU>
  7955. Message-Id: <9004200134.AA21462@sophist.uchicago.edu>
  7956. X-Envelope-To: icon-group@CS.Arizona.EDU
  7957. X-Vms-To: icon-group@Arizona.edu
  7958. Status: O
  7959.  
  7960. Something I was doing the other day got me into
  7961. a bit of trouble, and it seems obvious (at least
  7962. on one level) why.  The circumstances surrounding
  7963. my mistake, however, led me to wonder about the
  7964. underlying representation of functions - something
  7965. I'd appreciate guidance on from someone more fam-
  7966. iliar with the implementation.
  7967.  
  7968. If I execute a program containing the line -
  7969.  
  7970.     write(name(main))
  7971.  
  7972. I get "name" written to the standard output.  However,
  7973. if I write,
  7974.  
  7975.     func_lst := [main]
  7976.     write(name(func_lst[]))
  7977.  
  7978. I get "L[1]."  This was what I expected, given the docu-
  7979. mentation.  What I did not expect, but in retrospect
  7980. seems logical, was that when I execute
  7981.  
  7982.     write(name(func_lst[]))
  7983.  
  7984. I get the error message, "Run-time error 111, variable
  7985. expected."  Clearly, the global identifier main was de-
  7986. referenced when it was incorporated into func_lst.  So
  7987. func_lst[] is no longer a variable or identifier.  I'm
  7988. just curious what functions dereference as in Icon, as
  7989. opposed to, say, C (where "main" usually means &main).
  7990.  
  7991. Since I have functions and procedures on my mind right
  7992. now, I might as well ask another question that has been
  7993. interesting me.  If I sort a list of functions and pro-
  7994. cedures
  7995.  
  7996.     [many, any, myprocedure]
  7997.  
  7998. what I get is
  7999.  
  8000.     [any, many, myprocedure]
  8001.  
  8002. apparently in alphabetical order.  Is this behavior guar-
  8003. anteed?  Or is it just a consequence of the implementation,
  8004. and something I should not rely on?
  8005.  
  8006.  
  8007.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  8008.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  8009.  
  8010. From icon-group-request@arizona.edu  Fri Apr 20 05:58:02 1990
  8011. Resent-From: icon-group-request@arizona.edu
  8012. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  8013.     id AA17831; Fri, 20 Apr 90 05:58:02 MST
  8014. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Fri, 20 Apr 90 05:59 MST
  8015. Received: by ucbvax.Berkeley.EDU (5.62/1.41) id AA27838; Fri, 20 Apr 90
  8016.  05:45:26 -0700
  8017. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8018.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8019.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8020. Resent-Date: Fri, 20 Apr 90 05:59 MST
  8021. Date: 20 Apr 90 12:42:36 GMT
  8022. From: cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!jefu@tut.cis.ohio-state.EDU
  8023. Subject: Solving a simple problem
  8024. Sender: icon-group-request@arizona.edu
  8025. Resent-To: icon-group@cs.arizona.edu
  8026. To: icon-group@arizona.edu
  8027. Resent-Message-Id: <A8742E1195BFA03DD9@Arizona.EDU>
  8028. Message-Id: <|{W#QJ#@rpi.edu>
  8029. Organization: The Museum of Differential Geometry
  8030. X-Envelope-To: icon-group@CS.Arizona.EDU
  8031. X-Vms-To: icon-group@Arizona.edu
  8032. Status: O
  8033.  
  8034.  
  8035. The other day I needed to parse a line of comma separated fields into a list -
  8036. thus "one,two,three,four,five" -> ["one" "two" "three" "four" "five" ] . 
  8037. I worked out a way to handle this, but it was inelegant.  I tried at first
  8038. to use some sort of string generating function to parse things out, but
  8039. couldnt get it to work right.  
  8040.  
  8041. That is, I wanted to be able to say something like :
  8042.  
  8043. res := parse(read(file))
  8044.  
  8045. where parse would look something like :
  8046.  
  8047. procedure parse (line)
  8048.     local res
  8049.     every line ? (x := something()) do put(res,x) 
  8050. end
  8051.  
  8052. Where something would return the next field in line each time it is resumed.
  8053.  
  8054. Im sure there is a nice way to do this that I'm just missing.
  8055.  
  8056. So, my question is - what is the most _elegant_ way to solve this problem - 
  8057. preferably using generators of some sort?
  8058.  
  8059. -- 
  8060.  
  8061. jeff putnam (jefu@pawl.rpi.edu) 
  8062.  
  8063. From goer@sophist.uchicago.EDU  Fri Apr 20 08:08:04 1990
  8064. Resent-From: goer@sophist.uchicago.EDU
  8065. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  8066.     id AA27282; Fri, 20 Apr 90 08:08:04 MST
  8067. Return-Path: goer@sophist.uchicago.EDU
  8068. Received: from tank.uchicago.edu by Arizona.EDU; Fri, 20 Apr 90 08:07 MST
  8069. Received: from sophist.uchicago.edu by tank.uchicago.edu Fri, 20 Apr 90
  8070.  10:06:05 CDT
  8071. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA22198; Fri, 20 Apr 90
  8072.  10:02:05 CDT
  8073. Resent-Date: Fri, 20 Apr 90 08:08 MST
  8074. Date: Fri, 20 Apr 90 10:02:05 CDT
  8075. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  8076. Subject: tokenizing
  8077. Resent-To: icon-group@cs.arizona.edu
  8078. To: icon-group@arizona.edu
  8079. Resent-Message-Id: <A86222F0F11FA03ED9@Arizona.EDU>
  8080. Message-Id: <9004201502.AA22198@sophist.uchicago.edu>
  8081. X-Envelope-To: icon-group@CS.Arizona.EDU
  8082. X-Vms-To: icon-group@Arizona.edu
  8083. Status: O
  8084.  
  8085. Re: "one,two,three,four,five" -> ["one" "two" "three" "four" "five" ] . 
  8086.  
  8087. The method used:
  8088.  
  8089.      procedure parse (line)
  8090.          local res
  8091.          every line ? (x := something()) do put(res,x) 
  8092.      end
  8093.  
  8094. I don't see anything wrong with this method.  There's one thing to watch
  8095. out for, though.  If you say "every s ? move(1)", move will get called
  8096. once, and that's it.  What's more, it will reset &pos to the position it
  8097. had before it was called.  You almost always want to say "while tab(some
  8098. matching procedure) do { something else }."  Also, if you are going to
  8099. "put" something into something else, make sure that the something is not
  8100. &null (as above).  Remember to initialize the list by saying "res := []"
  8101. or "res := list(0)." I'm not sure precisely what you will be using your
  8102. tokenized lists for, but anyway here's an alternative way of doing
  8103. things (NB: *untested*):
  8104.  
  8105.      procedure tokenize(s)
  8106.         token_list := list()
  8107.         s ? {
  8108.           while put(token_list, 1(tab(find(",")),move(1)))
  8109.           put(token_list,tab(0))
  8110.           }
  8111.         return token_list
  8112.      end
  8113.  
  8114. Another option, using your format above, is:
  8115.  
  8116.      procedure parse (line)
  8117.          local res
  8118.          res := list()
  8119.          line ? {
  8120.             while x := tab(many(~','))
  8121.             do { put(res,x); move(1) }
  8122.             }
  8123.          return res
  8124.      end
  8125.  
  8126. If you wish to allow greater flexibility in your input strings,
  8127. add characters to ',' above.  Personally, I'd tend to think it
  8128. better to permit "hello,word", "hello, world", and an accidental
  8129. "hello, world,".  It might also be nice to be able to have spaces
  8130. in the tokens themselves (e.g. "hello, how, is, George Washington",
  8131. where George Washington is really a single lexical item).
  8132.  
  8133.      procedure parse (line)
  8134.          local res
  8135.          res := list()
  8136.          line ? {
  8137.             while x := tab(many(~',')) do {
  8138.               if (=",", (tab(many(' \t')) | &null)) | pos(0)
  8139.               then put(res,x) else stop("Cannot parse ",line,".")
  8140.             }
  8141.          return res
  8142.      end
  8143.  
  8144. Again, this is untested.  What it should allow you to do is input
  8145. "hello, how, are you doing" and get back ["hello", "how", "are you doing"].
  8146.  
  8147. Icon is indeed a very, very good language for doing things like
  8148. tokenizing strings.  That's one of the things that got me to thinking
  8149. a while back whether Prolog had been implemented in Icon.  It would
  8150. be kinda like having one's cake and eating it, too.
  8151.  
  8152. From icon-group-request@arizona.edu  Fri Apr 20 19:10:03 1990
  8153. Resent-From: icon-group-request@arizona.edu
  8154. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  8155.     id AA22426; Fri, 20 Apr 90 19:10:03 MST
  8156. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Fri, 20 Apr 90 19:03 MST
  8157. Received: by ucbvax.Berkeley.EDU (5.62/1.41) id AA17517; Fri, 20 Apr 90
  8158.  18:46:23 -0700
  8159. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  8160.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  8161.  usenet@ucbvax.Berkeley.EDU if you have questions)
  8162. Resent-Date: Fri, 20 Apr 90 19:10 MST
  8163. Date: 21 Apr 90 00:38:33 GMT
  8164. From: limbo!taylor@apple.COM
  8165. Subject: What's wrong with this Mac Icon program?
  8166. Sender: icon-group-request@arizona.edu
  8167. Resent-To: icon-group@cs.arizona.edu
  8168. To: icon-group@arizona.edu
  8169. Resent-Message-Id: <A805B831D7BFA04631@Arizona.EDU>
  8170. Message-Id: <702@limbo.Intuitive.Com>
  8171. Organization: Intuitive Systems, Mountain View, CA: +1 (415) 966-1151
  8172. X-Envelope-To: icon-group@CS.Arizona.EDU
  8173. X-Vms-To: icon-group@Arizona.edu
  8174. Status: O
  8175.  
  8176. I'm playing around with the Icon programming language, and am having
  8177. some very strange problems trying to get my sample program working.
  8178. The Icon I'm working with is ProIcon for the Macintosh, and the
  8179. sample program is:
  8180.  
  8181. ==========================================================
  8182.  
  8183. #  Compute simple readability score of given ASCII text file
  8184. #  
  8185. #  Based on a  program presented in "Icon Programming for Humanists"
  8186. #  by Alan Corre', Prentice Hall 1990
  8187.  
  8188. global wordlength
  8189.  
  8190. procedure main()
  8191.    compute_readability(getfile("Choose file for readability score"))
  8192. end
  8193.  
  8194. procedure compute_readability(filename)
  8195.   # main work loop of the program
  8196.   local total_words, sentence, sentences
  8197.   
  8198.   total_words := 0
  8199.   wordlength := 0
  8200.   sentences := 0
  8201.   
  8202.   every sentence := get_sentence(filename) do  {
  8203.     total_words +:= count_sentence(sentence)
  8204.     sentences +:= 1
  8205.   }
  8206.   
  8207.   display(total_words, wordlength, sentences)
  8208.   return
  8209. end
  8210.  
  8211. procedure get_sentence(filename)
  8212.   # gets a sentence from the file, even if less than a line or more
  8213.   # than a single line of input
  8214.   static markers
  8215.   local fileid, sentence, line, substring
  8216.   
  8217.   initial markers := '.!?'
  8218.   
  8219.   fileid := open(filename) | { write("couldn't open file"); return fail }
  8220.   sentence := ""
  8221.  
  8222.   while line := read(fileid) do {
  8223.     line ? 
  8224.     {  
  8225.       while substring := tab(upto(markers)) do {
  8226.       
  8227.         # if marker found add it to sentence incl. marker itself
  8228.         sentence ||:= (substring || tab(many(markers)))
  8229.         suspend sentence
  8230.         
  8231.         # skip blanks at beginning of next sentence
  8232.         tab(many(' '))
  8233.         sentence := ""
  8234.       }
  8235.       
  8236.      # if the line is not finished, append rest to sentence
  8237.      if not pos(0) then
  8238.        sentence ||:= (line[&pos:0] || " ") 
  8239.     }
  8240.   }
  8241.   close(fileid)
  8242. end
  8243.  
  8244. procedure getword_from_sentence(sentence)
  8245.   # produces a list of words from the given sentence
  8246.   static chars, punct
  8247.   local word
  8248.   
  8249.   initial { 
  8250.      chars := (&lcase ++ &ucase ++ '1234567890\'-')
  8251.      punct := ' .,?";:!'
  8252.   }
  8253.   
  8254.   sentence ? 
  8255.   { 
  8256.     tab(many(' '))     # skip leading white space
  8257.     while word := tab(many(chars)) do {
  8258.       tab(many(punct))
  8259.       suspend word
  8260.     }
  8261.   }
  8262. end
  8263.  
  8264. procedure count_sentence(sentence)
  8265.   # number of words in a sentence
  8266.   local total, word
  8267.  
  8268.   total := 0
  8269.   every word := getword_from_sentence(sentence) do {
  8270.     wordlength +:= *word
  8271.     total +:= 1
  8272.   }
  8273.  
  8274.   return total
  8275. end
  8276.  
  8277. procedure display(words, wordlength, sentences)
  8278.   local average_sentence_length, average_word_length
  8279.   
  8280.   average_sentence_length := real(words) / real(sentences)
  8281.   average_word_length := real(wordlength) / real(words)
  8282.  
  8283.   write("Total number of words in file: ", words)
  8284.   write("Total number of sentences in file: ", sentences)
  8285.   write("Total combined word length: ", wordlength)
  8286.   write("Average sentence length = ", average_sentence_length)
  8287.   write("Average word length = ", average_word_length)
  8288.   write()
  8289.   write("Readability score = ",  
  8290.             average_sentence_length * average_word_length)
  8291. end
  8292.  
  8293. ==========================================================
  8294.  
  8295. The problem I'm having with the program is that it doesn't
  8296. return the correct results!  That is, if I test it on files
  8297. that are sufficiently small that I can count the words in
  8298. the file, it gives me expected results.  But if I try with
  8299. an 8100 word file (word count from Microsoft Word) then the
  8300. Icon program only thinks that there are about 3100 words
  8301. therein!
  8302.  
  8303. What's worse is that I wrote a quick C program to compute
  8304. the same values and it returns much more reasonable 
  8305. values: 8500 words for the file (the difference I assume
  8306. is based on how Word defines individual word separators).
  8307.  
  8308. If someone can help me track down what's wrong with the
  8309. above program, I would be ever-so-grateful!  Thanks!
  8310.  
  8311.                         -- Dave Taylor
  8312.  
  8313. Intuitive Systems                Macintosh Editor
  8314. Mountain View, California        "Computer Language" Magazine
  8315.  
  8316. taylor@limbo.intuitive.com    or   {uunet!}{decwrl,apple}!limbo!taylor
  8317.  
  8318. From ralph  Sat Apr 21 06:34:19 1990
  8319. Date: Sat, 21 Apr 90 06:34:19 MST
  8320. From: "Ralph Griswold" <ralph>
  8321. Message-Id: <9004211334.AA20571@megaron.cs.arizona.edu>
  8322. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  8323.     id AA20571; Sat, 21 Apr 90 06:34:19 MST
  8324. To: limbo!taylor@apple.COM
  8325. Subject: Re:  What's wrong with this Mac Icon program?
  8326. Cc: icon-group
  8327. Status: O
  8328.  
  8329. The most obvious problem is in the loop that generates the words:
  8330. +++++++++++++++++++++++++++++++
  8331.   sentence ? 
  8332.   { 
  8333.     tab(many(' '))     # skip leading white space
  8334.     while word := tab(many(chars)) do {
  8335.       tab(many(punct))
  8336.       suspend word
  8337.     }
  8338. +++++++++++++++++++++++++++++++
  8339. The expression tab(many(chars)) only successed if there is a character in
  8340. chars at the current position. While that's probably true the first time
  8341. around, it most likely won't be the second time around, so most of
  8342. the words in the sentence will not be generated.  The better method
  8343. is
  8344. +++++++++++++++++++++++++++++++
  8345.    sentence {
  8346.       while tab(upto(chars)) do {
  8347.          word := tab(many(chars))
  8348.          suspend word
  8349.          }
  8350. +++++++++++++++++++++++++++++++
  8351.        
  8352.  
  8353.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  8354.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  8355.  
  8356. From goer@sophist.uchicago.EDU  Sat Apr 21 07:08:53 1990
  8357. Resent-From: goer@sophist.uchicago.EDU
  8358. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  8359.     id AA21796; Sat, 21 Apr 90 07:08:53 MST
  8360. Return-Path: goer@sophist.uchicago.EDU
  8361. Received: from tank.uchicago.edu by Arizona.EDU; Sat, 21 Apr 90 07:05 MST
  8362. Received: from sophist.uchicago.edu by tank.uchicago.edu Sat, 21 Apr 90
  8363.  09:04:21 CDT
  8364. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA23541; Sat, 21 Apr 90
  8365.  09:00:19 CDT
  8366. Resent-Date: Sat, 21 Apr 90 07:10 MST
  8367. Date: Sat, 21 Apr 90 09:00:19 CDT
  8368. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  8369. Subject: wordcounts
  8370. Resent-To: icon-group@cs.arizona.edu
  8371. To: icon-group@arizona.edu
  8372. Resent-Message-Id: <A7A1222BEC1FA0445E@Arizona.EDU>
  8373. Message-Id: <9004211400.AA23541@sophist.uchicago.edu>
  8374. X-Envelope-To: icon-group@CS.Arizona.EDU
  8375. X-Vms-To: icon-group@Arizona.edu
  8376. Status: O
  8377.  
  8378. A recent poster comments how Alan Corre's readability program
  8379. does not seem to come up with correct values.  The following is
  8380. a series of suggestions as to why this might be occurring.  If
  8381. I mention things you already know, I beg your indulgence.  It's
  8382. better to be safe (say too much) than sorry (not say enough).
  8383.  
  8384. First, please note that the readability score program gives only
  8385. a very rough count.  Also be sure (you probably were, but I'll
  8386. mention it anyway) that the program is fed ASCII files only.  If
  8387. you have anything fancy going on with the eighth bit of your char-
  8388. acters, the program will not work correctly.  What it will do un-
  8389. der such circumstances (I glean this from a quick perusal of the
  8390. source) is get the number of sentences about right, but undercount
  8391. the number of words.  Finally, note that the program is sentence-
  8392. based, so if your input file has a lot of headers or other text-
  8393. blocks not broken up into sentences, you'll get a wrong sentence
  8394. count (the word count should not be drastically affected).
  8395.  
  8396. In general, if you want to know what is going on inside an Icon
  8397. program, "compile" it with the -t option, or else stick a line
  8398. "&trace := -1" in your code near the beginning of where you want
  8399. to start tracing.  You probably knew this already, but I figured
  8400. it wouldn't hurt to mention it just in case.
  8401.  
  8402. One apparent bug in the program, incidentally, is that in the pro-
  8403. cedure which actually slices out individual words, "punct" is not
  8404. simply defined as the inverse of &lcase ++ &ucase ++ &digits.  As
  8405. a result, it cannot parse
  8406.  
  8407.     (Hi, this is an aside.)  But this is real text (or at least test).
  8408.  
  8409. I'd just point out again that the program is meant as a simple illus-
  8410. tration, probably meant to work on a fairly restricted range of texts.
  8411. Certainly AC could have broadened it to encompass a lot more texts,
  8412. but then it would have lost its pedagogical value.
  8413.  
  8414. I hope very much that this helps.  Please follow up if it doesn't.
  8415.  
  8416.  
  8417.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  8418.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  8419.  
  8420.  
  8421. BTW:  In the posting to which I am responding, not all of the program
  8422. was copied.  In particular, getfile() seemed to be missing.  I added
  8423. it in a manner different from how the author appearently did it.  I don't
  8424. have Corre's original here, so if this seems a hopeless perversion of the
  8425. pristine getfile(), think of it as a bit of programmer's licence.  The
  8426. program will compile now, and people learning Icon can use it to fol-
  8427. low what is going on:
  8428.  
  8429. -------------------------------------------------------------------------
  8430.  
  8431. #  Compute simple readability score of given ASCII text file
  8432. #  
  8433. #  Based on a  program presented in "Icon Programming for Humanists"
  8434. #  by Alan Corre', Prentice Hall 1990
  8435.  
  8436. global wordlength
  8437.  
  8438. procedure main(a)
  8439.     every in_list := getfile(a) do {
  8440.        compute_readability(in_list[1], in_list[2])
  8441.     }
  8442. end
  8443.  
  8444.  
  8445. procedure getfile(a)
  8446.     usage := "usage:  readable file1 [file2 [file3 [etc...]]]"
  8447.     if *a = 0 then stop(usage)
  8448.     while filename := get(a) do {
  8449.         if intext := open(filename,"r")
  8450.         then suspend [filename, intext]
  8451.     else write(&errout,"readable:  Cannot open ",filename,".")
  8452.     }
  8453. end
  8454.         
  8455.  
  8456. procedure compute_readability(filename,file)
  8457.  
  8458.   # main work loop of the program
  8459.   local total_words, sentence, sentences
  8460.   
  8461.   total_words := 0
  8462.   wordlength := 0
  8463.   sentences := 0
  8464.   
  8465.   every sentence := get_sentence(file) do  {
  8466.       total_words +:= count_sentence(sentence)
  8467.       sentences +:= 1
  8468.   }
  8469.   
  8470.   display(filename,total_words, wordlength, sentences)
  8471.   return
  8472.  
  8473. end
  8474.  
  8475.  
  8476. procedure get_sentence(fileid)
  8477.   # gets a sentence from the file, even if less than a line or more
  8478.   # than a single line of input
  8479.   static markers
  8480.   local sentence, line, substring
  8481.   
  8482.   initial markers := '.!?'
  8483.   
  8484.   sentence := ""
  8485.  
  8486.   while line := read(fileid) do {
  8487.     line ? 
  8488.     {  
  8489.       while substring := tab(upto(markers)) do {
  8490.       
  8491.         # if marker found add it to sentence incl. marker itself
  8492.         sentence ||:= (substring || tab(many(markers)))
  8493.         suspend sentence
  8494.         
  8495.         # skip blanks at beginning of next sentence
  8496.         tab(many(' '))
  8497.         sentence := ""
  8498.       }
  8499.       
  8500.      # if the line is not finished, append rest to sentence
  8501.      if not pos(0) then
  8502.        sentence ||:= (line[&pos:0] || " ") 
  8503.     }
  8504.   }
  8505.   close(fileid)
  8506. end
  8507.  
  8508. procedure getword_from_sentence(sentence)
  8509.   # produces a list of words from the given sentence
  8510.   static chars, punct
  8511.   local word
  8512.   
  8513.   initial { 
  8514.      chars := (&lcase ++ &ucase ++ '1234567890\'-')
  8515.      punct := ' .,?";:!'  # here's the apparent bug;
  8516.                               # try punct := ~chars at first
  8517.   }
  8518.   
  8519.   sentence ? 
  8520.   { 
  8521.     tab(many(' '))     # skip leading white space
  8522.     while word := tab(many(chars)) do {
  8523.       tab(many(punct)) 
  8524.       suspend word
  8525.     }
  8526.   }
  8527. end
  8528.  
  8529. procedure count_sentence(sentence)
  8530.   # number of words in a sentence
  8531.   local total, word
  8532.  
  8533.   total := 0
  8534.   every word := getword_from_sentence(sentence) do {
  8535.     wordlength +:= *word
  8536.     total +:= 1
  8537.   }
  8538.  
  8539.   return total
  8540. end
  8541.  
  8542. procedure display(filename,words, wordlength, sentences)
  8543.   local average_sentence_length, average_word_length
  8544.   
  8545.   average_sentence_length := real(words) / real(sentences)
  8546.   average_word_length := real(wordlength) / real(words)
  8547.  
  8548.   write("\nFilename:  ",filename)
  8549.   write("Total number of words in file: ", words)
  8550.   write("Total number of sentences in file: ", sentences)
  8551.   write("Total combined word length: ", wordlength)
  8552.   write("Average sentence length = ", average_sentence_length)
  8553.   write("Average word length = ", average_word_length)
  8554.   write()
  8555.   write("Readability score = ",  
  8556.             average_sentence_length * average_word_length)
  8557. end
  8558.  
  8559. # taylor@limbo.intuitive.com    or   {uunet!}{decwrl,apple}!limbo!taylor
  8560.  
  8561. From nowlin@iwtqg.att.COM  Sat Apr 21 15:51:50 1990
  8562. Resent-From: nowlin@iwtqg.att.COM
  8563. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  8564.     id AA04389; Sat, 21 Apr 90 15:51:50 MST
  8565. Received: from att-in.att.com by Arizona.EDU; Sat, 21 Apr 90 15:49 MST
  8566. Resent-Date: Sat, 21 Apr 90 15:53 MST
  8567. Date: Sat, 21 Apr 90 16:23 CDT
  8568. From: nowlin@iwtqg.att.COM
  8569. Subject: RE: What's wrong with ...
  8570. Resent-To: icon-group@cs.arizona.edu
  8571. To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  8572. Resent-Message-Id: <A7580FA8BC1FA04236@Arizona.EDU>
  8573. Message-Id: <A7588B2BFF5FA036B4@Arizona.EDU>
  8574. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  8575. X-Envelope-To: icon-group@CS.Arizona.EDU
  8576. X-Vms-To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  8577. Status: O
  8578.  
  8579. I'm working my way through the Humanist book.  I was intrigued by the
  8580. readability index program that Dave Taylor posted since it failed miserably
  8581. on the "read.me" file included on the disk that comes with the Humanist
  8582. book.  Even after Ralph's recommended fix.  This is no real fault of the
  8583. program.  This "read.me" file contains file names that contain embedded
  8584. periods and other characters that are normally used for punctuation.
  8585.  
  8586. I modified the program to work on this "read.me" file by changing the
  8587. algorithm for finding an end of sentence and by adding some characters to
  8588. the cset allowed for words.  My modified program still has some problems.
  8589. The count of words and sentences is correct for the "read.me" file but the
  8590. length of words is now wrong due to the end-of-sentence character being
  8591. counted in the length of the last word in a sentence.  I don't know.  Maybe
  8592. that's OK.
  8593.  
  8594. It's definitely non-trivial to parse text!  The text analysis assumptions
  8595. that work fine for plain vanilla text are mostly invalid for technical
  8596. documents.  I'd hate to have to parse text in any language besides Icon.
  8597.  
  8598. Jerry Nowlin (...!att!iwtqg!nowlin)
  8599.  
  8600. From goer@sophist.uchicago.EDU  Sun Apr 22 22:24:48 1990
  8601. Resent-From: goer@sophist.uchicago.EDU
  8602. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  8603.     id AA26298; Sun, 22 Apr 90 22:24:48 MST
  8604. Return-Path: goer@sophist.uchicago.EDU
  8605. Received: from tank.uchicago.edu by Arizona.EDU; Sun, 22 Apr 90 22:18 MST
  8606. Received: from sophist.uchicago.edu by tank.uchicago.edu Mon, 23 Apr 90
  8607.  00:17:15 CDT
  8608. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA25575; Mon, 23 Apr 90
  8609.  00:13:12 CDT
  8610. Resent-Date: Sun, 22 Apr 90 22:24 MST
  8611. Date: Mon, 23 Apr 90 00:13:12 CDT
  8612. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  8613. Subject: regular expressions for icon
  8614. Resent-To: icon-group@cs.arizona.edu
  8615. To: icon-group@arizona.edu
  8616. Resent-Message-Id: <A6582F67FD5FA04BBF@Arizona.EDU>
  8617. Message-Id: <9004230513.AA25575@sophist.uchicago.edu>
  8618. X-Envelope-To: icon-group@CS.Arizona.EDU
  8619. X-Vms-To: icon-group@Arizona.edu
  8620. Status: O
  8621.  
  8622.  
  8623. I recall several of us discussing some time ago the fact that
  8624. Icon does not have first-class data-object patterns like Sno-
  8625. bol, and that as a second best we might like to see an egrep()-
  8626. like function added.
  8627.  
  8628. After having thought about this for a while, I've decided that
  8629. adding something like this would be a bit like guilding the
  8630. lily.  Besides, even in C regex is a library function, and a nasty
  8631. one at that - one which really doesn't belong in Icon's core
  8632. language definition.
  8633.  
  8634. Most of the times I want to use an egrep-like function are when
  8635. I want to contruct recognizers at run-time from user input.
  8636. For most purposes, coexpressions suffice.  Where these don't
  8637. offer elegant solutions (or speed), I tend to use system("e-
  8638. grep...") or open("egrep...","pr").  This isn't portable, and
  8639. so I wrote an icon-ish egrep commmand that behaves a lot like
  8640. find().
  8641.  
  8642. The following is really an alpha test version of that command.
  8643. I'd appreciate input from others, especially bug reports.  The
  8644. code is not well-commented.  It's a bit redundant as well.  I
  8645. made no efforts to compress or optimize it.  I just wanted to
  8646. make it work.
  8647.  
  8648. One thing that is particularly nice about Icon is that it let
  8649. me handle things like position in the current string by using
  8650. string scanning.  Hash tables also served as the basic state-
  8651. recording structure.  I avoided using coexpressions by saving
  8652. operations in lists (e.g. [function, arg, resulting state])
  8653. so that, at run time, I could just say if lst[1](lst[2]) then
  8654. go to state lst[3].  By doing this, I added just a little
  8655. speed and portability (not everyone has coexpressions), and
  8656. perhaps a tad greater clarity as well.
  8657.  
  8658. Please, please send me comments.
  8659.  
  8660. ########################################################################
  8661. #    
  8662. #    Name:    find_re.icn
  8663. #    
  8664. #    Title:    "Find" Regular Expression
  8665. #    
  8666. #    Author:    Richard L. Goerwitz
  8667. #
  8668. #    Date:    April 22, 1990
  8669. #
  8670. ########################################################################
  8671. #    
  8672. #    DESCRIPTION:  Find_re is similar to the Icon builtin function
  8673. #    find(), except that it takes as its first argument a regular
  8674. #    expression of the sort used by the Unix egrep command.  For those
  8675. #    unfamiliar with the notion of regular expressions, they represent
  8676. #    a simple string representation of a finite state transition
  8677. #    network which can be converted into an automaton capable of
  8678. #    recognizing patterns in strings of characters.  The specific
  8679. #    symbols used, and the purposes they are used for, can be gleaned
  8680. #    from the Unix man pages for egrep and the regex library
  8681. #    functions.  In even more basic terms, regular expressions can be
  8682. #    thought of as a very flexible and powerful set of "wildcards."
  8683. #
  8684. #    DIFFERENCES between egrep and find_re:  Find_re utilizes the same
  8685. #    basic language as egrep.  The only major differences are: 1) That
  8686. #    find_re is a bit more rigid in its syntax (e.g. find_re will
  8687. #    reject vagarities like 'a*?'), and 2) that find_re utilizes the
  8688. #    intrinsic Icon data structures and escaping conventions, rather
  8689. #    than those of any particular Unix variant.
  8690. #
  8691. #    BUGS:  No attempt has been made to optimize find_re.  For work
  8692. #    that requires a quick response, you'll have to use something like
  8693. #    system("egrep...")!  Note, though, that while find_re takes a
  8694. #    while to compile a regular expression, find_re at least has enough
  8695. #    sense to store the resulting automaton for quick access in subse-
  8696. #    quent calls.
  8697. #    
  8698. ########################################################################
  8699.  
  8700. global state_table
  8701.  
  8702. procedure find_re(re, s, i, j)
  8703.  
  8704.     static FSTN_table
  8705.     initial FSTN_table := table()
  8706.  
  8707.     /re & stop("find_re:  Call me with at least one argument!")
  8708.  
  8709.     /i := \&pos | 1
  8710.     /s := \&subject | stop("find_re:  No string.")
  8711.     /j := *s+1
  8712.     if /FSTN_table[re] then {
  8713.     tokenized_re := tokenize(re)
  8714.     MakeFSTN(tokenized_re) | er(re,2)
  8715.     /FSTN_table[re] := copy(state_table)
  8716.     }
  8717.     s ? {
  8718.     tab(x := i to j) &
  8719.     apply_FSTN(&null,FSTN_table[re]) &
  8720.     (suspend x)
  8721.     }
  8722.  
  8723. end
  8724.  
  8725.  
  8726.  
  8727. procedure apply_FSTN(ini,tbl)
  8728.  
  8729.     static s_tbl
  8730.     local POS, tmp
  8731.  
  8732.     POS := &pos
  8733.     /ini := 1 & s_tbl := tbl
  8734.     fin := 2
  8735.     if ini == 0 then {
  8736.     return 0
  8737.     }
  8738.  
  8739.     if tmp := !s_tbl[ini] &
  8740.        tab(tmp[1](tmp[2]))
  8741.     then {
  8742.     if tmp[3] = fin
  8743.     then return 0
  8744.     else {
  8745.         return apply_FSTN(tmp[3]) |
  8746.            (&pos := POS, fail)
  8747.     }
  8748.     }
  8749.     else &pos := POS
  8750.  
  8751. end
  8752.     
  8753.  
  8754.  
  8755. procedure tokenize(s)
  8756.  
  8757.     token_list := list()
  8758.     s ? {
  8759.  
  8760.     while chr := move(1) do {
  8761.         if chr == "\\"
  8762.         # it can't be a metacharacter; remove the \ and "put"
  8763.         # the integer value of the next chr into token_list
  8764.         then put(token_list,ord(move(1))) | er(s,2,chr)
  8765.         else if any('*+()|?.$^',chr)
  8766.         then put(token_list,-ord(chr))
  8767.         else {
  8768.         case chr of {
  8769.             "["    : {
  8770.             every next_one := find("]")
  8771.             \next_one ~= &pos | er(s,2,chr)
  8772.             put(token_list,-ord(chr))
  8773.             }
  8774.                     "]"    : {
  8775.             if &pos = (\next_one+1)
  8776.             then put(token_list,-ord(chr)) &
  8777.                  next_one := &null
  8778.             else put(token_list,ord(chr))
  8779.             }
  8780.             default: put(token_list,ord(chr))
  8781.         }
  8782.         }
  8783.     }
  8784.     }
  8785.  
  8786.     token_list := UnMetaBrackets(token_list)
  8787.  
  8788.     fixed_length_token_list := list(*token_list)
  8789.     every i := 1 to *token_list
  8790.     do fixed_length_token_list[i] := token_list[i]
  8791.     return fixed_length_token_list
  8792.  
  8793. end
  8794.  
  8795.  
  8796.  
  8797. procedure UnMetaBrackets(l)
  8798.  
  8799.     # Since brackets delineate a cset, it doesn't make
  8800.     # any sense to have metacharacters inside of them.
  8801.     # UnMetaBrackets makes sure there are no metacharac-
  8802.     # ters inside of the braces.
  8803.  
  8804.     tmplst := list(); i := 0
  8805.     Lb := -ord("[")
  8806.     Rb := -ord("]")
  8807.  
  8808.     while (i +:= 1) <= *l do {
  8809.     if l[i] = Lb then {
  8810.         put(tmplst,l[i])
  8811.         until l[i +:= 1] = Rb
  8812.         do put(tmplst,abs(l[i]))
  8813.         put(tmplst,l[i])
  8814.     }
  8815.     else put(tmplst,l[i])
  8816.     }
  8817.     return tmplst
  8818.  
  8819. end
  8820.  
  8821.  
  8822.  
  8823. procedure MakeFSTN(l,INI,FIN)
  8824.  
  8825.     # MakeFSTN recursively descends through the tree structure
  8826.     # implied by the tokenized string, l, recording in (global)
  8827.     # fstn_table a list of operations to be performed, and the
  8828.     # initial and final states which apply to them.
  8829.  
  8830.     static Lp, Rp, Sl, Lb, Rb, Caret_inside, Dot, Dollar, Caret_outside
  8831.     initial {
  8832.     Lp := -ord("("); Rp := -ord(")")
  8833.     Sl := -ord("|")
  8834.     Lb := -ord("["); Rb := -ord("]"); Caret_inside := ord("^")
  8835.     Dot := -ord("."); Dollar := -ord("$"); Caret_outside := -ord("^")
  8836.     }
  8837.  
  8838.     /INI := NextState("new") & state_table := table()
  8839.     /FIN := NextState()
  8840.  
  8841.     # I haven't bothered to test for empty lists everywhere.
  8842.     if *l = 0 then {
  8843.     /state_table[INI] := []
  8844.     put(state_table[INI],[zSucceed,,FIN])
  8845.     return
  8846.     }
  8847.  
  8848.     # HUNT DOWN THE SLASH (ALTERNATION OPERATOR)
  8849.     ini := INI; inter := NextState()
  8850.     inter2:= NextState()
  8851.     every i := 1 to *l do {
  8852.     if l[i] = Sl & tab_bal(l,Lp,Rp) = i then {
  8853.         if i = 1 then er(l,2,char(abs(l[i]))) else {
  8854.         MakeFSTN(l[1:i],inter2,FIN)
  8855.         MakeFSTN(l[i+1:0],inter,FIN)
  8856.         /state_table[ini] := []
  8857.         put(state_table[ini],[apply_FSTN,inter2,0])
  8858.         put(state_table[ini],[apply_FSTN,inter,0])
  8859.         return
  8860.         }
  8861.     }
  8862.     }
  8863.  
  8864.     # HUNT DOWN PARENTHESES
  8865.     ini := INI; fin := FIN
  8866.     if l[1] = Lp then {
  8867.     i := tab_bal(l,Lp,Rp) | er(l,2,"(")
  8868.     inter := NextState()
  8869.     if any('*+?',char(abs(0 > l[i+1]))) then {
  8870.         case l[i+1] of {
  8871.         -ord("*")   : {
  8872.             /state_table[ini] := []
  8873.             put(state_table[ini],[apply_FSTN,inter,0])
  8874.             MakeFSTN(l[2:i],ini,ini)
  8875.             MakeFSTN(l[i+2:0],inter,fin)
  8876.             return
  8877.         }
  8878.         -ord("+")   : {
  8879.             inter2 := NextState()
  8880.             /state_table[inter2] := []
  8881.             MakeFSTN(l[2:i],ini,inter2)
  8882.             put(state_table[inter2],[apply_FSTN,inter,0])
  8883.             MakeFSTN(l[2:i],inter2,inter2)
  8884.             MakeFSTN(l[i+2:0],inter,fin)
  8885.             return
  8886.         }
  8887.         -ord("?")   : {
  8888.             /state_table[ini] := []
  8889.             put(state_table[ini],[apply_FSTN,inter,0])
  8890.             MakeFSTN(l[2:i],ini,inter)
  8891.             MakeFSTN(l[i+2:0],inter,fin)
  8892.             return
  8893.         }
  8894.         }
  8895.     }
  8896.     else {
  8897.         MakeFSTN(l[2:i],ini,inter)
  8898.         MakeFSTN(l[i+1:0],inter,fin)
  8899.         return
  8900.     }
  8901.     }
  8902.     else {     # I.E. l[1] NOT = Lp (left parenthesis as -ord("("))
  8903.     every i := 1 to *l do {
  8904.         case l[i] of {
  8905.         Lp     : {
  8906.             inter := NextState()
  8907.             MakeFSTN(l[1:i],ini,inter)
  8908.             MakeFSTN(l[i:0],inter,fin)
  8909.             return
  8910.         }
  8911.         Rp     : er(l,2,")")
  8912.         }
  8913.     }
  8914.     }
  8915.  
  8916.     # NOW, HUNT DOWN BRACKETS
  8917.     ini := INI; fin := FIN
  8918.     if l[1] = Lb then {
  8919.     i := tab_bal(l,Lb,Rb) | er(l,2,"[")
  8920.     inter := NextState()
  8921.     tmp := ""; every tmp ||:= char(l[2 to i-1])
  8922.     if Caret_inside = l[2]
  8923.     then tmp := ~cset(Expand(tmp[2:0]))
  8924.     else tmp :=  cset(Expand(tmp))
  8925.     if any('*+?',char(abs(0 > l[i+1]))) then {
  8926.         case l[i+1] of {
  8927.         -ord("*")   : {
  8928.             /state_table[ini] := []
  8929.             put(state_table[ini],[apply_FSTN,inter,0])
  8930.             put(state_table[ini],[any,tmp,ini])
  8931.             MakeFSTN(l[i+2:0],inter,fin)
  8932.             return
  8933.         }
  8934.         -ord("+")   : {
  8935.             inter2 := NextState()
  8936.             /state_table[ini] := []
  8937.             put(state_table[ini],[any,tmp,inter2])
  8938.             /state_table[inter2] := []
  8939.             put(state_table[inter2],[apply_FSTN,inter,0])
  8940.             put(state_table[inter2],[any,tmp,inter2])
  8941.             MakeFSTN(l[i+2:0],inter,fin)
  8942.             return
  8943.         }
  8944.         -ord("?")   : {
  8945.             /state_table[ini] := []
  8946.             put(state_table[ini],[apply_FSTN,inter,0])
  8947.             put(state_table[ini],[any,tmp,inter])
  8948.             MakeFSTN(l[i+2:0],inter,fin)
  8949.             return
  8950.         }
  8951.         }
  8952.     }
  8953.     else {
  8954.         /state_table[ini] := []
  8955.         put(state_table[ini],[any,tmp,inter])
  8956.         MakeFSTN(l[i+1:0],inter,fin)
  8957.         return
  8958.     }
  8959.     }
  8960.     else {           # I.E. l[1] not = Lb
  8961.     every i := 1 to *l do {
  8962.         case l[i] of {
  8963.         Lb     : {
  8964.             inter := NextState()
  8965.             MakeFSTN(l[1:i],ini,inter)
  8966.             MakeFSTN(l[i:0],inter,fin)
  8967.             return
  8968.         }
  8969.         Rb     : er(l,2,"]")
  8970.         }
  8971.     }
  8972.     }
  8973.  
  8974.     # FIND INITIAL SEQUENCES OF POSITIVE INTEGERS, CONCATENATE THEM
  8975.     if i := match_positive_ints(l) then {
  8976.     inter := NextState()
  8977.     tmp := Ints2String(l[1:i])
  8978.     /state_table[INI] := []
  8979.     put(state_table[INI],[match,tmp,inter])
  8980.     MakeFSTN(l[i:0],inter,FIN)
  8981.     return
  8982.     }
  8983.  
  8984.     # OKAY, CLEAN UP ALL THE JUNK THAT'S LEFT
  8985.     i := 0
  8986.     while (i +:= 1) <= *l do {
  8987.     case l[i] of {
  8988.         Dot          : { Op := any;   Arg := &cset }
  8989.         Dollar       : { Op := pos;   Arg := 0     }
  8990.         Caret_outside: { Op := pos;   Arg := 1     }
  8991.         default      : { Op := match; Arg := char(0 < l[i]) }
  8992.     } | er(l,2,char(abs(l[i])))
  8993.     ini := INI; fin := FIN
  8994.     inter := NextState()
  8995.     if any('*+?',char(abs(0 > l[i+1]))) then {
  8996.         case l[i+1] of {
  8997.         -ord("*")   : {
  8998.             /state_table[ini] := []
  8999.             put(state_table[ini],[apply_FSTN,inter,0])
  9000.             put(state_table[ini],[Op,Arg,ini])
  9001.             MakeFSTN(l[i+2:0],inter,FIN)
  9002.             return
  9003.         }
  9004.         -ord("+")   : {
  9005.             inter2 := NextState()
  9006.             /state_table[ini] := []
  9007.             put(state_table[ini],[Op,Arg,inter2])
  9008.             /state_table[inter2] := []
  9009.             put(state_table[inter2],[apply_FSTN,inter,0])
  9010.             put(state_table[inter2],[Op,Arg,inter2])
  9011.             MakeFSTN(l[i+2:0],inter,FIN)
  9012.             return
  9013.         }
  9014.         -ord("?")   : {
  9015.             /state_table[ini] := []
  9016.             put(state_table[ini],[apply_FSTN,inter,0])
  9017.             put(state_table[ini],[Op,Arg,inter])
  9018.             MakeFSTN(l[i+2:0],inter,FIN)
  9019.             return
  9020.         }
  9021.         }
  9022.     }
  9023.     else {
  9024.         /state_table[ini] := []
  9025.         put(state_table[ini],[Op,Arg,inter])
  9026.         MakeFSTN(l[i+1:0],inter,FIN)
  9027.         return
  9028.     }
  9029.     }
  9030.  
  9031.     # WE SHOULD NOW BE DONE INSERTING EVERYTHING INTO state_table
  9032.     # IF WE GET TO HERE, WE'VE PARSED INCORRECTLY!
  9033.     er(l,4)
  9034.  
  9035. end
  9036.  
  9037.  
  9038.  
  9039. procedure NextState(new)
  9040.     static nextstate
  9041.     if \new then nextstate := 0
  9042.     return nextstate +:= 1
  9043. end
  9044.  
  9045.  
  9046.  
  9047. procedure er(x,i,elem)
  9048.     writes(&errout,"Error number ",i," parsing ",image(x)," at ")
  9049.     if \elem 
  9050.     then write(&errout,image(elem),".")
  9051.     else write(&errout,"(?).")
  9052.     exit(i)
  9053. end
  9054.  
  9055.  
  9056.  
  9057. procedure zSucceed()
  9058.     return .&pos
  9059. end
  9060.  
  9061.  
  9062.  
  9063. procedure Expand(s)
  9064.  
  9065.     s2 := ""
  9066.     s ? {
  9067.     s2 ||:= ="^"
  9068.     s2 ||:= ="-"
  9069.     while s2 ||:= tab(find("-")-1) do {
  9070.         if (c1 := move(1), ="-",
  9071.         c2 := move(1),
  9072.         c1 << c2)
  9073.         then every s2 ||:= char(ord(c1) to ord(c2))
  9074.         else s2 ||:= 1(move(2), not(pos(0))) | er(s,2,"-")
  9075.     }
  9076.     s2 ||:= tab(0)
  9077.     }
  9078.     return s2
  9079.  
  9080. end
  9081.  
  9082.  
  9083.  
  9084. procedure tab_bal(l,i1,i2)
  9085.     i := 0
  9086.     i1_count := 0; i2_count := 0
  9087.     while (i +:= 1) <= *l do {
  9088.     case l[i] of {
  9089.         i1  : i1_count +:= 1
  9090.         i2  : i2_count +:= 1
  9091.     }
  9092.     if i1_count = i2_count
  9093.     then suspend i
  9094.     }
  9095. end
  9096.  
  9097.  
  9098. procedure match_positive_ints(l)
  9099.     
  9100.     # Matches the longest sequence of positive integers in l,
  9101.     # beginning at l[1], which neither contains, nor is fol-
  9102.     # lowed by a negative integer.  Returns the first position
  9103.     # after the match.  Hence, given [55, 55, 55, -42, 55],
  9104.     # match_positive_ints will return 3.  [55, -42] will cause
  9105.     # it to fail rather than return 1 (NOTE WELL!).
  9106.  
  9107.     every i := 1 to *l do {
  9108.     if l[i] < 0
  9109.     then return (3 < i) - 1
  9110.     }
  9111.  
  9112. end
  9113.  
  9114.  
  9115. procedure Ints2String(l)
  9116.     tmp := ""
  9117.     every tmp ||:= char(!l)
  9118.     return tmp
  9119. end
  9120.  
  9121. From nowlin@iwtqg.att.COM  Mon Apr 23 07:05:37 1990
  9122. Resent-From: nowlin@iwtqg.att.COM
  9123. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  9124.     id AA12657; Mon, 23 Apr 90 07:05:37 MST
  9125. Received: from att-in.att.com by Arizona.EDU; Mon, 23 Apr 90 07:04 MST
  9126. Resent-Date: Mon, 23 Apr 90 07:05 MST
  9127. Date: Mon, 23 Apr 90 08:45 CDT
  9128. From: nowlin@iwtqg.att.COM
  9129. Subject: RE: regular expressions for icon
  9130. Resent-To: icon-group@cs.arizona.edu
  9131. To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  9132. Resent-Message-Id: <A60F7C62E87FA04C35@Arizona.EDU>
  9133. Message-Id: <A60F96D22E5FA03DB4@Arizona.EDU>
  9134. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  9135. X-Envelope-To: icon-group@CS.Arizona.EDU
  9136. X-Vms-To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  9137. Status: O
  9138.  
  9139. It just so happens I have a set of tests for regular expression matching
  9140. since I had an Icon version of grep to test a few years ago.  I wrote a
  9141. main program to test the version of find_re() posted to this group and it
  9142. did OK.  Of the 100 tests I have, it only matched two patterns it shouldn't
  9143. have and only missed 17 patterns that it should have matched.  I've
  9144. included the main program that uses the find_re() procedure to simulate a
  9145. grep command here.  I get really bugged by partial postings that people
  9146. have to hack a front on before they can try.
  9147.  
  9148. procedure main(a)
  9149.  
  9150.     # the usage message
  9151.     usage := "Usage: RGgrep pattern [ file ... ]"
  9152.  
  9153.     # the first program argument must be the pattern
  9154.     pattern := get(a) | stop("I at least need a pattern\n",usage)
  9155.  
  9156.     # trick the program into using standard input if no files were passed
  9157.     if *a = 0 then a := [&null]
  9158.  
  9159.     # the rest of the arguments are files to search through
  9160.     every f := !a do {
  9161.  
  9162.         # if the file isn't null try to open it
  9163.         if \f then in := open(f) | stop("I can't open '",f,"'")
  9164.  
  9165.         # otherwise use standard input
  9166.         else in := &input
  9167.  
  9168.         # if there is only one file skip printing the file name
  9169.         if *a = 1 then f := ""
  9170.  
  9171.         # otherwise tack on a colon
  9172.         else f ||:= ":"
  9173.  
  9174.         # read all the lines
  9175.         every l := !in do {
  9176.  
  9177.             # scan the line for the pattern
  9178.             l ? {
  9179.  
  9180. ##### BELOW IS THE CALL TO the find_re() procedure posted earlier #####
  9181.  
  9182.                 # if the pattern is found print the line
  9183.                 if find_re(pattern) then write(f,l)
  9184.             }
  9185.         }
  9186.  
  9187.         # close the input file is one was opened
  9188.         if in ~=== &input then close(in)
  9189.     }
  9190. end
  9191.  
  9192. I'll post the tests in a separate message since there's an Icon program to
  9193. run the tests (naturally) along with the file of tests and they total more
  9194. than 100 lines.  The comments in the test program should be enough to use
  9195. the program and the included tests.
  9196.  
  9197. Jerry Nowlin (...!att!iwtqg!nowlin)
  9198.  
  9199. From nowlin@iwtqg.att.COM  Mon Apr 23 07:18:33 1990
  9200. Resent-From: nowlin@iwtqg.att.COM
  9201. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  9202.     id AA14809; Mon, 23 Apr 90 07:18:33 MST
  9203. Received: from att-in.att.com by Arizona.EDU; Mon, 23 Apr 90 07:15 MST
  9204. Resent-Date: Mon, 23 Apr 90 07:19 MST
  9205. Date: Mon, 23 Apr 90 08:58 CDT
  9206. From: nowlin@iwtqg.att.COM
  9207. Subject: regular expression tests
  9208. Resent-To: icon-group@cs.arizona.edu
  9209. To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  9210. Resent-Message-Id: <A60D72A6265FA04848@Arizona.EDU>
  9211. Message-Id: <A60E14D3C9FFA04943@Arizona.EDU>
  9212. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  9213. X-Envelope-To: icon-group@CS.Arizona.EDU
  9214. X-Vms-To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  9215. Status: O
  9216.  
  9217. Below is a program that will test any grep-like command and a file of the
  9218. tests that it uses.  I've run these tests with the standard UNIX grep and
  9219. it only fails on the tests that use the '+' character to match at least one
  9220. and any subsequent number of characters.  The grep on my system doesn't
  9221. like that particular expression.  The Icon grep I have does like it and
  9222. that's why these tests are still in this suite.  If anyone finds bugs in
  9223. these tests let me know.  Your software is only as good as your tests.
  9224.  
  9225. Jerry Nowlin (..!att!iwtqg!nowlin)
  9226.  
  9227. -------------------------- test program follows --------------------------
  9228.  
  9229. # This program is to test commands that work like the standard UNIX grep.
  9230. # That is, they can read from standard input and their first argument is a
  9231. # regular expression that is searched for in the input.  The first argument
  9232. # to the program is the name of a command to test.  The second argument to
  9233. # the program is a file containing tests to be executed.  For example, the
  9234. # following is a valid invocation of this program:
  9235. #
  9236. #    tst grep test.pats
  9237. #
  9238. # Each line in the file of tests must contain a string followed by a
  9239. # regular expression followed by a comment.  I use the comment field to
  9240. # indicate whether or not the test is supposed to succeed or fail but
  9241. # anything you want can be included in the comment field.  The token
  9242. # separating the three fields is a pipe symbol.  This was completely
  9243. # arbitrary.  You can change it to anything you want.  The following is a
  9244. # valid test line:
  9245. #
  9246. #    abbbbc|ab*c|YES
  9247. #
  9248. # This test should succeed.  If it doesn't there's a problem with the
  9249. # program being tested.
  9250. #
  9251. # I use this program to test a version of grep written in Icon.  Since I
  9252. # can test the standard versions of grep with this program to I can compare
  9253. # the Icon version to the standard.
  9254.  
  9255. procedure main(args)
  9256.  
  9257.     # this program requires two arguments
  9258.     if *args ~= 2 then stop("Usage: tst cmd file")
  9259.  
  9260.     # the command to be tested is the first argument
  9261.     cmd := get(args)
  9262.     write("Testing the ",cmd," command")
  9263.  
  9264.     # the file of tests is the second argument
  9265.     file := get(args)
  9266.     in := open(file) | stop("I can't open '",file,"'")
  9267.     
  9268.     # each line should contains a test
  9269.     every !in ? {
  9270.         str := tab(upto('|'))
  9271.         move(1)
  9272.         pat := tab(upto('|'))
  9273.         move(1)
  9274.         com := tab(0)
  9275.     
  9276.         write(com,": searching '",str,"' for pattern '",pat,"'")
  9277.     
  9278.         # quote the string
  9279.         if not find("\"",str) then str := "\"" || str || "\""
  9280.         else if not find("'",str) then str := "'" || str || "'"
  9281.         else stop("Bad string: ",str)
  9282.     
  9283.         # quote the pattern
  9284.         if not find("\"",pat) then pat := "\"" || pat || "\""
  9285.         else if not find("'",pat) then pat := "'" || pat || "'"
  9286.         else stop("Bad pattern: ",pat)
  9287.     
  9288.         # invoke the command
  9289.         system("echo " || str || " | " || cmd || " " || pat)
  9290.     }
  9291.     
  9292.     # close the test file
  9293.     close(in)
  9294. end
  9295.  
  9296. -------------------------- test file follows --------------------------
  9297.  
  9298. ac|ab|NO
  9299. ac|abc|NO
  9300. ac|ab*c|YES
  9301. ac|ab+c|NO
  9302. ac|a.*c|YES
  9303. ac|a.+c|NO
  9304. abc|ab|YES
  9305. abc|abc|YES
  9306. abc|ab*c|YES
  9307. abc|ab+c|YES
  9308. abc|a.*c|YES
  9309. abc|a.+c|YES
  9310. abbbbc|ab|YES
  9311. abbbbc|abc|NO
  9312. abbbbc|ab*c|YES
  9313. abbbbc|ab+c|YES
  9314. abbbbc|a.*c|YES
  9315. abbbbc|a.+c|YES
  9316. akc|ab|NO
  9317. akc|abc|NO
  9318. akc|ab*c|NO
  9319. akc|ab+c|NO
  9320. akc|a.*c|YES
  9321. akc|a.+c|YES
  9322. akjhgfc|ab|NO
  9323. akjhgfc|abc|NO
  9324. akjhgfc|ab*c|NO
  9325. akjhgfc|ab+c|NO
  9326. akjhgfc|a.*c|YES
  9327. akjhgfc|a.+c|YES
  9328. this is it|^this|YES
  9329. this is it|^his|NO
  9330. this is it|his|YES
  9331. this is it|his$|NO
  9332. this is it|it$|YES
  9333. match carat|.*^|NO
  9334. match (^) carat|.*^|YES
  9335. (^) match carat|.^|YES
  9336. (^) match carat|(^|YES
  9337. match dollar|$.*|NO
  9338. match ($) dollar|$.*|YES
  9339. ($) match dollar|$.|YES
  9340. ($) match dollar|$)|YES
  9341. no stars|^**|YES
  9342. no stars|^*+|NO
  9343. *#$%&@!_+=:|^**|YES
  9344. *#$%&@!_+=:|^*+|YES
  9345. no stars|**|YES
  9346. no stars|*+|NO
  9347. *#$%&@!_+=:|**|YES
  9348. *#$%&@!_+=:|*+|YES
  9349. no pluses|^+*|YES
  9350. no pluses|^++|NO
  9351. +#$%&@!_*=:|^+*|YES
  9352. +#$%&@!_*=:|^++|YES
  9353. no pluses|+*|YES
  9354. no pluses|++|NO
  9355. +#$%&@!_*=:|+*|YES
  9356. +#$%&@!_*=:|++|YES
  9357. ABCabcdefDEF|^[a-z]|NO
  9358. ABCabcdefDEF|[a-z]$|NO
  9359. ABCabcdefDEF|^[A-Z]|YES
  9360. ABCabcdefDEF|[A-Z]$|YES
  9361. abcABCDEFdef|^[a-z]|YES
  9362. abcABCDEFdef|[a-z]$|YES
  9363. abcABCDEFdef|^[A-Z]|NO
  9364. abcABCDEFdef|[A-Z]$|NO
  9365. ABCabcdefDEF|^[acbfed]|NO
  9366. ABCabcdefDEF|[acbfed]$|NO
  9367. ABCabcdefDEF|^[FA]|YES
  9368. ABCabcdefDEF|[FA]$|YES
  9369. abcABCDEFdef|^[acbfed]|YES
  9370. abcABCDEFdef|[acbfed]$|YES
  9371. abcABCDEFdef|^[FEADCB]|NO
  9372. abcABCDEFdef|[FEADCB]$|NO
  9373. ABCabcdefDEF|^[FE0DCB]|NO
  9374. ABCabcdefDEF|[9EADCB]$|NO
  9375. abcABCDEFdef|^[9cbfed]|NO
  9376. abcABCDEFdef|[acb0ed]$|NO
  9377. ABCabcdefDEF|[a-cd-f]D|YES
  9378. ABCabcdefDEF|C[fa]|YES
  9379. abcABCDEFdef|c[^a-z]|YES
  9380. abcABCDEFdef|[^0-9]A|YES
  9381. this is a more complicated test| is .*test$|YES
  9382. this is a more complicated test| is .*test|YES
  9383. this is a more complicated test| is *test$|NO
  9384. this is a more complicated test.| is .*test$|NO
  9385. this is a more complicated test|is.*test|YES
  9386. this istest may be weird|is.*test|YES
  9387. this may be a more complicated test| is .*test$|NO
  9388. this may be a more complicated test|is .*test$|YES
  9389. this may be a more complicated test| is .*test|NO
  9390. this may be a more complicated test| is .*test$|NO
  9391. this may be a more complicated test.|is .*test$|NO
  9392. this may be a more complicated test|is.*test|YES
  9393. test ranges 5198402 ablkseimnfaKJLDLD|[-D]|YES
  9394. test ranges 5198402 ablkseimnfaKJLDLD|[-Z]|NO
  9395. test ranges 5198402 ablkseimnfaKJLDLD|[A-Z]|YES
  9396. test ranges 5198402 ablkseimnfaKJLDLD|[A-]|NO
  9397. test ranges 5198402 ablkseimnfaKJLDLD|[a-]|YES
  9398.  
  9399. From goer@sophist.uchicago.EDU  Mon Apr 23 13:50:42 1990
  9400. Resent-From: goer@sophist.uchicago.EDU
  9401. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  9402.     id AA28441; Mon, 23 Apr 90 13:50:42 MST
  9403. Return-Path: goer@sophist.uchicago.EDU
  9404. Received: from tank.uchicago.edu by Arizona.EDU; Mon, 23 Apr 90 10:44 MST
  9405. Received: from sophist.uchicago.edu by tank.uchicago.edu Mon, 23 Apr 90
  9406.  11:49:40 CDT
  9407. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA28106; Mon, 23 Apr 90
  9408.  11:45:10 CDT
  9409. Resent-Date: Mon, 23 Apr 90 13:48 MST
  9410. Date: Mon, 23 Apr 90 11:45:10 CDT
  9411. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  9412. Subject: find_re and egrep
  9413. Resent-To: icon-group@cs.arizona.edu
  9414. To: nowlin@iwtqg.att.COM
  9415. Cc: icon-group@arizona.edu
  9416. Resent-Message-Id: <A5D72FD7177FA05340@Arizona.EDU>
  9417. Message-Id: <9004231645.AA28106@sophist.uchicago.edu>
  9418. X-Envelope-To: icon-group@CS.Arizona.EDU
  9419. X-Vms-To: nowlin@iwtqg.att.COM
  9420. X-Vms-Cc: icon-group@Arizona.edu
  9421. Status: O
  9422.  
  9423.  
  9424. JN expressed some annoyance that I did not provide find_re() in a form
  9425. that would make it immediately testable.  I am sorry that I annoyed anyone.
  9426. My intent was to help!  My reason for posting this way was that find_re is
  9427. NOT just an egrep without "procedure main."  If people wanna put wrappers
  9428. around it, and then run it through egrep-like tests they can do this.  The
  9429. comments prepended to it, however, state very clearly that it will not pass
  9430. all tests geared for the Unix egrep system command.  In particular (as Jerry
  9431. Nowlin's tests confirm), find_re will reject constructs like '.*?'.  If
  9432. I ever chance to write '.*?', it always means one of two things:  1) I am
  9433. being very sloppy, or 2) I am not thinking about what I am doing, and am
  9434. in fact making an error.  Note also that find_re utilizes Icon's escaping
  9435. conventions, and does not attempt to accommodate itself to any particular
  9436. Unix variant.  Again, I am sorry if the way I posted find_re annoyed any-
  9437. one else.  My aim was not to make testing difficult.  In fact, I have al-
  9438. ready put it through a large battery of egrep tests.  Differences that ex-
  9439. ist between egrep and find_re are there because I want them there (or else
  9440. because egrep is not consistent from operating system [version] to operating
  9441. system [version]).  What I had hoped is that people might test it within
  9442. Icon as a "find" variant with added functionality (but a lot slower).  One
  9443. thing that might be done with it, in fact, is to place a test right at the
  9444. outset that checks for input strings without metacharacters and then calls
  9445. find() if none are found.  Another thing to do might be to add a fifth argu-
  9446. ment, which if it is nonnull, frees up all the space allocated for stored
  9447. automata.  I have no idea whether this would be worth it (probably not).
  9448.  
  9449. Naturally, I'll work on speeding it up.
  9450.  
  9451. If people do in fact want to test find_re as an egrep program, I don't
  9452. object.  I just want to be sure everyone realizes that in the marginal kinds
  9453. of cases that standard tests tend to work on, find_re will show certain sys-
  9454. tematic differences from egrep.  In actual usage, these differences will
  9455. only show up once in a blue moon, and should always consist in an error mes-
  9456. sage flagging a pattern like '.*+' or '$)' (the last of which most egrep
  9457. commands will flag as an error as well).  Like all egrep commands I have
  9458. access to, find_re will not construe $ and ^ as literals in contexts like
  9459. '.*^' or '$?', even though it might make better sense to do so.  Because
  9460. these sequences lie in one of those gray areas, maybe I should consider
  9461. flagging them as errors?
  9462.  
  9463.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  9464.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  9465.  
  9466. From icon-group-request@arizona.edu  Tue Apr 24 11:07:41 1990
  9467. Resent-From: icon-group-request@arizona.edu
  9468. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  9469.     id AA06257; Tue, 24 Apr 90 11:07:41 MST
  9470. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 24 Apr 90 11:08 MST
  9471. Received: by ucbvax.Berkeley.EDU (5.62/1.41) id AA23588; Tue, 24 Apr 90
  9472.  11:03:16 -0700
  9473. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9474.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9475.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9476. Resent-Date: Tue, 24 Apr 90 11:09 MST
  9477. Date: 24 Apr 90 18:02:36 GMT
  9478. From: sdd.hp.com!zaphod.mps.ohio-state.edu!uwm.edu!csd4.csd.uwm.edu!corre@ucsd.EDU
  9479. Subject: Word Counts
  9480. Sender: icon-group-request@arizona.edu
  9481. Resent-To: icon-group@cs.arizona.edu
  9482. To: icon-group@arizona.edu
  9483. Resent-Message-Id: <A5243E38369FA05A45@Arizona.EDU>
  9484. Message-Id: <3594@uwm.edu>
  9485. Organization: University of Wisconsin-Milwaukee
  9486. X-Envelope-To: icon-group@CS.Arizona.EDU
  9487. X-Vms-To: icon-group@Arizona.edu
  9488. Status: O
  9489.  
  9490. I think the relevant points concerning the program in my book have
  9491. been made by others with the skill that one is accustomed to seeing on
  9492. this newsgroup, but I should like to add some meditations on this
  9493. theme.
  9494. Leslie Lamport writes: "TeX ... has trouble deciding which periods end
  9495. sentences." The statement is not strictly accurate. The author of TeX
  9496. apparently decided that while it was worth while to teach TeX to
  9497. hyphenate virtually every word in the English language (with the
  9498. possible exception of "gnomonly"), it was not worth while to allow for
  9499. the etc.'s and viz.'s and I + II.'s. The task of making determinations
  9500. about the period is left in human hands. Actually it would be quite
  9501. possible to write an Icon preprocessor to take care of that gap, but
  9502. one likewise has to decide if it is worth it. The fact is that our
  9503. notation both of natural and mathematical language is saddled with
  9504. centuries of accrued accidents. Consider:
  9505. Capitalization: Semitic languages manage just fine without it. So did
  9506. computers for a while. FORTRAN is not written like that because it is
  9507. an acronym, but because the limited character set forced it. what a
  9508. chance was missed to dump our two-tier system, the main function of
  9509. which is to make third graders miserable! but QWERTY reared its head,
  9510. and we had to squeeze computers into our foolishness. if
  9511. Capitalization had any Meaning we might be capitalizing our Nouns like
  9512. german and norwegian.
  9513. Functions: The fact that "plus" is written in between its arguments,
  9514. "square" is written after and superscript, and "square root" is written
  9515. before obscures the essential similarity of these items which
  9516. establish relationships. Yet we really can't get used to Polish type
  9517. notation.
  9518. Intonation: A tremendously significant force which has a wretched
  9519. representation in punctuation and underlining. The possibilities of
  9520. recording saying a simple "yes" fearfully, enthusiastically,
  9521. grudgingly have not even been explored. If we must have complicated
  9522. representation systems, why leave this out?
  9523. Spelling: enuff said.
  9524. We need not think that these anomalies do not take their toll. When
  9525. Joshua was pursuing some kings and wanted to know their names, a
  9526. simple shepherd boy was able to write them down for him. The new
  9527. alphabetic system was devoid of frills, could be written on a piece of
  9528. broken pot, and learned in short order. Our clumsy system leaves us
  9529. with vast numbers of intelligent illiterates trying to master a
  9530. fundamentally rong sistem. G.B. Shaw left his entire estate to
  9531. bankroll a reform of English spelling, but it didn't help. The toll in
  9532. human deprivation is quite substantial. Of course, we'd have to find
  9533. something for the teachers to do if the representation of English
  9534. could be learned in five easy lessons... I suspect that the ancient
  9535. Akkadian scribes who had to master an incredibly complicated writing
  9536. system liked it that way, because it made them indispensible. Their
  9537. monopoly was smashed by the inventors of the alphabet, but we have
  9538. managed to reestablish the old, turf-bound order to a certain degree.
  9539. Computers bring us head to head with all the inconsistencies that we
  9540. cope with daily. Instead of fitting their simple logic, we massage or
  9541. bludgeon them into accepting our outworn habits.
  9542. Now on the pedagogical issue. My definition of "word" is then
  9543. simplistic, if indeed we could ever agree on what a word is. I define
  9544. it as a string of alphabetic characters, or something marked off by
  9545. markers such as space and period. If you consider the following
  9546. sentence which is a bit Elizabethan but nonetheless valid
  9547.     'Tis the boys'.
  9548. (= modern English, "It belongs to the boys") you will see the
  9549. difficult of teaching the machine that this is not a pair of single
  9550. quotes but two apostrophes. I do hint on page forty that the
  9551. apostrophe is troublesome, but deem it better to let the reader find
  9552. his or her own problems that belong in the realm of the way we
  9553. represent things in general rather than in Icon or the hardware. Let
  9554. me give another example. On p. 36 there is a little program which
  9555. simply puts on the screen the entire ascii character set. It had
  9556. worked fine when I originally tried it with version 5 of Icon, but
  9557. when I tried it on version 7 it failed. Control-Z would not allow
  9558. itself to be written to the screen. Since I could not solve this
  9559. problem, I applied to Ralph who ascertained that the problem is a
  9560. feature (or bug, depending how you look at it) of one of the C
  9561. compilers, and this had been differently implemented in v5. I opted to
  9562. include in the program an instruction to omit Control-Z if the program
  9563. failed, but did not explain the details to the reader. I figured that
  9564. a student at that point would really not want to be bothered by the
  9565. vagaries of C compilers and would probably prefer to remain in
  9566. blissful ignorance (as, in general, I do myself on such matters.) This
  9567. is the kind of paternalistic decision which teachers (like parents)
  9568. are continually called upon to make. Reference manuals should be
  9569. exhaustive, and exhaustiveness should have priority over clarity if a
  9570. choice has to be made. But books meant to teach have to be clear, and
  9571. this means leaving a great deal out. When I started to learn Hebrew, I
  9572. used a grammar (by the Scotsman Davidson) which started with a vast
  9573. amount of theoretical knowledge of Hebrew's complex vocalization
  9574. system. It was a chicken and egg situation; you needed the theory to
  9575. understand the rest of the book, but you couldn't understand the
  9576. theory until you had read the rest of the book. That may be the real
  9577. reason that I have small classes, so maybe I shouldn't complain.
  9578. Seriously though, it is difficult to determine how much detail a
  9579. student can handle---and one can't write a book to fit the needs of
  9580. every individual. As the judge said in the Ulysses case, you just have
  9581. to consider the reader whose degree of sensuality is average. Read
  9582. sense for sensuality in this case.
  9583. What is all of this doing in an Icon discussion? It is relevant I
  9584. believe. The development of algorithmic thinking is a valuable asset
  9585. which has a distinct humanistic value. Not to say that there is no
  9586. room for sentiment, opinion, taste. But one has to know the
  9587. difference, and the great thing about programming is that ideas can be
  9588. tested by a reliable arbiter. As a child I was told that learning
  9589. Latin would help me "think logically", and for seven long years I had
  9590. Caesar, Virgil and Lucretius shoved down my throat. I disagreed with
  9591. my teachers, although I rarely expressed it because it could result in
  9592. a sore bottom. The logic of Latin grammar seemed to me a myth to which
  9593. I was forced to give lip service. (I was delighted when I found later
  9594. that the Classical Arabic verb "to be" takes an accusative---which my
  9595. Latin teachers declared to be a sin against logic.) Computer languages
  9596. really are logical, and I believe they really do make a difference in
  9597. the way one approaches day to day problems. So programming has a
  9598. humanistic value in its own right. And from this point of view, I
  9599. believe that Icon is the best language to study. It gets across the
  9600. fundamental point of algorithmic thinking without burdening one with
  9601. endless struggles with data types, significant though they may be. It
  9602. gives fair treatment to text and to math. It doesn't pretend to be
  9603. "English-like" on the one hand, or use impenetrable abbreviations on
  9604. the other. And if I never write a compiler in it, I won't be heart
  9605. broken.
  9606. --
  9607. Alan D. Corre
  9608. Department of Hebrew Studies
  9609. University of Wisconsin-Milwaukee                     (414) 229-4245
  9610. PO Box 413, Milwaukee, WI 53201               corre@csd4.csd.uwm.edu
  9611.  
  9612. From icon-group-request@arizona.edu  Tue Apr 24 14:52:48 1990
  9613. Resent-From: icon-group-request@arizona.edu
  9614. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  9615.     id AA00443; Tue, 24 Apr 90 14:52:48 MST
  9616. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 24 Apr 90 14:52 MST
  9617. Received: by ucbvax.Berkeley.EDU (5.62/1.41) id AA07280; Tue, 24 Apr 90
  9618.  14:47:34 -0700
  9619. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9620.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9621.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9622. Resent-Date: Tue, 24 Apr 90 14:53 MST
  9623. Date: 20 Apr 90 06:26:42 GMT
  9624. From: helios.ee.lbl.gov!hellgate.utah.edu!uplherc!wicat!sarek!gsarff@ucsd.EDU
  9625. Subject: How to obtain IDOL?
  9626. Sender: icon-group-request@arizona.edu
  9627. Resent-To: icon-group@cs.arizona.edu
  9628. To: icon-group@arizona.edu
  9629. Resent-Message-Id: <A504D7ECDE5FA05A46@Arizona.EDU>
  9630. Message-Id: <00464@sarek.UUCP>
  9631. Organization: Programmers in Exile
  9632. X-Envelope-To: icon-group@CS.Arizona.EDU
  9633. X-Vms-To: icon-group@Arizona.edu
  9634. Status: O
  9635.  
  9636. As in the subject line, how can I obtain a copy of IDOL?  Preferably non-ftp
  9637. since I don't have access myself.  Does the Icon project have a mail server
  9638. or would anyone there be able to mail it, or possibly better, is it online on
  9639. any other system that does have a mail-archive-server?  
  9640.  
  9641. Thanks.
  9642.  
  9643. From cjeffery  Tue Apr 24 15:15:33 1990
  9644. Resent-From: "Clinton Jeffery" <cjeffery>
  9645. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  9646.     id AA02404; Tue, 24 Apr 90 15:15:33 MST
  9647. Received: from megaron.cs.arizona.edu by Arizona.EDU; Tue, 24 Apr 90 15:14 MST
  9648. Received: from caslon.cs.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15)
  9649.  via SMTP id AA02162; Tue, 24 Apr 90 15:13:01 MST
  9650. Received: by caslon; Tue, 24 Apr 90 15:13:01 mst
  9651. Resent-Date: Tue, 24 Apr 90 15:17 MST
  9652. Date: Tue, 24 Apr 90 15:13:01 mst
  9653. From: Clinton Jeffery <cjeffery@cs.arizona.edu>
  9654. Subject: How to obtain IDOL?
  9655. Resent-To: icon-group@cs.arizona.edu
  9656. To: helios.ee.lbl.gov!hellgate.utah.edu!uplherc!wicat!sarek!gsarff@ucsd.EDU
  9657. Cc: icon-group@arizona.edu
  9658. Resent-Message-Id: <A5019BB4F15FA05D2C@Arizona.EDU>
  9659. Message-Id: <9004242213.AA14596@caslon>
  9660. In-Reply-To: 
  9661.  helios.ee.lbl.gov!hellgate.utah.edu!uplherc!wicat!sarek!gsarff@ucsd.EDU's
  9662.  message of 20 Apr 90 06:26:42 GMT <00464@sarek.UUCP>
  9663. X-Envelope-To: icon-group@CS.Arizona.EDU
  9664. X-Vms-To: 
  9665.  helios.ee.lbl.gov!hellgate.utah.edu!uplherc!wicat!sarek!gsarff@ucsd.EDU
  9666. X-Vms-Cc: icon-group@Arizona.edu
  9667. Status: O
  9668.  
  9669. You asked if Idol is available electronically to people without ftp access.
  9670. cs.arizona.edu does not have a mail server that I know of.
  9671.  
  9672. I have automated the process of e-mailing out copies of Idol in the
  9673. form of UNIX shell-archive files for people who can send me a working
  9674. e-mail address.  I guess that makes me a mail server.
  9675.  
  9676. Idol is also distributed with various systems' Version 8 of the
  9677. Icon Program Library, which can be ordered from the Icon Project.
  9678. --
  9679. | Clint Jeffery, U. of Arizona Dept. of Computer Science
  9680. | cjeffery@cs.arizona.edu -or- {noao allegra}!arizona!cjeffery
  9681. --
  9682.  
  9683. From icon-group-request@arizona.edu  Wed Apr 25 11:37:48 1990
  9684. Resent-From: icon-group-request@arizona.edu
  9685. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  9686.     id AA16446; Wed, 25 Apr 90 11:37:48 MST
  9687. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 25 Apr 90 11:38 MST
  9688. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA17908; Wed, 25 Apr 90
  9689.  11:30:47 -0700
  9690. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  9691.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  9692.  usenet@ucbvax.Berkeley.EDU if you have questions)
  9693. Resent-Date: Wed, 25 Apr 90 11:39 MST
  9694. Date: 25 Apr 90 18:30:08 GMT
  9695. From: usc!cs.utexas.edu!jnino@ucsd.EDU
  9696. Subject: what is IDOL
  9697. Sender: icon-group-request@arizona.edu
  9698. Resent-To: icon-group@cs.arizona.edu
  9699. To: icon-group@arizona.edu
  9700. Resent-Message-Id: <A456DFF45F5FA064DA@Arizona.EDU>
  9701. Message-Id: <1254@gorath.cs.utexas.edu>
  9702. Organization: U. Texas CS Dept., Austin, Texas
  9703. X-Envelope-To: icon-group@CS.Arizona.EDU
  9704. X-Vms-To: icon-group@Arizona.edu
  9705. Status: O
  9706.  
  9707. I have very recently become interested in Icon, and I'm new to this news
  9708. group. I read a message of someone inquiring about IDOL. Could anybody 
  9709. drop me a hint as to what that is...just wondering.
  9710.  
  9711. Thank you.
  9712.  
  9713. Jaime
  9714.  
  9715. From goer@sophist.uchicago.EDU  Wed Apr 25 12:24:02 1990
  9716. Resent-From: goer@sophist.uchicago.EDU
  9717. Received: from maggie.telcom.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  9718.     id AA21179; Wed, 25 Apr 90 12:24:02 MST
  9719. Return-Path: goer@sophist.uchicago.EDU
  9720. Received: from tank.uchicago.edu by Arizona.EDU; Wed, 25 Apr 90 12:25 MST
  9721. Received: from sophist.uchicago.edu by tank.uchicago.edu Wed, 25 Apr 90
  9722.  14:23:09 CDT
  9723. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA02170; Wed, 25 Apr 90
  9724.  14:18:59 CDT
  9725. Resent-Date: Wed, 25 Apr 90 12:25 MST
  9726. Date: Wed, 25 Apr 90 14:18:59 CDT
  9727. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  9728. Subject: great set of wildcards - improved
  9729. Resent-To: icon-group@cs.arizona.edu
  9730. To: icon-group@arizona.edu
  9731. Resent-Message-Id: <A4506B3E31FFA06363@Arizona.EDU>
  9732. Message-Id: <9004251918.AA02170@sophist.uchicago.edu>
  9733. X-Envelope-To: icon-group@CS.Arizona.EDU
  9734. X-Vms-To: icon-group@Arizona.edu
  9735. Status: O
  9736.  
  9737. (It has come to my attention that many reading this newsgroup do not know
  9738. about egrep.  In nontechnical terms, egrep is a great little pattern-
  9739. finding program that uses a powerful wildcard system.  These wildcards
  9740. are far, far superior to, anything you might find in a wordprocessor, or
  9741. say, in MS-DOS's ? and * [these symbols are used, but they mean something
  9742. different to egrep].  Icon's pattern-matching facilities are, in fact,
  9743. much more powerful than egrep's.  However, you can't generally access
  9744. them at run-time as elegantly as with, say, Snobol4.  I.e. you can't
  9745. easily tell Icon what to scan for while the program is running.  Unless
  9746. you want to write a compiler yourself, use a lot of coexpressions, or
  9747. use a variant translator like the one Ken Walker constructed, you will
  9748. be up a creek - UNLESS you have find_re() [which essentially is a lit-
  9749. tle compiler].  I hope this helps everyone understand the following
  9750. posting.)
  9751.  
  9752. Okay, okay, I've been chided by several people now privately about not
  9753. just biting the bullet and making find_re fully egrep-compatible.  Here's
  9754. a new version WITH a wrapper (courtesy of Jerry Nowlin).  It fails only
  9755. one of the tests included with the gnu egrep distribution, and this be-
  9756. cause of differences in escaping conventions that I don't think would be
  9757. wise to change.
  9758.  
  9759. In essence, find_re() is now compatible both with find() (as to its syn-
  9760. tax), and with egrep (as to its input language and exit codes).  I hope
  9761. that it will provide people with distinctly Iconish access to the ori-
  9762. ginally non-Iconish egrep-style pattern-matching language.
  9763.  
  9764. Note that the program posted here runs from two to twenty-five times as
  9765. fast as the previous version.  Jerry Nowlin reminded that he had earlier
  9766. posted a grep-like utility.  I found it in my archives, ran it, found it
  9767. to be MUCH faster than my command.  Though JN's grep did not implement
  9768. things like () and |, find_re hardly seemed worth its added functionality
  9769. if it was so slow.  I used some of the ideas in JN's grep, added a few
  9770. easy optimizations, ran it through all the tests again, and presto!
  9771.  
  9772. Please tell me if any bugs are found.  Note that the syntax is like that
  9773. of *e*grep - not grep.  Note also that I am not in any way directly con-
  9774. nected with computer science as a field.  I've never read the egrep
  9775. source code, and I've never written a compiler.  This is just a utility
  9776. I wrote because I myself needed it.  It would *certainly* be possible to
  9777. write it faster.  I invite (in fact, let me challenge) the real computer
  9778. science people around here to do it *right* (= faster, better).  No
  9779. cheating, either (i.e. adding C calls to the Icon source, as one can do
  9780. with version 8).  It's gotta have full egrep functionality as well, and
  9781. pass all the main tests one might subject an egrepi-like command to!
  9782.  
  9783. --------------------------------RGegrep.icn----------------------------------
  9784. # wrapper by Jerry Nowlin
  9785.  
  9786. procedure main(a)
  9787.  
  9788.     # the usage message
  9789.     usage := "Usage: RGegrep pattern [ file ... ]"
  9790.  
  9791.     # the first program argument must be the pattern
  9792.     # Perhaps:  *a = 0 & stop("more args!"); while pattern := get(a) do {
  9793.     pattern := get(a) | stop("I at least need a pattern\n",usage)
  9794.  
  9795.     # trick the program into using standard input if no files were passed
  9796.     if *a = 0 then a := [&null]
  9797.  
  9798.     # the rest of the arguments are files to search through
  9799.     every f := !a do {
  9800.  
  9801.         # if the file isn't null try to open it
  9802.         if \f then in := open(f) | stop("I can't open '",f,"'")
  9803.  
  9804.         # otherwise use standard input
  9805.         else in := &input
  9806.  
  9807.         # if there is only one file skip printing the file name
  9808.         if *a = 1 then f := ""
  9809.  
  9810.         # otherwise tack on a colon
  9811.         else f ||:= ":"
  9812.  
  9813.         # read all the lines
  9814.         every l := !in do {
  9815.  
  9816.             # scan the line for the pattern
  9817.             l ? {
  9818.  
  9819. ##### BELOW IS THE CALL TO the find_re() procedure listed below #####
  9820.  
  9821.                 # if the pattern is found print the line
  9822.                 if find_re(pattern)
  9823.                                 then exit_status := 0 & write(f,l)
  9824.             }
  9825.         }
  9826.  
  9827.         # close the input file is one was opened
  9828.         if in ~=== &input then close(in)
  9829.     }
  9830.    
  9831.     # If set in a while loop, put another brace around the above -
  9832.     #   }
  9833.  
  9834.     exit(\exit_status | 1)
  9835.  
  9836. end
  9837.  
  9838. ########################################################################
  9839. #    
  9840. #    Name:    find_re.icn
  9841. #    
  9842. #    Title:    "Find" Regular Expression
  9843. #    
  9844. #    Author:    Richard L. Goerwitz
  9845. #
  9846. #    Date:    April 25, 1990 (version 0.9)
  9847. #
  9848. ########################################################################
  9849. #    
  9850. #    DESCRIPTION:  Find_re is similar to the Icon builtin function
  9851. #    find(), except that it takes as its first argument a regular
  9852. #    expression of the sort used by the Unix egrep command.  For those
  9853. #    unfamiliar with the notion of regular expressions, they represent
  9854. #    a simple string representation of a finite state transition
  9855. #    network which can be converted into an automaton capable of
  9856. #    recognizing patterns in strings of characters.  The specific
  9857. #    symbols used, and the purposes they are used for, can be gleaned
  9858. #    from the Unix man pages for egrep and the regex library
  9859. #    functions.  In nontechnical terms, regular expressions are a
  9860. #    great set of wildcards.
  9861. #
  9862. #    DIFFERENCES between find and find_re:  Find_re is backwards com-
  9863. #    patible with find().  Aside from permitting regular expressions,
  9864. #    the only difference between find_re() and find() is that find_re
  9865. #    sets the global variable __endpoint to the first position after
  9866. #    any given match occurs.  Use this variable with great care, pre-
  9867. #    ferably assigning its value to some other variable immediately
  9868. #    after the match (e.g. find_re("hello[. ?!]*",s) & tmp := __end-
  9869. #    point).  Otherwise, you will certainly run into trouble!
  9870. #
  9871. #    DIFFERENCES between egrep and find_re:  Find_re utilizes the same
  9872. #    basic language as egrep.  The only big diff. is that find_re uses
  9873. #    intrinsic Icon data structures and escaping conventions rather
  9874. #    than those of any particular Unix variant.  Be careful!  If you
  9875. #    put find_re('\(hello\)',s) into your source file, find_re will
  9876. #    treat it just like find_re('(hello)',s).  If, however, you enter
  9877. #    '\(hello\)' at run-time (due to find_re(!&input,s)), what Icon
  9878. #    receives will depend on your operating system (most likely, a
  9879. #    trace will show "\\(hello\\)").
  9880. #
  9881. #    BUGS:  Little attempt has been made to optimize find_re.  For work
  9882. #    that requires a quick response, you'll have to use something like
  9883. #    system("egrep...")!
  9884. #    
  9885. ########################################################################
  9886.  
  9887.  
  9888. global state_table, biggest_nonmeta_str, __endpoint
  9889. record o_a_s(op,arg,state)
  9890.  
  9891. procedure find_re(re, s, i, j)
  9892.  
  9893.     static FSTN_table, STRING_table
  9894.     initial {
  9895.     FSTN_table := table()
  9896.     STRING_table := table()
  9897.     }
  9898.  
  9899.     /re & stop("find_re:  Call me with at least one argument!")
  9900.  
  9901.     /i := \&pos | 1
  9902.     /s := \&subject | stop("find_re:  No string.")
  9903.     /j := *s+1
  9904.     if /FSTN_table[re] then {
  9905.     if \STRING_table[re] then {
  9906.         every p := find(STRING_table[re],s,i,j)
  9907.         do { __endpoint := p + *re; suspend p }
  9908.         fail
  9909.     }
  9910.     else {
  9911.         tokenized_re := tokenize(re)
  9912.         if 0 > !tokenized_re then {
  9913.         MakeFSTN(tokenized_re) | er(re,2)
  9914.         /FSTN_table[re] := copy(state_table)
  9915.         }
  9916.         else {
  9917.         tmp := ""; every tmp ||:= char(!tokenized_re)
  9918.         insert(STRING_table,re,tmp)
  9919.         every p := find(STRING_table[re],s,i,j)
  9920.         do { __endpoint := p + *re; suspend p }
  9921.         fail
  9922.         }
  9923.     }
  9924.     }
  9925.  
  9926.  
  9927.     s ? {
  9928.     tab(x := i to j) &
  9929.     (find(biggest_nonmeta_str) | fail) \ 1 &
  9930.     apply_FSTN(&null,FSTN_table[re]) &
  9931.     (__endpoint := .&pos - 1, suspend x)
  9932.     }
  9933.  
  9934. end
  9935.  
  9936.  
  9937.  
  9938. procedure apply_FSTN(ini,tbl)
  9939.  
  9940.     static s_tbl
  9941.     local POS, tmp, fin
  9942.  
  9943.     /ini := 1 & s_tbl := tbl
  9944.     if ini = 0 then {
  9945.     return .&pos
  9946.     }
  9947.     POS := &pos
  9948.     fin := 0
  9949.  
  9950.     if tmp := !s_tbl[ini] &
  9951.        tab(tmp.op(tmp.arg))
  9952.     then {
  9953.     if tmp.state = fin
  9954.     then return .&pos
  9955.     else {
  9956.         return apply_FSTN(tmp.state) |
  9957.            (&pos := POS, fail)
  9958.     }
  9959.     }
  9960.     else &pos := POS
  9961.  
  9962. end
  9963.     
  9964.  
  9965.  
  9966. procedure tokenize(s)
  9967.  
  9968.     local chr, tmp
  9969.  
  9970.     token_list := list()
  9971.     s ? {
  9972.     tab(many('*+?|'))
  9973.     while chr := move(1) do {
  9974.         if chr == "\\"
  9975.         # it can't be a metacharacter; remove the \ and "put"
  9976.         # the integer value of the next chr into token_list
  9977.         then put(token_list,ord(move(1))) | er(s,2,chr)
  9978.         else if any('*+()|?.$^',chr)
  9979.         then {
  9980.         # Yuck!  Egrep compatibility stuff.
  9981.         case chr of {
  9982.             "*"    : {
  9983.             tab(many('*+?'))
  9984.             put(token_list,-ord("*"))
  9985.             }
  9986.             "+"    : {
  9987.             tmp := tab(many('*?+')) | &null
  9988.             if upto('*?',\tmp)
  9989.             then put(token_list,-ord("*"))
  9990.             else put(token_list,-ord("+"))
  9991.             }
  9992.             "?"    : {
  9993.             tmp := tab(many('*?+')) | &null
  9994.             if upto('*+',\tmp)
  9995.             then put(token_list,-ord("*"))
  9996.             else put(token_list,-ord("?"))
  9997.             }
  9998.             "("    : {
  9999.             tab(many('*+?'))
  10000.             put(token_list,-ord("("))
  10001.             }
  10002.             default: put(token_list,-ord(chr))
  10003.         }
  10004.         }
  10005.         else {
  10006.         case chr of {
  10007.             # More egrep compatibility stuff.
  10008.             "["    : {
  10009.             every next_one := find("]")
  10010.             \next_one ~= &pos | er(s,2,chr)
  10011.             put(token_list,-ord(chr))
  10012.             }
  10013.                     "]"    : {
  10014.             if &pos = (\next_one+1)
  10015.             then put(token_list,-ord(chr)) &
  10016.                  next_one := &null
  10017.             else put(token_list,ord(chr))
  10018.             }
  10019.             default: put(token_list,ord(chr))
  10020.         }
  10021.         }
  10022.     }
  10023.     }
  10024.  
  10025.     token_list := UnMetaBrackets(token_list)
  10026.  
  10027.     fixed_length_token_list := list(*token_list)
  10028.     every i := 1 to *token_list
  10029.     do fixed_length_token_list[i] := token_list[i]
  10030.     return fixed_length_token_list
  10031.  
  10032. end
  10033.  
  10034.  
  10035.  
  10036. procedure UnMetaBrackets(l)
  10037.  
  10038.     # Since brackets delineate a cset, it doesn't make
  10039.     # any sense to have metacharacters inside of them.
  10040.     # UnMetaBrackets makes sure there are no metacharac-
  10041.     # ters inside of the braces.
  10042.  
  10043.     local tmplst, i, Lb, Rb
  10044.  
  10045.     tmplst := list(); i := 0
  10046.     Lb := -ord("[")
  10047.     Rb := -ord("]")
  10048.  
  10049.     while (i +:= 1) <= *l do {
  10050.     if l[i] = Lb then {
  10051.         put(tmplst,l[i])
  10052.         until l[i +:= 1] = Rb
  10053.         do put(tmplst,abs(l[i]))
  10054.         put(tmplst,l[i])
  10055.     }
  10056.     else put(tmplst,l[i])
  10057.     }
  10058.     return tmplst
  10059.  
  10060. end
  10061.  
  10062.  
  10063.  
  10064. procedure MakeFSTN(l,INI,FIN)
  10065.  
  10066.     # MakeFSTN recursively descends through the tree structure
  10067.     # implied by the tokenized string, l, recording in (global)
  10068.     # fstn_table a list of operations to be performed, and the
  10069.     # initial and final states which apply to them.
  10070.  
  10071.     static Lp, Rp, Sl, Lb, Rb, Caret_inside, Dot, Dollar, Caret_outside
  10072.     local i, inter, inter2, tmp
  10073.     initial {
  10074.     Lp := -ord("("); Rp := -ord(")")
  10075.     Sl := -ord("|")
  10076.     Lb := -ord("["); Rb := -ord("]"); Caret_inside := ord("^")
  10077.     Dot := -ord("."); Dollar := -ord("$"); Caret_outside := -ord("^")
  10078.     biggest_nonmeta_str := ""
  10079.     }
  10080.  
  10081.     /INI := 1 & state_table := table() & NextState("new")
  10082.     /FIN := 0
  10083.  
  10084.     # I haven't bothered to test for empty lists everywhere.
  10085.     if *l = 0 then {
  10086.     /state_table[INI] := []
  10087.     put(state_table[INI],o_a_s(zSucceed,&null,FIN))
  10088.     return
  10089.     }
  10090.  
  10091.     # HUNT DOWN THE SLASH (ALTERNATION OPERATOR)
  10092.     every i := 1 to *l do {
  10093.     if l[i] = Sl & tab_bal(l,Lp,Rp) = i then {
  10094.         if i = 1 then er(l,2,char(abs(l[i]))) else {
  10095.         inter := NextState()
  10096.         inter2:= NextState()
  10097.         MakeFSTN(l[1:i],inter2,FIN)
  10098.         MakeFSTN(l[i+1:0],inter,FIN)
  10099.         /state_table[INI] := []
  10100.         put(state_table[INI],o_a_s(apply_FSTN,inter2,0))
  10101.         put(state_table[INI],o_a_s(apply_FSTN,inter,0))
  10102.         return
  10103.         }
  10104.     }
  10105.     }
  10106.  
  10107.     # HUNT DOWN PARENTHESES
  10108.     if l[1] = Lp then {
  10109.     i := tab_bal(l,Lp,Rp) | er(l,2,"(")
  10110.     inter := NextState()
  10111.     if any('*+?',char(abs(0 > l[i+1]))) then {
  10112.         case l[i+1] of {
  10113.         -ord("*")   : {
  10114.             /state_table[INI] := []
  10115.             put(state_table[INI],o_a_s(apply_FSTN,inter,0))
  10116.             MakeFSTN(l[2:i],INI,INI)
  10117.             MakeFSTN(l[i+2:0],inter,FIN)
  10118.             return
  10119.         }
  10120.         -ord("+")   : {
  10121.             inter2 := NextState()
  10122.             /state_table[inter2] := []
  10123.             MakeFSTN(l[2:i],INI,inter2)
  10124.             put(state_table[inter2],o_a_s(apply_FSTN,inter,0))
  10125.             MakeFSTN(l[2:i],inter2,inter2)
  10126.             MakeFSTN(l[i+2:0],inter,FIN)
  10127.             return
  10128.         }
  10129.         -ord("?")   : {
  10130.             /state_table[INI] := []
  10131.             put(state_table[INI],o_a_s(apply_FSTN,inter,0))
  10132.             MakeFSTN(l[2:i],INI,inter)
  10133.             MakeFSTN(l[i+2:0],inter,FIN)
  10134.             return
  10135.         }
  10136.         }
  10137.     }
  10138.     else {
  10139.         MakeFSTN(l[2:i],INI,inter)
  10140.         MakeFSTN(l[i+1:0],inter,FIN)
  10141.         return
  10142.     }
  10143.     }
  10144.     else {     # I.E. l[1] NOT = Lp (left parenthesis as -ord("("))
  10145.     every i := 1 to *l do {
  10146.         case l[i] of {
  10147.         Lp     : {
  10148.             inter := NextState()
  10149.             MakeFSTN(l[1:i],INI,inter)
  10150.             MakeFSTN(l[i:0],inter,FIN)
  10151.             return
  10152.         }
  10153.         Rp     : er(l,2,")")
  10154.         }
  10155.     }
  10156.     }
  10157.  
  10158.     # NOW, HUNT DOWN BRACKETS
  10159.     if l[1] = Lb then {
  10160.     i := tab_bal(l,Lb,Rb) | er(l,2,"[")
  10161.     inter := NextState()
  10162.     tmp := ""; every tmp ||:= char(l[2 to i-1])
  10163.     if Caret_inside = l[2]
  10164.     then tmp := ~cset(Expand(tmp[2:0]))
  10165.     else tmp :=  cset(Expand(tmp))
  10166.     if any('*+?',char(abs(0 > l[i+1]))) then {
  10167.         case l[i+1] of {
  10168.         -ord("*")   : {
  10169.             /state_table[INI] := []
  10170.             put(state_table[INI],o_a_s(apply_FSTN,inter,0))
  10171.             put(state_table[INI],o_a_s(any,tmp,INI))
  10172.             MakeFSTN(l[i+2:0],inter,FIN)
  10173.             return
  10174.         }
  10175.         -ord("+")   : {
  10176.             inter2 := NextState()
  10177.             /state_table[INI] := []
  10178.             put(state_table[INI],o_a_s(any,tmp,inter2))
  10179.             /state_table[inter2] := []
  10180.             put(state_table[inter2],o_a_s(apply_FSTN,inter,0))
  10181.             put(state_table[inter2],o_a_s(any,tmp,inter2))
  10182.             MakeFSTN(l[i+2:0],inter,FIN)
  10183.             return
  10184.         }
  10185.         -ord("?")   : {
  10186.             /state_table[INI] := []
  10187.             put(state_table[INI],o_a_s(apply_FSTN,inter,0))
  10188.             put(state_table[INI],o_a_s(any,tmp,inter))
  10189.             MakeFSTN(l[i+2:0],inter,FIN)
  10190.             return
  10191.         }
  10192.         }
  10193.     }
  10194.     else {
  10195.         /state_table[INI] := []
  10196.         put(state_table[INI],o_a_s(any,tmp,inter))
  10197.         MakeFSTN(l[i+1:0],inter,FIN)
  10198.         return
  10199.     }
  10200.     }
  10201.     else {           # I.E. l[1] not = Lb
  10202.     every i := 1 to *l do {
  10203.         case l[i] of {
  10204.         Lb     : {
  10205.             inter := NextState()
  10206.             MakeFSTN(l[1:i],INI,inter)
  10207.             MakeFSTN(l[i:0],inter,FIN)
  10208.             return
  10209.         }
  10210.         Rb     : er(l,2,"]")
  10211.         }
  10212.     }
  10213.     }
  10214.  
  10215.     # FIND INITIAL SEQUENCES OF POSITIVE INTEGERS, CONCATENATE THEM
  10216.     if i := match_positive_ints(l) then {
  10217.     inter := NextState()
  10218.     tmp := Ints2String(l[1:i])
  10219.     if *tmp > *biggest_nonmeta_str
  10220.     then biggest_nonmeta_str := tmp
  10221.     /state_table[INI] := []
  10222.     put(state_table[INI],o_a_s(match,tmp,inter))
  10223.     MakeFSTN(l[i:0],inter,FIN)
  10224.     return
  10225.     }
  10226.  
  10227.     # OKAY, CLEAN UP ALL THE JUNK THAT'S LEFT
  10228.     i := 0
  10229.     while (i +:= 1) <= *l do {
  10230.     case l[i] of {
  10231.         Dot          : { Op := any;   Arg := &cset }
  10232.         Dollar       : { Op := pos;   Arg := 0     }
  10233.         Caret_outside: { Op := pos;   Arg := 1     }
  10234.         default      : { Op := match; Arg := char(0 < l[i]) }
  10235.     } | er(l,2,char(abs(l[i])))
  10236.     inter := NextState()
  10237.     if any('*+?',char(abs(0 > l[i+1]))) then {
  10238.         case l[i+1] of {
  10239.         -ord("*")   : {
  10240.             /state_table[INI] := []
  10241.             put(state_table[INI],o_a_s(apply_FSTN,inter,0))
  10242.             put(state_table[INI],o_a_s(Op,Arg,INI))
  10243.             MakeFSTN(l[i+2:0],inter,FIN)
  10244.             return
  10245.         }
  10246.         -ord("+")   : {
  10247.             inter2 := NextState()
  10248.             /state_table[INI] := []
  10249.             put(state_table[INI],o_a_s(Op,Arg,inter2))
  10250.             /state_table[inter2] := []
  10251.             put(state_table[inter2],o_a_s(apply_FSTN,inter,0))
  10252.             put(state_table[inter2],o_a_s(Op,Arg,inter2))
  10253.             MakeFSTN(l[i+2:0],inter,FIN)
  10254.             return
  10255.         }
  10256.         -ord("?")   : {
  10257.             /state_table[INI] := []
  10258.             put(state_table[INI],o_a_s(apply_FSTN,inter,0))
  10259.             put(state_table[INI],o_a_s(Op,Arg,inter))
  10260.             MakeFSTN(l[i+2:0],inter,FIN)
  10261.             return
  10262.         }
  10263.         }
  10264.     }
  10265.     else {
  10266.         /state_table[INI] := []
  10267.         put(state_table[INI],o_a_s(Op,Arg,inter))
  10268.         MakeFSTN(l[i+1:0],inter,FIN)
  10269.         return
  10270.     }
  10271.     }
  10272.  
  10273.     # WE SHOULD NOW BE DONE INSERTING EVERYTHING INTO state_table
  10274.     # IF WE GET TO HERE, WE'VE PARSED INCORRECTLY!
  10275.     er(l,4)
  10276.  
  10277. end
  10278.  
  10279.  
  10280.  
  10281. procedure NextState(new)
  10282.     static nextstate
  10283.     if \new then nextstate := 1
  10284.     else nextstate +:= 1
  10285.     return nextstate
  10286. end
  10287.  
  10288.  
  10289.  
  10290. procedure er(x,i,elem)
  10291.     writes(&errout,"Error number ",i," parsing ",image(x)," at ")
  10292.     if \elem 
  10293.     then write(&errout,image(elem),".")
  10294.     else write(&errout,"(?).")
  10295.     exit(i)
  10296. end
  10297.  
  10298.  
  10299.  
  10300. procedure zSucceed()
  10301.     return .&pos
  10302. end
  10303.  
  10304.  
  10305.  
  10306. procedure Expand(s)
  10307.  
  10308.     s2 := ""
  10309.     s ? {
  10310.     s2 ||:= ="^"
  10311.     s2 ||:= ="-"
  10312.     while s2 ||:= tab(find("-")-1) do {
  10313.         if (c1 := move(1), ="-",
  10314.         c2 := move(1),
  10315.         c1 << c2)
  10316.         then every s2 ||:= char(ord(c1) to ord(c2))
  10317.         else s2 ||:= 1(move(2), not(pos(0))) | er(s,2,"-")
  10318.     }
  10319.     s2 ||:= tab(0)
  10320.     }
  10321.     return s2
  10322.  
  10323. end
  10324.  
  10325.  
  10326.  
  10327. procedure tab_bal(l,i1,i2)
  10328.     i := 0
  10329.     i1_count := 0; i2_count := 0
  10330.     while (i +:= 1) <= *l do {
  10331.     case l[i] of {
  10332.         i1  : i1_count +:= 1
  10333.         i2  : i2_count +:= 1
  10334.     }
  10335.     if i1_count = i2_count
  10336.     then suspend i
  10337.     }
  10338. end
  10339.  
  10340.  
  10341. procedure match_positive_ints(l)
  10342.     
  10343.     # Matches the longest sequence of positive integers in l,
  10344.     # beginning at l[1], which neither contains, nor is fol-
  10345.     # lowed by a negative integer.  Returns the first position
  10346.     # after the match.  Hence, given [55, 55, 55, -42, 55],
  10347.     # match_positive_ints will return 3.  [55, -42] will cause
  10348.     # it to fail rather than return 1 (NOTE WELL!).
  10349.  
  10350.     every i := 1 to *l do {
  10351.     if l[i] < 0
  10352.     then return (3 < i) - 1
  10353.     }
  10354.  
  10355. end
  10356.  
  10357.  
  10358. procedure Ints2String(l)
  10359.     tmp := ""
  10360.     every tmp ||:= char(!l)
  10361.     return tmp
  10362. end
  10363.  
  10364.  
  10365. procedure StripChar(s,s2)
  10366.     if find(s2,s) then {
  10367.     tmp := ""
  10368.     s ? {
  10369.         while tmp ||:= tab(find("s2"))
  10370.         do tab(many(cset(s2)))
  10371.         tmp ||:= tab(0)
  10372.     }
  10373.     }
  10374.     return \tmp | s
  10375. end
  10376.  
  10377. From @RELAY.CS.NET:Adalbert.Kerber@uni-bayreuth.dbp.de  Thu Apr 26 02:46:52 1990
  10378. Received: from relay.cs.net by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10379.     id AA19701; Thu, 26 Apr 90 02:46:52 MST
  10380. Received: from relay2.cs.net by RELAY.CS.NET id aa13696; 26 Apr 90 5:46 EDT
  10381. Received: from zix.gmd.dbp.de by RELAY.CS.NET id ae06551; 26 Apr 90 5:38 EDT
  10382. Received: from zix.gmd.dbp.de by .zix.gmd.dbp.de id a001775; 26 Apr 90 8:41 MET
  10383. Date: 26 Apr 90 07:31 GMT
  10384. From: Adalbert.Kerber%uni-bayreuth.dbp.de@RELAY.CS.NET
  10385. To: ICON-GROUP@cs.arizona.edu
  10386. Message-Id: <94138062400991/13537 X400>
  10387. Status: O
  10388.  
  10389. please stop subscription for btm203@dbthrz5.bitnetplease stop subscription for btm203@dbthrz5.bitnet
  10390.  
  10391. From goer@sophist.uchicago.EDU  Fri Apr 27 08:05:57 1990
  10392. Resent-From: goer@sophist.uchicago.EDU
  10393. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10394.     id AA16824; Fri, 27 Apr 90 08:05:57 MST
  10395. Return-Path: goer@sophist.uchicago.EDU
  10396. Received: from tank.uchicago.edu by Arizona.EDU; Fri, 27 Apr 90 08:07 MST
  10397. Received: from sophist.uchicago.edu by tank.uchicago.edu Fri, 27 Apr 90
  10398.  08:44:41 CDT
  10399. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA04266; Fri, 27 Apr 90
  10400.  08:40:31 CDT
  10401. Resent-Date: Fri, 27 Apr 90 08:07 MST
  10402. Date: Fri, 27 Apr 90 08:40:31 CDT
  10403. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  10404. Subject: coexpressions, questions
  10405. Resent-To: icon-group@cs.arizona.edu
  10406. To: icon-group@arizona.edu
  10407. Resent-Message-Id: <A2E22055697FA06BB8@Arizona.EDU>
  10408. Message-Id: <9004271340.AA04266@sophist.uchicago.edu>
  10409. X-Envelope-To: icon-group@CS.Arizona.EDU
  10410. X-Vms-To: icon-group@Arizona.edu
  10411. Status: O
  10412.  
  10413. I've always wondered why coexpressions were introduced.  Was it because
  10414. people wanted coroutines?  Or did the idea of delaying evaluation prompt
  10415. its inclusion (a holdover from SNOBOL's *)?  Final question:  How is it
  10416. that the designers came to recognize that coroutines and delayed evalu-
  10417. ation (or really, controlled evaluation) could be united under the same
  10418. syntactic rubric as coroutines?
  10419.  
  10420.  
  10421.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  10422.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  10423.  
  10424. From goer@sophist.uchicago.EDU  Fri Apr 27 08:06:08 1990
  10425. Resent-From: goer@sophist.uchicago.EDU
  10426. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10427.     id AA16848; Fri, 27 Apr 90 08:06:08 MST
  10428. Return-Path: goer@sophist.uchicago.EDU
  10429. Received: from tank.uchicago.edu by Arizona.EDU; Fri, 27 Apr 90 08:06 MST
  10430. Received: from sophist.uchicago.edu by tank.uchicago.edu Fri, 27 Apr 90
  10431.  09:13:06 CDT
  10432. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA04306; Fri, 27 Apr 90
  10433.  09:08:52 CDT
  10434. Resent-Date: Fri, 27 Apr 90 08:07 MST
  10435. Date: Fri, 27 Apr 90 09:08:52 CDT
  10436. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  10437. Subject: grammars, questions
  10438. Resent-To: icon-group@cs.arizona.edu
  10439. To: icon-group@arizona.edu
  10440. Resent-Message-Id: <A2E22ABA8B7FA07336@Arizona.EDU>
  10441. Message-Id: <9004271408.AA04306@sophist.uchicago.edu>
  10442. X-Envelope-To: icon-group@CS.Arizona.EDU
  10443. X-Vms-To: icon-group@Arizona.edu
  10444. Status: O
  10445.  
  10446. My last questions were centered on coexpressions.  These ones concern
  10447. representation of various types of grammars in Icon.  They seemed to
  10448. belong in separate postings.
  10449.  
  10450. I've long wondered what sorts of grammars Icon is capable of representing,
  10451. using string scanning.  It appears that Icon has no trouble representing
  10452. context free languages, with the restriction that there can be no left-
  10453. recursion in the grammar.  For representing natural languages, this can
  10454. be a serious drawback.  Lots of natural language constructs cannot be rep-
  10455. resented without left recursion (e.g. the possessive 's construct).
  10456.  
  10457. Prolog has a thing called indexed grammars, which on the infamous "Chomsky
  10458. hierarchy" seem to fall between context free phrase structure grammars and
  10459. context sensitive phrase structure grammars.  These grammars are like con-
  10460. text free grammars except that while recognizing sequences the various nodes
  10461. are given labels which can be correlated and compared with labels for other
  10462. nodes.  The result is that you can have the NP node labeled as plural, and
  10463. the VP node as well, and tell the grammar that if the two do not match the
  10464. sentence must be regected.  As far as I can see, this could be done in Icon
  10465. simply by having matching procedures return values.  I dunno.  Has anyone
  10466. looked into this?
  10467.  
  10468. It seems to me that Icon has the distinct advantage of allowing the user to
  10469. skip the tokenizing stage in many cases.  You can just parse the string di-
  10470. rectly.  I like this.  But what do we do in cases where we must deal with
  10471. a backslash.  Most solutions I've seen are pretty ugly.  What I did in my
  10472. find_re procedure posted a few days ago was to convert input strings to lists,
  10473. and then convert metacharacters to negative integers, leaving nonmetas as
  10474. positive integers.  This worked well, since Icon has ord() and char().  Has
  10475. anyone developed an elegant solution to the \ problem using string scanning?
  10476.  
  10477. This posting has wandered a bit, so let me summarize.  I am curious, first
  10478. of all, about what sorts of grammars can easily be represented using Icon's
  10479. special string-processing facilities.  Secondly, I'm curious whether anyone
  10480. has done research into indexed grammars in Icon.  Thirdly, I'd like to know
  10481. whether there exist elegant solutions to the \ problem.
  10482.  
  10483. I hope that these questions are relevant, interesting, etc., and not just
  10484. a waste of bandwidth.
  10485.  
  10486.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  10487.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  10488.  
  10489. From ralph  Fri Apr 27 08:26:26 1990
  10490. Resent-From: "Ralph Griswold" <ralph>
  10491. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10492.     id AA19579; Fri, 27 Apr 90 08:26:26 MST
  10493. Received: from megaron.cs.Arizona.EDU by Arizona.EDU; Fri, 27 Apr 90 08:27 MST
  10494. Received: by megaron.cs.arizona.edu (5.59-1.7/15) id AA19537; Fri, 27 Apr 90
  10495.  08:25:52 MST
  10496. Resent-Date: Fri, 27 Apr 90 08:27 MST
  10497. Date: Fri, 27 Apr 90 08:25:52 MST
  10498. From: Ralph Griswold <ralph@cs.arizona.edu>
  10499. Subject: RE:  coexpressions, questions
  10500. Resent-To: icon-group@cs.arizona.edu
  10501. To: goer@sophist.uchicago.EDU, icon-group@arizona.edu
  10502. Resent-Message-Id: <A2DF439D1E3FA078DD@Arizona.EDU>
  10503. Message-Id: <9004271525.AA19537@megaron.cs.arizona.edu>
  10504. In-Reply-To: <9004271340.AA04266@sophist.uchicago.edu>
  10505. X-Envelope-To: icon-group@CS.Arizona.EDU
  10506. X-Vms-To: goer@sophist.uchicago.EDU, icon-group@Arizona.edu
  10507. Status: RO
  10508.  
  10509. The motivation for adding co-expressions to Icon was to be able to
  10510. control when and where the results of a generator are produced.
  10511.  
  10512. Without co-expressions, the results of a generator are produced in
  10513. a last-in-first-out fashion at the lexical site in program at
  10514. which the generator apprears, as demanded by the enclosing expression.
  10515. Parallel production of the results of two generators, for example,
  10516. is impossible without co-expressions.
  10517.  
  10518.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  10519.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  10520.  
  10521. From icon-group-request@arizona.edu  Fri Apr 27 10:57:05 1990
  10522. Resent-From: icon-group-request@arizona.edu
  10523. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10524.     id AA05153; Fri, 27 Apr 90 10:57:05 MST
  10525. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Fri, 27 Apr 90 10:58 MST
  10526. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA15563; Thu, 26 Apr 90
  10527.  12:41:59 -0700
  10528. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  10529.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  10530.  usenet@ucbvax.Berkeley.EDU if you have questions)
  10531. Resent-Date: Fri, 27 Apr 90 10:58 MST
  10532. Date: 26 Apr 90 18:50:05 GMT
  10533. From: nic!hri!sparc9!rolandi@bbn.COM
  10534. Subject: ftp new sparc station icon sources
  10535. Sender: icon-group-request@arizona.edu
  10536. Resent-To: icon-group@cs.arizona.edu
  10537. To: icon-group@arizona.edu
  10538. Resent-Message-Id: <A2CA3D27445FA07E57@Arizona.EDU>
  10539. Message-Id: <1990Apr26.185005.19973@hri.com>
  10540. Organization: Horizon Research
  10541. X-Envelope-To: icon-group@CS.Arizona.EDU
  10542. X-Vms-To: icon-group@Arizona.edu
  10543. Status: RO
  10544.  
  10545. What does one need to do in order to obtain the new SPARC 
  10546. station Icon source code?  
  10547.  
  10548.  
  10549.  
  10550.               ***************************************
  10551.               *          Walter G. Rolandi          *
  10552.               *        Horizon Research, Inc.       *
  10553.               *           1432 Main Street          *
  10554.               *       Waltham, MA  02154  USA       *
  10555.               *            (617) 466 8339           *
  10556.               *                                     *
  10557.               *           rolandi@hri.com           *
  10558.               ***************************************
  10559.  
  10560. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Fri Apr 27 11:07:25 1990
  10561. Received: from umich.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10562.     id AA06381; Fri, 27 Apr 90 11:07:25 MST
  10563. Received: from ummts.cc.umich.edu by umich.edu (5.61/1123-1.0)
  10564.     id AA05405; Fri, 27 Apr 90 14:07:15 -0400
  10565. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Fri, 27 Apr 90 14:06:43 EDT
  10566. Date: Fri, 27 Apr 90 12:59:36 EDT
  10567. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  10568. To: icon-group@cs.arizona.edu
  10569. Message-Id: <221535@Wayne-MTS>
  10570. Subject: Why co-expressions?
  10571. Status: RO
  10572.  
  10573. Ralph's explanation of the motivation for co-expressions is right on.
  10574. But Ralph--why do they have to be symmetric?  An asymmetric version,
  10575. which is what I have in SPLASH, is conceptually simpler (rather like
  10576. Unix piping, but with branching) and seems to provide all the functionality
  10577. I've ever needed.
  10578.  
  10579. Paul Abrahams
  10580. abrahams%wayne-mts@um.cc.umich.edu
  10581.  
  10582. From ralph  Fri Apr 27 11:14:42 1990
  10583. Date: Fri, 27 Apr 90 11:14:42 MST
  10584. From: "Ralph Griswold" <ralph>
  10585. Message-Id: <9004271814.AA06892@megaron.cs.arizona.edu>
  10586. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  10587.     id AA06892; Fri, 27 Apr 90 11:14:42 MST
  10588. To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  10589. Subject: Re:  Why co-expressions?
  10590. Cc: icon-group
  10591. In-Reply-To: <221535@Wayne-MTS>
  10592. Status: O
  10593.  
  10594.    Ralph's explanation of the motivation for co-expressions is right on.
  10595.    But Ralph--why do they have to be symmetric?  An asymmetric version,
  10596.    which is what I have in SPLASH, is conceptually simpler (rather like
  10597.    Unix piping, but with branching) and seems to provide all the functionality
  10598.    I've ever needed.
  10599.     
  10600.    Paul Abrahams
  10601.    abrahams%wayne-mts@um.cc.umich.edu
  10602.  
  10603. This is a long-standing question.  In fact, it's been posed as a challenge --
  10604. produce a program that really needs the full coroutine capabilities of
  10605. co-expressions.
  10606.  
  10607. Perhaps Steve Wampler, who designed and implemented co-expressions, will
  10608. respond.
  10609.  
  10610. It's worth noting that symmetry usually is viewed as an aesthetic virtue.
  10611.  
  10612. I guess my personal view is that I can ignore the coroutine aspects of
  10613. co-expressions.  Except when I have to document them or teach about them.
  10614.  
  10615.  
  10616.    
  10617.  
  10618.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  10619.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  10620.  
  10621. From kwalker  Fri Apr 27 11:19:06 1990
  10622. Date: Fri, 27 Apr 90 11:19:06 MST
  10623. From: "Kenneth Walker" <kwalker>
  10624. Message-Id: <9004271819.AA07299@megaron.cs.arizona.edu>
  10625. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  10626.     id AA07299; Fri, 27 Apr 90 11:19:06 MST
  10627. In-Reply-To: <9004271408.AA04306@sophist.uchicago.edu>
  10628. To: icon-group
  10629. Subject: Re:  grammars, questions
  10630. Status: O
  10631.  
  10632. > Date: Fri, 27 Apr 90 09:08:52 CDT
  10633. > From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  10634. > It appears that Icon has no trouble representing
  10635. > context free languages, with the restriction that there can be no left-
  10636. > recursion in the grammar.
  10637.  
  10638. Certain special cases of left-recursion can be converted into looping.
  10639. Unfortunately, this bounds backtracking so to you have to know that
  10640. backtracking won't find other solutions.
  10641.  
  10642. For example, the production
  10643.  
  10644. s ::=  t  |  s "+" t
  10645.  
  10646. can be parsed with a procedure something like
  10647.  
  10648. procedure s()
  10649.    x := []
  10650.    push(x, t()) | fail
  10651.    while ="+" do
  10652.       push(x, t()) | stop("syntax error")
  10653.    return x
  10654. end
  10655.  
  10656. (I haven't tested this code; in any event it needs to be a little more
  10657. sophisticated.) This pattern of left recursion comes up a lot in
  10658. programming languages. Is it common in natural languages?
  10659.  
  10660.   Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  10661.   +1 602 621-4324  kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker
  10662.  
  10663. From cargo@tardis.cray.com  Fri Apr 27 12:06:16 1990
  10664. Received: from timbuk.cray.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10665.     id AA10501; Fri, 27 Apr 90 12:06:16 MST
  10666. Received: from hall.cray.com by timbuk.CRAY.COM (4.1/CRI-1.34)
  10667.     id AA18506; Fri, 27 Apr 90 14:06:25 CDT
  10668. Received: from zk.cray.com by hall.cray.com
  10669.     id AA15158; 4.1/CRI-3.12; Fri, 27 Apr 90 14:06:24 CDT
  10670. Received: by zk.cray.com
  10671.     id AA04961; 3.2/CRI-3.12; Fri, 27 Apr 90 14:06:45 CDT
  10672. Date: Fri, 27 Apr 90 14:06:45 CDT
  10673. From: cargo@tardis.cray.com (David S. Cargo)
  10674. Message-Id: <9004271906.AA04961@zk.cray.com>
  10675. To: icon-group@cs.arizona.edu
  10676. Subject: parsers
  10677. Status: O
  10678.  
  10679. I am interested in using Icon to write parsers for what I have heard
  10680. called "braced languages."  "The braced languages are deterministic
  10681. and context-free langauges that explicity identify and mark the
  10682. beginning and end of each piece of information comprising the data
  10683. object." [from The automatic generation of software for data exchange
  10684. in the graphics domain, Sandra A. Mamrak, et al., The Ohio State
  10685. University]
  10686.  
  10687. The languages in general are SGML documents (with the document type
  10688. description defining the particular structure of the data objects).
  10689.  
  10690. I haven't had time to do much aside from research some of the work
  10691. that other people have done.
  10692.  
  10693. dsc
  10694.  
  10695. From wunder@hpsdel.sde.hp.com  Fri Apr 27 12:53:27 1990
  10696. Received: from hp-sde.sde.hp.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10697.     id AA13751; Fri, 27 Apr 90 12:53:27 MST
  10698. Received: from orac.sde.hp.com by hp-sde.sde.hp.com with SMTP
  10699.     (16.2A/15.5+IOS 3.13) id AA22723; Fri, 27 Apr 90 12:53:01 -0700
  10700. Received: by hpsdel.sde.hp.com
  10701.         (15.7/SES42.42) id AA25100; Fri, 27 Apr 90 12:52:42 pdt
  10702. Date: Fri, 27 Apr 90 12:52:42 pdt
  10703. From: Walter Underwood <wunder@hpsdel.sde.hp.com>
  10704. Message-Id: <9004271952.AA25100@hpsdel.sde.hp.com>
  10705. To: cargo@tardis.cray.com
  10706. Cc: icon-group@cs.arizona.edu
  10707. In-Reply-To: David S. Cargo's message of Fri, 27 Apr 90 14:06:45 CDT <9004271906.AA04961@zk.cray.com>
  10708. Subject: parsers
  10709. Status: O
  10710.  
  10711.    The languages in general are SGML documents (with the document type
  10712.    description defining the particular structure of the data objects).
  10713.  
  10714. Check out this paper:
  10715.  
  10716.   The implementation of the Amsterdam SGML parser
  10717.   J Warmer & S Van Egmond
  10718.   Electronic Publishing, vol 2 no 2, page 65
  10719.   July 1989
  10720.  
  10721. They talk about why SGML is not LL(1), and about implementing a parser
  10722. with the Amsterdam Compiler Kit.
  10723.  
  10724. wunder
  10725.  
  10726.  
  10727. From sbw@naucse.cse.nau.edu  Fri Apr 27 12:55:05 1990
  10728. Received: from naucse.cse.nau.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10729.     id AA13884; Fri, 27 Apr 90 12:55:05 MST
  10730. Received: by naucse.cse.nau.edu (5.61/1.34)
  10731.     id AA05834; Fri, 27 Apr 90 12:54:21 -0700
  10732. Message-Id: <9004271954.AA05834@naucse.cse.nau.edu>
  10733. Date: Fri, 27 Apr 90 12:54:12 MST
  10734. X-Mailer: Mail User's Shell (6.5 4/17/89)
  10735. From: sbw@naucse.cse.nau.edu (Steve Wampler)
  10736. To: "Ralph Griswold" <ralph@cs.arizona.edu>,
  10737.         um.cc.umich.edu!Wayne-MTS!Paul_Abrahams@cs.arizona.edu
  10738. Subject: Re:  Why co-expressions?
  10739. Cc: icon-group@cs.arizona.edu
  10740. Status: O
  10741.  
  10742. On Apr 27 at 11:18, "Ralph Griswold" writes:
  10743. }    Ralph's explanation of the motivation for co-expressions is right on.
  10744. }    But Ralph--why do they have to be symmetric?  An asymmetric version,
  10745. }    which is what I have in SPLASH, is conceptually simpler (rather like
  10746. }    Unix piping, but with branching) and seems to provide all the functionality
  10747. }    I've ever needed.
  10748. }     
  10749. }    Paul Abrahams
  10750. }    abrahams%wayne-mts@um.cc.umich.edu
  10751. } This is a long-standing question.  In fact, it's been posed as a challenge --
  10752. } produce a program that really needs the full coroutine capabilities of
  10753. } co-expressions.
  10754. } Perhaps Steve Wampler, who designed and implemented co-expressions, will
  10755. } respond.
  10756.  
  10757. Well, let's see, just what do I want my memory of back then to be...
  10758.  
  10759. Oh yes.
  10760.  
  10761. One thing to keep in mind is that, as a PhD student, I was interested in
  10762. 'research' topics, not just implementation.  The nice thing about a
  10763. symmetric view of co-expressions is that they are full of interesting
  10764. potentials - for example, since they effectively provide a heap-based
  10765. calling structure (instead of the conventional stack-based model), they
  10766. provide all sorts of fun graph-based programming strategies.  And, of
  10767. course, lend themselves reasonably well to exploring certain multi-
  10768. process programming strategies (could do better at this one, though).
  10769.  
  10770. I think I can claim (heck, I can claim anything - wonder if I'm right?)
  10771. that asymmetric co-expressions provide lazy evaluation of a tree-based
  10772. calling structure - which is interesting, but not as general (from a
  10773. research point of view, remember).
  10774.  
  10775. And, I know it seems odd, but I find the symmetric view very straight-forward,
  10776. there isn't much special-casing going on.  I think this is reflected in
  10777. the original implementation, which was flat-out trivial on a PDP (to activate
  10778. a co-expression, you simply changed the sp register to point into the stack
  10779. for the co-expression, saved the pc and reset it to the saved pc for
  10780. the co-expression.  Only about 4 instructions.  Returning was, well,
  10781. symmetric.)  I'd bet that an implementation of the asymmetric model
  10782. would be no easier, and possibly more complex (since you may need to
  10783. worry about preventing cycles).  Since all that changes is the CPU state,
  10784. this seems naturally (to my warped mind) as a simple multi-processor model.
  10785.  
  10786. Of course, the original model was flawed if one really wanted coroutines,
  10787. but there are other things (such as the heap-based call graph mentioned
  10788. above) that are nice *from a research point of view*.
  10789.  
  10790. Sigh, I wish someone would throw me a couple of graduate students and
  10791. some time to really explore these things.
  10792.  
  10793. Paul, I'm anxious to learn more about SPLASH!  I'd like to play with
  10794. asymmetric co-expressions as well as some of the other features you've
  10795. tempted us with!
  10796.  
  10797. -- 
  10798.     Steve Wampler
  10799.     {....!arizona!naucse!sbw}
  10800.     {sbw@naucse.cse.nau.edu}
  10801.  
  10802. From goer@sophist.uchicago.EDU  Fri Apr 27 12:57:36 1990
  10803. Resent-From: goer@sophist.uchicago.EDU
  10804. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10805.     id AA14211; Fri, 27 Apr 90 12:57:36 MST
  10806. Return-Path: goer@sophist.uchicago.EDU
  10807. Received: from tank.uchicago.edu by Arizona.EDU; Fri, 27 Apr 90 12:58 MST
  10808. Received: from sophist.uchicago.edu by tank.uchicago.edu Fri, 27 Apr 90
  10809.  14:57:23 CDT
  10810. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA04801; Fri, 27 Apr 90
  10811.  14:53:10 CDT
  10812. Resent-Date: Fri, 27 Apr 90 12:59 MST
  10813. Date: Fri, 27 Apr 90 14:53:10 CDT
  10814. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  10815. Subject: left recursion in natural languages
  10816. Resent-To: icon-group@cs.arizona.edu
  10817. To: icon-group@arizona.edu
  10818. Resent-Message-Id: <A2B963D86B3FA07326@Arizona.EDU>
  10819. Message-Id: <9004271953.AA04801@sophist.uchicago.edu>
  10820. X-Envelope-To: icon-group@CS.Arizona.EDU
  10821. X-Vms-To: icon-group@Arizona.edu
  10822. Status: O
  10823.  
  10824. Ken Walker kindly responds to my query about parsing strategies (or at
  10825. least one of the many queries):
  10826.  
  10827.     For example, the production
  10828.     
  10829.     s ::=  t  |  s "+" t
  10830.  
  10831. (For those who want to get in this game, quick read Griswold & Griswold,
  10832. chapter 15.)
  10833.     
  10834.     can be parsed with a procedure something like
  10835.     
  10836.     procedure s()
  10837.        x := []
  10838.        push(x, t()) | fail
  10839.        while ="+" do
  10840.           push(x, t()) | stop("syntax error")
  10841.        return x
  10842.     end
  10843.     
  10844.     (I haven't tested this code; in any event it needs to be a little more
  10845.     sophisticated.) This pattern of left recursion comes up a lot in
  10846.     programming languages. Is it common in natural languages?
  10847.  
  10848. Yes, it's fairly common.  One case in point is the 's construction.
  10849. You can define a noun phrase as a combination of articles, simple
  10850. nouns, adjectives, relative clauses, etc.  This works fairly well
  10851. using a simple phrase structure grammar.  However, as soon as you try
  10852. to include 's, you have to define a noun phrase as a noun phrase fol-
  10853. lowed by an 's.  E.g. -
  10854.  
  10855.     the queen of England
  10856.     the queen of England's throne
  10857.  
  10858. The phrase "the queen of England" is a noun phrase, and so is "the queen
  10859. of England's throne."  You can see immediately how there's left recursion
  10860. here.  Any time you get a postpositions (which is what 's really is -
  10861. it's not a "case" or an affix of any kind) you'll have this problem of
  10862. left recursion.  Sumerian, which is one language I've studied, is all
  10863. postpositions - no prepositions at all.  In fact, you can often do a
  10864. mirror-image lexical calque of a phrase and have it come out as acceptable
  10865. English.
  10866.  
  10867. The problem with natural language parsing strategies that don't permit
  10868. elegant left-recursion is that they don't mirror the apparent ability
  10869. for people to handle both sorts of recursion in any given languages.
  10870. Normally a language will use one or the other predominantly, but often
  10871. there is mixing (as in English).
  10872.  
  10873. One way out is to permit X levels of left recursion, with X representing
  10874. the number of levels beyond which people get confused, and don't really
  10875. talk that way.  The problem with this is that people might perhaps really
  10876. be using an internal grammar that permits infinite recursion, but that
  10877. they just can't fully realize the grammar.  This seems a bit silly to
  10878. me.
  10879.  
  10880. I have to admit that my main interest is in the sounds - the phonemes,
  10881. or systmatic pronunciation units - of ancient Semitic languages.
  10882. Someone who is more into the suntax of natural languages, please jump
  10883. in here --->
  10884.  
  10885. From @s.ms.uky.edu:mtbb95@ms.uky.edu  Fri Apr 27 14:29:16 1990
  10886. Received: from e.ms.uky.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10887.     id AA21281; Fri, 27 Apr 90 14:29:16 MST
  10888. Received: from s.ms.uky.edu by g.ms.uky.edu id aa24729; 27 Apr 90 16:48 EDT
  10889. From: Bob Maras <mtbb95@ms.uky.edu>
  10890. Date: Fri, 27 Apr 90 16:47:52 EDT
  10891. X-Mailer: Mail User's Shell (6.4 2/14/89)
  10892. To: icon-group@cs.arizona.edu, mtbb95@ms.uky.edu
  10893. Subject: Removal
  10894. Message-Id:  <9004271647.aa22801@s.s.ms.uky.edu>
  10895. Status: O
  10896.  
  10897. Please remove my name from your Icon mailing list of users.  I appreciate the fine effort you are making and wish each of you the very best.  I have enjoyed
  10898. your information very much.
  10899.  
  10900. Robert Maras
  10901.  
  10902. -- 
  10903.                           _      _
  10904.                          ( ) __ ( )
  10905.                           | O  O |         B O B   M A R A S
  10906.                           /  __  \      /
  10907.                          (   \/   )  __/
  10908.                           \ \__/ / 
  10909.                            \____/ 
  10910.                            |_/\_|     H A P P Y    C O M P U T I N G    !!!
  10911.         
  10912.  
  10913. From icon-group-request@arizona.edu  Fri Apr 27 17:54:28 1990
  10914. Resent-From: icon-group-request@arizona.edu
  10915. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10916.     id AA06635; Fri, 27 Apr 90 17:54:28 MST
  10917. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Fri, 27 Apr 90 17:54 MST
  10918. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA27061; Fri, 27 Apr 90
  10919.  17:39:16 -0700
  10920. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  10921.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  10922.  usenet@ucbvax.Berkeley.EDU if you have questions)
  10923. Resent-Date: Fri, 27 Apr 90 17:54 MST
  10924. Date: 27 Apr 90 18:22:00 GMT
  10925. From: swrinde!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!daniel@ucsd.EDU
  10926. Subject: Icon v8 port for Convex ?
  10927. Sender: icon-group-request@arizona.edu
  10928. Resent-To: icon-group@cs.arizona.edu
  10929. To: icon-group@arizona.edu
  10930. Resent-Message-Id: <A2900CB3721FA084E1@Arizona.EDU>
  10931. Message-Id: <6900001@ux1.cso.uiuc.edu>
  10932. X-Envelope-To: icon-group@CS.Arizona.EDU
  10933. X-Vms-To: icon-group@Arizona.edu
  10934. Status: O
  10935.  
  10936.  
  10937. I desire to bring up Icon version 8 on a Convex 220.  Has anyone done
  10938. the port yet?  I see that version 7 was ported.
  10939.  
  10940. -- Daniel Pommert
  10941.  
  10942. email.internet:    pommert@uiuc.edu
  10943. email.bitnet:    daniel@uiucvmd
  10944.  
  10945. phone:    (217) 333-8629
  10946.  
  10947. post:    DCL Rm, 150
  10948.     1304 W. Springfield
  10949.     Urbana, IL  61801-2987
  10950.  
  10951. where:    40  6 47 N Latitude
  10952.     88 13 36 W Longitude
  10953.  
  10954. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Fri Apr 27 19:20:34 1990
  10955. Received: from umich.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  10956.     id AA11705; Fri, 27 Apr 90 19:20:34 MST
  10957. Received: from ummts.cc.umich.edu by umich.edu (5.61/1123-1.0)
  10958.     id AA27095; Fri, 27 Apr 90 22:20:30 -0400
  10959. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Fri, 27 Apr 90 22:20:12 EDT
  10960. Date: Fri, 27 Apr 90 22:14:38 EDT
  10961. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  10962. To: icon-group@cs.arizona.edu
  10963. Message-Id: <221656@Wayne-MTS>
  10964. Subject: Deletions from the Icon mailing list
  10965. Status: O
  10966.  
  10967. Would all you people who (unwisely) want to get off the Icon mailing list
  10968. please send notice of that to icon-PROJECT, not to icon-GROUP.
  10969. (If I'm leading the flocks astray, dear icon-group-person, please let
  10970. us know.) - Paul Abrahams
  10971.  
  10972. From ralph  Fri Apr 27 19:43:06 1990
  10973. Date: Fri, 27 Apr 90 19:43:06 MST
  10974. From: "Ralph Griswold" <ralph>
  10975. Message-Id: <9004280243.AA12512@megaron.cs.arizona.edu>
  10976. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  10977.     id AA12512; Fri, 27 Apr 90 19:43:06 MST
  10978. To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu, icon-group@cs.arizona.edu
  10979. Subject: Re:  Deletions from the Icon mailing list
  10980. Status: O
  10981.  
  10982. The correct e-mail address to use to get on/off the icon-group
  10983. mailing list is icon-group-request.  The name is common protocol
  10984. used for all such groups.
  10985.  
  10986. The problem is that folks can't be expected to know/remember that.
  10987.  
  10988. A good alternative is icon-project; we'll handle icon-group changes,
  10989. and, at least, mail to icon-project doesn't get resent to hundreds of
  10990. addresses all over the world.
  10991.  
  10992. In general, if you have something that's not suitable for broadcasting,
  10993. send it to icon-project.
  10994.  
  10995.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  10996.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  10997.  
  10998. p.s.  Thanks, Paul.
  10999.  
  11000. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Sun Apr 29 13:01:50 1990
  11001. Received: from umich.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11002.     id AA14826; Sun, 29 Apr 90 13:01:50 MST
  11003. Received: from ummts.cc.umich.edu by umich.edu (5.61/1123-1.0)
  11004.     id AA13598; Sun, 29 Apr 90 16:01:45 -0400
  11005. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sun, 29 Apr 90 16:01:27 EDT
  11006. Date: Sun, 29 Apr 90 15:45:40 EDT
  11007. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  11008. To: icon-group@cs.arizona.edu
  11009. Message-Id: <221847@Wayne-MTS>
  11010. Subject: Co-expressions, symmetric and otherwise
  11011. Status: O
  11012.  
  11013.  
  11014. Rich Goerwitz asked me what the difference was between symmetric and
  11015. asymmetric co-expressions.  The answer, in terms of Icon, is simple:
  11016. if you disallow the expressions @&source, @&main, and the binary form
  11017. e1@e2 (see p. 138 of the Icon book), then you have asymmetric co-expressions.
  11018. In other words, you can create a co-expression e, which can then pass
  11019. back values at various points of call with suspend (or return--just once).
  11020. These values can be picked up by evaluating @e.  So the co-expression
  11021. sends values (via suspend), and various callers can retrieve them
  11022. (via @).  But there's no way for a caller to pass a value to e once it's been
  11023. created except, of course, through globals or other such devices.
  11024.  
  11025. In my experience the asymmetric form is extremely useful, and it's all that
  11026. I've ever needed.  To tell the truth, I never fully fathomed the program on
  11027. p. 139.  (How many of you out there have really understood it?)  My suspicion
  11028. is that if the facilities of Sec. 13.4.1 were dropped from Icon, no useful
  11029. programs would be broken.  To answer Steve Wampler's point about restrictions,
  11030. the only restriction needed to limit Icon to asymmetric coexpressions would
  11031. be to eliminate those facilities--so it would be pretty simple if the Icon
  11032. project wanted to do it.
  11033.  
  11034. Historically, I think that the symmetric form of coroutine arose because there
  11035. was no natural way to make coroutines asymmetric.  The suspend notation
  11036. provides such a way.
  11037.  
  11038. In terms of implementation, the hard part is not so much passing control back
  11039. and forth but the storage allocation.  A coexpression requires either heap
  11040. allocation or a stack of its own, and if you choose the stack, you either have
  11041. to limit its size or make it relocatable from one place to another.  Hence the
  11042. references in the literature to cactus stacks, which are what you need to
  11043. implement coroutines.  With asymmetric coroutines, there are some interesting
  11044. optimization possibilities if the optimizer can discover that a coexpression
  11045. only uses a bounded amount of storage.  (This is how it works in SPLASH.)
  11046. I don't know whether symmetric co-expressions make this much harder to do.
  11047. Coroutines were originally designed for Fortran-like (or assembly) languages
  11048. in environments without recursion, so the storage allocation problem was
  11049. essentially trivial.
  11050.  
  11051. Paul Abrahams
  11052. abrahams%wayne-mts@um.cc.umich.edu
  11053.  
  11054. From goer@sophist.uchicago.EDU  Sun Apr 29 15:45:51 1990
  11055. Resent-From: goer@sophist.uchicago.EDU
  11056. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11057.     id AA23817; Sun, 29 Apr 90 15:45:51 MST
  11058. Return-Path: goer@sophist.uchicago.EDU
  11059. Received: from tank.uchicago.edu by Arizona.EDU; Sun, 29 Apr 90 15:46 MST
  11060. Received: from sophist.uchicago.edu by tank.uchicago.edu Sun, 29 Apr 90
  11061.  17:45:37 CDT
  11062. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA02634; Sun, 29 Apr 90
  11063.  17:41:26 CDT
  11064. Resent-Date: Sun, 29 Apr 90 15:47 MST
  11065. Date: Sun, 29 Apr 90 17:41:26 CDT
  11066. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  11067. Subject: hell
  11068. Resent-To: icon-group@cs.arizona.edu
  11069. To: icon-group@arizona.edu
  11070. Resent-Message-Id: <A10F8C79D93FA08D2B@Arizona.EDU>
  11071. Message-Id: <9004292241.AA02634@sophist.uchicago.edu>
  11072. X-Envelope-To: icon-group@CS.Arizona.EDU
  11073. X-Vms-To: icon-group@Arizona.edu
  11074. Status: O
  11075.  
  11076.  
  11077.     In my experience the asymmetric form is extremely useful, and it's
  11078.     all that I've ever needed.  To tell the truth, I never fully
  11079.     fathomed the program on p. 139.  (How many of you out there have
  11080.     really understood it?)  My suspicion is that if the facilities of
  11081.     Sec. 13.4.1 were dropped from Icon, no useful programs would be
  11082.     broken.  To answer Steve Wampler's point about restrictions, the
  11083.     only restriction needed to limit Icon to asymmetric coexpressions
  11084.     would be to eliminate those facilities--so it would be pretty
  11085.     simple if the Icon project wanted to do it.
  11086.  
  11087. I guess my experience was this:  I learned Icon on my own, and I figured
  11088. than anything in "the book" was there because it was important for a fun-
  11089. damental understanding of the language.  As a result, I fooled with the
  11090. example of symmetric coexpressions until I understood what they were used
  11091. for.  I'd say that for about two years at least half the programs I wrote
  11092. used these symmetric coexpressions.  I've written some very extensive con-
  11093. version programs using methods like those outlined on the infamous p.
  11094. 139.
  11095.  
  11096. I recall being a bit surprised several years ago when David Gudeman ex-
  11097. pressed a dislike for coroutines.  Jerry Nowlin also used to jump in and
  11098. redo most programs that were posted using coexpressions (still less co-
  11099. routines) so that these were not necessary, mumbling something about
  11100. speed :-).  My problem is that, although I like using them for some things,
  11101. they usually obfuscate my code unless I am careful.
  11102.  
  11103. I guess I've gotten away from coroutines, but I'd note that, at least here
  11104. on my home machine, they do not cause much of a speed decrease over other
  11105. methods.
  11106.  
  11107. I would be very, very interested in seeing a short, clean example of a
  11108. situation where symmetric coroutines provide at least the most elegant,
  11109. if not the only possible, way of doing something.
  11110.  
  11111.  
  11112. Another subject (yes, this should have been placed in another posting,
  11113. but I post here often enough as it is):  What are Backus-Naur Forms?
  11114. I was reading about SNOBOL the other day - a language I am only very
  11115. superficially familiar with.  The author of the article I was perusing
  11116. stated that BNFs could be translated directly into SNOBOL4 patterns.
  11117. First of all, like so many others who use Icon, I am not a computer
  11118. scientist.  I do linguistics and text processing mainly.  I have no
  11119. idea what BNFs are.  I'd like to know what they are.  Secondly, I'd
  11120. enjoy knowing whether the same translation as is possible for SNOBOL
  11121. is possible for Icon.
  11122.  
  11123. If someone knows the answers to these questions, could he or she
  11124. perhaps chime in?
  11125.  
  11126.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  11127.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  11128.  
  11129. From ralph  Sun Apr 29 16:08:52 1990
  11130. Date: Sun, 29 Apr 90 16:08:52 MST
  11131. From: "Ralph Griswold" <ralph>
  11132. Message-Id: <9004292308.AA25231@megaron.cs.arizona.edu>
  11133. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  11134.     id AA25231; Sun, 29 Apr 90 16:08:52 MST
  11135. To: goer@sophist.uchicago.EDU
  11136. Subject: Re:  hell
  11137. Cc: icon-group
  11138. In-Reply-To: <9004292241.AA02634@sophist.uchicago.edu>
  11139. Status: O
  11140.  
  11141. Co-expressions are space-intensive, but not time-intensive.  In fact,
  11142. activating a co-expression is a bit faster than calling a procedure.
  11143.  
  11144. The biggest problem is that co-expressions are not supported in all versions
  11145. of Icon, so code that uses them is not portable.
  11146.  
  11147. Symmetry/non-symmetry aside, co-expressions as they are in Icon are not
  11148. going to be changed.  I can't really see what all the fuss is about;
  11149. the symmetry costs relatively little code, it's be done, and you can
  11150. ignore the symmetric uses if you don't need them.
  11151.  
  11152. As to BNF:  It's a notational system for writing context-free production
  11153. grammars.  It was first used in the design of Algol 60 (or possibly
  11154. Algol 58).  It's nothing special, but it can be found in many older
  11155. programming language texts, used for describing syntax.  There are examples
  11156. of BNF grammars in the Icon langauge book, although they may not be
  11157. labeled as such.
  11158.  
  11159. There's a fairly simple mapping from BNF (and other CF production grammar
  11160. systems) to patterns in SNOBOL4.  There's a similar mapping for Icon,
  11161. provided matching procedures are used for the nonterminal symbols.  The
  11162. result is a recursive-descent parser with backtracking.  Aside from
  11163. efficiency considerations, the main problem is that left-recursion in
  11164. productions translates into left recusrion in matching.  SNOBOL4 avoids
  11165. this by using a length-shortening heuristic.
  11166.  
  11167. The mapping is described in the Icon language book.
  11168.  
  11169.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  11170.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  11171.  
  11172. From cjeffery  Sun Apr 29 16:19:29 1990
  11173. Resent-From: "Clinton Jeffery" <cjeffery>
  11174. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11175.     id AA25760; Sun, 29 Apr 90 16:19:29 MST
  11176. Received: from megaron.cs.Arizona.EDU by Arizona.EDU; Sun, 29 Apr 90 16:18 MST
  11177. Received: from caslon.cs.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15)
  11178.  via SMTP id AA25635; Sun, 29 Apr 90 16:17:09 MST
  11179. Received: by caslon; Sun, 29 Apr 90 16:17:09 mst
  11180. Resent-Date: Sun, 29 Apr 90 16:20 MST
  11181. Date: Sun, 29 Apr 90 16:17:09 mst
  11182. From: Clinton Jeffery <cjeffery@cs.arizona.edu>
  11183. Subject: hell
  11184. Resent-To: icon-group@cs.arizona.edu
  11185. To: goer@sophist.uchicago.EDU
  11186. Cc: icon-group@arizona.edu
  11187. Resent-Message-Id: <A10AE048433FA08FC7@Arizona.EDU>
  11188. Message-Id: <9004292317.AA02545@caslon>
  11189. In-Reply-To: Richard Goerwitz's message of Sun, 29 Apr 90 17:41:26 CDT
  11190.  <9004292241.AA02634@sophist.uchicago.edu>
  11191. X-Envelope-To: icon-group@CS.Arizona.EDU
  11192. X-Vms-To: goer@sophist.uchicago.EDU
  11193. X-Vms-Cc: icon-group@Arizona.edu
  11194. Status: O
  11195.  
  11196. Backus Naur Forms (or Backus Normal Forms, and including
  11197. "Extended Backus Naur Forms) are one notation for expressing
  11198. "Phrase Structure Grammars"--I'm sure the main reason we call
  11199. them BNF is to avoid giving linguists the credit where credit
  11200. is due.  Well, I am just kidding here folks; computer scientists
  11201. use it for historical reasons, but BNF's are essentially PSG's.
  11202. Most BNF grammars would translate easily into Icon, as has
  11203. been discussed in the past two weeks.
  11204.  
  11205. I am going to stay out of the co-routine squabble for the moment.
  11206. I think that symmetric co-expressions can defend themselves.
  11207. --
  11208. | Clint Jeffery, U. of Arizona Dept. of Computer Science
  11209. | cjeffery@cs.arizona.edu -or- {noao allegra}!arizona!cjeffery
  11210. --
  11211.  
  11212. From gudeman  Sun Apr 29 21:36:32 1990
  11213. Resent-From: "David Gudeman" <gudeman>
  11214. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11215.     id AA12514; Sun, 29 Apr 90 21:36:32 MST
  11216. Received: from megaron.cs.Arizona.EDU by Arizona.EDU; Sun, 29 Apr 90 21:37 MST
  11217. Received: by megaron.cs.arizona.edu (5.59-1.7/15) id AA12501; Sun, 29 Apr 90
  11218.  21:36:06 MST
  11219. Resent-Date: Sun, 29 Apr 90 21:38 MST
  11220. Date: Sun, 29 Apr 90 21:36:06 MST
  11221. From: David Gudeman <gudeman@cs.arizona.edu>
  11222. Subject: hell
  11223. Resent-To: icon-group@cs.arizona.edu
  11224. To: icon-group@arizona.edu
  11225. Resent-Message-Id: <A0DE8DB29D9FA09240@Arizona.EDU>
  11226. Message-Id: <9004300436.AA12501@megaron.cs.arizona.edu>
  11227. In-Reply-To: Richard Goerwitz's message of Sun, 29 Apr 90 17:41:26 CDT
  11228.  <9004292241.AA02634@sophist.uchicago.edu>
  11229. X-Envelope-To: icon-group@CS.Arizona.EDU
  11230. X-Vms-To: icon-group@Arizona.edu
  11231. Status: O
  11232.  
  11233.    From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  11234.  
  11235.    I recall being a bit surprised several years ago when David Gudeman ex-
  11236.    pressed a dislike for coroutines.
  11237.  
  11238. Well..., more accurately I _prefer_ to use recursive procedures.  On
  11239. the other hand, there are certainly some problems that are more
  11240. conveniently solved with coroutines.  My preference for recursive
  11241. procedures is largely based on the fact that _I_ find them easier to
  11242. understand than I do coroutines.  I can rationalize this rather
  11243. selfish attitude by noting that this is probably typical: it is likely
  11244. that most people find procedures easier to understand.  So if your
  11245. code is going to be read by others, it is probably best not to go
  11246. looking for places to use coroutines.
  11247.  
  11248. People generally learn to use recursive procedures long before they
  11249. ever hear of coexpressions, and (like me) they are too lazy to spend a
  11250. lot of time with a new construction when most problems can be
  11251. adequately solved without it.  In some ways this is similar to the
  11252. resistance people have against learning a new programming language.
  11253.  
  11254. We are probably poorer for our specialization, and given your unusual
  11255. experience in learning Icon, you surely have some unique perspectives
  11256. to contribute.  In particular, it is interesting to see how coroutines
  11257. are used by someone who never developed a strong prejudice in favor of
  11258. procedures.
  11259.  
  11260. From @mirsa.inria.fr:ol@cerisi.cerisi.Fr  Sun Apr 29 23:05:03 1990
  11261. Received: from mirsa.inria.fr by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11262.     id AA17108; Sun, 29 Apr 90 23:05:03 MST
  11263. Received: from cerisi.cerisi.fr by mirsa.inria.fr with SMTP
  11264.     (5.59++/IDA-1.2.8) id AA08681; Mon, 30 Apr 90 08:05:11 +0200
  11265. Message-Id: <9004300605.AA08681@mirsa.inria.fr>
  11266. Date: Mon, 30 Apr 90 08:03:44 -0100
  11267. Posted-Date: Mon, 30 Apr 90 08:03:44 -0100
  11268. From: Lecarme Olivier <ol@cerisi.cerisi.Fr>
  11269. To: icon-group@cs.arizona.edu
  11270. In-Reply-To: "Ralph Griswold"'s message of Sun, 29 Apr 90 16:08:52 MST <9004292308.AA25231@megaron.cs.arizona.edu>
  11271. Subject:  hell
  11272. Status: O
  11273.  
  11274. A point of history: BNF was first used in the description of Algol 60
  11275. (Algol 58, names IAL (for International Algorithmic Language) when it
  11276. was first designed, used a notation similar to that used for Fortran).
  11277. It's called Backus Normal Form because first used in a draft document by
  11278. John Backus. It is also known as Backus-Naur Form, because its final
  11279. form, used in the "Report about the Algorithmic Language Algol", was
  11280. designed by Peter Naur.
  11281.  
  11282. Original BNF had flaws: for example, terminal symbols were not specially
  11283. quoted, contrarily to non-terminal symbols; there was no delimiter
  11284. between rules; meta-symbols of the notation could not be used in the
  11285. language being described. The most popular notation presently is
  11286. probably EBNF (Extended Backus-Naur Form), designed by Niklaus Wirth,
  11287. which corrects these flaws and adds some more meta-operators for
  11288. expressing frequent cases (optional parts, repetitions, and so on).
  11289.  
  11290.  
  11291.                 Olivier Lecarme
  11292.  
  11293. From goer@sophist.uchicago.EDU  Mon Apr 30 06:59:28 1990
  11294. Resent-From: goer@sophist.uchicago.EDU
  11295. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11296.     id AA06121; Mon, 30 Apr 90 06:59:28 MST
  11297. Return-Path: goer@sophist.uchicago.EDU
  11298. Received: from tank.uchicago.edu by Arizona.EDU; Mon, 30 Apr 90 07:00 MST
  11299. Received: from sophist.uchicago.edu by tank.uchicago.edu Mon, 30 Apr 90
  11300.  08:59:54 CDT
  11301. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA03346; Mon, 30 Apr 90
  11302.  08:55:43 CDT
  11303. Resent-Date: Mon, 30 Apr 90 07:01 MST
  11304. Date: Mon, 30 Apr 90 08:55:43 CDT
  11305. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  11306. Subject: BNFs
  11307. Resent-To: icon-group@cs.arizona.edu
  11308. To: icon-group@arizona.edu
  11309. Resent-Message-Id: <A08FE708BD1FA091AF@Arizona.EDU>
  11310. Message-Id: <9004301355.AA03346@sophist.uchicago.edu>
  11311. X-Envelope-To: icon-group@CS.Arizona.EDU
  11312. X-Vms-To: icon-group@Arizona.edu
  11313. Status: O
  11314.  
  11315. It really is a shame that there has to be this sort of terminological
  11316. fragmentation.  I see now that Backus Naur Forms (and EBNFs) are really
  11317. just a notational device for expressing context free grammars.  Good-
  11318. ness.  What a fuss :-)!  As one poster pointed out, linguists have been
  11319. using their own practical notation for context free grammars for some
  11320. time now.  Prolog is one language that implements this notation in the
  11321. form of its definite clause grammars (which in reality are slightly more
  11322. powerful than context free grammars).  I suppose it's all a matter of
  11323. which tradition you "grew up" in.
  11324.  
  11325. In a previous posting, I showed how left recursion occurs in English.
  11326. There are also lots of context-dependent rules, such as verb-noun agree-
  11327. ment.  You can't use a context free phrase structure grammar, for in-
  11328. stance, to recognize a sentence that goes -
  11329.  
  11330.            The woman loves me.
  11331.            The woman I married loves me.
  11332.            The woman I married, who won't love me if my son and I forget
  11333.              Mother's Day, loves me.
  11334.  
  11335. There are two problems here:  1) We have to get the verb phrase - something
  11336. that must be defined separately from the noun phrase - to know about what
  11337. is going on in the noun phrase, namely that it is singular (hence "loves" and
  11338. not "love."  The other problem (2) is what I mentioned before, namely left re-
  11339. cursion in the grammar.  Another thing to consider is the arbitrary complexity
  11340. of the noun phrase, and the theoretically unlimited distance that separates
  11341. the main noun of that phrase (above = "woman") from the verb phrase ("loves
  11342. me").
  11343.  
  11344. Phrase structure grammars, BNFs, regular expressions, definite clause grammars
  11345. without indexing - whatever you happen to call them (they are all context free)
  11346. - are, to the linguist, not of most central interest.
  11347.  
  11348. As I hinted at above, the problem of the verb knowing what the noun before it
  11349. is doing number-wise can be solved.  In Prolog you do it using indexed gram-
  11350. mars.  In Icon, the solution looks pretty straightforward, even elegant.
  11351. Just have your matching procedures return a value.  This has the effect of
  11352. allowing nodes to have labels.  I'd tend to want to create a list, and then
  11353. have each node, if it wishes, simply return a value, which is then "put" into
  11354. a list and returned (or put into another list by the calling node, or whatever).
  11355. Anyway, all you would have to do is make sure that neither the noun phrase
  11356. nor the verb phrase conflict as to number (in this case, I'd just check to
  11357. be sure that, if the one is marked "singular," the other is as well).
  11358.  
  11359. Again, I'd really like to see some comments by someone who has studied the
  11360. syntax of natural languages in more detail than I.  It just seemed useful
  11361. to provide a little input from linguistics.  It will be useful in the long
  11362. run, I think, if I keep reminding computer scientists that their work has
  11363. implications in closely related fields.
  11364.  
  11365.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  11366.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  11367.  
  11368. From @RELAY.CS.NET,@dg-rtp.rtp.dg.com:langley@DG-RTP.DG.COM  Mon Apr 30 08:05:02 1990
  11369. Received: from relay.cs.net by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11370.     id AA11625; Mon, 30 Apr 90 08:05:02 MST
  11371. Received: from dg-rtp.rtp.dg.com by RELAY.CS.NET id aa23732; 30 Apr 90 11:01 EDT
  11372. Received: from bigbird.rtp.dg.com by dg-rtp.dg.com (4.20/4.7)
  11373.     id AA17366; Mon, 30 Apr 90 10:59:37 edt via SMTP
  11374. Received: by bigbird.rtp.dg.com (4.20/rtp-s01)
  11375.     id AA06810; Mon, 30 Apr 90 11:00:37 edt
  11376. Date: Mon, 30 Apr 90 11:00:37 edt
  11377. From: Mark L Langley <langley@DG-RTP.DG.COM>
  11378. Message-Id: <9004301500.AA06810@bigbird.rtp.dg.com>
  11379. Return-Receipt-To: langley@dg-rtp.dg.com
  11380. To: icon-group@cs.arizona.edu
  11381. Subject: linguism
  11382. Status: O
  11383.  
  11384. First, I just wanted to say that I have really enjoyed the linguistic-
  11385. related postings.
  11386.  
  11387. This group is quite a melting pot of Computer Scientists, Researchers,
  11388. and thinkers-in-general, centered around the unlikely vehicle of Icon.
  11389. (Now back to the show....)
  11390.  
  11391. Richard Goerwitz remarked
  11392. > It really is a shame that there has to be this sort of terminological
  11393. > fragmentation.  I see now that Backus Naur Forms (and EBNFs) are really
  11394. > just a notational device for expressing context free grammars.  Good-
  11395. > ness.  What a fuss :-)!  As one poster pointed out, linguists have been
  11396. > using their own practical notation for context free grammars for some
  11397. > time now.  Prolog is one language that implements this notation in the
  11398. > form of its definite clause grammars (which in reality are slightly more
  11399. > powerful than context free grammars).  I suppose it's all a matter of
  11400. > which tradition you "grew up" in.
  11401.  
  11402. Can you say a little about the linguistic convention for describing
  11403. cfg-s?  What are it's advantages? Does it submit more readily to being
  11404. manipulated by a program?  I once wrote Icon (what else?) programs to 
  11405. manipulate a cfg, by putting it through its paces/transformations between 
  11406. normal forms, factoring left recursion, et al.
  11407.  
  11408. I would be interested in seeing an alternate representation than BNF
  11409. that might offer conceptual improvements.
  11410.  
  11411. >            The woman loves me.
  11412. >            The woman I married loves me.
  11413. >            The woman I married, who won't love me if my son and I forget
  11414. >              Mother's Day, loves me.
  11415. > There are two problems here:  1) We have to get the verb phrase - something
  11416. > that must be defined separately from the noun phrase - to know about what
  11417. > is going on in the noun phrase, namely that it is singular (hence "loves" and
  11418. > not "love."  The other problem (2) is what I mentioned before, namely left re-
  11419. > cursion in the grammar.  Another thing to consider is the arbitrary complexity
  11420. > of the noun phrase, and the theoretically unlimited distance that separates
  11421. > the main noun of that phrase (above = "woman") from the verb phrase ("loves
  11422. > me").
  11423. > Phrase structure grammars, BNFs, regular expressions, definite clause grammars
  11424. > without indexing - whatever you happen to call them (they are all context free)
  11425. > - are, to the linguist, not of most central interest.
  11426. > As I hinted at above, the problem of the verb knowing what the noun before it
  11427. > is doing number-wise can be solved.  In Prolog you do it using indexed gram-
  11428. > mars.  In Icon, the solution looks pretty straightforward, even elegant.
  11429. > Just have your matching procedures return a value.  This has the effect of
  11430. > allowing nodes to have labels.  I'd tend to want to create a list, and then
  11431. > have each node, if it wishes, simply return a value, which is then "put" into
  11432. > a list and returned (or put into another list by the calling node, or whatever).
  11433. > Anyway, all you would have to do is make sure that neither the noun phrase
  11434. > nor the verb phrase conflict as to number (in this case, I'd just check to
  11435. > be sure that, if the one is marked "singular," the other is as well).
  11436.  
  11437. This looks like what we compiler wonks do when we check non-syntactic
  11438. things (like whether something is declared or not...) during the translation
  11439. process.  Is there a better (more fully encompassing) formalism here?  That
  11440. is, syntax-with-ad-hoc-checking is highly impure...
  11441.  
  11442. > Again, I'd really like to see some comments by someone who has studied the
  11443. > syntax of natural languages in more detail than I.  It just seemed useful
  11444. > to provide a little input from linguistics.  It will be useful in the long
  11445. > run, I think, if I keep reminding computer scientists that their work has
  11446. > implications in closely related fields.
  11447.  
  11448. So would I...
  11449.  
  11450. Has anyone successfully parsed
  11451.     "The policeman raised his hand and stopped the car"
  11452.         (Courtesy of R. Schank.)
  11453.     
  11454. >     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  11455. >     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  11456.  
  11457. Mark
  11458. langley@dg-rtp.dg.com
  11459.  
  11460. From sboisen@BBN.COM  Mon Apr 30 09:17:00 1990
  11461. Message-Id: <9004301617.AA16804@megaron.cs.arizona.edu>
  11462. Received: from RIGEL.BBN.COM by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11463.     id AA16804; Mon, 30 Apr 90 09:17:00 MST
  11464. To: langley@dg-rtp.dg.com
  11465. Cc: icon-group@cs.arizona.edu
  11466. In-Reply-To: Mark L Langley's message of Mon, 30 Apr 90 11:00:37 edt <9004301500.AA06810@bigbird.rtp.dg.com>
  11467. Subject: linguism
  11468. From: Sean Boisen <sboisen@BBN.COM>
  11469. Sender: sboisen@BBN.COM
  11470. Reply-To: sboisen@BBN.COM
  11471. Date: Mon, 30 Apr 90 12:15:00 EDT
  11472. Status: O
  11473.  
  11474. > Can you say a little about the linguistic convention for describing
  11475. > cfg-s?  What are it's advantages? Does it submit more readily to being
  11476. > manipulated by a program?  I once wrote Icon (what else?) programs to 
  11477. > manipulate a cfg, by putting it through its paces/transformations between 
  11478. > normal forms, factoring left recursion, et al.
  11479. > I would be interested in seeing an alternate representation than BNF
  11480. > that might offer conceptual improvements.
  11481.  
  11482. As someone working in Natural Language Processing (NLP), i'll jump
  11483. into the fray:
  11484.  
  11485. There really is no single linguistic convention for representing CFGs,
  11486. and it's not at all clear that CFGs are sufficiently powerful for
  11487. representing NL (one classic case for this argument is a construction
  11488. like "John, Bill, and Fred love Mary, Sally, and Julie,
  11489. respectively"). Most current lingustic theories use grammars whose
  11490. power is somewhere between context-free and context-sensitive,
  11491. inclusive. In addition to strictly parsing, there are also the
  11492. problems of building semantic representations (since it usually
  11493. doesn't do much good to simply represent the structure of a sentence:
  11494. you want to know what it *means*). 
  11495.  
  11496. Note to Richard Goerwitz: left-recursion is only a problem if you are
  11497. parsing top-down, and that's not a foregone conclusion. In fact, many
  11498. very good NLP systems use bottom-up parsing for independent reasons. 
  11499.  
  11500. > This looks like what we compiler wonks do when we check non-syntactic
  11501. > things (like whether something is declared or not...) during the translation
  11502. > process.  Is there a better (more fully encompassing) formalism here?  That
  11503. > is, syntax-with-ad-hoc-checking is highly impure...
  11504.  
  11505. One popular approach these days is unification-based formalisms, where
  11506. the agreement checking is at least not quite so ad hoc. DCGs under
  11507. Prolog are a well-known instance, although one can also do unification
  11508. in many other languages (we use a unification-based formalism in
  11509. Lisp). 
  11510.  
  11511. > Has anyone successfully parsed
  11512. >     "The policeman raised his hand and stopped the car"
  11513. >         (Courtesy of R. Schank.)
  11514.  
  11515. This isn't really a parsing problem (this sentence is pretty clearly a
  11516. conjoined verb phrase with a single subject noun phrase), but a
  11517. problem of semantics: the raised hand "primes" one to think that he
  11518. stopped it by contacting the car, but the pragmatics of this don't
  11519. work. We don't work on any traffic domains :-) but this doesn't seem
  11520. all that problematic to the generally-naive semantics of most of
  11521. today's NLP systems. 
  11522.  
  11523. Hope this is helpful.
  11524.  
  11525. ........................................
  11526. Sean Boisen -- sboisen@bbn.com
  11527. BBN Systems and Technologies Corporation, Cambridge MA
  11528. Disclaimer: these opinions void where prohibited by lawyers.
  11529.  
  11530. From goer@sophist.uchicago.EDU  Mon Apr 30 09:32:04 1990
  11531. Resent-From: goer@sophist.uchicago.EDU
  11532. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11533.     id AA17729; Mon, 30 Apr 90 09:32:04 MST
  11534. Return-Path: goer@sophist.uchicago.EDU
  11535. Received: from tank.uchicago.edu by Arizona.EDU; Mon, 30 Apr 90 09:33 MST
  11536. Received: from sophist.uchicago.edu by tank.uchicago.edu Mon, 30 Apr 90
  11537.  11:32:14 CDT
  11538. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA03522; Mon, 30 Apr 90
  11539.  11:28:01 CDT
  11540. Resent-Date: Mon, 30 Apr 90 09:33 MST
  11541. Date: Mon, 30 Apr 90 11:28:01 CDT
  11542. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  11543. Subject: encompassing formalism (stealing from Prolog)
  11544. Resent-To: icon-group@cs.arizona.edu
  11545. To: icon-group@arizona.edu
  11546. Resent-Message-Id: <A07A95FC09FFA0900F@Arizona.EDU>
  11547. Message-Id: <9004301628.AA03522@sophist.uchicago.edu>
  11548. X-Envelope-To: icon-group@CS.Arizona.EDU
  11549. X-Vms-To: icon-group@Arizona.edu
  11550. Status: O
  11551.  
  11552.     Can you say a little about the linguistic convention for describing
  11553.     cfg-s?  What are it's advantages? Does it submit more readily to being
  11554.     manipulated by a program?
  11555.  
  11556. You know, I should throw in here that linguists are pretty bad about notation
  11557. as well.  On of the tremendous annoyances a researcher in a specific language
  11558. field runs into is the proliferation of formalisms to represent grammars of
  11559. various kinds.  The most prominent methods are two.  The first is a notation
  11560. for context-sensitive grammars.  For instance, in Akkadian, you have a rule
  11561. which deletes short vowels in open syllables if preceded by another syllable
  11562. with a short vowel and followed by another syllable (below, V: is a long vowel,
  11563. while V is short):
  11564.  
  11565.      V -> 0 / CVC_CV
  11566.  
  11567. I.e. a short vowel, V, goes to nut'n (zero) in the context consonant, vowel,
  11568. consonant, ___, consonant, vowel (where the blank is our vowel).  Linguists
  11569. try to keep one symbol on the right, thus preventing the notation from lean-
  11570. ing towards an unrestricted rewrite system.
  11571.  
  11572. The other formalism is more process-oriented (hence it is ironic that Prolog
  11573. is the main language which implements it).  You say -
  11574.  
  11575.       S -> NP VP
  11576.  
  11577. and what not (i.e. "a sentence may be broken down into a noun phrase and a
  11578. verb phrase," or, depending on your model, "a sentence consists of" [more
  11579. like a definition).  Anyway, it's pretty much like the Backus-Naur formal-
  11580. ism, though it is less well-defined, and tends to get modified ad hoc by
  11581. everyone who uses it.
  11582.  
  11583. Particularly interesting for us here is the way Prolog implements this for-
  11584. malism.  Assuming the Prolog you use implements definite clause grammar no-
  11585. tation, you can say,
  11586.  
  11587.       s --> np(Number), vp(Number).
  11588.       np(Number) --> det, n(Number).
  11589.       vp(Number) --> v, np.
  11590.       det --> [the].
  11591.       n(singular) --> [woman]
  11592.       n(plural) --> [husbands]
  11593.       v(singular) --> [love]
  11594.  
  11595. etc.  You get the idea.  I don't see any reason that this couldn't be im-
  11596. plemented EASILY in Icon.  And Icon has some neat advantages over Prolog,
  11597. such as very good string handling.  There needs to be some research on just
  11598. how far these indexed grammars can represent natural languages.  They are
  11599. kind of an intemediate creature on the hierarchy of grammar types - some-
  11600. thing that has not really been studied a great deal.
  11601.  
  11602. Recently a formalism called PATR has been evolved.  This formalism has been
  11603. implemented in Prolog and Lisp.  PATR is an extension, so far as I can see,
  11604. of this definite clause notation we seen in Prolog.  I have toyed with doing
  11605. it in Icon.  The question is whether to create a PATR -> Icon translator
  11606. that outputs code that must be translated and linked, or if it should be
  11607. permit the user to "consult" a database at run-time.
  11608.  
  11609. In my find_re posting (which, incidentally had yet a few small bugs, since
  11610. after all it *was* version 0.9; it is very usable, though, and I hope that
  11611. people test it) I adopted the run-time approach.  Basically I just did what
  11612. regex does - it compiles a string representation of a finite state transi-
  11613. tion network into an automaton, stored in a small table (and which can be
  11614. eval()'d any time).  I dunno what would be best with PATR.  Both facilities
  11615. would be nice.  Icon is a very good language for natural language proces-
  11616. sing, and I would like very much to see it gain greater popularity in a
  11617. field now dominated by (lots (of (and (extremely annoying) (unintuitive))
  11618. parentheses)).
  11619.  
  11620.  
  11621.  
  11622.  
  11623.  
  11624.   I once wrote Icon (what else? programs to 
  11625.     manipulate a cfg, by putting it through its paces/transformations between 
  11626.     normal forms, factoring left recursion, et al.
  11627.     
  11628.     I would be interested in seeing an alternate representation...
  11629.     
  11630.     > 
  11631.     >            The woman loves me.
  11632.     >            The woman I married loves me.
  11633.     >            The woman I married, who won't love me if my son and I forget
  11634.     >              Mother's Day, loves me.
  11635.     > 
  11636.     > There are two problems here:  1) We have to get the verb phrase - something
  11637.     > that must be defined separately from the noun phrase - to know about what
  11638.     > is going on in the noun phrase, namely that it is singular (hence "loves" and
  11639.     > not "love."  The other problem (2) is what I mentioned before, namely left re-
  11640.     > cursion in the grammar.  Another thing to consider is the arbitrary complexity
  11641.     > of the noun phrase, and the theoretically unlimited distance that separates
  11642.     > the main noun of that phrase (above = "woman") from the verb phrase ("loves
  11643.     > me").
  11644.     > 
  11645.     > Phrase structure grammars, BNFs, regular expressions, definite clause grammars
  11646.     > without indexing - whatever you happen to call them (they are all context free)
  11647.     > - are, to the linguist, not of most central interest.
  11648.     > 
  11649.     > As I hinted at above, the problem of the verb knowing what the noun before it
  11650.     > is doing number-wise can be solved.  In Prolog you do it using indexed gram-
  11651.     > mars.  In Icon, the solution looks pretty straightforward, even elegant.
  11652.     > Just have your matching procedures return a value.  This has the effect of
  11653.     > allowing nodes to have labels.  I'd tend to want to create a list, and then
  11654.     > have each node, if it wishes, simply return a value, which is then "put" into
  11655.     > a list and returned (or put into another list by the calling node, or whatever).
  11656.     > Anyway, all you would have to do is make sure that neither the noun phrase
  11657.     > nor the verb phrase conflict as to number (in this case, I'd just check to
  11658.     > be sure that, if the one is marked "singular," the other is as well).
  11659.     
  11660.     This looks like what we compiler wonks do when we check non-syntactic
  11661.     things (like whether something is declared or not...) during the translation
  11662.     process.  Is there a better (more fully encompassing) formalism here?  That
  11663.     is, syntax-with-ad-hoc-checking is highly impure...
  11664.     
  11665.     > 
  11666.     > Again, I'd really like to see some comments by someone who has studied the
  11667.     > syntax of natural languages in more detail than I.  It just seemed useful
  11668.     > to provide a little input from linguistics.  It will be useful in the long
  11669.     > run, I think, if I keep reminding computer scientists that their work has
  11670.     > implications in closely related fields.
  11671.     
  11672.     So would I...
  11673.     
  11674.     Has anyone successfully parsed
  11675.         "The policeman raised his hand and stopped the car"
  11676.             (Courtesy of R. Schank.)
  11677.         
  11678.     >     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  11679.     >     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  11680.     > 
  11681.     > 
  11682.     
  11683.     Mark
  11684.     
  11685.  
  11686.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  11687.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  11688.  
  11689. From ralph  Mon Apr 30 09:48:30 1990
  11690. Date: Mon, 30 Apr 90 09:48:30 MST
  11691. From: "Ralph Griswold" <ralph>
  11692. Message-Id: <9004301648.AA18532@megaron.cs.arizona.edu>
  11693. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  11694.     id AA18532; Mon, 30 Apr 90 09:48:30 MST
  11695. To: icon-group
  11696. Subject: Version 8 of Icon for personal computers
  11697. Status: O
  11698.  
  11699. Version 8 of Icon for personal computers is now available.
  11700.  
  11701. In addition to Version 8 for MS-DOS, announced earlier, there are
  11702. now implementations for the Amiga, the Atari ST, and the Macintosh (under MPW).
  11703.  
  11704. There are two packages for each computer -- one contains executable binary
  11705. files and the other contains source code. 1MB of RAM is about the minimum for
  11706. successful use.
  11707.  
  11708. Version 8 of Icon for these computers can be obtained by anonymous FTP
  11709. to cs.arizona.edu. After connecting, cd /icon/v8. Get READ.ME there for more
  11710. information.
  11711.  
  11712. If you do not have FTP access or prefer to obtain diskettes and printed
  11713. documentation, Version 8 of Icon for for the computers listed above can be
  11714. ordered from:
  11715.  
  11716.     Icon Project
  11717.     Department of Computer Science
  11718.     Gould-Simpson Building
  11719.     The University of Arizona
  11720.     Tucson, AZ   85721
  11721.  
  11722.     602 621-2018 (voice)
  11723.     602 621-4246 (FAX)
  11724.  
  11725. Specify whether you want executable binaries, source code, or both.
  11726.  
  11727. The packages are $15 each, payable in US dollars to The University of Arizona
  11728. with a check written on a bank in the United States.  Orders also can be
  11729. charged to MasterCard or Visa.  The price includes shipping by parcel post
  11730. in the United States, Canada, and Mexico. Add $5 per package for air mail
  11731. delivery to other countries.
  11732.  
  11733. Please direct any questions to me, not to icon-project or icon-group.
  11734.  
  11735.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  11736.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  11737.  
  11738.  
  11739. From reid@ctc.contel.COM  Mon Apr 30 10:47:52 1990
  11740. Resent-From: reid@ctc.contel.COM
  11741. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11742.     id AA23971; Mon, 30 Apr 90 10:47:52 MST
  11743. Received: from ctc.contel.com (turing.ctc.contel.com) by Arizona.EDU; Mon, 30
  11744.  Apr 90 10:49 MST
  11745. Received: from demo360.ctc.contel.com by ctc.contel.com (4.0/SMI-4.0) id
  11746.  AA04565; Mon, 30 Apr 90 13:47:19 EDT
  11747. Resent-Date: Mon, 30 Apr 90 10:49 MST
  11748. Date: Mon, 30 Apr 90 13:47:19 EDT
  11749. From: reid@ctc.contel.COM
  11750. Subject: RE:  grammars, questions
  11751. Resent-To: icon-group@cs.arizona.edu
  11752. To: icon-group@arizona.edu
  11753. Resent-Message-Id: <A06FFFB52ADFA095D1@Arizona.EDU>
  11754. Message-Id: <9004301747.AA04565@ctc.contel.com>
  11755. X-Envelope-To: icon-group@CS.Arizona.EDU
  11756. X-Vms-To: icon-group@Arizona.edu
  11757. Status: O
  11758.  
  11759. > > It appears that Icon has no trouble representing
  11760. > > context free languages, with the restriction that there can be no left-
  11761. > > recursion in the grammar.
  11762. > Certain special cases of left-recursion can be converted into looping.
  11763. > Unfortunately, this bounds backtracking so to you have to know that
  11764. > backtracking won't find other solutions.
  11765. > For example, the production
  11766. > s ::=  t  |  s "+" t
  11767. > can be parsed with a procedure something like
  11768. > procedure s()
  11769. >    x := []
  11770. >    push(x, t()) | fail
  11771. >    while ="+" do
  11772. >       push(x, t()) | stop("syntax error")
  11773. >    return x
  11774. > end
  11775.  
  11776. Look at converting your LL1-style BNF to extended BNF (EBNF).  Three nice
  11777. things happen:
  11778.  
  11779. 1) your grammar is shorter, much more readable and no left recursion 
  11780.    is needed
  11781.  
  11782. 2) the implementing procedure for a nonterminal is real straight 
  11783.    forward and
  11784.  
  11785. 3) adding attributes and semantic actions is much easier.
  11786.  
  11787. Tom.
  11788.  
  11789. Thomas F. Reid, Ph. D.                   (703)818-4505 (work)
  11790. Contel Technology Center                 (703)742-8720 (home)
  11791. 15000 Conference Center Drive            Net: reid@ctc.contel.com
  11792. P.O. Box 10814  
  11793. Chantilly, Va.  22021-3808
  11794.  
  11795. From goer@sophist.uchicago.EDU  Mon Apr 30 12:28:33 1990
  11796. Resent-From: goer@sophist.uchicago.EDU
  11797. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11798.     id AA02825; Mon, 30 Apr 90 12:28:33 MST
  11799. Return-Path: goer@sophist.uchicago.EDU
  11800. Received: from tank.uchicago.edu by Arizona.EDU; Mon, 30 Apr 90 12:29 MST
  11801. Received: from sophist.uchicago.edu by tank.uchicago.edu Mon, 30 Apr 90
  11802.  14:28:40 CDT
  11803. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA03997; Mon, 30 Apr 90
  11804.  14:24:28 CDT
  11805. Resent-Date: Mon, 30 Apr 90 12:30 MST
  11806. Date: Mon, 30 Apr 90 14:24:28 CDT
  11807. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  11808. Subject: clarification requested
  11809. Resent-To: icon-group@cs.arizona.edu
  11810. To: icon-group@arizona.edu
  11811. Resent-Message-Id: <A061ED019A3FA087A6@Arizona.EDU>
  11812. Message-Id: <9004301924.AA03997@sophist.uchicago.edu>
  11813. X-Envelope-To: icon-group@CS.Arizona.EDU
  11814. X-Vms-To: icon-group@Arizona.edu
  11815. Status: O
  11816.  
  11817.  
  11818. # It has been asked of me that I clarify what I mean by implementing
  11819. # indexed grammars like Prolog's in Icon.  What follows here is a
  11820. # very simple example.  Note how Prolog has the advantage of either
  11821. # producing or recognizing.  Icon, however, has the advantage of
  11822. # providing an immediate interface with the outside world (no need
  11823. # for tokenizing or for giving input like :- s([the husband...],[])).
  11824. # Please don't anyone gripe about how incomplete the grammars are,
  11825. # or about the fact that the Prolog and Icon code are not exactly
  11826. # equivalent!  Maybe someone will kindly offer us a DCG -> Icon con-
  11827. # verter.
  11828. #
  11829. # Naturally, the Prolog is much shorter.  This is the sort of thing
  11830. # it was designed to do.
  11831. #
  11832. #   s --> np(Number), vp(Number).
  11833. #   np(Number) --> det, n(Number).
  11834. #   vp(Number) --> v(Number), np(_).
  11835. # % I get so tired of "man and wife"; let's try "woman and husband" :-)
  11836. #
  11837. #   n(singular) --> [woman].
  11838. #   n(plural) --> [husbands].
  11839. #   n(plural) --> [women].
  11840. #   n(singular) --> [husband].
  11841. #   v(singular) --> [loves].
  11842. #   v(singular) --> [hates].
  11843. #   v(plural) --> [hate].
  11844. #   v(plural) --> [love].
  11845. #   det --> [the].
  11846.  
  11847. procedure main()
  11848.     while input_line := trim(map(!&input),',.?!')
  11849.     do write(input_line ? S())
  11850. end
  11851.  
  11852. procedure S()
  11853.     NP() == VP() &
  11854.     pos(0) &
  11855.     (return "yes")
  11856.     return "no"
  11857. end
  11858.  
  11859. procedure NP()
  11860.     DET() &
  11861.     tag := N() &
  11862.     (suspend tag)
  11863. end
  11864.  
  11865. procedure VP()
  11866.     tag := V() &
  11867.     NP() | &null &
  11868.     (suspend tag)
  11869. end
  11870.  
  11871. procedure DET()
  11872.     ="the" &
  11873.     =" " | &null &
  11874.     suspend
  11875. end
  11876.  
  11877. procedure N()
  11878.     suspend Nsing() | Nplur()
  11879. end
  11880.  
  11881. procedure Nsing()
  11882.     wordlst := ["husband","woman"]
  11883.     =!wordlst &
  11884.     =" " | &null &
  11885.     (suspend "singular")
  11886. end
  11887.  
  11888. procedure Nplur()
  11889.     wordlst := ["husbands","women"]
  11890.     =!wordlst &
  11891.     =" " | &null &
  11892.     (suspend "plural")
  11893. end
  11894.  
  11895. procedure V()
  11896.     suspend Vsing() | Vplur()
  11897. end
  11898.  
  11899. procedure Vsing()
  11900.     wordlst := ["loves","hates"]
  11901.     =!wordlst &
  11902.     =" " | &null &
  11903.     (suspend "singular")
  11904. end
  11905.  
  11906. procedure Vplur()
  11907.     wordlst := ["love","hate"]
  11908.     =!wordlst &
  11909.     =" " | &null &
  11910.     (suspend "plural")
  11911. end
  11912.  
  11913.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  11914.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  11915.  
  11916. From reid@ctc.contel.com  Mon Apr 30 14:16:46 1990
  11917. Received: from turing.ctc.contel.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11918.     id AA11520; Mon, 30 Apr 90 14:16:46 MST
  11919. Received: from demo360.ctc.contel.com by ctc.contel.com (4.0/SMI-4.0)
  11920.     id AA05049; Mon, 30 Apr 90 17:16:55 EDT
  11921. Date: Mon, 30 Apr 90 17:16:55 EDT
  11922. From: reid@ctc.contel.com (Tom Reid  x4505)
  11923. Message-Id: <9004302116.AA05049@ctc.contel.com>
  11924. To: goer@sophist.uchicago.edu, icon-group@cs.arizona.edu
  11925. Subject: RE:  grammars, questions
  11926. Cc: reid@ctc.contel.com
  11927. Status: O
  11928.  
  11929. > From goer@sophist.uchicago.edu Mon Apr 30 14:58:46 1990
  11930. > From: Richard Goerwitz <goer@sophist.uchicago.edu>
  11931. > To: reid@ctc.contel.com
  11932. > Subject: RE:  grammars, questions
  11933. > What are LL1-style BNFs?  It's the LL1 that I don't understand.
  11934. > You don't need to post this to the group, unless you want to
  11935. > approach this as an "in case not everyone knows what we're talk-
  11936. > ing about, here's some background" type posting.
  11937. >     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  11938. >     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  11939.  
  11940. Richard (and others):
  11941.  
  11942. Sorry about that.  LL1 grammars are a subset of context-free grammars (cfgs)
  11943. that arose in (automatic) parser construction.  There are two kinds of
  11944. classical parsers: bottom-up and top-down.  Bottom-up spawned the LR, LALR,
  11945. etc. cfg-subset grammars as the largest languages recognized by 
  11946. particular kinds of pushdown automata (PDA) which recognized in linear time 
  11947. and space.  
  11948.  
  11949. In order to design a top-down predictive, recursive descent parser, you 
  11950. needed to restrict cfgs to what was termed ll1 grammars.  The two basic 
  11951. restrictions were that no production could have left recursion and that you 
  11952. could not have common prefixes.  The reason for both is in the following 
  11953. example.
  11954.  
  11955. Assume that 
  11956.     A ::= q1
  11957.     A ::= q2
  11958.        ...
  11959.     A ::= qn
  11960. are A's productions in a grammar G.  In order for G to be LL1 (and thus have
  11961. a non ambiguous, non backtracking recursive descent parser), the FIRST
  11962. sets of q1, q2, ..., qn must be disjoint (i.e., in order to to have
  11963. backtracking, the PDA must be able to uniquely choose which A-production
  11964. to apply by looking at just the next token).  Unless the language is
  11965. trivial, the FIRST set of the left recursive production A := A .. 
  11966. would contain all the other FIRST symbols.
  11967.  
  11968. Oh yes, the FIRST set for a production is the set of all terminal symbols
  11969. which can begin a string derived from that symbol.
  11970.  
  11971.  
  11972. From @RELAY.CS.NET,@dg-rtp.rtp.dg.com:langley@DG-RTP.DG.COM  Tue May  1 05:51:44 1990
  11973. Received: from relay.cs.net by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  11974.     id AA09247; Tue, 1 May 90 05:51:44 MST
  11975. Received: from dg-rtp.rtp.dg.com by RELAY.CS.NET id aa16747; 1 May 90 8:51 EDT
  11976. Received: from bigbird.rtp.dg.com by dg-rtp.dg.com (4.20/4.7)
  11977.     id AA28301; Tue, 1 May 90 08:49:18 edt via SMTP
  11978. Received: by bigbird.rtp.dg.com (4.20/rtp-s01)
  11979.     id AA19283; Tue, 1 May 90 08:50:20 edt
  11980. Date: Tue, 1 May 90 08:50:20 edt
  11981. From: Mark L Langley <langley@DG-RTP.DG.COM>
  11982. Message-Id: <9005011250.AA19283@bigbird.rtp.dg.com>
  11983. Return-Receipt-To: langley@dg-rtp.dg.com
  11984. To: icon-group@cs.arizona.edu
  11985. Subject: Challenge! & more on grammars, questions
  11986. Status: O
  11987.  
  11988. <the <Challenge> is at the end, skip ahead if you like...>
  11989.  
  11990. Richard Goerwitz asks
  11991. > > 
  11992. > > What are LL1-style BNFs?  
  11993. > Richard (and others):
  11994. To which Tom Reid replied
  11995. > Sorry about that.  LL1 grammars are a subset of context-free grammars (cfgs)
  11996. > that arose in (automatic) parser construction.  There are two kinds of
  11997. > classical parsers: bottom-up and top-down.  Bottom-up spawned the LR, LALR,
  11998. > etc. cfg-subset grammars as the largest languages recognized by 
  11999. > particular kinds of pushdown automata (PDA) which recognized in linear time 
  12000. > and space.  
  12001. If I may add a little,...
  12002.  
  12003. LL(1) refers to LEFT-scan-of-input (i.e. reading left to right), producing
  12004. a LEFTmost derivation, using at most ONE token of lookahead.  Thus LR(1)
  12005. means producing a rightmost derivation.  LALR(1) means Look-ahead LR(1)
  12006. which is a technique for reducing LR parsing which are linear (though huge)
  12007. to something a lot smaller.  (The Icon parser is written in YACC, which is
  12008. an LALR parser generator.)  LALR(1) is theoretically less powerful than LR(1)
  12009. but I have never found a grammar I couldn't rewrite.
  12010.  
  12011. LL parsing is the same thing as recursive descent parsing.  It is generally 
  12012. thought to be more intuitive -- you can think about an LL parser as always
  12013. making forward progress by consuming one token per state.  LR parsing detects
  12014. errors as soon as is possible.  (i.e. the fewest number of tokens that
  12015. can't be something legitimate are flagged, whereas LL parsers may kick
  12016. around and not report an error right away.)
  12017.  
  12018. While LL parsers can't handle Left-recursion, Alternatively LR parsers 
  12019. don't like right-recursion.  It tends to overflow the internal pushdown
  12020. stack.  For example, matching parenthesis using right-recursion in LR
  12021. is bad.  Therefore in LR and LALR you should rewrite your rules to be 
  12022. left recursive.  This is usually a mechanical process, but not always.
  12023. (Consider what happens if you are expecting some action to take place
  12024. at the same time a production is matched.)
  12025.  
  12026. <Challenge>
  12027.  
  12028. There is a well-known theorem (I couldn't find it) that states that any
  12029. LL(k) grammar can be rewritten as an LL(1) grammar.  This is easy to see
  12030. because you can keep "left-factoring" productions.
  12031.  
  12032. Can you rewrite an arbitrary LR(k) grammar as an LR(1) grammar?
  12033.  
  12034. I have yet to find an LR(k) grammar that I couldn't rewrite, but I haven't
  12035. successfully proven the theorem either...  But I'm not a bright 
  12036. theoretician...
  12037.  
  12038. Anybody?
  12039. Mark
  12040.  
  12041. From @mirsa.inria.fr:ol@cerisi.cerisi.Fr  Tue May  1 11:04:23 1990
  12042. Received: from mirsa.inria.fr by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  12043.     id AA28571; Tue, 1 May 90 11:04:23 MST
  12044. Received: from cerisi.cerisi.fr by mirsa.inria.fr with SMTP
  12045.     (5.59++/IDA-1.2.8) id AA04105; Tue, 1 May 90 20:05:37 +0200
  12046. Message-Id: <9005011805.AA04105@mirsa.inria.fr>
  12047. Date: Tue, 1 May 90 20:03:23 -0100
  12048. Posted-Date: Tue, 1 May 90 20:03:23 -0100
  12049. From: Lecarme Olivier <ol@cerisi.cerisi.Fr>
  12050. To: langley@DG-RTP.DG.COM
  12051. Cc: icon-group@cs.arizona.edu
  12052. In-Reply-To: Mark L Langley's message of Tue, 1 May 90 08:50:20 edt <9005011250.AA19283@bigbird.rtp.dg.com>
  12053. Subject: Challenge! & more on grammars, questions
  12054. Status: O
  12055.  
  12056. The theorem that for every LR(k) grammar with k>1 there exists an
  12057. equivalent LR(1) grammar is only stated by Waite & Goos (Compiler
  12058. construction, Springer-Verlag 1984), but it is demonstrated by Aho &
  12059. Ullman (The theory of parsing, translation, and compiling, Prentice-Hall
  12060. 1972). Unfortunately, as explained by Waite & Goos, "the transformation
  12061. underlying the proof of this theorem is unsuitable for practical
  12062. purposes".
  12063.  
  12064.  
  12065.                 Olivier Lecarme
  12066.  
  12067. From icon-group-request@arizona.edu  Tue May  1 13:57:01 1990
  12068. Resent-From: icon-group-request@arizona.edu
  12069. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  12070.     id AA12403; Tue, 1 May 90 13:57:01 MST
  12071. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 1 May 90 13:53 MST
  12072. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA17432; Tue, 1 May 90 13:15:57
  12073.  -0700
  12074. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  12075.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  12076.  usenet@ucbvax.Berkeley.EDU if you have questions)
  12077. Resent-Date: Tue, 1 May 90 13:57 MST
  12078. Date: 1 May 90 20:00:17 GMT
  12079. From: tank!sophist!goer@handies.ucar.EDU
  12080. Subject: RE: linguism
  12081. Sender: icon-group-request@arizona.edu
  12082. Resent-To: icon-group@cs.arizona.edu
  12083. To: icon-group@arizona.edu
  12084. Resent-Message-Id: <9F8C8DA101FFA097D5@Arizona.EDU>
  12085. Message-Id: <9062@tank.uchicago.edu>
  12086. Organization: University of Chicago
  12087. X-Envelope-To: icon-group@CS.Arizona.EDU
  12088. X-Vms-To: icon-group@Arizona.edu
  12089. References: <9004301500.AA06810@bigbird.rtp.dg.com>,
  12090.  <9004301617.AA16804@megaron.cs.arizona.edu>
  12091. Status: O
  12092.  
  12093. In article <9004301617.AA16804@megaron.cs.arizona.edu> sboisen@BBN.COM writes:
  12094. >> Can you say a little about the linguistic convention for describing
  12095. >...it's not at all clear that CFGs are sufficiently powerful for
  12096. >representing NL (one classic case for this argument is a construction
  12097. >like "John, Bill, and Fred love Mary, Sally, and Julie,
  12098. >respectively").
  12099.  
  12100. I'd think that the real problem here is that the noun phrases must be
  12101. recursively defined (as someone pointed out, it's not problem if we
  12102. are using a bottom-up parser).
  12103.  
  12104. I think what the argument here is is that the two noun phrases, "John,
  12105. Bill, and Fred" and "Mary, Sally, and Julie" must be of equal length.
  12106. I dunno.  We should probably extend this statement even further.  We
  12107. should probably be saying that the two noun phrases have to have equal
  12108. length AND that each member in the first set should plausibly be able
  12109. to "love" the corresponding member in the second set.  Both of these
  12110. criteria, the length of the noun phrases, and the applicability of
  12111. the action "love" to each of the respective members are really se-
  12112. mantic considerations.
  12113.  
  12114. Let me explain this another way.  From the standpoint of the grammar,
  12115. there is absolutely nothing wrong with saying, "John, Bill, and Fred
  12116. love Mary, Sally, and Julie."  You can, if you want, tack on an ad-
  12117. verb, "J, B, and F love M, S, and J very much."  Whether that adverb
  12118. is "respectively" or "very much" is not important to the grammar.
  12119. The consideration that the length of the noun phrases must "make
  12120. sense" (i.e. be of the same length, and have members that can love
  12121. and be loved) is extraneous to the basic grammar.  Perhaps we should
  12122. be integrating syntax and semantics from the start.  Still, looking at
  12123. this sentence in the terms we in this group are currently discussing
  12124. parsing problems, the word "respectively" cannot be said to impose
  12125. any extraordinary new organization on a sentence.  It is just an
  12126. adverb which the speaker may or may not add, depending on what his/her
  12127. meaning is, and whether the word makes sense in the context of what
  12128. is being said.
  12129.  
  12130. Perhaps irrelevant side note:  How often do you really hear people
  12131. use the term, respectively, in the context you mentioned?  Just cu-
  12132. rious.  To me it is primarily an affectation of the educated, and
  12133. I rarely hear even them using it in contexts where more than two
  12134. things are being respectively-ed.  This is due to the fact that
  12135. people don't naturally think about how many members are in the
  12136. noun phrases they are using, and it's pretty easy to forget, and,
  12137. say, put four nouns in the first set, and five in the second.  The
  12138. very fact that we have to strain at this construction tells me that
  12139. it is not really a fundamental part of the grammar in the same sense
  12140. as is the fact that most sentences consist of a noun and a verb
  12141. phrase.
  12142.  
  12143. Point:  Many such examples where natural languages are said to re-
  12144. quire exotic parsing mechanisms in fact may not.  What they re-
  12145. quire is a way of integrating semantics more closely into syntax.
  12146. We also have to keep our eyes peeled for cases where marginal or
  12147. literary usage is thrust into the core of the grammar.  In most
  12148. such cases there is indeed a important process at work.  How-
  12149. ever, this process rarely belongs in the basic structural me-
  12150. chanisms.  In the case of "respectively," I believe the correct
  12151. interpretation resides in the interactions of syntax and seman-
  12152. tics.
  12153.  
  12154. I'd appreciate argument on this point, especially if it is ac-
  12155. companied by Icon code!
  12156.  
  12157.    -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  12158.    goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  12159.  
  12160. From icon-group-request@arizona.edu  Tue May  1 18:02:30 1990
  12161. Resent-From: icon-group-request@arizona.edu
  12162. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  12163.     id AA29079; Tue, 1 May 90 18:02:30 MST
  12164. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 1 May 90 18:02 MST
  12165. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA04828; Tue, 1 May 90 17:54:00
  12166.  -0700
  12167. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  12168.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  12169.  usenet@ucbvax.Berkeley.EDU if you have questions)
  12170. Resent-Date: Tue, 1 May 90 18:04 MST
  12171. Date: 1 May 90 15:12:40 GMT
  12172. From: ntvax!leff@tut.cis.ohio-state.EDU
  12173. Subject: Reversible Assignment Problem
  12174. Sender: icon-group-request@arizona.edu
  12175. Resent-To: icon-group@cs.arizona.edu
  12176. To: icon-group@arizona.edu
  12177. Resent-Message-Id: <9F6A1EE99FFFA09F0F@Arizona.EDU>
  12178. Message-Id: <1990May1.151240.11020@dept.csci.unt.edu>
  12179. Organization: University of North Texas
  12180. X-Envelope-To: icon-group@CS.Arizona.EDU
  12181. X-Vms-To: icon-group@Arizona.edu
  12182. Status: O
  12183.  
  12184.  
  12185. Reversible assignments to global variables inside procedures are
  12186. not being reversed. 
  12187.  
  12188. The program below prints out three.  It should print out one.  Obviously,
  12189. the reversible assignment to z is not being reversed when test does not 
  12190. lead to an eventual success.
  12191.  
  12192. Why does the reversing of the assignment not take place, and what would
  12193. make it do so?
  12194.  
  12195. The Icon Programming Language, Chapter 11, section 11.8.2 did not shed
  12196. any light on these issues.
  12197.  
  12198. global z
  12199. procedure test(i)
  12200. z<-z+1
  12201. if i~=3 then fail
  12202. if i=3 then return 1
  12203. end
  12204.  
  12205. procedure main()
  12206. z:=0
  12207. every i:=(1 to 10) do if test(i) then write("test succeeded ",i," ",z)
  12208. end
  12209.  
  12210.  
  12211. From goer@sophist.uchicago.EDU  Tue May  1 19:28:53 1990
  12212. Resent-From: goer@sophist.uchicago.EDU
  12213. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  12214.     id AA04110; Tue, 1 May 90 19:28:53 MST
  12215. Return-Path: goer@sophist.uchicago.EDU
  12216. Received: from tank.uchicago.edu by Arizona.EDU; Tue, 1 May 90 19:28 MST
  12217. Received: from sophist.uchicago.edu by tank.uchicago.edu Tue, 1 May 90 21:27:23
  12218.  CDT
  12219. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA06119; Tue, 1 May 90
  12220.  21:23:09 CDT
  12221. Resent-Date: Tue, 1 May 90 19:28 MST
  12222. Date: Tue, 1 May 90 21:23:09 CDT
  12223. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  12224. Subject: reversible assignment
  12225. Resent-To: icon-group@cs.arizona.edu
  12226. To: icon-group@arizona.edu
  12227. Resent-Message-Id: <9F5E450635BFA0A633@Arizona.EDU>
  12228. Message-Id: <9005020223.AA06119@sophist.uchicago.edu>
  12229. X-Envelope-To: icon-group@CS.Arizona.EDU
  12230. X-Vms-To: icon-group@Arizona.edu
  12231. Status: O
  12232.  
  12233.  
  12234. # Reversible assignments to global variables inside procedures are
  12235. # not being reversed.
  12236. #
  12237. # The program below prints out three.  It should print out one.  Obviously,
  12238. # the reversible assignment to z is not being reversed when test does not 
  12239. # lead to an eventual success.
  12240. #
  12241. # Why does the reversing of the assignment not take place, and what would
  12242. # make it do so?
  12243. #
  12244. # The Icon Programming Language, Chapter 11, section 11.8.2 did not shed
  12245. # any light on these issues.
  12246.  
  12247.  
  12248. global z
  12249.  
  12250. procedure test(i)
  12251.  
  12252.   z<-z+1
  12253.   if i~=3 then fail
  12254.   if i=3 then return 1
  12255.  
  12256. end
  12257.  
  12258.  
  12259.  
  12260. procedure main()
  12261.  
  12262.   z:=0        # not needed!!!!!
  12263.   every i:= 1 to 10
  12264.   do if test(i)
  12265.      then write("test succeeded ",i," ",z)
  12266.  
  12267. end
  12268.  
  12269.  
  12270.  
  12271. Okay, it appears that you are misunderstanding the purpose of reversible
  12272. assignment, and, because of this, are not quite getting the idea of how
  12273. and when to use it (or how it behaves when you do).  Don't worry.  You
  12274. aren't the only one who has had trouble with this....
  12275.  
  12276. Basically, Icon is set up for control backtracking.  Hence if you say
  12277.  
  12278.     i := 0
  12279.     i +:= |1 & i = 5
  12280.  
  12281. the i = 5 comparison will fail at first.  So the expression will back-
  12282. track to the i +:= |1 expression to see if it can produce another re-
  12283. sult.  The assignment itself doesn't produce another result; however
  12284. the expression |1 can (basically | before something makes Icon do it
  12285. repeatedly).  Hence it produces another 1, and that 1 is then added
  12286. (+:=) to i to make i one bigger.  This assignment operation succeeds,
  12287. and so control passes to the i = 5 comparison.  This fails, and so the
  12288. process of backtracking and incrementing is repeated once again.
  12289.  
  12290. Note that throughout this process, the i, when it is assigned a value,
  12291. keeps that value, even if the expression i +:= |1 is being resumed.
  12292. That is, if you add 1 to i, then go on to test whether i is equal to
  12293. 5, and then resume to increment i again - if you do this, the i will
  12294. not get reset to whatever value it had before you started.  It will
  12295. keep the last assigned value.  This is what makes it get bigger every
  12296. time i +:= 1 is resumed, rather then going back to the original value
  12297. it had.  Eventually it will reach the value of 5, and the expression
  12298. as a whole will succeed.
  12299.  
  12300. Sometimes this feature isn't wanted.  Sometimes you don't want the
  12301. i to keep the value you gave it if it is resumed.  Let me offer a
  12302. silly example:
  12303.  
  12304.     str := "string of nonsensical strings"
  12305.     59 < (position <- find("string",str))
  12306.         if \position
  12307.     then write("the word \"string\" occurs after position 13")
  12308.     else write("the word \"string\" occurs before position 14")
  12309.  
  12310. Essentially, position will be assigned the value of the find ex-
  12311. pression, and then its value will be compared with 59.  If it is
  12312. less than or equal to 59 (which it will be every time the com-
  12313. parison takes place), then the expression (position <- find(...))
  12314. will get resumed.  When it is resumed, the former assignment of
  12315. position will get undone.  Then it will be assigned a new value,
  12316. and the comparison will be made again.  On the next resumption, find
  12317. will fail.  There are only two places where "string" occurs in str.
  12318. Because we included the reversible assignment operator, position
  12319. will be returned to its former value (namely &null), and control
  12320. will move to the next line.
  12321.  
  12322. I know that this example is silly, but I wanted to illustrate the
  12323. point without having to get into string scanning (the place where
  12324. reversible assignment seems most handy).  You'll eventually get to
  12325. the chapter in Griswold & Griswold on complex string processing.
  12326. The Arb() procedure is a nice little example of where you really
  12327. have to have reversible assignment.  Put in general terms, re-
  12328. versible assignment makes backtracking undo assignments.  Normally
  12329. backtracking doesn't do this.
  12330.  
  12331. Now, to your sample program.  I don't know exactly what you would
  12332. be using this for, but it doesn't matter.  If I say
  12333.  
  12334.     a <- 1
  12335.  
  12336. a will be assigned the value of 1.  Nothing will change this be-
  12337. cause the expression a <- 1 will not be resumed.  I have heard
  12338. the term "bounded" applied to this situation.  Whatever you call
  12339. it, it means it's done and that's it.  Even if the procedure in
  12340. which it occurs is resumed, you won't see any change.  It is only
  12341. if you set it in a context where the expression itself will be
  12342. resumed will you see any effects.  You might write, for example,
  12343.  
  12344.     a <- 1 & open("inputfile","r")
  12345.  
  12346. If the open() function fails to open "inputfile," then the ex-
  12347. pression a <- 1 will be resumed.  Since there are no generators
  12348. there, it will not produce another result, and a will be returned
  12349. to the value it had before the assignment was made.
  12350.  
  12351. I hope that this long-winded discursus helps you.  Basically,
  12352. I'd stay away from reversible assignment until you have gotten
  12353. past generators, and into string scanning far enough to understand
  12354. say, the Arb() program.  Your basic misconception is that if
  12355. a procedure is called in which reversible assignment occurs
  12356. the assignment will be undone.  This isn't the case.  It is 
  12357. only if the expression in which it occurs causes control to
  12358. backtrack through the assignment that it will be undone.
  12359.  
  12360. It's nice to see questions like this on this newsgroup.  The
  12361. surveys tell us that most Icon users call themselves beginners
  12362. or, perhaps, intermediate-ers.  I sometimes wonder whether the
  12363. fact that discussion here is dominated by people who have been
  12364. doing Icon for some time intimidates these people, or whether
  12365. they feel they are wasting bandwidth.  It's not a waste at all!
  12366. Don't be intimidated!
  12367.  
  12368. -Richard
  12369.  
  12370. From wgg@cs.washington.EDU  Tue May  1 21:01:22 1990
  12371. Resent-From: wgg@cs.washington.EDU
  12372. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  12373.     id AA09716; Tue, 1 May 90 21:01:22 MST
  12374. Return-Path: wgg@cs.washington.EDU
  12375. Received: from june.cs.washington.edu by Arizona.EDU; Tue, 1 May 90 21:01 MST
  12376. Received: by june.cs.washington.edu (5.61/7.0jh) id AA04237; Tue, 1 May 90
  12377.  20:59:24 -0700
  12378. Resent-Date: Tue, 1 May 90 21:02 MST
  12379. Date: Tue, 1 May 90 20:59:24 -0700
  12380. From: wgg@cs.washington.EDU
  12381. Subject: RE:  reversible assignment
  12382. Resent-To: icon-group@cs.arizona.edu
  12383. To: goer@sophist.uchicago.EDU, icon-group@arizona.edu
  12384. Resent-Message-Id: <9F513282723FA0A08F@Arizona.EDU>
  12385. Message-Id: <9005020359.AA04237@june.cs.washington.edu>
  12386. X-Envelope-To: icon-group@CS.Arizona.EDU
  12387. X-Vms-To: goer@sophist.uchicago.EDU, icon-group@Arizona.edu
  12388. Status: O
  12389.  
  12390. Richard Goerwitz's answer is correct:  data backtracking is possible only
  12391. if the control backtracks to the expression involved. 
  12392.  
  12393. In the expressions
  12394.  
  12395.     z <- 1
  12396.     z = 10
  12397.  
  12398. each has an implicit semi-colon at the end:
  12399.  
  12400.     z <- 1;
  12401.     z = 10;
  12402.  
  12403. The first semicolon delimits the assignment from the comparison, and prevents
  12404. backtracking back into the assignment from the comparison if it fails.  
  12405. Thus the assignment expression is ``bounded'' by the semicolon, and cannot
  12406. be resumed once it has yielded a result. 
  12407.  
  12408. On the other hand, in the expression
  12409.  
  12410.     (z <- i) & (z = 10)
  12411.  
  12412. The assignment itself is not bounded, and it is possible to backtrack from the
  12413. comparison into the assignment, if the comparison fails. 
  12414.  
  12415. In most cases the semantics of traditional-appearing control structures in
  12416. Icon is to bound an expression so that it produces only one result.  This
  12417. prevents ``surprises'', and also avoids the overhead of often unneeded
  12418. backtracking.  Hence the control structures if-then and while-do bound their
  12419. control expressions (but not their bodies!).   Of course, it is easy to
  12420. phrase ``backtracking'' versions of these control structures:
  12421.  
  12422.     basic                backtracking
  12423. -------------------------------------------------------
  12424. if X then Y else Z            (X & Y) | Z
  12425.  
  12426. while X do Y                every X do Y
  12427.  
  12428. X;Y                    X & Y
  12429.  
  12430. return X                suspend X
  12431.  
  12432. One could easily argue that I've chosen the wrong analogues.  (Suppose 
  12433. that the analogue for while-do resumes X only if Y fails, otherwise X
  12434. just starts over.  Consider, too, its behavior when Y contains a break.)
  12435.  
  12436.                     Bill Griswold
  12437.  
  12438. From ralph  Wed May  2 09:54:57 1990
  12439. Date: Wed, 2 May 90 09:54:57 MST
  12440. From: "Ralph Griswold" <ralph>
  12441. Message-Id: <9005021654.AA23250@megaron.cs.arizona.edu>
  12442. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  12443.     id AA23250; Wed, 2 May 90 09:54:57 MST
  12444. To: icon-group
  12445. Subject: icon-group mail
  12446. Status: O
  12447.  
  12448. There's been a lot of interesting mail to icon-group recently.  We're
  12449. encouraged to see this activity and hope it will keep up.
  12450.  
  12451. Please bear in mind when you're sending e-mail to icon-group that long
  12452. messages sometimes cause problems.  The main difficulty is when one
  12453. person responds to icon-group mail and includes most or all of the
  12454. text of the message toward which the response is directed.  This sometimes
  12455. makes such responses very bulky.  While this is no problem for most
  12456. persons on icon-group, it is for some.  Persons who get icon-group mail
  12457. via a modem connections may have difficulty receiving long messages and
  12458. it's also expensive for them. Long messages also may be refused by
  12459. electronic gateways.  This, for example, can prevent icon-group mail from
  12460. getting to electronic news distribution.
  12461.  
  12462. Please take a little extra time when composing lengthy messages to be sure
  12463. you only include relevant information.
  12464.  
  12465.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  12466.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  12467.  
  12468. From gudeman  Wed May  2 12:44:25 1990
  12469. Resent-From: "David Gudeman" <gudeman>
  12470. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  12471.     id AA05435; Wed, 2 May 90 12:44:25 MST
  12472. Received: from megaron.cs.Arizona.EDU by Arizona.EDU; Wed, 2 May 90 12:40 MST
  12473. Received: by megaron.cs.arizona.edu (5.59-1.7/15) id AA05223; Wed, 2 May 90
  12474.  12:38:12 MST
  12475. Resent-Date: Wed, 2 May 90 12:41 MST
  12476. Date: Wed, 2 May 90 12:38:12 MST
  12477. From: David Gudeman <gudeman@cs.arizona.edu>
  12478. Subject: backtracking rules (was: Reversible Assignment Problem)
  12479. Resent-To: icon-group@cs.arizona.edu
  12480. To: icon-group@arizona.edu
  12481. Resent-Message-Id: <9ECDF6D2891FA09E8B@Arizona.EDU>
  12482. Message-Id: <9005021938.AA05223@megaron.cs.arizona.edu>
  12483. In-Reply-To: ntvax!leff@tut.cis.ohio-state.EDU's message of 1 May 90 15:12:40
  12484.  GMT <1990May1.151240.11020@dept.csci.unt.edu>
  12485. X-Envelope-To: icon-group@CS.Arizona.EDU
  12486. X-Vms-To: icon-group@Arizona.edu
  12487. Status: O
  12488.  
  12489. This problem with reversible assignment is part of a larger problem
  12490. that a lot of people seem to have with Icon.  That is the problem of
  12491. understanding where backtracking "goes".  In particular, the
  12492. reversible assignment problem seems to be caused by the following
  12493. misunderstanding: 
  12494.  
  12495.   global x
  12496.   procedure foo()
  12497.     x <- 1
  12498.     suspend x
  12499.   end
  12500.  
  12501.   procedure main()
  12502.     every foo()
  12503.   end
  12504.  
  12505. where people think that when foo gets resumed, that resumes every
  12506. expression in foo that suspended in the past.  But once you pass the
  12507. semi-colon (an implicit one in this case) the expression before the
  12508. semicolon is no longer suspended, it is finished.  Here is a good test
  12509. for what expressions in a procedure can be resumed after a suspend:
  12510. imagine what would happen if you replaced
  12511.  
  12512.   suspend EXPRESSION
  12513.  
  12514. with 
  12515.  
  12516.   every write(image(EXPRESSION))
  12517.  
  12518. basically, the sequence that would be written is the sequence that a
  12519. calling procedure would see.  Also, any backtracking that would be
  12520. done between written values gets done between real suspensions.  If
  12521. you wrote
  12522.  
  12523.   procedure foo()
  12524.     x <- 1
  12525.     every write(image(x))
  12526.   end
  12527.  
  12528. from above, would the assignment ever get reversed?
  12529.  
  12530. From utah-cs!boulder!ncar.UCAR.EDU!oddjob!sophist.uchicago.edu.richard!zenu!  Thu May  3 09:55:47 1990
  12531. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  12532.     id AA07804; Thu, 3 May 90 09:55:47 MST
  12533. Received: from boulder.UUCP by cs.utah.edu (5.61/utah-2.10-cs)
  12534.     id AA13526; Thu, 3 May 90 10:54:27 -0600
  12535. Received: by boulder.Colorado.EDU (cu-hub.890824)
  12536. Received: by ncar.ucar.EDU (5.61/ NCAR Central Post Office 04/10/90)
  12537.     id AA07950; Thu, 3 May 90 10:53:42 MDT
  12538. Received: from tank.uchicago.edu by oddjob.uchicago.edu Thu, 3 May 90 11:16:11 CDT
  12539. Received: from sophist.uchicago.edu by tank.uchicago.edu Thu, 3 May 90 11:17:09 CDT
  12540. Return-Path: <richard@zenu.uucp>
  12541. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  12542.     id AA08195; Thu, 3 May 90 11:12:52 CDT
  12543. Received: by sophist.uchicago.edu (smail2.5)
  12544.     id AA00229; 3 May 90 10:31:14 CDT (Thu)
  12545. Subject: lifetime of variables
  12546. To: icon-group@arizona.edu
  12547. Date: Thu, 3 May 90 10:31:13 CDT
  12548. X-Mailer: ELM [version 2.2 PL0]
  12549. Message-Id: <9005031031.AA00229@sophist.uchicago.edu>
  12550. From: utah-cs!boulder!sophist.uchicago.edu!richard (Richard L. Goerwitz III)
  12551. Status: O
  12552.  
  12553.  
  12554. Why is it that a procedure like
  12555.  
  12556.   procedure return_table()
  12557.     tbl := table()
  12558.     return tbl
  12559.   end
  12560.  
  12561. works.  I guess I never really thought about it before (I don't
  12562. mentally transfer Icon into equivalent constructions in other
  12563. languages).  If I had no familiarity with Icon, I'd probably way
  12564. "make tbl static or global, 'cause it'll disappear when return_
  12565. table() returns, and all you'll be left with is a pointer aiming
  12566. into the great void."
  12567.  
  12568. From icon-group-request@arizona.edu  Thu May  3 13:34:18 1990
  12569. Resent-From: icon-group-request@arizona.edu
  12570. Received: from Maggie.Telcom.Arizona.EDU by megaron (5.59-1.7/15) via SMTP
  12571.     id AA22791; Thu, 3 May 90 13:34:18 MST
  12572. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 3 May 90 13:34 MST
  12573. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA04254; Thu, 3 May 90 13:18:55
  12574.  -0700
  12575. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  12576.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  12577.  usenet@ucbvax.Berkeley.EDU if you have questions)
  12578. Resent-Date: Thu, 3 May 90 13:34 MST
  12579. Date: 3 May 90 20:18:39 GMT
  12580. From: swrinde!cs.utexas.edu!jnino@ucsd.EDU
  12581. Subject: Differences between version 5 and version 7
  12582. Sender: icon-group-request@arizona.edu
  12583. Resent-To: icon-group@cs.arizona.edu
  12584. To: icon-group@arizona.edu
  12585. Resent-Message-Id: <9DFD6CB34E7FA05491@Arizona.EDU>
  12586. Message-Id: <1280@gorath.cs.utexas.edu>
  12587. Organization: U. Texas CS Dept., Austin, Texas
  12588. X-Envelope-To: icon-group@CS.Arizona.EDU
  12589. X-Vms-To: icon-group@Arizona.edu
  12590. Status: O
  12591.  
  12592. I am getting started with this language. I got a book written by R. Griswold
  12593. and published in 1983 tittled "The Icon programming Language". In the preface
  12594. it is indicated that Version 5 is to be used in the book. I'd like to know
  12595. how different is Version 5 from version 7 or even version 8. Is it advisable
  12596. to go ahead and get an intro to Icon using this book?
  12597.  
  12598. Thanks
  12599.  
  12600. Jaime Nino
  12601.  
  12602. From goer@sophist.uchicago.EDU  Thu May  3 16:53:20 1990
  12603. Resent-From: goer@sophist.uchicago.EDU
  12604. Received: from Maggie.Telcom.Arizona.EDU by megaron (5.59-1.7/15) via SMTP
  12605.     id AA05262; Thu, 3 May 90 16:53:20 MST
  12606. Return-Path: goer@sophist.uchicago.EDU
  12607. Received: from tank.uchicago.edu by Arizona.EDU; Thu, 3 May 90 16:54 MST
  12608. Received: from sophist.uchicago.edu by tank.uchicago.edu Thu, 3 May 90 18:53:45
  12609.  CDT
  12610. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA08853; Thu, 3 May 90
  12611.  18:49:25 CDT
  12612. Resent-Date: Thu, 3 May 90 16:54 MST
  12613. Date: Thu, 3 May 90 18:49:25 CDT
  12614. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  12615. Subject: go ahead with Griswold & Griswold
  12616. Resent-To: icon-group@cs.arizona.edu
  12617. To: icon-group@arizona.edu
  12618. Resent-Message-Id: <9DE172D9C61FA0B255@Arizona.EDU>
  12619. Message-Id: <9005032349.AA08853@sophist.uchicago.edu>
  12620. X-Envelope-To: icon-group@CS.Arizona.EDU
  12621. X-Vms-To: icon-group@Arizona.edu
  12622. Status: O
  12623.  
  12624. Go ahead and use Griswold & Griswold.  Icon is mostly backwards
  12625. compatible with its former incarnations.  You'll notice that co-
  12626. routines came and went and came back again from version 5 to 7.
  12627. String scanning no longer operates with simple global variables
  12628. &pos and &source.  These variables still exist.  However, their
  12629. scope is a bit different.  No need to worry about the specifics.
  12630. There are a few nice features, like faster and cleaner options
  12631. 3 and 4 for sort.  We now have math functions that used to be
  12632. part of the library (sin, etc.).
  12633.  
  12634. In general, don't worry about the differences.  If something seems
  12635. awry - which is unlikely - post.  You certainly won't be the only
  12636. one whose had questions :-).  The version of Icon you are using
  12637. will certainly have documentation to go with it.  When you feel
  12638. comfortable enough with the language, just browse through them.
  12639. They are well-written and pretty concise.  You quickly get caught
  12640. up on the additions that have been made to the language since ver-
  12641. sion 5.
  12642.  
  12643.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  12644.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  12645.  
  12646. From nevin1@ihlpb.att.com  Thu May  3 19:41:49 1990
  12647. Message-Id: <9005040241.AA13224@megaron>
  12648. Received: from att-in.att.com by megaron (5.59-1.7/15) via SMTP
  12649.     id AA13224; Thu, 3 May 90 19:41:49 MST
  12650. From: nevin1@ihlpb.att.com
  12651. Date: Thu, 3 May 90 19:41 CDT
  12652. Original-From: ihlpb!nevin1 (Nevin J Liber +1 708 979 4751)
  12653. To: att!cs.arizona.edu!icon-group
  12654. Subject: Re: lifetime of variables
  12655. Status: O
  12656.  
  12657. >Why is it that a procedure like
  12658. >
  12659. >  procedure return_table()
  12660. >    tbl := table()
  12661. >    return tbl
  12662. >  end
  12663. >
  12664. >works. [...]
  12665. >If I had no familiarity with Icon, I'd probably way
  12666. >"make tbl static or global, 'cause it'll disappear when return_
  12667. >table() returns, and all you'll be left with is a pointer aiming
  12668. >into the great void."
  12669.  
  12670. [Side note:  the above is a good explanation of a very common C
  12671. programming error.]
  12672.  
  12673. The the table sticks around because is it is stored in that
  12674. area of memory commonly referred to as the "heap".  (This is the same
  12675. type of memory that C's malloc() function returns pointers into.)
  12676.  
  12677. [Note:  there are other ways of implementing call-return mechanisms
  12678. (eg: copy the object before returning), but they have other problems
  12679. associated with it.]
  12680.  
  12681. One purpose of a heap is to have objects survive procedure calls and
  12682. returns.  Like static variables, it has limited visibility.  However,
  12683. it differs from statics in that each call to a function like your
  12684. return_table() returns a DIFFERENT table each time.  (I don't mean to
  12685. say that if tbl were declared static that the return_table() would
  12686. return the same table each time; its behavior would not change.  What I mean
  12687. is that in the framework of a language like C, if you return a pointer to
  12688. a static you will always get the same address, while if you return a
  12689. pointer to something malloc()ed you will get a different address.)
  12690.  
  12691. The other purpose to having a heap is to create objects of arbitrary
  12692. size or of sizes unknown at compile time.
  12693.  
  12694.  
  12695. I hoped I haven't rambled too long.  It's been a long day. :-)
  12696.  
  12697.     NEVIN ":-)" LIBER  nevin1@ihlpb.ATT.COM  (708) 831-FLYS
  12698.  
  12699. From icon-group-request@arizona.edu  Thu May  3 19:48:11 1990
  12700. Resent-From: icon-group-request@arizona.edu
  12701. Received: from Maggie.Telcom.Arizona.EDU by megaron (5.59-1.7/15) via SMTP
  12702.     id AA13499; Thu, 3 May 90 19:48:11 MST
  12703. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Thu, 3 May 90 19:49 MST
  12704. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA27182; Thu, 3 May 90 19:35:29
  12705.  -0700
  12706. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  12707.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  12708.  usenet@ucbvax.Berkeley.EDU if you have questions)
  12709. Resent-Date: Thu, 3 May 90 19:49 MST
  12710. Date: 4 May 90 01:45:12 GMT
  12711. From: uupsi!sunic!sics.se!sics!soder@rice.EDU
  12712. Subject: Icon on Sun386i
  12713. Sender: icon-group-request@arizona.edu
  12714. Resent-To: icon-group@cs.arizona.edu
  12715. To: icon-group@arizona.edu
  12716. Resent-Message-Id: <9DC90397F2DFA022A0@Arizona.EDU>
  12717. Message-Id: <SODER.90May4034512@basf.nmpcad.se>
  12718. Organization: nmp
  12719. X-Envelope-To: icon-group@CS.Arizona.EDU
  12720. X-Vms-To: icon-group@Arizona.edu
  12721. Status: O
  12722.  
  12723. I have run Icon 7.5 successfully on a Sun386i for a long
  12724. time. But without co-expressions. I recently fetched Icon
  12725. 8.0. There is a configuration called "sun386i" in the
  12726. distribution. I copied "rswitch.c" from the "i386_sysv"
  12727. configuration and ended up with the following "define.h":
  12728.  
  12729. #define SysTime <sys/time.h>
  12730. #define GetHost
  12731. #define MaxHdr 5000
  12732.  
  12733. #define UNIX 1
  12734.  
  12735. No other modifications to the "sun386i" configuration.  My
  12736. knowledge of assembler and co-expression implementation is
  12737. identical to zero, but this installation passed the
  12738. co-expression tests and seems to work fine.
  12739.  
  12740. Well, there is one Sun386i-specific glitch. (It was there in
  12741. 7.5 too.)  Icon programs generate a random (?) return code,
  12742. except "stop" that reliably returns '1'.  Not even "exit(0)"
  12743. helps.  I've noticed that C programs that just flow out of
  12744. "main" also return "random" codes.  Can this be the problem
  12745. in "iconx"? I can't easily find out. Anyway, a C program
  12746. must end by executing "exit" to be portable.
  12747. --
  12748. ----------------------------------------------------
  12749. Hakan Soderstrom             Phone: +46 (8) 752 1138
  12750. NMP-CAD                      Fax:   +46 (8) 750 8056
  12751. P.O. Box 1193                E-mail: soder@nmpcad.se
  12752. S-164 22 Kista, Sweden
  12753.  
  12754. From @RELAY.CS.NET,@dg-rtp.rtp.dg.com:langley@DG-RTP.DG.COM  Fri May  4 06:55:47 1990
  12755. Received: from relay.cs.net by megaron (5.59-1.7/15) via SMTP
  12756.     id AA16623; Fri, 4 May 90 06:55:47 MST
  12757. Received: from dg-rtp.rtp.dg.com by RELAY.CS.NET id aa18447; 4 May 90 9:55 EDT
  12758. Received: from bigbird.rtp.dg.com by dg-rtp.dg.com (4.20/4.7)
  12759.     id AA03537; Fri, 4 May 90 09:53:38 edt via SMTP
  12760. Received: by bigbird.rtp.dg.com (4.20/rtp-s01)
  12761.     id AA17493; Fri, 4 May 90 09:54:50 edt
  12762. Date: Fri, 4 May 90 09:54:50 edt
  12763. From: Mark L Langley <langley@DG-RTP.DG.COM>
  12764. Message-Id: <9005041354.AA17493@bigbird.rtp.dg.com>
  12765. Return-Receipt-To: langley@dg-rtp.dg.com
  12766. To: icon-group@cs.arizona.edu
  12767. Subject: Re: lifetime of variables
  12768. Status: O
  12769.  
  12770. Richard Goerwitz III asks
  12771. > Why is it that a procedure like
  12772. >   procedure return_table()
  12773. >     tbl := table()
  12774. >     return tbl
  12775. >   end
  12776. > works.  I guess I never really thought about it before (I don't
  12777. > mentally transfer Icon into equivalent constructions in other
  12778. > languages).  If I had no familiarity with Icon, I'd probably way
  12779. > "make tbl static or global, 'cause it'll disappear when return_
  12780. > table() returns, and all you'll be left with is a pointer aiming
  12781. > into the great void."
  12782.  
  12783. Ah, this is one of the great things about Icon -- Memory management
  12784. is done for you.  Dynamic storage allocation is the trick.  Imagine
  12785. two ways of using your office, playroom, or kitchen counter.
  12786.  
  12787. Static Storage Allocation: 
  12788.     Take something out, put it back, Take it out, put it back...
  12789. Dynamic Storage Allocation:
  12790.     Take things out, put them back when you need the space.
  12791.  
  12792. To make a long story short, the Icon garbage collector is responsible 
  12793. for collecting things that you no longer need.  The interpreter doles 
  12794. out memory as needed.  When it runs out, it finds all the objects that 
  12795. could still be referenced and moves them together.  This writes over all 
  12796. the objects that cannot be reached anymore, leaving space at the end.  
  12797. Between this and saying "Mother may I have some more?" to the operating 
  12798. system, it usually avoids running out of memory.
  12799.  
  12800. Mark
  12801.  
  12802. From utah-cs!boulder!ncar.UCAR.EDU!oddjob!sophist.uchicago.edu.goer!zenu!  Fri May  4 13:48:45 1990
  12803. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  12804.     id AA24398; Fri, 4 May 90 13:48:45 MST
  12805. Received: from boulder.UUCP by cs.utah.edu (5.61/utah-2.10-cs)
  12806.     id AA06666; Fri, 4 May 90 14:48:24 -0600
  12807. Received: by boulder.Colorado.EDU (cu-hub.890824)
  12808. Received: by ncar.ucar.EDU (5.61/ NCAR Central Post Office 04/10/90)
  12809.     id AA06967; Fri, 4 May 90 14:47:06 MDT
  12810. Received: from tank.uchicago.edu by oddjob.uchicago.edu Fri, 4 May 90 15:17:42 CDT
  12811. Received: from sophist.uchicago.edu by tank.uchicago.edu Fri, 4 May 90 15:18:02 CDT
  12812. Return-Path: <goer@zenu.uucp>
  12813. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  12814.     id AA10051; Fri, 4 May 90 15:13:36 CDT
  12815. Received: by sophist.uchicago.edu (smail2.5)
  12816.     id AA00157; 4 May 90 11:18:15 PDT (Fri)
  12817. Subject: frequently-asked questions
  12818. To: icon-group@arizona.edu
  12819. Date: Fri, 4 May 90 11:18:14 PDT
  12820. X-Mailer: ELM [version 2.2 PL0]
  12821. Message-Id: <9005041118.AA00157@sophist.uchicago.edu>
  12822. From: utah-cs!boulder!sophist.uchicago.edu!goer (Richard qua goer.)
  12823. Status: O
  12824.  
  12825.  
  12826.  
  12827. I wonder if we might do well to accumulate a "frequently-asked
  12828. questions" list, to make things easier for people starting to learn
  12829. Icon (presumably a large portion of the Icon-group's membership).
  12830. I'll just post an entry, and if anyone wants to add to it, I'll simply
  12831. append their additions to my list.  I find that people starting to
  12832. learn Icon tend to make similar mistakes, and I end up answering the
  12833. same questions over and over.  Not that answering them is difficult or
  12834. tedious.  I just hate to see people have to find out, after hours of
  12835. debugging, that they have run into a problem that might easily have
  12836. been avoided through the use of such a list.  Take five minutes out,
  12837. and add to the list!
  12838.  
  12839.  
  12840. Problem:  Why do I get unexpected results when I initialize a table
  12841.     like this:  tbl := table([])?  What I want is to make all the keys
  12842.     in tbl have empty lists as their initial values.
  12843.  
  12844. Answer:  Tables, sets, and lists in Icon are handled differently than,
  12845.     say, strings, csets, and integers.  When you "dereference" a
  12846.     variable whose value is a string, cset, or integer, you get a
  12847.     string, cset or integer (nothing complicated here).  In other
  12848.     words, if you say
  12849.  
  12850.     i := 1
  12851.     j := i
  12852.  
  12853.     j will end up with a value of 1.  When the i is dereferenced, it
  12854.     produces the integer 1, and *that* is what gets assigned to j.
  12855.     With structures like lists, however, dereferencing them produces a
  12856.     "pointer" to the structure in question.  It does not produce a
  12857.     copy of the structure (for that, you have to use copy()).  This is
  12858.     why, if you say
  12859.  
  12860.     l1 := ["hello"]
  12861.     l2 := ["hello"]
  12862.     if l1 === l2
  12863.     then write("the same")
  12864.     else write("different")
  12865.  
  12866.     you will see "different" written to the screen.  In effect, you
  12867.     have created two lists which, although they bear a structural
  12868.     similarity, reside in different places in memory, and therefore
  12869.     are *different lists*.
  12870.  
  12871.     What is the point here?  The point is that, if you say
  12872.  
  12873.     tbl := table([])
  12874.  
  12875.     you are actually setting up tbl so that each time you insert a new
  12876.     key, it will automatically be assigned the value produced by [].
  12877.     If you had said "tbl := table(1)" this would be fine.  "1"
  12878.     produces the integer 1.  Remember, however, that [] creates a
  12879.     specific structure (an empty list) and produces a pointer to that
  12880.     list.  What you'll end up with, therefore, is a table with keys
  12881.     whose values are all pointers to the one list structure!  What
  12882.     this does to your program is make it so that if you make any
  12883.     insertions into any key's value (e.g.  tbl[key1] |||:= ["hello"]
  12884.     or insert(tbl[key1],"hello")), you will find, suddenly, that *all*
  12885.     of the keys' values have been modified.
  12886.  
  12887.     To make the long story short, you have to initialize the table
  12888.     using &null,
  12889.  
  12890.     tbl := table()    # the same as tbl := table(&null)
  12891.  
  12892.     and then, each time you add a key, do this:
  12893.  
  12894.     /tbl[key] := []   # or /tbl[key] := list()
  12895.  
  12896.     The above expression first checks to see whether key has been
  12897.     inserted into tbl yet, and if not, makes its value the empty list
  12898.     (the forward slash tests for the null value, and so if key is
  12899.     already present in the table, and has been assigned a value,
  12900.     tbl[key] := [] will not take place).  You can then go about
  12901.     inserting things into this list as expected.
  12902.  
  12903. From ralph  Sat May  5 07:19:59 1990
  12904. Date: Sat, 5 May 90 07:19:59 MST
  12905. From: "Ralph Griswold" <ralph>
  12906. Message-Id: <9005051419.AA14654@megaron.cs.arizona.edu>
  12907. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  12908.     id AA14654; Sat, 5 May 90 07:19:59 MST
  12909. To: icon-group
  12910. Subject: Second Edition of the Icon programming language book
  12911. Status: O
  12912.  
  12913. The second edition of The Icon Programming Language is now available.
  12914.  
  12915. The second edition describes Version 8 of Icon (the first edition, published in
  12916. 1983, describes Version 5.9).
  12917.  
  12918. In addition to describing Version 8, the second edition is completely revised.
  12919. Important concepts such as generators and string scanning are presented first,
  12920. allowing subsequent material to be presented in ways more natural to Icon.
  12921.  
  12922. New material includes a chapter on the details of running Icon programs,
  12923. more (and harder) exercises, several large sample programs, and an
  12924. expanded "mini-reference" to Icon's functions and operations.
  12925.  
  12926. Here's the publication information:
  12927.  
  12928.     The Icon Programming Language, second edition. Ralph E.  Griswold and
  12929.     Madge T. Griswold, Prentice Hall, 1990.  367 pages. $29.95.
  12930.     ISBN 0-13-447889-4.
  12931.  
  12932. The book can be ordered from any full-service bookstore or from the Icon
  12933. Project.  The Icon Project pays postage in the United States, Canada, and
  12934. Mexico.  There is a $13 charge for shipping to other countries, which is
  12935. by air mail.  
  12936.  
  12937. Orders placed with the Icon Project must be in US dollars to The University of
  12938. Arizona with a check written on a bank in the United States.  Orders also can be
  12939. charged to MasterCard or Visa.
  12940.  
  12941.     Icon Project
  12942.     Department of Computer Science
  12943.     Gould-Simpson Building
  12944.     The University of Arizona
  12945.     Tucson, AZ   85721
  12946.  
  12947.     602 621-2018 (voice)
  12948.     602 621-4246 (FAX)
  12949.  
  12950. Please address any questions to me, not icon-project or icon-group.
  12951.  
  12952.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  12953.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  12954.  
  12955. From ralph  Sat May  5 08:37:23 1990
  12956. Date: Sat, 5 May 90 07:19:59 MST
  12957. From: "Ralph Griswold" <ralph>
  12958. Message-Id: <9005051419.AA14654@megaron.cs.arizona.edu>
  12959. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  12960.     id AA14654; Sat, 5 May 90 07:19:59 MST
  12961. To: icon-group
  12962. Subject: Second Edition of the Icon programming language book
  12963. Status: RO
  12964.  
  12965. The second edition of The Icon Programming Language is now available.
  12966.  
  12967. The second edition describes Version 8 of Icon (the first edition, published in
  12968. 1983, describes Version 5.9).
  12969.  
  12970. In addition to describing Version 8, the second edition is completely revised.
  12971. Important concepts such as generators and string scanning are presented first,
  12972. allowing subsequent material to be presented in ways more natural to Icon.
  12973.  
  12974. New material includes a chapter on the details of running Icon programs,
  12975. more (and harder) exercises, several large sample programs, and an
  12976. expanded "mini-reference" to Icon's functions and operations.
  12977.  
  12978. Here's the publication information:
  12979.  
  12980.     The Icon Programming Language, second edition. Ralph E.  Griswold and
  12981.     Madge T. Griswold, Prentice Hall, 1990.  367 pages. $29.95.
  12982.     ISBN 0-13-447889-4.
  12983.  
  12984. The book can be ordered from any full-service bookstore or from the Icon
  12985. Project.  The Icon Project pays postage in the United States, Canada, and
  12986. Mexico.  There is a $13 charge for shipping to other countries, which is
  12987. by air mail.  
  12988.  
  12989. Orders placed with the Icon Project must be in US dollars to The University of
  12990. Arizona with a check written on a bank in the United States.  Orders also can be
  12991. charged to MasterCard or Visa.
  12992.  
  12993.     Icon Project
  12994.     Department of Computer Science
  12995.     Gould-Simpson Building
  12996.     The University of Arizona
  12997.     Tucson, AZ   85721
  12998.  
  12999.     602 621-2018 (voice)
  13000.     602 621-4246 (FAX)
  13001.  
  13002. Please address any questions to me, not icon-project or icon-group.
  13003.  
  13004.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  13005.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  13006.  
  13007. From icon-group-request@arizona.edu  Wed May  9 01:49:45 1990
  13008. Resent-From: icon-group-request@arizona.edu
  13009. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13010.     id AA01904; Wed, 9 May 90 01:49:45 MST
  13011. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 9 May 90 01:43 MST
  13012. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA24236; Wed, 9 May 90 01:09:52
  13013.  -0700
  13014. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  13015.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  13016.  usenet@ucbvax.Berkeley.EDU if you have questions)
  13017. Resent-Date: Wed, 9 May 90 01:50 MST
  13018. Date: 9 May 90 08:08:06 GMT
  13019. From: zaphod.mps.ohio-state.edu!sdd.hp.com!uakari.primate.wisc.edu!samsung!munnari.oz.au!mudla!ok@tut.cis.ohio-state.EDU
  13020. Subject: RE: encompassing formalism (stealing from Prolog)
  13021. Sender: icon-group-request@arizona.edu
  13022. Resent-To: icon-group@cs.arizona.edu
  13023. To: icon-group@arizona.edu
  13024. Resent-Message-Id: <99A8C815087FA04FA2@Arizona.EDU>
  13025. Message-Id: <3948@munnari.oz.au>
  13026. X-Envelope-To: icon-group@CS.Arizona.EDU
  13027. X-Vms-To: icon-group@Arizona.edu
  13028. References: <9004301628.AA03522@sophist.uchicago.edu>
  13029.  
  13030. In article <9004301628.AA03522@sophist.uchicago.edu>, goer@SOPHIST.UCHICAGO.EDU (Richard Goerwitz) writes:
  13031. > The other formalism is more process-oriented (hence it is ironic that
  13032. > Prolog is the main language which implements it).  You say -
  13033. >       S -> NP VP
  13034.  
  13035. *process*-oriented?  It's just a declarative constraint on a node in a
  13036.  =======             constituent structure:  a node labelled S may 
  13037. dominate two daughters, one labelled NP and one labelled VP, and the
  13038. one labelled NP must precede the one labelled VP.  Rules like this can
  13039. be used as easily for generation as for parsing.
  13040.  
  13041. > Particularly interesting for us here is the way Prolog implements this
  13042. > for malism.  Assuming the Prolog you use implements definite clause
  13043. > grammar notation, you can say,
  13044.  
  13045. Since there is a *freely* distributable DCG->Prolog rule-at-a-time translator
  13046. which has been broadcast over the net, I think it's safe to say that any
  13047. Prolog system which _hasn't_ got DCG rules isn't trying.  The really
  13048. exciting thing about grammar rules in Prolog is that (if you avoid cuts
  13049. and non-logical features of Prolog) you have a non-directional declarative
  13050. formalism which can be processed in a variety of ways:  one and the same
  13051. set of rules may be loaded directly as Prolog code, or parsed with a left-
  13052. corner parser, or given to a chart parser, or (and this _happens_) used
  13053. for generation.  In each case one "compiles" rather easily from rules to
  13054. Prolog.
  13055.  
  13056. > I don't see any reason that this couldn't be implemented EASILY in Icon.
  13057. > And Icon has some neat advantages over Prolog,
  13058. > such as very good string handling.
  13059.  
  13060. I think Icon is a _wonderful_ language.  But it isn't supposed to be a
  13061. declarative language.  Most of the time when I write grammar rules in
  13062. Prolog I am using them to _generate_ lists.  Some of the rest of the
  13063. time I don't know whether the code I write will generate or parse, and
  13064. have no reason to care.  In the case of PATR-II, people are writing
  13065. large grammars where one and the same grammar is used for both parsing
  13066. and generation, basically by switching control strategies in a kind of
  13067. interpreter.
  13068.  
  13069. Yes, Icon has very good string handling.  Anyone with substantial
  13070. string-handling problems would be crazy not to use Icon if they had
  13071. the chance.  But what has that to do with parsing?  I think that the
  13072. most important lesson I ever learned about SNOBOL was when I enthused
  13073. about it to an anthropologist, who said "it can parse sequences of
  13074. characters?  Great!  Can it parse sequences of words?  No?  Then it's
  13075. no use to me!"  That is one of (several) respects in which Icon
  13076. improves dramatically on SNOBOL:  you _can_ parse a sequence of words
  13077. in Icon using the same basic mechanisms that you use for string
  13078. scanning.  I imagine that someone writing a parser for English (or
  13079. Akkadian!) in Icon would represent a sentence as a list of (pointers
  13080. to) dictionary entries, where a dictionary entry might be a record
  13081. or quite possibly a set of "senses".
  13082.  
  13083. > [still talking about grammar rules in Prolog]
  13084. > There needs to be some research on just
  13085. > how far these indexed grammars can represent natural languages.
  13086.  
  13087. Prolog grammar rules have the full power of Turing machines,
  13088. because the additional arguments may be arbitrarily complex.
  13089. (So may the attribute/value matrices used in several current formalisms.)
  13090.  
  13091. > Recently a formalism called PATR has been developed.
  13092.  
  13093. PATR is based on the idea of "complex categories".
  13094. The label on a node of the constituent structure is taken to be,
  13095. not a simple name as in BNF, but an attribute/value matrix in which
  13096. the traditional category label itself, if there is such a thing at
  13097. all, is merely one of the attributes.  For example, instead of the
  13098. simple categories S(entence), V(erb)P(hrase), V(erb), it is common
  13099. to talk about [cat=v,bar=2], [cat=v,bar=1], [cat=v,bar=0] in order
  13100. to capture certain regularities.  For example, there is something
  13101. called the Head Feature Convention in GPSG, which basically says
  13102. that in a meaningful rule X0 -> X1 ... Xn there is a distinguished
  13103. daughter Xi called the "head" of the phrase and X0 and Xi have
  13104. certain features in common (such as 'cat' but not 'bar').
  13105.  
  13106. Information is passed around in PATR by a method similar to unification.
  13107. Icon can certainly implement this, but so can Pascal...  The point is
  13108. that it isn't directional.  In one use of a rule, an attribute may be
  13109. in effect copied from the parent to its head daughter; in another use
  13110. of the same rule in the same parse, the same attribute may be in
  13111. effect copied from the daughter to the parent.
  13112.  
  13113. The fact that PATR-II has been implemented in Lisp as well as Prolog
  13114. shows that backtracking built into the the implementation language is
  13115. not necessary.  Icon may well make a good base for such parsers and
  13116. generators, but don't expect it to have any advantage over Lisp
  13117. (other than size, and of course price...).
  13118.  
  13119. From cargo@tardis.cray.com  Wed May  9 08:23:13 1990
  13120. Received: from timbuk.cray.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13121.     id AA19476; Wed, 9 May 90 08:23:13 MST
  13122. Received: from hall.cray.com by timbuk.CRAY.COM (4.1/CRI-1.34)
  13123.     id AA22200; Wed, 9 May 90 08:54:35 CDT
  13124. Received: from zk.cray.com by hall.cray.com
  13125.     id AA20018; 4.1/CRI-3.12; Wed, 9 May 90 08:54:33 CDT
  13126. Received: by zk.cray.com
  13127.     id AA06993; 3.2/CRI-3.12; Wed, 9 May 90 08:54:42 CDT
  13128. Date: Wed, 9 May 90 08:54:42 CDT
  13129. From: cargo@tardis.cray.com (David S. Cargo)
  13130. Message-Id: <9005091354.AA06993@zk.cray.com>
  13131. To: icon-group@cs.arizona.edu
  13132. Subject: Icon 8.0 MS-DOS performance
  13133.  
  13134. A user of some Icon programs for MS-DOS written in Icon 7.0 was
  13135. asking me if V8.0 had any performance differences over V7.0.
  13136.  
  13137. Anybody know?
  13138.  
  13139. dsc
  13140.  
  13141. From ralph  Wed May  9 08:38:08 1990
  13142. Date: Wed, 9 May 90 08:38:08 MST
  13143. From: "Ralph Griswold" <ralph>
  13144. Message-Id: <9005091538.AA20409@megaron.cs.arizona.edu>
  13145. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  13146.     id AA20409; Wed, 9 May 90 08:38:08 MST
  13147. To: cargo@tardis.cray.com
  13148. Subject: Re:  Icon 8.0 MS-DOS performance
  13149. Cc: icon-group
  13150. In-Reply-To: <9005091354.AA06993@zk.cray.com>
  13151.  
  13152. Version 8 is faster especially with large sets and tables.  It also
  13153. has somewhat smaller structures for lists, tables, sets, and records.
  13154.  
  13155. Anyone using 7.0 under MS-DOS should upgrade to 8.0 for two reasons:
  13156. 8.0 fixes several bugs and if you need help from the Icon Project, you'll
  13157. have to be running 8.0.
  13158.  
  13159.   Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
  13160.   +1 602 621 6609   ralph@cs.arizona.edu  uunet!arizona!ralph
  13161.  
  13162. From icon-group-request@arizona.edu  Wed May  9 18:01:30 1990
  13163. Resent-From: icon-group-request@arizona.edu
  13164. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13165.     id AA07060; Wed, 9 May 90 18:01:30 MST
  13166. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 9 May 90 18:01 MST
  13167. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA21791; Wed, 9 May 90 17:51:41
  13168.  -0700
  13169. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  13170.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  13171.  usenet@ucbvax.Berkeley.EDU if you have questions)
  13172. Resent-Date: Wed, 9 May 90 18:03 MST
  13173. Date: 8 May 90 17:24:21 GMT
  13174. From: hpfcso!hpldola!schreck@hplabs.hp.COM
  13175. Subject: RE: Reversible Assignment Problem
  13176. Sender: icon-group-request@arizona.edu
  13177. Resent-To: icon-group@cs.arizona.edu
  13178. To: icon-group@arizona.edu
  13179. Resent-Message-Id: <9920E9BE77FFA0E30F@Arizona.EDU>
  13180. Message-Id: <1130001@hpldola.HP.COM>
  13181. Organization: HP Elec. Design Div. -ColoSpgs
  13182. X-Envelope-To: icon-group@CS.Arizona.EDU
  13183. X-Vms-To: icon-group@Arizona.edu
  13184. References: <1990May1.151240.11020@dept.csci.unt.edu>
  13185.  
  13186. / hpldola:comp.lang.icon / leff@dept.csci.unt.edu (Dr. Laurence L. Leff) /  9:12 am  May  1, 1990 /
  13187.  
  13188. > Reversible assignments to global variables inside procedures are
  13189. > not being reversed. 
  13190.  
  13191. > The program below prints out three.  It should print out one.  Obviously,
  13192. > the reversible assignment to z is not being reversed when test does not 
  13193. > lead to an eventual success.
  13194.  
  13195. > Why does the reversing of the assignment not take place, and what would
  13196. > make it do so?
  13197.  
  13198. > The Icon Programming Language, Chapter 11, section 11.8.2 did not shed
  13199. > any light on these issues.
  13200.  
  13201. > global z
  13202. > procedure test(i)
  13203. > z<-z+1
  13204. > if i~=3 then fail
  13205. > if i=3 then return 1
  13206. > end
  13207. > procedure main()
  13208. > z:=0
  13209. > every i:=(1 to 10) do if test(i) then write("test succeeded ",i," ",z)
  13210. > end
  13211.  
  13212. There is no reason for reversing the assignment, because the choice point
  13213. created by "<-" is never resumed.  The expression z <- z+1 succeeds.  To get
  13214. the effect you're looking for, you could substitute the following for the body
  13215. of test:
  13216.  
  13217.     return (z <- z+1, i = 3, 1)
  13218.  
  13219. When the i = 3 expression fails, the assignment statement will be resumed
  13220. and z will be restored to its original value.  Backtracking is initiated,
  13221. in this case, by a failure.
  13222.  
  13223. From icon-group-request@arizona.edu  Fri May 11 07:50:47 1990
  13224. Resent-From: icon-group-request@arizona.edu
  13225. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13226.     id AA19955; Fri, 11 May 90 07:50:47 MST
  13227. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Fri, 11 May 90 07:51 MST
  13228. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA25339; Fri, 11 May 90
  13229.  07:43:49 -0700
  13230. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  13231.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  13232.  usenet@ucbvax.Berkeley.EDU if you have questions)
  13233. Resent-Date: Fri, 11 May 90 07:52 MST
  13234. Date: 11 May 90 14:43:35 GMT
  13235. From: usc!zaphod.mps.ohio-state.edu!uwm.edu!csd4.csd.uwm.edu!corre@ucsd.EDU
  13236. Subject: Boolean
  13237. Sender: icon-group-request@arizona.edu
  13238. Resent-To: icon-group@cs.arizona.edu
  13239. To: icon-group@arizona.edu
  13240. Resent-Message-Id: <97E3E4092D7FA0EDC9@Arizona.EDU>
  13241. Message-Id: <3919@uwm.edu>
  13242. Organization: University of Wisconsin-Milwaukee
  13243. X-Envelope-To: icon-group@CS.Arizona.EDU
  13244. X-Vms-To: icon-group@Arizona.edu
  13245.  
  13246.  
  13247.     Iconists don't seem to use the word "boolean" very much. As an
  13248.   emigrant from Pascal-land I guess I notice this. I suppose the
  13249.   reason is partly than boolean concepts are written into the fabric
  13250.   of the language by the succeed/fail mechanism and partly that Icon
  13251.   allows constructs that belie strict structuring but are sensible and
  13252.   useful. I have in mind such things as break and stop() which render
  13253.   unnecessary the typical WHILE.....AND NOT FINISHED of Pascal.
  13254.   Occasionally though, I find it desirable to establish a global
  13255.   variable which toggles between having a value and having the null
  13256.   value. For example, I have a program which enables printed output in
  13257.   mixed Hebrew and English, the input file being in normal English and
  13258.   transcribed Hebrew. An arbitrary symbol (I used tilde) tells the
  13259.   program that a change has taken place, and this can be recorded by
  13260.                           roman := 1         or
  13261.                           roman := &null
  13262.   In this way the program always "knows" what mode it is in, as it can
  13263.   always check \roman or /roman and maybe change it while it is about
  13264.   it:
  13265.                           if (\roman := &null)
  13266.   Pascal has a rather neat
  13267.                          ROMAN := TRUE
  13268.                            ...
  13269.                          ROMAN := NOT ROMAN
  13270.   which toggles a boolean variable. I have represented this in Icon by
  13271.                          roman := 1
  13272.                          ....
  13273.                          roman :=: other
  13274.   (where other was previously undefined.)
  13275.  
  13276.     Maybe some of you have evolved better ways of handling such
  13277.   issues.
  13278. --
  13279. Alan D. Corre
  13280. Department of Hebrew Studies
  13281. University of Wisconsin-Milwaukee                     (414) 229-4245
  13282. PO Box 413, Milwaukee, WI 53201               corre@csd4.csd.uwm.edu
  13283.  
  13284. From utah-cs!boulder!ncar.UCAR.EDU!oddjob!sophist.uchicago.edu.goer!zenu!  Sun May 13 20:49:14 1990
  13285. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  13286.     id AA03057; Sun, 13 May 90 20:49:14 MST
  13287. Received: from boulder.UUCP by cs.utah.edu (5.61/utah-2.11-cs)
  13288.     id AA02629; Sun, 13 May 90 21:48:54 -0600
  13289. Received: by boulder.Colorado.EDU (cu-hub.890824)
  13290. Received: by ncar.ucar.EDU (5.61/ NCAR Central Post Office 04/10/90)
  13291.     id AA10385; Sun, 13 May 90 21:48:28 MDT
  13292. Received: from tank.uchicago.edu by oddjob.uchicago.edu Sun, 13 May 90 22:26:29 CDT
  13293. Received: from sophist.uchicago.edu by tank.uchicago.edu Sun, 13 May 90 22:27:35 CDT
  13294. Return-Path: <goer@zenu.uucp>
  13295. Received:  by sophist.uchicago.edu (3.2/UofC3.0)
  13296.     id AA21993; Sun, 13 May 90 22:23:05 CDT
  13297. Received: by sophist.uchicago.edu (smail2.5)
  13298.     id AA00361; 13 May 90 20:06:09 PDT (Sun)
  13299. Subject: determinism - how?
  13300. To: icon-group@arizona.edu
  13301. Date: Sun, 13 May 90 20:06:09 PDT
  13302. X-Mailer: ELM [version 2.2 PL0]
  13303. Message-Id: <9005132006.AA00361@sophist.uchicago.edu>
  13304. From: utah-cs!boulder!sophist.uchicago.edu!goer (Richard Goerwitz qua goer.)
  13305.  
  13306.  
  13307. This question is not strictly related to Icon, but since many of those
  13308. reading this group are interested in parsing strategies (whether for
  13309. natural or "artificial" languages) I felt it reasonable to seek some
  13310. guidance here.  Let me add that I'd enjoy seeing Icon code as part of
  13311. any response that might appear.
  13312.  
  13313. Let's say we have a regular expression like
  13314.  
  13315.     a*aab
  13316.  
  13317. (I use plain ol' regular expressions because a previous discussion has
  13318. shown me that people utilize different notational conventions,
  13319. depending on whether their training is primarily computational or
  13320. linguistic).  I'd figure that the above regular expression would
  13321. translate into a transition network having an initial state (call it
  13322. zero), with two arcs leading from it, the one labeled "a" (leading
  13323. back to itself) and the other labeled "aa" (leading to state 1).  From
  13324. state one would be another arc leading to the final state (state 2).
  13325. This arc would be labeled "b."
  13326.  
  13327. Problem: The resulting transition network will not convert into a
  13328. deterministic finite state automaton.  In more concrete terms, if you
  13329. were to turn a*aab loose on a string beginning with "aa," you wouldn't
  13330. know that the arc labeled "aa" lead up a "false path" until the
  13331. automaton reached the next state (1), and attempted to cross over to
  13332. state 2 (via "b").
  13333.  
  13334. Normally, when I am confronted with this sort of situation, I just
  13335. laugh and use a pushdown automaton of some sort.  Clearly, though, it
  13336. is possible to make this into a deterministic automaton.  All you
  13337. gotta do is turn a*aab into aaa*b.  I'd just rearrange everything I
  13338. run into in this manner were it not for the fact that things get
  13339. considerably nastier when you get involved in things like
  13340. (a*|b)(aa|b|c).
  13341.  
  13342. Is there some conversion method I am overlooking?
  13343.  
  13344. NB:  I'm coming at this from the standpoint of a student of the
  13345. humanities, and so if I am given references to computational journals,
  13346. chances are that I'll have more difficulty using them than a bit of
  13347. sample Icon (or, for that matter, C, Prolog, or even Lisp) code.  I
  13348. admit that I prefer to read Icon code, though (hence my posting to
  13349. this group).  Beggars can't be choosers, though, I guess, so I will
  13350. gladly accept any suggestions, references, or even flames that come my
  13351. way.
  13352.  
  13353.  
  13354.    -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  13355.    goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  13356.  
  13357. From tenaglia@fps.mcw.edu  Mon May 14 10:23:53 1990
  13358. From: tenaglia@fps.mcw.edu
  13359. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13360.     id AA11961; Mon, 14 May 90 10:23:53 MST
  13361. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.06) with UUCP 
  13362.     id AA21961; Mon, 14 May 90 12:16:59 EDT
  13363. Received: by uwm.edu; id AA02910; Mon, 14 May 90 10:58:24 -0500
  13364. Date: Mon, 14 May 90 10:58:24 -0500
  13365. Message-Id: <9005141558.AA02910@uwm.edu>
  13366. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  13367.           Mon, 14 May 90 10:58:58 CDT
  13368. Apparently-To: rutgers!uwvax!cs.arizona.edu!icon-group
  13369.  
  13370. >     Iconists don't seem to use the word "boolean" very much. As an
  13371. >   emigrant from Pascal-land I guess I notice this. I suppose the
  13372. >   reason is partly than boolean concepts are written into the fabric
  13373. >   of the language by the succeed/fail mechanism and partly that Icon
  13374. >   allows constructs that belie strict structuring but are sensible and
  13375. >   useful.
  13376.  
  13377. I have found 2 useful approaches to it. The quick and dirty method I use
  13378. for throw away one shot deals works like this.
  13379.  
  13380.   global toggle
  13381.   ...
  13382.   toggle := 1
  13383.   ...
  13384.   if change(state) then toggle := -toggle
  13385.   (toggle = 1) | map(item,&lcase,&ucase)
  13386.  
  13387. This fragment is handy for things like converting source to all upper case
  13388. except for quoted strings.
  13389.  
  13390. To accomplish the same thing in a more permanent program, one might use
  13391. named variables for readibility.
  13392.  
  13393.   global true,false,condition
  13394.   ...
  13395.   true  := 1
  13396.   false := -1
  13397.   ...
  13398.   condition := true
  13399.   ...
  13400.   if chage(state) then condition := -condition
  13401.   (condition = true)  | map(item,&lcase,&ucase)
  13402.   ... or ...
  13403.   case condition of
  13404.     {
  13405.     true : condition := false
  13406.     false: condition := true
  13407.   default: stop("Logic has ceased to function!")
  13408.     }
  13409.  
  13410. After looking at these, it becomes obvious that they are the same thing.
  13411. If one wanted to get very tricky with bit masks and 'exclusive or', that
  13412. might be way to handle large amounts of booleans. I haven't gotten latest
  13413. Icon book yet, so I don't know if the bit operations include a bitest()
  13414. procedure which helps process binary bit data. Here's how it might work.
  13415.  
  13416. procedure bitest(bitpat,boolnum)
  13417.   local i,count
  13418.   count := 0
  13419.   (*bitpat <= *boolnum) | (bitpat  := right(bitpat,*boolnum,"0"))
  13420.   (*bitpat >= *boolnum) | (boolnum := right(boolnum,*bitpat,"0"))
  13421.   every i := 1 to *bitpat do
  13422.     if bitpat[i] == boolnum[i] then count +:= 1
  13423.   if count = 0 then return "none"  
  13424.   if count = *bitpat then return "full"
  13425.   return "some"
  13426.   end
  13427.  
  13428. Returns the degree of bitmatch. Whether 'full', 'none', or 'some'. Or else
  13429. maybe it could return a list containing the position numbers of matches? Or
  13430. maybe 0 - 0 matches might not be included? Any other nifty variations?
  13431.   
  13432. Chris Tenaglia (System Manager)
  13433. Medical College of Wisconsin
  13434. 8701 W. Watertown Plank Rd.
  13435. Milwaukee, WI 53226
  13436. (414)257-8765
  13437. tenaglia@mis.mcw.edu
  13438.  
  13439.  
  13440. From nowlin@iwtqg.att.COM  Mon May 14 12:59:15 1990
  13441. Resent-From: nowlin@iwtqg.att.COM
  13442. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13443.     id AA24666; Mon, 14 May 90 12:59:15 MST
  13444. Received: from att-in.att.com by Arizona.EDU; Mon, 14 May 90 12:55 MST
  13445. Resent-Date: Mon, 14 May 90 12:57 MST
  13446. Date: Mon, 14 May 90 13:57 CDT
  13447. From: nowlin@iwtqg.att.COM
  13448. Subject: RE: boolean
  13449. Resent-To: icon-group@cs.arizona.edu
  13450. To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  13451. Resent-Message-Id: <955DBB548ABFA108D4@Arizona.EDU>
  13452. Message-Id: <955E203F329FA1034C@Arizona.EDU>
  13453. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  13454. X-Envelope-To: icon-group@CS.Arizona.EDU
  13455. X-Vms-To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  13456.  
  13457. > >     Iconists don't seem to use the word "boolean" very much. As an
  13458. > >   emigrant from Pascal-land I guess I notice this. I suppose the
  13459. > >   reason is partly than boolean concepts are written into the fabric
  13460. > >   of the language by the succeed/fail mechanism and partly that Icon
  13461. > >   allows constructs that belie strict structuring but are sensible and
  13462. > >   useful.
  13463. > I have found 2 useful approaches to it. The quick and dirty method I use
  13464. > for throw away one shot deals works like this.
  13465. >   global toggle
  13466. >   ...
  13467. >   toggle := 1
  13468. >   ...
  13469. >   if change(state) then toggle := -toggle
  13470. >   (toggle = 1) | map(item,&lcase,&ucase)
  13471. > This fragment is handy for things like converting source to all upper case
  13472. > except for quoted strings.
  13473.  
  13474. Icon doesn't need booleans.  Unset versus set or &null versus some value
  13475. handle the problem.  I know I saw someone say this before but what the hay.
  13476. A COMPLETE and SIMPLISTIC example for converting everything not enclosed in
  13477. double quotes to upper case follows:
  13478.  
  13479. procedure main()
  13480.     chgcase := 1
  13481.     tmp := &null
  13482.  
  13483.     while inline := read() do {
  13484.         outline := ""
  13485.         inline ? {
  13486.             while part := tab(upto('"')) do {
  13487.                 if \chgcase then
  13488.                     outline ||:= map(part,&lcase,&ucase)
  13489.                 else    outline ||:= part
  13490.  
  13491.                 outline ||:= move(1)
  13492.  
  13493.                 chgcase :=: temp
  13494.             }
  13495.             if \chgcase then
  13496.                 outline ||:= map(tab(0),&lcase,&ucase)
  13497.             else    outline ||:= tab(0)
  13498.         }
  13499.         write(outline)
  13500.     }
  13501. end
  13502.  
  13503. This example is to illustrate set and unset used as boolean and is not a
  13504. complete solution.  Notice that this program fails when used to print
  13505. itself.  There are other design problems too.  Fix it?
  13506.  
  13507. > If one wanted to get very tricky with bit masks and 'exclusive or', that
  13508. > might be way to handle large amounts of booleans. 
  13509. > Returns the degree of bitmatch. Whether 'full', 'none', or 'some'. Or else
  13510. > maybe it could return a list containing the position numbers of matches? Or
  13511. > maybe 0 - 0 matches might not be included? Any other nifty variations?
  13512.  
  13513. Not like any boolean I ever saw.  I thought boolean implied on or off?
  13514.  
  13515. Jerry Nowlin (...!att!iwtqg!nowlin)
  13516.  
  13517. From gudeman  Mon May 14 14:08:20 1990
  13518. Date: Mon, 14 May 90 14:08:20 MST
  13519. From: "David Gudeman" <gudeman>
  13520. Message-Id: <9005142108.AA01957@megaron.cs.arizona.edu>
  13521. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  13522.     id AA01957; Mon, 14 May 90 14:08:20 MST
  13523. To: icon-group@cs.arizona.edu
  13524. In-Reply-To: nowlin@iwtqg.att.COM's message of Mon, 14 May 90 13:57 CDT <955E203F329FA1034C@Arizona.EDU>
  13525. Subject: boolean
  13526.  
  13527. How about using csets for booleans?  After all, they _do_ form a
  13528. boolean algebra.  Just subsitute
  13529.  
  13530.   &cset for TRUE
  13531.   '' for FALSE
  13532.   ++ for AND
  13533.   ** for OR
  13534.   ~ for NOT
  13535.  
  13536. Of course, this isn't very efficient...
  13537.  
  13538. More seriously, Pascal boolean values and operations represent an
  13539. inadequate attempt to force predicates to be functions.  This is
  13540. because Pascal does not support true predicates.  Icon doesn't support
  13541. true predicates either, but Icon's succeed/fail is closer to the pure
  13542. concept of valid/invalid than are Pascal's booleans.  There _are_ some
  13543. applications for having true/false as values, but these applications
  13544. are fairly rare, and the paradigm is easily simulated by other types
  13545. (as has been pointed out before).
  13546.  
  13547. From cargo@tardis.cray.com  Mon May 14 14:41:08 1990
  13548. Received: from timbuk.cray.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13549.     id AA04417; Mon, 14 May 90 14:41:08 MST
  13550. Received: from hall.cray.com by timbuk.CRAY.COM (4.1/CRI-1.34)
  13551.     id AA25102; Mon, 14 May 90 16:40:50 CDT
  13552. Received: from zk.cray.com by hall.cray.com
  13553.     id AA16667; 4.1/CRI-3.12; Mon, 14 May 90 16:40:47 CDT
  13554. Received: by zk.cray.com
  13555.     id AA11027; 3.2/CRI-3.12; Mon, 14 May 90 16:41:01 CDT
  13556. Date: Mon, 14 May 90 16:41:01 CDT
  13557. From: cargo@tardis.cray.com (David S. Cargo)
  13558. Message-Id: <9005142141.AA11027@zk.cray.com>
  13559. To: icon-group@cs.arizona.edu
  13560. Subject: boolean
  13561.  
  13562. I have found that I use one of two methods of dealing with "boolean"
  13563. operations in Icon.  One is the aforementioned use of null values
  13564. in a variable.  (I had a long time trying to memorize what operation
  13565. the / and \ operators performed.  I knew that they were for testing
  13566. for null and nonnull values, but I could never remember which did
  13567. what.  I finally developed this mnemonic device.  / slopes Up and
  13568. tests for Undefined; \ slopes Down and tests for Defined.  I
  13569. recognize that defined and undefined are not the exact Icon concepts,
  13570. but at least I can remember the operations now.)
  13571.  
  13572. The other way I deal with boolean operations is to use null records:
  13573.  
  13574. record true()
  13575. record false()
  13576. ...
  13577. flag := true()
  13578. ...
  13579. if type(flag) == "true"
  13580. then ...
  13581.  
  13582. I have also seen someone learning to program in Icon use
  13583.  
  13584. global false, true
  13585. ...
  13586. false := "false"
  13587. true := "true"
  13588. ...
  13589. etc.
  13590.  
  13591. dsc
  13592.  
  13593. From icon-group-request@arizona.edu  Tue May 15 10:01:48 1990
  13594. Resent-From: icon-group-request@arizona.edu
  13595. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13596.     id AA11683; Tue, 15 May 90 10:01:48 MST
  13597. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Tue, 15 May 90 09:58 MST
  13598. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA06788; Tue, 15 May 90
  13599.  09:54:45 -0700
  13600. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  13601.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  13602.  usenet@ucbvax.Berkeley.EDU if you have questions)
  13603. Resent-Date: Tue, 15 May 90 10:02 MST
  13604. Date: 15 May 90 16:54:40 GMT
  13605. From: usc!zaphod.mps.ohio-state.edu!uwm.edu!csd4.csd.uwm.edu!corre@ucsd.EDU
  13606. Subject: RE: boolean
  13607. Sender: icon-group-request@arizona.edu
  13608. Resent-To: icon-group@cs.arizona.edu
  13609. To: icon-group@arizona.edu
  13610. Resent-Message-Id: <94AD16B4707FA1085A@Arizona.EDU>
  13611. Message-Id: <3979@uwm.edu>
  13612. Organization: University of Wisconsin-Milwaukee
  13613. X-Envelope-To: icon-group@CS.Arizona.EDU
  13614. X-Vms-To: icon-group@Arizona.edu
  13615. References: <9005142141.AA11027@zk.cray.com>
  13616.  
  13617. In article <9005142141.AA11027@zk.cray.com> cargo@TARDIS.CRAY.COM (David S. Cargo) writes:
  13618. >I have found that I use one of two methods of dealing with "boolean"
  13619. >operations in Icon.  One is the aforementioned use of null values
  13620. >in a variable.  (I had a long time trying to memorize what operation
  13621. >the / and \ operators performed.  I knew that they were for testing
  13622. >for null and nonnull values, but I could never remember which did
  13623. >what.  
  13624.  
  13625. I had the same problem. I decided that the "natural" state of a variable
  13626. is null and the "natural" slash succeeds therefor. (Who ever saw a
  13627. backslash before they saw a computer?)
  13628. --
  13629. Alan D. Corre
  13630. Department of Hebrew Studies
  13631. University of Wisconsin-Milwaukee                     (414) 229-4245
  13632. PO Box 413, Milwaukee, WI 53201               corre@csd4.csd.uwm.edu
  13633.  
  13634. From gmt  Tue May 15 10:18:06 1990
  13635. Date: Tue, 15 May 90 10:18:06 MST
  13636. From: "Gregg Townsend" <gmt>
  13637. Message-Id: <9005151718.AA13161@megaron.cs.arizona.edu>
  13638. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  13639.     id AA13161; Tue, 15 May 90 10:18:06 MST
  13640. To: icon-group
  13641. Subject: mnemonics for / and \
  13642.  
  13643. I remember the meanings of / and \ by the slant of the first consonant in:
  13644.  
  13645.     /    iZnull
  13646.     \    Notnull
  13647.  
  13648. I read that first in this group, but I don't know who to credit.
  13649.  
  13650.     Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  13651.     +1 602 621 4325     gmt@cs.arizona.edu     110 57 16 W / 32 13 45 N / +758m
  13652.  
  13653. From goer@sophist.uchicago.EDU  Wed May 16 10:30:28 1990
  13654. Resent-From: goer@sophist.uchicago.EDU
  13655. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13656.     id AA10601; Wed, 16 May 90 10:30:28 MST
  13657. Return-Path: goer@sophist.uchicago.EDU
  13658. Received: from tank.uchicago.edu by Arizona.EDU; Wed, 16 May 90 10:28 MST
  13659. Received: from sophist.uchicago.edu by tank.uchicago.edu Wed, 16 May 90
  13660.  12:27:00 CDT
  13661. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA25307; Wed, 16 May 90
  13662.  12:22:22 CDT
  13663. Resent-Date: Wed, 16 May 90 10:28 MST
  13664. Date: Wed, 16 May 90 12:22:22 CDT
  13665. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  13666. Subject: problem:  Use records, tables, or lists?
  13667. Resent-To: icon-group@cs.arizona.edu
  13668. To: icon-group@arizona.edu
  13669. Resent-Message-Id: <93E0453CE8FFA0871E@Arizona.EDU>
  13670. Message-Id: <9005161722.AA25307@sophist.uchicago.edu>
  13671. X-Envelope-To: icon-group@CS.Arizona.EDU
  13672. X-Vms-To: icon-group@Arizona.edu
  13673.  
  13674. I have to make a very basic decision about how I'm going to imple-
  13675. ment a lexicon in some language processing I'm doing.  It's one of
  13676. those cases where many solutions present themselves, and the prob-
  13677. lem is which solution will really prove fastest and most flexible in the
  13678. long run.  It'll take me a moment to explain, so bear with me....
  13679.  
  13680. Let's say that I have a program which creates a little database.
  13681. Lets say that, at run time, I'm reading in a key, and maybe between
  13682. five and ten fields of information for that key:
  13683.  
  13684.     language:  part_of_speech, noun
  13685.                number, singular
  13686.                gender,
  13687.                person, 3
  13688.                etc.
  13689.  
  13690. Now I don't want to use a record, because the record is fixed in
  13691. terms of the number of fields it has.  Though access is very fast,
  13692. and I'd LIKE to use a record, I can't rely on knowing just what
  13693. and how many fields will be filled at run-time.  I also might need
  13694. to augment the record at run-time.  The natural idea of creating a
  13695. table with the keys being lexical items (e.g. "language"), and the
  13696. values being a record, won't work.
  13697.  
  13698. How about we keep the table, but instead of using a record as each
  13699. key's value, use instead another table?  I dunno.  What if the lexi-
  13700. con is a couple of thousand words long?  Will thousands of tables
  13701. with just five or ten elements work out?  Maybe someone familiar
  13702. with the internals of Icon heap allocation and memory management
  13703. will offer a guess as to whether this will ultimately prove a pro-
  13704. ductive method.  Like records, tables at least offer easy access via
  13705. fields or keys.  Unlike records, though, they are easily manipulated
  13706. at run-time.  This is their big advantage.
  13707.  
  13708. Another possibility is to use a list to store the various fields'
  13709. values (["part_of_speech.verb","number.singular"], or the like).  It
  13710. would be fairly easy to extract the values (untested!!!):
  13711.  
  13712.     procedure Get_Value(key)
  13713.         return !List ? (tab(find("."))==key,move(1),tab(0))
  13714.     end
  13715.  
  13716. The lists would be fairly small, but changing the values of fields
  13717. would become non-trivial, and perhaps a bit slow.  So would simply
  13718. accessing them.  The above procedure is going to take some time every
  13719. time it's called.  From previous experience with Icon, I'd say
  13720. it'd be less than a twentieth the speed of a simple record access.
  13721.  
  13722. Anyway, my question is which of these various solutions might in
  13723. the long run prove best.  The record solution isn't workable.  The
  13724. tables and lists are fine.  I don't know which will prove better in
  13725. terms of memory/speed.  Nor do I know whether there are other solutions I
  13726. might use (other than, say, using a set rather than a list, so that
  13727. insertions are not duplicating already existing material - but then
  13728. how much overhead is there for sets, over and above what I would
  13729. expect for a list?).
  13730.  
  13731. Any suggestions would be welcome.  Please feel free to write me or
  13732. post.  I'm not *only* interested in high-power comments about the
  13733. nature of the underlying implementation.  I'm sure that there are
  13734. lots of things I haven't thought of.
  13735.  
  13736.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  13737.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  13738.  
  13739. From cjeffery  Wed May 16 12:24:47 1990
  13740. Resent-From: "Clinton Jeffery" <cjeffery>
  13741. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13742.     id AA19678; Wed, 16 May 90 12:24:47 MST
  13743. Received: from megaron.cs.Arizona.EDU by Arizona.EDU; Wed, 16 May 90 12:26 MST
  13744. Received: from caslon.cs.arizona.edu by megaron.cs.arizona.edu (5.59-1.7/15)
  13745.  via SMTP id AA19652; Wed, 16 May 90 12:24:08 MST
  13746. Received: by caslon; Wed, 16 May 90 12:24:07 mst
  13747. Resent-Date: Wed, 16 May 90 12:26 MST
  13748. Date: Wed, 16 May 90 12:24:07 mst
  13749. From: Clinton Jeffery <cjeffery@cs.arizona.edu>
  13750. Subject: problem:  Use records, tables, or lists?
  13751. Resent-To: icon-group@cs.arizona.edu
  13752. To: goer@sophist.uchicago.EDU
  13753. Cc: icon-group@arizona.edu
  13754. Resent-Message-Id: <93CFC6EF2E5FA11CD4@Arizona.EDU>
  13755. Message-Id: <9005161924.AA08082@caslon>
  13756. In-Reply-To: Richard Goerwitz's message of Wed, 16 May 90 12:22:22 CDT
  13757.  <9005161722.AA25307@sophist.uchicago.edu>
  13758. X-Envelope-To: icon-group@CS.Arizona.EDU
  13759. X-Vms-To: goer@sophist.uchicago.EDU
  13760. X-Vms-Cc: icon-group@Arizona.edu
  13761.  
  13762. Richard Goerwitz asks: what is the best Icon representation for lexicon
  13763. entries which consist of a variable number of name-attribute pairs?  Records
  13764. are Icon's fastest group data type.  Unfortunately, records do not work for
  13765. everything.  A table of tables would provide acceptable speed but it would
  13766. be Really Really space-consuming.  Use it only if your lexical entries have
  13767. a LOT of fields.  A table of lists would use way less space, but run slower.
  13768.  
  13769. If your lexicon entries have a largely common set of field names,
  13770. I would suggest a hybrid approach.  Declare a record like
  13771.  
  13772.     record lexentry( part_of_speech, number, gender, person , other )
  13773.  
  13774. And allocate a list for the "other" field only for those entries which
  13775. have exotic fields.  Records use way less space than lists, so
  13776. you might declare ALL of the common fields, and use the "other" field
  13777. only for really weird words.
  13778.  
  13779. You can hide the hybrid approach with a few procedures similar to the one
  13780. you suggested, or better yet write an Idol class, and share it with me!
  13781. Here's a start:
  13782.  
  13783. procedure Get_Value(rec,key)
  13784.   return case key of {
  13785.   "part_of_speech": rec.part_of_speech
  13786.   "number":         rec.number
  13787.   "gender":         rec.gender
  13788.   "person":         rec.person
  13789.   default:  (!(\(rec.other)) ? (tab(find("."))==key,move(1),tab(0)))
  13790.   }
  13791. end
  13792.  
  13793. This is still a linear search through a bunch of strings, but when you
  13794. know you are accessing one of the builtin fields, you can just access
  13795. the field directly by name, e.g. rec.part_of_speech
  13796.  
  13797. Hope this helps,
  13798. Clint
  13799.  
  13800. From nowlin@iwtqg.att.COM  Wed May 16 13:17:17 1990
  13801. Resent-From: nowlin@iwtqg.att.COM
  13802. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13803.     id AA24036; Wed, 16 May 90 13:17:17 MST
  13804. Received: from att-in.att.com by Arizona.EDU; Wed, 16 May 90 13:12 MST
  13805. Resent-Date: Wed, 16 May 90 13:15 MST
  13806. Date: Wed, 16 May 90 14:17 CDT
  13807. From: nowlin@iwtqg.att.COM
  13808. Subject: RE: problem: Use records, tables, or lists?
  13809. Resent-To: icon-group@cs.arizona.edu
  13810. To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  13811. Resent-Message-Id: <93C8E778833FA11D54@Arizona.EDU>
  13812. Message-Id: <93C9678E1FDFA11951@Arizona.EDU>
  13813. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  13814. X-Envelope-To: icon-group@CS.Arizona.EDU
  13815. X-Vms-To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  13816.  
  13817. > Let's say that I have a program which creates a little database.
  13818. > Lets say that, at run time, I'm reading in a key, and maybe between
  13819. > five and ten fields of information for that key:
  13820. >     language:  part_of_speech, noun
  13821. >                number, singular
  13822. >                gender,
  13823. >                person, 3
  13824. >                etc.
  13825. > Now I don't want to use a record, because the record is fixed in
  13826. > terms of the number of fields it has.  Though access is very fast,
  13827. > and I'd LIKE to use a record, I can't ...
  13828. > ...
  13829. > Anyway, my question is which of these various solutions might in
  13830. > the long run prove best.  The record solution isn't workable.  The
  13831. > tables and lists are fine.  I don't know which will prove better in
  13832. > terms of memory/speed.  ...
  13833.  
  13834. I think the first rule of Icon programming should be:
  13835.  
  13836.     1) Don't worry about efficiency until you get it to work.
  13837.  
  13838. One of the beauties of Icon is that you can get this kind of application
  13839. going in a flash.  If you find efficiency in speed or memory a problem then
  13840. the real decision should be if you want to leave it in Icon so it's easy to
  13841. maintain (or if Icon is your only choice) or if you want to convert it to
  13842. something like C and really make it efficient.
  13843.  
  13844. This application sounds like a real good use for objects with inheritance. 
  13845. A base class of words could have attributes like length and frequency of
  13846. use.  The sub-class noun could have attributes like plural or singular and
  13847. the sub-class verb could have attributes like tense.  You get the idea.
  13848.  
  13849. I've done some pseudo class stuff like this with records of records in
  13850. Icon.  You can included function as fields in records that use other fields
  13851. in the record as arguments.
  13852.  
  13853.     record word(word,length,freq,details)
  13854.     record noun(number,gender,...)
  13855.     record verb(tense,object,...)
  13856.  
  13857. With this data layout a noun or verb record could be assigned to the
  13858. details member of a word record and another word.noun record could be
  13859. assigned to the object member of a verb record?  This example assumes I
  13860. know something about English grammar which could suffer the fate of most
  13861. assumptions.
  13862.  
  13863. Maybe the Idol language (which I've heard about but haven't looked into
  13864. yet...I'm busy) actually has this kind of feature built in.  Does it?
  13865.  
  13866. Jerry
  13867.  
  13868. From tenaglia@fps.mcw.edu  Wed May 16 14:09:46 1990
  13869. Received: from RUTGERS.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13870.     id AA29152; Wed, 16 May 90 14:09:46 MST
  13871. Received: from uwm.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.06) with UUCP 
  13872.     id AA09621; Wed, 16 May 90 16:45:02 EDT
  13873. Received: by uwm.edu; id AA08551; Wed, 16 May 90 15:38:13 -0500
  13874. Message-Id: <9005162038.AA08551@uwm.edu>
  13875. Received: from mis by fps.mcw.edu (DECUS UUCP w/Smail);
  13876.           Wed, 16 May 90 14:59:07 CDT
  13877. Received: by mis.mcw.edu (DECUS UUCP w/Smail);
  13878.           Wed, 16 May 90 14:41:06 CDT
  13879. Date: Wed, 16 May 90 14:41:06 CDT
  13880. From: Chris Tenaglia - 257-8765 <tenaglia@mis.mcw.edu>
  13881. To: icon-group@cs.arizona.edu
  13882. Subject: Lexicon Database
  13883.  
  13884.  
  13885. Concerning the generation of a lexicon, and what are the best structures,...
  13886.  
  13887. I think I have played with similar concepts in a different application a long
  13888. time ago. I think a table is nice. The word in question is the entry. To the
  13889. assigned value a long delimted string with a fixed rule tree for each part of
  13890. language.
  13891.  
  13892. For example :   vocab := table()
  13893.                 vocab["car"] := "noun,singular,neuter,A motorized vehicle"
  13894.                 vocab["cows"]:= "noun,plural,female,Female Cattle"
  13895.                 vocab["red"] := "adjective,Color"
  13896.                 vocab["a"]   := "article,singular,Indefinite article for one"
  13897.                 vocab["any"] := "article,plural,Indefinate article for many"
  13898.                 vocab["paint"]:="verb,transitive,Apply a colored fluid"
  13899.                 vocab["jump"]:= "verb,intransitive,Hop over"
  13900.  
  13901. Depending on the eventual application, this may or may not work. One tranvesty
  13902. generator I wrote, used separate lists loaded from files for each part of the
  13903. language. It was pretty random and useless. The structure above, is more
  13904. flexible, and easy to parse.
  13905.  
  13906. Chris Tenaglia (System Manager)
  13907. Medical College of Wisconsin
  13908. 8701 W. Watertown Plank Rd.
  13909. Milwaukee, WI 53226
  13910. (414)257-8765
  13911. tenaglia@mis.mcw.edu
  13912.  
  13913.  
  13914. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Wed May 16 19:28:36 1990
  13915. Received: from umich.edu by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13916.     id AA19823; Wed, 16 May 90 19:28:36 MST
  13917. Received: from ummts.cc.umich.edu by umich.edu (5.61/1123-1.0)
  13918.     id AA18730; Wed, 16 May 90 22:28:12 -0400
  13919. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 16 May 90 22:27:03 EDT
  13920. Date: Wed, 16 May 90 18:36:08 EDT
  13921. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  13922. To: icon-group@cs.arizona.edu
  13923. Message-Id: <225766@Wayne-MTS>
  13924. Subject: Booleans
  13925.  
  13926.  
  13927. Booleans and success/failure play complementary roles in a programming
  13928. language.  You can think of a boolean as capturing and preserving the result
  13929. of success/failure.  It's too bad that Icon doesn't have natural boolean
  13930. operators.  Of course there are umpteen ways to fake them, but none of those
  13931. ways are quite as nice as the standard boolean operators (where I include
  13932. short-circuit "and" and "or" among the standard boolean operators, as they are
  13933. in C).  But I'd much rather have a language like Icon that has success/failure
  13934. but lacks true booleans than a language like Pascal that lacks success/failure
  13935. but has true booleans.
  13936.  
  13937. My approach in SPLASH is to provide both.  The ? operator converts
  13938. success/failure to true/false, while the "is" operator converts true/false to
  13939. success/failure.  Here's an example of a SPLASH generator that illustrates
  13940. these operators.  The generator merges the output of a sequence of other
  13941. generators.
  13942.  
  13943. merge: generic(t) process(stream(*): generator(t)) yield t is
  13944.     declare
  13945.         found: boolean
  13946.     in do { % get one element from each stream
  13947.             found := false
  13948.             for i in stream'range do
  13949.                 found |:= ?yield *stream(i) % yield is like suspend
  13950.             }
  13951.         until is ~found
  13952. end merge
  13953.  
  13954. Paul Abrahams
  13955.  
  13956. From markc%essex.ac.uk@NSFnet-Relay.AC.UK  Thu May 17 00:26:16 1990
  13957. Received: from nsfnet-relay.ac.uk by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13958.     id AA04423; Thu, 17 May 90 00:26:16 MST
  13959. Received: from sun.nsfnet-relay.ac.uk by vax.NSFnet-Relay.AC.UK 
  13960.            via Janet with NIFTP  id aa01072; 17 May 90 8:03 BST
  13961. Received: from ese by servax0.sx.ac.uk   SMTP/TCP  id aa15922;
  13962.           17 May 90 8:20 WET DST
  13963. From: Clark Mark <markc%essex.ac.uk@NSFnet-Relay.AC.UK>
  13964. Date: Thu, 17 May 90 08:20:24 +0100
  13965. Message-Id: <794.9005170720@ese.essex.ac.uk>
  13966. To: icon-group@cs.arizona.edu
  13967. Subject: Withdrawl
  13968.  
  13969. Please remove my name from your icon-group, thanks.
  13970.  
  13971. From nowlin@iwtqg.att.COM  Thu May 17 05:50:28 1990
  13972. Resent-From: nowlin@iwtqg.att.COM
  13973. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  13974.     id AA18791; Thu, 17 May 90 05:50:28 MST
  13975. Received: from att-in.att.com by Arizona.EDU; Thu, 17 May 90 05:49 MST
  13976. Resent-Date: Thu, 17 May 90 05:51 MST
  13977. Date: Thu, 17 May 90 07:37 CDT
  13978. From: nowlin@iwtqg.att.COM
  13979. Subject: RE: problem: Use records, tables, or lists?
  13980. Resent-To: icon-group@cs.arizona.edu
  13981. To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  13982. Resent-Message-Id: <933DBD555FFFA12404@Arizona.EDU>
  13983. Message-Id: <933E0EF7CFFFA1195A@Arizona.EDU>
  13984. Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
  13985. X-Envelope-To: icon-group@CS.Arizona.EDU
  13986. X-Vms-To: arizona.edu!icon-group%att.UUCP@cs.arizona.edu
  13987.  
  13988. Regarding records and their use in holding features such as
  13989. number, gender, word-class:
  13990.  
  13991. I've looked over the solutions offered, and have found them
  13992. tempting.  Whatever I end up doing, I'll post the code.  It'll
  13993. end up a left corner bottom-up parser (that way I can avoid
  13994. the problem of left recursion which so often comes up in
  13995. natural languages).  I've decided, at least provisionally,
  13996. against the "record" solution.  Let me explain why.  The rea-
  13997. son might not be obvious to people working primarily with
  13998. regular languages or with programming languages that can
  13999. be handled with a deterministic pushdown automaton.
  14000.  
  14001. If I use records, I'll have to do things like decide what the
  14002. most often used categories will be, and then enforce a con-
  14003. stant spelling across all files (i.e. no sing, s, singular -
  14004. just one of them).  What's terrible about this is that, even
  14005. if I do remember all the naming conventions, I'll be sad-
  14006. dled with lots of extraneous record fields.  Arabic and Ugar-
  14007. itic, say, will use a dual category.  This will be superflu-
  14008. ous for English, German, Hebrew, etc. (but not, say, clas-
  14009. sical Greek).  Likewise, gender will be important for French,
  14010. German, Latin, Arabic, less so for Dutch, and hardly at all
  14011. for English.  What I'm attempting to illustrate is that, if
  14012. the system is to achieve some theoretical elegance (and a
  14013. nice, clean look, too), it's not going to be desirable to
  14014. spend any effort trying to predict what categories will be
  14015. most often used.  Even if we were talking about a single-
  14016. language system, many categories would not come into play
  14017. for a given range of constructions.
  14018.  
  14019. It is true that, at some point, especially when dealing with
  14020. a specific set of problems within a specific language, I
  14021. *might* find it sensible to introduce records.  However, as
  14022. Jerry Nowlin pointed out, at this stage it is important to
  14023. make it work rather than start worrying too much about
  14024. speed.
  14025.  
  14026. This doesn't mean that speed is not a consideration.  It is
  14027. important that I not lose sight of it.  Memory requirements
  14028. are also important (which is why I can't just use tables and
  14029. forget it).  My tendency right now is to use lists or sets.
  14030. But I dunno.  I do know that records will take me way out of
  14031. line with what the system itself needs in order to operate
  14032. cleanly and elegantly.
  14033.  
  14034.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  14035.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  14036.  
  14037. From esquire!info8!yost@cmcl2.NYU.EDU  Thu May 17 08:02:51 1990
  14038. Received: from NYU.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  14039.     id AA25200; Thu, 17 May 90 08:02:51 MST
  14040. Received: by cmcl2.NYU.EDU (5.61/1.34)
  14041.     id AA07024; Thu, 17 May 90 11:03:40 -0400
  14042. Received: from info8 by ESQUIRE.DPW. id aa21254; 17 May 90 10:57 EDT
  14043. Received: from localhost by info8. (4.0/SMI-4.0)
  14044.     id AA02151; Thu, 17 May 90 10:59:56 EDT
  14045. Message-Id: <9005171459.AA02151@info8.>
  14046. From: yost@DPW.COM (Dave Yost)
  14047. Reply-To: yost@DPW.COM (Dave Yost)
  14048. To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  14049. Cc: icon-group@cs.arizona.edu, yost@cmcl2.NYU.EDU
  14050. Subject: Re: Booleans 
  14051. In-Reply-To: Your message of Wed, 16 May 90 18:36:08 EDT.
  14052.              <225766@Wayne-MTS> 
  14053. Phone: +1 212-266-0796 (Voice Direct Line)
  14054. Fax: +1 212-266-0790
  14055. Organization: Davis Polk & Wardwell
  14056.           1 Chase Manhattan Plaza
  14057.           New York, NY  10005
  14058. Date: Thu, 17 May 90 10:59:53 -0400
  14059. Sender: yost@info8.NYU.EDU
  14060.  
  14061. > Booleans and success/failure play complementary roles in a programming
  14062. > language.  You can think of a boolean as capturing and preserving the result
  14063. > of success/failure.  It's too bad that Icon doesn't have natural boolean
  14064. > operators.  Of course there are umpteen ways to fake them, but none of those
  14065. > ways are quite as nice as the standard boolean operators (where I include
  14066. > short-circuit "and" and "or" among the standard boolean operators, as they are
  14067. > in C).  But I'd much rather have a language like Icon that has success/failure
  14068. > but lacks true booleans than a language like Pascal that lacks success/failure
  14069. > but has true booleans.
  14070.  
  14071. I agree!  Is there even a convention in Icon on how to store true/false
  14072. state?  I've used both (\x) and (x = 1) and (x ~= 0) as true/false indicators.
  14073. The last two (last one preferred)  I have found better because I get the
  14074. extra benefit of a runtime error if I try to test x before it is set --
  14075. which can also be *not* what you want sometimes.  Mostly I would rather
  14076. have a syntax that says what I mean than to use a nonstandardized fake.
  14077. Someone reading the code (x ~= 0) has to look around to see if x can take
  14078. on more than two values.
  14079.  
  14080.  --dave yost
  14081.    yost@dpw.com or uunet!esquire!yost
  14082.    Please ignore the From or Reply-To fields above, if different.
  14083.  
  14084. From utah-cs!cs.utexas.edu!yale!LRW.COM!lrw!leichter  Thu May 17 08:39:49 1990
  14085. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  14086.     id AA28306; Thu, 17 May 90 08:39:49 MST
  14087. Received: from cs.utexas.edu by cs.utah.edu (5.61/utah-2.11-cs)
  14088.     id AA17130; Thu, 17 May 90 09:39:21 -0600
  14089. Posted-Date: Thu, 17 May 90 11:08:45 EDT
  14090. Received: from ames.arc.nasa.gov by cs.utexas.edu (5.61/1.62)
  14091.     id AA16008; Thu, 17 May 90 10:35:48 -0500
  14092. Received: from harvard.harvard.edu by ames.arc.nasa.gov (5.61/1.2); Thu, 17 May 90 08:35:30 -0700
  14093. Received: by harvard.harvard.edu (5.54/a0.25)
  14094.     (for cs.utexas.edu!utah-cs!arizona!CS.Arizona.EDU!icon-group) id AA28867; Thu, 17 May 90 11:35:11 EDT
  14095. Received: from lrw.UUCP by BULLDOG.CS.YALE.EDU via UUCP; Thu, 17 May 90 11:08:10 EDT
  14096. Message-Id: <9005171508.AA01693@BULLDOG.CS.YALE.EDU>
  14097. Received: by lrw.UUCP (DECUS UUCP w/Smail);
  14098.           Thu, 17 May 90 11:08:45 EDT
  14099. Date: Thu, 17 May 90 11:08:45 EDT
  14100. From: <utah-cs!cs.utexas.edu!yale!LRW.COM!leichter>
  14101. To: CS.Arizona.EDU!icon-group@cs.utexas.edu
  14102. Subject: RE: problem: Use records, tables, or lists?
  14103. X-Vms-Mail-To: IN::"icon-group@CS.Arizona.EDU"
  14104.  
  14105. There's actually a standard technique to deal with this kind of problem.
  14106. Stated more generally:  You have a set of pairs of names and (attribute,value)
  14107. pairs; for example:
  14108.  
  14109.     {("green",{("part","adjective"),("plural","none")}),
  14110.         ("dog",{("part","noun")})}
  14111.  
  14112. You are viewing this as a two-level hierarchy:  First you map from the name
  14113. ("green") to the set of pairs {(part,adjective),(plural,none)}; then within
  14114. that set of pairs, you map an attribute ("part") to a value ("adjective").
  14115. The problem with this approach, as you've noted, is that the lower level of
  14116. the hierarchy is difficult to implement efficiently:  It consists of many
  14117. small collections, and you are forced to pay the overhead of a data structure
  14118. per collection.
  14119.  
  14120. So, the trick is to amortize the cost by collapsing the hierarchy.  Logically,
  14121. this involves changing the collection above to the following:
  14122.  
  14123.     {(("green","part"),"adjective"),(("green","plural"),"none"),
  14124.         (("dog","part"),"noun")}
  14125.  
  14126. That is, where you previously had two functions of one argument,
  14127. word-to-attribute-list and attribute-to-value, you now have a single function,
  14128. word-and-attribute-to-value.
  14129.  
  14130. In Icon terms, this is very simple:  Make a single table whose keys consist
  14131. of name-attribute pairs, which could be records or simply strings (e.g.,
  14132. "green:part"), and whose values are the values you want associated.
  14133.  
  14134. The advantage of this approach is that you pay the cost of table maintenance
  14135. only once.  As long as large tables are efficiently implemented, this method
  14136. will work very well.
  14137.  
  14138. What you lose if you use this approach is the ability to pick up all the
  14139. attribute-value pairs associated with a single word:  There is no efficient
  14140. way to extract from a table everything whose key is of the from
  14141. "green:<something>".  Depending on your application, this may not be an issue
  14142. at all, or it may be one that you can work around.  For example, you can
  14143. maintain a separate table in which the keys are words and the values are
  14144. lists of attributes.  This will work well unless you need to look up all
  14145. the attributes very often, or you change the attribute lists associated with
  14146. a given word frequently.
  14147.  
  14148. There are, of course, many possible optimizations.  For example, if there is
  14149. a list of common attributes which almost all words have values for, it is
  14150. probably better to store those in a separate record, and only store the extras
  14151. in the table.  Optimizing the common case often gives you most of the perfor-
  14152. mance advantage with very little of the extra cost.
  14153.                             -- Jerry
  14154.  
  14155. From gmt  Thu May 17 10:07:02 1990
  14156. Date: Thu, 17 May 90 10:07:02 MST
  14157. From: "Gregg Townsend" <gmt>
  14158. Message-Id: <9005171707.AA04752@megaron.cs.arizona.edu>
  14159. Received: by megaron.cs.arizona.edu (5.59-1.7/15)
  14160.     id AA04752; Thu, 17 May 90 10:07:02 MST
  14161. To: icon-group
  14162. Subject: memory requirements of tables
  14163.  
  14164. Small tables in Icon v8 use *much* less space than in version 7.  This doesn't
  14165. necessarily make them the best approach (small records are still cheaper), but
  14166. don't make any decisions based on the old version's behavior.
  14167.  
  14168.     Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  14169.     +1 602 621 4325     gmt@cs.arizona.edu     110 57 16 W / 32 13 45 N / +758m
  14170.  
  14171. From goer@sophist.uchicago.EDU  Fri May 18 13:49:44 1990
  14172. Resent-From: goer@sophist.uchicago.EDU
  14173. Received: from Maggie.Telcom.Arizona.EDU by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  14174.     id AA00357; Fri, 18 May 90 13:49:44 MST
  14175. Return-Path: goer@sophist.uchicago.EDU
  14176. Received: from tank.uchicago.edu by Arizona.EDU; Fri, 18 May 90 13:48 MST
  14177. Received: from sophist.uchicago.edu by tank.uchicago.edu Fri, 18 May 90
  14178.  15:21:45 CDT
  14179. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA28592; Fri, 18 May 90
  14180.  15:14:27 CDT
  14181. Resent-Date: Fri, 18 May 90 13:48 MST
  14182. Date: Fri, 18 May 90 15:14:27 CDT
  14183. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  14184. Subject: deterministic automata
  14185. Resent-To: icon-group@cs.arizona.edu
  14186. To: icon-group@arizona.edu
  14187. Resent-Message-Id: <923202F42DFFA12DCC@Arizona.EDU>
  14188. Message-Id: <9005182014.AA28592@sophist.uchicago.edu>
  14189. X-Envelope-To: icon-group@CS.Arizona.EDU
  14190. X-Vms-To: icon-group@Arizona.edu
  14191.  
  14192. Thanks to everyone who responded regarding converting nondeterministic
  14193. finite state automata to deterministic ones.
  14194.  
  14195. I read and thought about the responses for a couple of days.  The dfsa
  14196. would be too big, I gathered - at least in some instances.  And rarely
  14197. would all of it get used.  So I just built a program that makes the
  14198. nfsa, and then builds the dfsa as it goes, removing epsilon moves, and
  14199. collapsing states together on the fly.
  14200.  
  14201. It is true that this system works out conceptually very cleanly.  I
  14202. just found that it is slow, slow, slow.
  14203.  
  14204. The reason is that, in order for it to work, I could not play games that
  14205. I use with fsa's and pushdown automata, namely utilize Icon's existing
  14206. functions like find, any, match, etc.  I had to break each step down
  14207. into a node and arcs labeled with a single character.  Only in this man-
  14208. ner is it easy to find out, after removing epsilon moves, and multiplying
  14209. out the states, whether two or more arcs with the same label diverge from
  14210. a single state(-set).  I also have not found a good, clean way of using
  14211. Icon to make references to state-sets clean.  It's not a matter of making
  14212. table which stores simple integer-labeled nodes.  We're not talking about
  14213. states that can be labeled with simple integers anymore, but rather sets
  14214. of integers (corresponding to states in the nfsa).
  14215.  
  14216. Anyway, although converting an nfsa to a dfsa proved pretty easy, I have
  14217. yet to make it really efficient within Icon.
  14218.  
  14219. Having said this, let me ask if anyone else has played with dfsa's in
  14220. Icon.  Has anyone found a clean way of referring to (and checking for
  14221. the previous existence of) sets of states?  I don't even have a good way
  14222. of, say, collecting final state-sets together and storing them.  I have 
  14223. to convert them to some other data type (usually a string), and then
  14224. store them in this form.  Lotsa space.  I also have no way of easily
  14225. getting back to using any() for what corresponds to regular expressions
  14226. such as [a-z].  I'm sure I could somehow collect the arcs, check to
  14227. see whether they point to the same state-sets (with the attendant prob-
  14228. lems noted above regarding uniqueness of sets), and then make them all
  14229. point to a string equivalent to the set which they all lead to, and
  14230. then enter that string equivalent in a table....
  14231.  
  14232. My mind's beginning to wander as I try to fathom the overhead.  Is this
  14233. really a job I should reasonably only be doing in C, or am I just mis-
  14234. sing some shortcuts?
  14235.  
  14236. I have, by the way, made the nfsa work all by itself pretty nicely and
  14237. efficiently in Icon (small, too - just a couple of table entries).  It's
  14238. the dfsa that's killing me.
  14239.  
  14240.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  14241.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  14242.  
  14243. From nevin1@ihlpb.att.com  Fri May 18 16:18:47 1990
  14244. Message-Id: <9005182318.AA10442@megaron.cs.arizona.edu>
  14245. Received: from att-in.att.com by megaron.cs.arizona.edu (5.59-1.7/15) via SMTP
  14246.     id AA10442; Fri, 18 May 90 16:18:47 MST
  14247. From: nevin1@ihlpb.att.com
  14248. Date: Fri, 18 May 90 17:53 CDT
  14249. Original-From: ihlpb!nevin1 (Nevin J Liber +1 708 979 4751)
  14250. To: att!cs.arizona.edu!icon-group
  14251. Cc: Richard Goerwitz <att!sophist.uchicago.EDU!goer>
  14252. Subject: Re: deterministic automata
  14253.  
  14254. Richard Goerwitz <goer@sophist.uchicago.EDU> writes:
  14255. >We're not talking about
  14256. >states that can be labeled with simple integers anymore, but rather sets
  14257. >of integers (corresponding to states in the nfsa).
  14258.  
  14259. But you CAN still use integers (especially since Icon now has
  14260. arbitrarily large integers); all you need to do is encode the states.
  14261.  
  14262. You could use a binary encoding scheme, where each position corresponds
  14263. to a state in the NFA (non-deterministic finite automata).
  14264.  
  14265. Suppose that your DFA (deterministic finite automata) state is [0,2,3].
  14266. Converting this to a binary string, you get (from most significant bit
  14267. to least significant bit) "1101" (bits 3, 2, and 0 are "on").
  14268. This is easily converted to 13, an integer (in Icon, try converting
  14269. with integer("2r" || "1101"), or the "uglier" 2^3 + 2^2 +2^0), or
  14270. you can keep it in binary string form if that is more convenient.
  14271. [Note:  for the string form, it may or may not prove useful to pad it
  14272. out with 0's on the left so all the strings have the same length, which
  14273. would be equal to the number of states in the NFA.]
  14274.  
  14275. Once in this form, the problem you had with the inefficiency of having
  14276. different sets of the exact same elements goes away, and it is still
  14277. relatively easy to check and see if a given NFA state is part of a
  14278. certain DFA state (in binary string form, for example, use
  14279. dfaState[-1 - nfaState]).
  14280.  
  14281. >Anyway, although converting an nfsa to a dfsa proved pretty easy, I have
  14282. >yet to make it really efficient within Icon.
  14283.  
  14284. But how often are you going to do the conversion?  Unless you are
  14285. building these state machines on the fly, this part of the project
  14286. probably isn't worth making more efficient.
  14287.  
  14288.     NEVIN ":-)" LIBER  nevin1@ihlpb.ATT.COM  (708) 831-FLYS
  14289.  
  14290. From icon-group-request@arizona.edu  Wed May 23 12:41:08 1990
  14291. Resent-From: icon-group-request@arizona.edu
  14292. Received: from Arizona.EDU (Maggie.Telcom.Arizona.EDU) by megaron (5.61/15) via SMTP
  14293.     id AA19800; Wed, 23 May 90 12:41:08 -0700
  14294. Received: from ucbvax.Berkeley.EDU by Arizona.EDU; Wed, 23 May 90 12:40 MST
  14295. Received: by ucbvax.Berkeley.EDU (5.63/1.41) id AA08014; Wed, 23 May 90
  14296.  12:32:25 -0700
  14297. Received: from USENET by ucbvax.Berkeley.EDU with netnews for
  14298.  icon-group@arizona.edu (icon-group@arizona.edu) (contact
  14299.  usenet@ucbvax.Berkeley.EDU if you have questions)
  14300. Resent-Date: Wed, 23 May 90 12:41 MST
  14301. Date: 23 May 90 18:27:14 GMT
  14302. From: usc!snorkelwacker!ai-lab!idsardi@ucsd.EDU
  14303. Subject: graphics
  14304. Sender: icon-group-request@arizona.edu
  14305. Resent-To: icon-group@cs.arizona.edu
  14306. To: icon-group@arizona.edu
  14307. Resent-Message-Id: <8E4D882E88FF2012D2@Arizona.EDU>
  14308. Message-Id: <8683@rice-chex.ai.mit.edu>
  14309. Organization: MIT Artificial Intelligence Laboratory
  14310. X-Envelope-To: icon-group@CS.Arizona.EDU
  14311. X-Vms-To: icon-group@Arizona.edu
  14312.  
  14313. I'm looking to draw some trees and graphs, especially
  14314. on the Mac.  I have ProIcon and was wondering whether
  14315. there's a hack that would allow quickdraw calls to
  14316. be made on ProIcon windows.  Barring that does anyone
  14317. have character-oriented graphics, stuff that would
  14318. approximate line drawing.
  14319.  
  14320. Thanks,
  14321.  
  14322. Bill Idsardi
  14323.  
  14324. From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS  Thu May 24 07:34:19 1990
  14325. Received: from umich.edu by megaron (5.61/15) via SMTP
  14326.     id AA10074; Thu, 24 May 90 07:34:19 -0700
  14327. Received: from ummts.cc.umich.edu by umich.edu (5.61/1123-1.0)
  14328.     id AA03230; Thu, 24 May 90 10:34:18 -0400
  14329. Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Thu, 24 May 90 10:33:00 EDT
  14330. Date: Wed, 23 May 90 22:45:42 EDT
  14331. From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
  14332. To: icon-group@cs.arizona.edu
  14333. Message-Id: <227438@Wayne-MTS>
  14334. Subject: Coexpressions revisited
  14335.  
  14336.  
  14337. In some earlier messages I advanced the view that there really wasn't much use
  14338. in Icon for coexpressions other than those that returned values via `suspend'.
  14339. In other words, coexpressions should be limited to the generalization of
  14340. generators that would enable them to be called from different places or from
  14341. the same place at different times.  Such coexpressions seemed capable of doing
  14342. all the "interesting" examples, such as interleaving the output of two
  14343. generators. 
  14344.  
  14345. Since then I've thought of another example that shows why the more general form
  14346. of coexpressions might be needed after all.  This example is not theoretical
  14347. at all.
  14348.  
  14349. Suppose we want to write an error-listing routine `errlist' that receives
  14350. error messages, each consisting of a page number and a string.  We want the
  14351. output of this routine to indicate all the errors on a page, listing the page
  14352. number *just once*.  Easy enough with an ordinary procedure, it seems.  But
  14353. now let's impose one restriction: `errlist' cannot use any static or
  14354. global variables to save its state from one call to another.  This restriction
  14355. is one often encountered in writing recursive procedures.  Now `errlist' has a
  14356. problem: how to know if an error message has the same page number as its
  14357. predecessor. 
  14358.  
  14359. Here's how `errlist' might be written using coexpressions(I haven't tested it):
  14360.  
  14361. record errmessage(page, text)
  14362.  
  14363. procedure errmessage()
  14364.    local prevpage, err
  14365.    repeat {
  14366.       while (err := @&source).page = \prevpage do 
  14367.          write(repl(" ", 10), err.text)
  14368.       write(right(err.page, 8), "  ", text)
  14369.       prevpage = err.page
  14370.    }
  14371. end
  14372.  
  14373. If `errlist' produced values instead of receiving them, we could make it into
  14374. a single coexpression that suspended the values in turn.  But there's no
  14375. `accept' expression corresponding to `suspend', so  `errlist' needs to use @
  14376. to pick up the message pairs, and the various callers need to use @ to
  14377. transmit those pairs.  There is a kludgy way around this: `errlist' suspends a
  14378. record object, and the caller fills in the object.  When `errlist' gets
  14379. control back, it processes whatever is in the object.  But this kludge is not
  14380. at all satisfying; not only is it awkward to use, but it requires special
  14381. handling to initiate and terminate `errlist'.
  14382.  
  14383. A more intuitive explanation of what's going on here is that connecting
  14384. coexpressions via `suspend' provides a form of input piping, rather like Unix
  14385. but generalized to allow several inputs to one filter.  Input piping usually
  14386. suffices, but in cases such as 'errlist', output piping is needed as well.
  14387.  
  14388. Paul Abrahams
  14389. abrahams%wayne-mts@um.cc.umich.edu
  14390.  
  14391. From pax@ihcup.att.com  Thu May 24 15:48:42 1990
  14392. Date: Thu, 24 May 90 15:48:42 -0700
  14393. From: pax@ihcup.att.com
  14394. Message-Id: <9005242248.AA14248@megaron.cs.arizona.edu>
  14395. Received: from att.UUCP by megaron.cs.arizona.edu (5.61/15) via UUCP
  14396.     id AA14248; Thu, 24 May 90 15:48:42 -0700
  14397. To: icon-group@arizona.att.com
  14398. Subject: Icon cross ref
  14399.  
  14400. I seem to remember some time ago that someone posted to this group
  14401. the Icon source for an Icon Cross Refrence program.  At the time I
  14402. did not save the source but would now like to have such a program.
  14403.  
  14404. I need to cross reference Iocn V8 procedures and global variables.
  14405.  
  14406. I would appreciate it very much if the provider(s) of cross reference
  14407. program(s) would send me the source to:
  14408.  
  14409.     att!ihcup!pax
  14410.  
  14411. Thanks
  14412.  
  14413. Joe T. Hall
  14414. AT&T Bell Laboratories
  14415. 200 Park Plaza, Room IHP 2B-524
  14416. Naperville, Illinois 60566-7050
  14417. USA
  14418. att!ihcup!pax
  14419. tel: +1 708 713-7285
  14420. fax: +1 708 713-7480
  14421. tlx:157294384(JTHALL)
  14422.  
  14423. From buchs@Mayo.edu  Tue May 29 12:57:36 1990
  14424. Received: from fermat.Mayo.edu by megaron (5.61/15) via SMTP
  14425.     id AA04505; Tue, 29 May 90 12:57:36 -0700
  14426. Received: from FALCON.DECnet MAIL11D_V3 by fermat.Mayo.edu (5.57/Ultrix2.4-C)
  14427.     id AA16575; Tue, 29 May 90 14:48:07 CDT
  14428. Date: Tue, 29 May 90 14:48:06 CDT
  14429. Message-Id: <9005291948.AA16575@fermat.Mayo.edu>
  14430. From: buchs@Mayo.edu
  14431. To: :"icon-group@cs.arizona.edu"@FERMAT
  14432. Cc: BUCHS@fermat.Mayo.edu
  14433. Subject: beginner help
  14434.  
  14435.  
  14436. I have just started with Icon.  It looks like I really need to
  14437. get "The Icon Programming Language" to get very far.  What have
  14438. others done?  I have found a bit of info in some of the TR
  14439. documents and I could probably read through some of the library
  14440. programs to get ideas.
  14441.  
  14442. I am trying to parse a file with lines of backslash delimited
  14443. fields, with no trailing delimiter:
  14444.  
  14445.   field1\field2\field3
  14446.  
  14447. I thought I was on to an elegant way with the string scanning
  14448. operator:
  14449.  
  14450.   procedure main()
  14451.     while line := read() do {
  14452.       line ? while write(tab(find("\\")))
  14453.         do move(1)
  14454.     }
  14455.   end
  14456.  
  14457. But I cannot get the last field.  Any ideas?
  14458. -------------------------------------------------------------
  14459. Kevin Buchs          Internet: buchs@mayo.edu
  14460. Mayo Foundation              Is this my life or is it just an
  14461. Rochester, MN 55905          incredible, high-speed, simulation?
  14462. (507) 284-0009                         -S. R. Cleaves
  14463. -------------------------------------------------------------
  14464.  
  14465.  
  14466. From goer@sophist.uchicago.EDU  Tue May 29 16:37:23 1990
  14467. Resent-From: goer@sophist.uchicago.EDU
  14468. Received: from Arizona.EDU (Maggie.Telcom.Arizona.EDU) by megaron (5.61/15) via SMTP
  14469.     id AA21065; Tue, 29 May 90 16:37:23 -0700
  14470. Return-Path: goer@sophist.uchicago.EDU
  14471. Received: from tank.uchicago.edu by Arizona.EDU; Tue, 29 May 90 16:27 MST
  14472. Received: from sophist.uchicago.edu by tank.uchicago.edu Tue, 29 May 90
  14473.  18:26:43 CDT
  14474. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA13953; Tue, 29 May 90
  14475.  18:22:07 CDT
  14476. Resent-Date: Tue, 29 May 90 16:29 MST
  14477. Date: Tue, 29 May 90 18:22:07 CDT
  14478. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  14479. Resent-To: icon-group@cs.arizona.edu
  14480. To: icon-group@arizona.edu
  14481. Resent-Message-Id: <8976B8E3B55F20A047@Arizona.EDU>
  14482. Message-Id: <9005292322.AA13953@sophist.uchicago.edu>
  14483. X-Envelope-To: icon-group@CS.Arizona.EDU
  14484. X-Vms-To: icon-group@Arizona.edu
  14485.  
  14486.   I am trying to parse a file with lines of backslash delimited
  14487.   fields, with no trailing delimiter:
  14488.  
  14489.     field1\field2\field3
  14490.  
  14491.   I thought I was on to an elegant way with the string scanning
  14492.   operator:
  14493.  
  14494.     procedure main()
  14495.       while line := read() do {
  14496.         line ? while write(tab(find("\\")))
  14497.           do move(1)
  14498.       }
  14499.     end
  14500.  
  14501. It looks to me as though, for a beginner, you have gotten pretty
  14502. far into string scanning.  Nice work.
  14503.  
  14504. The problem is easy to see - once, that is, you "get it."  Find()
  14505. will tell you the position in line (the subject of the string-
  14506. scanning operation) at which a backslash occurs.  Tab() will then
  14507. move you there.  This works fine for a while.  But what happens
  14508. when you've come to the last \, have move()'d past it?  You have
  14509. no backslashes left on the line to find(), and so naturally find()
  14510. fails, the loop fails, the scanning espression fails, and you
  14511. are sent back for another input string.
  14512.  
  14513. Try doing something like this:
  14514.  
  14515. while line := read() do {
  14516.   line ? {
  14517.     while write(tab(find("\\")|0))
  14518.     do move(1) | break
  14519.   }
  14520. }
  14521.  
  14522. The expression a|b yields all results in a, then those for b.  In
  14523. the context above, the a side is all that will normally get evalu-
  14524. ated.  In other words, when you say, tab(find(x)), find will only
  14525. look for one result.  Icon only starts backtracking and doing all
  14526. those fancy result-sequences in contexts like
  14527.  
  14528.     every i := tab(find(x))
  14529.     do ...
  14530.  
  14531. Right here we are looking for only one result.  What I've done
  14532. above is to show you how to exploit Icon's desire to find just
  14533. one result.  find() in tab(find(x)) will return an integer as
  14534. long as there is a backslash ahead of it in the current subject.
  14535. When it fails, that's it.  However, if we say
  14536.  
  14537.     tab(find(x)|0)
  14538.  
  14539. when find() fails, Icon has another expression it can try to
  14540. see if it produces another result, namely the 0.  Tab(0) means,
  14541. "go to the end of the line."  You'll note above that I put in
  14542. the expression "move(1) | break" as the do-clause associated
  14543. with tab(find("\\")|0).  All this does is make sure that if
  14544. you can't move one character (i.e. you've hit line's end), the
  14545. loop will fail.  "Move(1) | fail" means, at least in this con-
  14546. text, "try to move(1), and if you can't, try to do whatever is
  14547. on the other side of the slash (namely break out of the loop)."
  14548.  
  14549. This should do what you want, though I confess that I haven't
  14550. tested the code.
  14551.  
  14552. You might want to use the fields of your backslashed strings
  14553. in various ways, but I'd guess you best bet is to place them
  14554. in a list:
  14555.  
  14556. tmp_list := []
  14557. line ? {
  14558.   while put(tmp_lst,tab(find("\\")|0))
  14559.   do move(1) | break
  14560.   }
  14561. now do something with tmp_lst, like save it in a bigger list,
  14562. or permutate it, or just print it...
  14563.  
  14564. Get it?  Am I being too pedantic, or is this okay?
  14565.  
  14566. Nice job picking up string scanning so fast.
  14567.  
  14568.  
  14569. From nevin1@ihlpb.att.com  Tue May 29 17:17:59 1990
  14570. Message-Id: <9005300017.AA24779@megaron>
  14571. Received: from att-in.att.com by megaron (5.61/15) via SMTP
  14572.     id AA24779; Tue, 29 May 90 17:17:59 -0700
  14573. From: nevin1@ihlpb.att.com
  14574. Date: Tue, 29 May 90 19:16 CDT
  14575. Original-From: ihlpb!nevin1 (Nevin J Liber +1 708 979 4751)
  14576. To: att!cs.arizona.edu!icon-group
  14577. Cc: att!Mayo.edu!buchs
  14578. Subject: Re: beginner help
  14579.  
  14580. >I am trying to parse a file with lines of backslash delimited
  14581. >fields, with no trailing delimiter:
  14582.  
  14583. >  field1\field2\field3
  14584.  
  14585. >I thought I was on to an elegant way with the string scanning
  14586. >operator:
  14587. >
  14588. >  procedure main()
  14589. >    while line := read() do {
  14590. >      line ? while write(tab(find("\\")))
  14591. >        do move(1)
  14592. >    }
  14593. >  end
  14594. >
  14595. >But I cannot get the last field.  Any ideas?
  14596.  
  14597. The reason that you don't get the last field is because your expression
  14598. fails just before that point.  What happens is find() doesn't see a
  14599. backslash so it fails, and since failure is inherited, tab() fails,
  14600. write() fails, the inner while clause fails, the string scanning fails,
  14601. the do part of the outer while loop is done, and control is passed back
  14602. to the outer while clause (to read in another line).  You need to
  14603. specify what happens when find() can't find a backslash.
  14604.  
  14605.  
  14606. Here is how I would have coded it (late at night after work :-)):
  14607.  
  14608.     procedure main()
  14609.  
  14610.     local    line
  14611.  
  14612.     while line := read() do
  14613.         line ? while write(tab(upto('\\') | 0)) & move(1)
  14614.  
  14615.     end
  14616.  
  14617. Note:  you could use find("\\") in place of the upto('\\'), but I
  14618. prefer using upto() for three reasons:
  14619.  
  14620. 1.  It emphasizes that you are looking for a delimiter of length 1.
  14621. 2.  It allows you to look for more than one delimiter at the same time.
  14622. 3.  If I recall correctly, it is the idiom found in the Icon documentation.
  14623.  
  14624. Anyway, here is an explanation of what goes on at the last field:  the
  14625. upto('\\') fails, so by alternation (the | operator) a write(tab(0)) is
  14626. performed, printing out the last field.  Next move(1) fails (since the
  14627. current position is at the end of the string, it cannot move over one
  14628. position to the right), the inner while clause fails, the string
  14629. scanning fails, the do part of the outer while loop is done, and
  14630. control is passed back to the outer while loop (to read in another
  14631. line).
  14632.  
  14633.     NEVIN ":-)" LIBER  ..!gargoyle!igloo!nevin  (708) 831-FLYS
  14634.  
  14635. From CELEX@HNYMPI52.BITNET  Wed May 30 03:19:39 1990
  14636. Received: from rvax.ccit.arizona.edu by megaron (5.61/15) via SMTP
  14637.     id AA22964; Wed, 30 May 90 03:19:39 -0700
  14638. Received: from HNYMPI52.BITNET by rvax.ccit.arizona.edu; Wed, 30 May 90 03:18
  14639.  MST
  14640. Date: Wed, 30 May 90 11:14 N
  14641. From: CELEX@HNYMPI52.BITNET
  14642. Subject: splitting up lines.
  14643. To: icon-group@cs.arizona.edu
  14644. Message-Id: <891BFBCD971F602E5A@rvax.ccit.arizona.edu>
  14645. X-Original-To:  icon-group@cs.arizona.edu, CELEX
  14646. X-Envelope-To: icon-group@cs.arizona.edu
  14647.  
  14648. I found the recent discussion on dividing a line into its fields very
  14649. interesting. A lot of our files are organized in this way, so we have to
  14650. use these techniques pretty often.
  14651. For finding the n-th field of a line we use the following procedure:
  14652.  
  14653. procedure field(line,n)
  14654.  
  14655. if n = 1 then return line[1:find("\\",line)]
  14656. every x := 1 + find("\\",line) \ (n - 1)
  14657. return line[x:find("\\",line,x)]
  14658.  
  14659. end
  14660.  
  14661. It does the job, but I wonder if this can be done quicker or more
  14662. elegantly. Any comments?
  14663.  
  14664. Marcel Bingley
  14665.  
  14666. CELEX
  14667. University of Nijmegen
  14668. Nijmegen - The Netherlands
  14669.  
  14670. From buchs@Mayo.edu  Wed May 30 08:14:53 1990
  14671. Received: from fermat.Mayo.edu by megaron (5.61/15) via SMTP
  14672.     id AA03402; Wed, 30 May 90 08:14:53 -0700
  14673. Received: from FALCON.DECnet MAIL11D_V3 by fermat.Mayo.edu (5.57/Ultrix2.4-C)
  14674.     id AA18237; Wed, 30 May 90 10:09:25 CDT
  14675. Date: Wed, 30 May 90 10:09:24 CDT
  14676. Message-Id: <9005301509.AA18237@fermat.Mayo.edu>
  14677. From: buchs@Mayo.edu
  14678. To: :"icon-group@cs.arizona.edu"@FERMAT
  14679. Cc: BUCHS@fermat.Mayo.edu
  14680. Subject: Re: beginner help
  14681.  
  14682. Thanks to everyone who helped me over my first hurdle.
  14683. -------------------------------------------------------------
  14684. Kevin Buchs          Internet: buchs@mayo.edu
  14685. Mayo Foundation              Is this my life or is it just an
  14686. Rochester, MN 55905          incredible, high-speed, simulation?
  14687. (507) 284-0009                         -S. R. Cleaves
  14688. -------------------------------------------------------------
  14689.  
  14690.  
  14691. From goer@sophist.uchicago.EDU  Wed May 30 12:23:29 1990
  14692. Resent-From: goer@sophist.uchicago.EDU
  14693. Received: from Arizona.EDU (Maggie.Telcom.Arizona.EDU) by megaron (5.61/15) via SMTP
  14694.     id AA21030; Wed, 30 May 90 12:23:29 -0700
  14695. Return-Path: goer@sophist.uchicago.EDU
  14696. Received: from tank.uchicago.edu by Arizona.EDU; Wed, 30 May 90 12:09 MST
  14697. Received: from sophist.uchicago.edu by tank.uchicago.edu Wed, 30 May 90
  14698.  14:08:04 CDT
  14699. Received: by sophist.uchicago.edu (3.2/UofC3.0) id AA15300; Wed, 30 May 90
  14700.  14:03:28 CDT
  14701. Resent-Date: Wed, 30 May 90 12:15 MST
  14702. Date: Wed, 30 May 90 14:03:28 CDT
  14703. From: Richard Goerwitz <goer@sophist.uchicago.EDU>
  14704. Subject: splitting up lines
  14705. Resent-To: icon-group@cs.arizona.edu
  14706. To: icon-group@arizona.edu
  14707. Resent-Message-Id: <88D10B1CC47F20B3CB@Arizona.EDU>
  14708. Message-Id: <9005301903.AA15300@sophist.uchicago.edu>
  14709. X-Envelope-To: icon-group@CS.Arizona.EDU
  14710. X-Vms-To: icon-group@Arizona.edu
  14711.  
  14712.     I found the recent discussion on dividing a line into its fields very
  14713.     interesting. A lot of our files are organized in this way, so we have to
  14714.     use these techniques pretty often.
  14715.     For finding the n-th field of a line we use the following procedure:
  14716.  
  14717.     procedure field(line,n)
  14718.  
  14719.     if n = 1 then return line[1:find("\\",line)]
  14720.     every x := 1 + find("\\",line) \ (n - 1)
  14721.     return line[x:find("\\",line,x)]
  14722.  
  14723.     end
  14724.  
  14725. Icon is pretty good about letting us dispense with what I call
  14726. disparagingly the "ij stuff" (this isn't a joke about Dutch, by
  14727. the way :-), but rather a reference to the usual variable names
  14728. used in explicit subscripting operations).
  14729.  
  14730. procedure find_field(line,sep,n)
  14731.  
  14732.     x := 0
  14733.     line ? {
  14734.         until (x +:= 1) = n
  14735.         do tab(find(sep)+*sep) | fail
  14736.         target := tab(find(sep)|0)
  14737.      }
  14738.  
  14739.     return target
  14740.  
  14741. end
  14742.  
  14743. Note that sep defines the field separator.  It has to be a string.  It
  14744. would be pretty easy to have it be itself a pattern.  A few weeks ago
  14745. I posted a program called find_re that works like find above, except
  14746. that it takes an egrep-style regular expression.  I have a new version
  14747. around if anyone wants it.  I see no reason to keep on posting code,
  14748. when the old code works (it has some minor bugs) - at least until I
  14749. can prod people into trying it out and letting me know if it works as
  14750. it should.  I can only be just so imaginative on my own :-).
  14751.  
  14752. Is this more elegant that what you posted?  There is no disputing
  14753. matters of taste.  Take your pick.  Probably I'd use a completely
  14754. different approach, like make your field-finder a matching procedure
  14755. used in string scanning expressions.  What sort of context would you
  14756. use this in?
  14757.  
  14758.     -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  14759.     goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  14760.  
  14761.