The Icon Newsletter Write("Gen: Starting Up...") Suspend 3 Ralph E

The Icon Newsletter Write("Gen: Starting Up...") Suspend 3 Ralph E

TheThe IconIcon NewsletterNewsletter No. 51 – December 1, 1996 dresses in the United States, Canada, and Mexico. There is an additional charge for shipping to addresses in other countries. See the order form enclosed with this Newsletter. The book also can be ordered from the pub- lisher: Peer-to-Peer Communications, Inc. P.O. Box 640218 Contents San Jose, California 95164-0218 Third Edition of the Icon Book ........... 1 U.S.A. Graphics Programming Book ............. 1 voice: 408-420-2677 Version 9.3 of Icon ................................ 2 fax: 408-435-0895 [email protected] Version 9.3 of the Program Library ... 2 http://www.peer-to-peer.com New MS-DOS Implementation .......... 2 Peer-to-Peer Communications’ books are dis- Icon in Java ............................................ 2 tributed to bookstores worldwide through Inter- Teaching Icon ........................................ 3 national Thomson Publishing. In the United States, Web Links .............................................. 7 contact ITP at: Chicon .................................................... 7 7625 Empire Drive Florence, KY 41042 Third Edition of The Icon For addresses of ITP offices in other countries, contact Peer-to-Peer. Programming Language The third edition of The Icon Programming Lan- guage is now available. Graphics Programming Book In preparing the third edition, we revised much We have contracted with Peer-to-Peer Commu- of the material in the second edition and added nications, Inc., the publisher of the third edition of chapters on debugging, the Icon program library, the Icon Programming Language, to publish Graph- and an overview of graphics. There also are new ics Programming in Icon as well. appendices and more reference material. The date of publication is uncertain at this point, Here‘s the publication information: but we are aiming for late in the summer of 1997. The Icon Programming Language, Ralph E. Details are subject to change, but we expect a Griswold and Madge T. Griswold, Peer-to- book about 512 pages with eight color plates and Peer Communications, Inc., ISBN 1-57398- a CD-ROM. The price should be around $45. 001-3, $34.95. We’re contemplating the following content for The book can be ordered from the Icon Project, the CD-ROM, which will be “universal“ and us- which pays handling and shipping costs to ad- able on different platforms: 1 1. Material from the book The section Program Library has links to indexes program segments for the library that lead to the individual files. The images complete collection can be downloaded by fol- reference material from appendices lowing the FTP Area link. 2. Icon material New MS-DOS Implementation source code A new MS-DOS/386 implementation of Ver- executables for various platforms sion 9 of Icon with graphics is nearing comple- program library tion. This implementation also will run under documentation various versions of Windows in a DOS box in full data screen mode, or in OS/2 2.0 similarly. 3. Tools Completion of this implementation is outside of compression and archiving our control, but it seems likely it will be ready file conversion before the end of 1996. image viewing 4. Images Icon in Java pictures color palettes Todd Proebsting is heading a project to con- patterns and backgrounds struct an entirely new Icon translation system. icons and ornaments The compiler will translate Icon into Java for Let us know if you have any suggestions for execution in any Java environment. The system other content for the CD-ROM. will also include a completely new Icon run-time system. While we don’t plan to change the Icon language, modest extensions to data types are anticipated (for example, using Unicode charac- Version 9.3 of Icon ters in strings and csets). The project is a large Version 9.3 of Icon is in the final stages of undertaking and has just begun — it will be some testing. This version contains a few new features time before it bears fruit. and improvements to the graphics facilities. It This is an experiment, and we will continue to also fixes several bugs. support the present C implementation of Icon Watch our Web site for announcements of re- regardless of the outcome. leases of the source and executable files for vari- ous platforms as they become available. Teaching Icon Version 9.3 of the Program Library Editor’s Note: The following article was contributed by Version 9.3 of the Icon program library now is Bill Mitchell. available. This version of the program library not only contains new material, but more of the pro- I’ve taught Icon only once, in the context of a cedures have been packaged in modules to re- comparative programming languages class, C.Sc. duce the number of files in the library and to make 372 at The University of Arizona. Icon was the it easier to find commonly needed procedures. second of four languages studied in turn. Icon followed ML and in turn was followed by C++ Version 9.3 files can be downloaded from our and Prolog. Nine hours of lecture were budgeted FTP site: for Icon. ftp.cs.arizona.edu During the course I came across a few things From there, cd /icon/library. That area contains that perhaps are worth mentioning, as follows. library packages in several different forms. Overall Strategy Or you can use our Web site: A fundamental decision made when planning http://www.cs.arizona.edu/icon/ the order of presentation was to present first the 2 aspects of Icon that are close to conventional Expression Failure languages and later bring in generators and string Failure is a fundamental concept in Icon and I scanning operations. This is based on the obser- wanted to be sure that students really understood vation that one can do quite a number of interest- it. The example of an out-of-bounds string sub- ing things without using either generators or script was used to introduce the concept: string scanning. ][ s := "testing"; A fair amount of time was spent describing r := "testing" (string) Icon’s place in the programming language com- ][ s[50]; munity. My experience is that Icon’s greatest Failure strength is that it can be used to build tools easily, the construction of which would not be cost- String subscripting was chosen because the same effective in conventional languages. construct presents conventional languages with a problem: What should happen in this situation? ie — The Icon Evaluator With the notion of failure, Icon avoids the two common solutions of throwing an exception or Being a great fan of Icon, I wanted to introduce producing a contrived value of some sort (per- the language in the best light possible, but follow- haps a null string). ing ML presented an immediate problem: ML has an interactive mode and Icon does not. It was said that “s[50] fails — it produces no value” and then this rule was cited: I felt that ML’s interactive mode, the commonly seen read-evaluate-print loop, proved to be a “An operation is performed only if a great aid in learning ML, and I wanted something value is present for all operands. If a value similar for Icon. I produced a hasty solution, the is not present for all operands, the opera- Icon Evaluator (ie) based on the idea of interpe.icn tion fails.” in the Icon program library. interpe.icn takes an Examples were built on that rule: arbitrary Icon expression, wraps it in a main procedure, and then translates and runs the pro- ][ "x" || s[50]; gram. ie extended that idea a bit to provide con- Failure text so that expressions can use the results of ][ reverse("x" || s[50]); Failure previous expressions. ][ s := reverse("x" || s[50]); With ie in hand it was possible to present over- Failure head slides that showed expressions and the re- ][ s; sult of evaluating them. For example: r := "testing" (string) % My personal experience is that a very common ie Icon Evaluator, Version 0.0, ? for help source of bugs in Icon programs is due to unan- ][ 3+4; ticipated failures. Based on that I cited this rule: r1 := 7 (integer) “Unexpected failure is the root of mad- ][ 3.4*5.6; ness.” r2 := 19.04 (real) ][ "x" || "y" || "z"; Text Processing with split() r3 := "xyz" (string) ][ reverse(r3); An observation of mine is that a number of text r4 := "zyx" (string) processing problems can be addressed with a ][ center("hello",20,"."); simple paradigm: split a line into pieces based on r5 := ".......hello........" (string) delimiters and then process those pieces. Without showing the implementation I introduced a pro- ie provided benefits to both the instructor and cedure called split(). From the slides: the student. When preparing slides, ie made it possible to see easily if an expression produced There is a procedure split(s, delims) that returns a list consisting of the portions of the what was expected. For students, ie made it easy string s delimited by characters in delims: to try out code in a controlled environment that ][ split("just a test here ", " "); presented results in an unambiguous fashion. 3 r := L1:["just","a","test","here"] (list) nums := split(line, " \t") ][ split("...1..3..45,78,,9 10 ", "., "); every num := !nums do sum +:= num r := L1:["1","3","45","78","9","10"] (list) } A simple example then was posed: write("The sum is ", sum) end Consider a file whose lines consist of zero or more integers separated by white space: split() provides an easy way to turn input text into lists of strings. By using split() it was possible 5 10 0 100 50 to delay string scanning but at the same time 200 1 2 3 4 5 6 7 8 9 10 immediately work with nontrivial text process- A program to sum the numbers in such a file: ing problems.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us