Book review: The Icon Programming Language

1
achieved by duplication and the inclusion of a comparator to provide a self-checking capability. The key to the fault tolerance is the comparator, which has to be self-testing. A self-testing comparator implemented as a PLA has been investigated which, because of its regular and simple structure, can be fully analysed to ensure it can detect all single faults within itself. In summary, the conference demonstrated the growing importance of VLSI in computers and the techniques and tools that will be needed to take full advantage of this potential. The Conference Proceedings may be obtained from the IEEE, Catalogue Number 83CH1935-6 or IEEE Computer Society Order 480. OJ. DAVIES Department of Electronic & Electrical Engineering University College London Torrington Place London WC1E 7JE, England - Book review The Icon programming language R.E. Griswold and M.T. Griswold Prentice-Hall International, 1983, 313pp., £16.10 ISBN: 0-13-449777-5 Icon is a programming language developed primarily for string processing which has been attracting considerable interest. This definitive book has been eagerly awaited by all its devotees. With its focus on the solution of non- numerical problems, Icon continues in the tradition of SNOBOL4, a language with which most readers will be familiar and with which they will also associate Ralph Griswold and his Department of Computer Science at the University of Arizona, Tucson. SNOBOL4, however, has been heavily criticised; its lack of modern control structures makes programming and debugging difficult and the pattern matching constructs can lead to the most opaque code. Icon is an expression-oriented language with modern control structures superficially reminiscent of Algol 68. However, it also has some very unusual features which are carefully described in this text. As in SNOBOL4, operations in Icon may succeed or fail. A statement like i < j succeeds if i is less than j and then delivers the value j. If i is greater than or equal to j, the statement fails and delivers no value. Hence i < j < k is a valid Icon expression. A control structure such as if exprj else expr 3 is driven by the success or failure of expr x . If expr! succeeds then expr 2 is evaluated; otherwise expr 3 is evaluated. The value produced by the whole expression is the value produced by whichever of expr 2 or expr 3 is selected. Hence one can write code such as k: = (if i > j then i else j) One of the most unusual and yet useful features of Icon is the concept of generators. These are expressions which may produce more than one value. For example, the control structure expri | expr 2 generates the sequence of results for expr x followed by that for expr 2 .So 112 has result sequence {1,2 } , and if one writes this will succeed if x = 1 or x = 2. The familiar operation i to j by k also fits naturally into the concept of a generator. In Icon, generators are completely general and may occur in any computation. They provide conciseness and enormous expressive power. An Icon expression is evaluated in such a way that it succeeds if at all possible: this is called goal-directed evalua- tion. If generators are part of an expression, then values in the result sequence are tried until the expression succeeds. If later it is found that this expression is part of a larger expression that has failed, backtracking will take place to try other values in the result sequence in an attempt to make the whole expression succeed. Icon also provides a large repertoire of string-handling facilities. The high-level string scanning facility of Icon establishes a subject that is the focus for any string process- ing operations. Scanning operations apply to the subject and a given position in the subject. Matching functions change this position and produce the substring of the subject that they match. Such facilities, together with procedures and generators, enable Icon to offer pattern matching facilities similar to SNOBOL4 but in a much more natural yet controlled way. This book provides a lucid introduction to Icon for experienced programmers. Part I covers the basic features of Icon which are similar in nature to other programming languages. Part II covers advanced features including generators, goal-directed evaluation and string scanning. Part III is devoted to programming techniques with emphasis on data structures. The fourth part of the book gives some welcome illustrative programs. The authors, who were involved in the design of the language, are expert Icon programmers and it is a valuable exercise to study their code. Novices may find Icon programming a difficult exercise; their code is often difficult to follow and un- necessarily (and sometimes grossly) inefficient. This is not an uncommon problem with the language: a small piece of code can result in an exceptional amount of needless work. Icon appears to have sacrificed efficiency in an attempt to save programmer time. This is not really a criticism! As the authors say, Icon is an excellent language for 'one-shot' programs and for speculative efforts in which a proposed solution is more heuristic than algorithmic. It also excels for very complicated programs. The text is equipped with a comprehensive index and useful appendices including instructions on how to run Icon programs. The book uses Version 5 of the language and one appendix describes how this is run under Version 7 of the UNIX operating system. Details of other imple- mentations have been published in a series of Icon News- letters which are available from the Department of Computer Science at Tucson. V.J. RAYWARD-SMITH 168 Software & Microsystems, Vol. 2, No. 6, December 1983

Transcript of Book review: The Icon Programming Language

Page 1: Book review: The Icon Programming Language

achieved by duplication and the inclusion of a comparatorto provide a self-checking capability. The key to the faulttolerance is the comparator, which has to be self-testing. Aself-testing comparator implemented as a PLA has beeninvestigated which, because of its regular and simplestructure, can be fully analysed to ensure it can detect allsingle faults within itself.

In summary, the conference demonstrated the growingimportance of VLSI in computers and the techniques andtools that will be needed to take full advantage of this

potential. The Conference Proceedings may be obtainedfrom the IEEE, Catalogue Number 83CH1935-6 or IEEEComputer Society Order 480.

OJ. DAVIESDepartment of Electronic & Electrical EngineeringUniversity College LondonTorrington PlaceLondon WC1E 7JE, England

- Book reviewThe Icon programming languageR.E. Griswold and M.T. GriswoldPrentice-Hall International, 1983, 313pp., £16.10ISBN: 0-13-449777-5

Icon is a programming language developed primarily forstring processing which has been attracting considerableinterest. This definitive book has been eagerly awaited byall its devotees. With its focus on the solution of non-numerical problems, Icon continues in the tradition ofSNOBOL4, a language with which most readers will befamiliar and with which they will also associate RalphGriswold and his Department of Computer Science at theUniversity of Arizona, Tucson. SNOBOL4, however, hasbeen heavily criticised; its lack of modern control structuresmakes programming and debugging difficult and the patternmatching constructs can lead to the most opaque code.Icon is an expression-oriented language with moderncontrol structures superficially reminiscent of Algol 68.However, it also has some very unusual features which arecarefully described in this text.

As in SNOBOL4, operations in Icon may succeed or fail.A statement like i < j succeeds if i is less than j and thendelivers the value j . If i is greater than or equal to j , thestatement fails and delivers no value. Hence i < j < k is avalid Icon expression. A control structure such as if exprjelse expr3 is driven by the success or failure of exprx. Ifexpr! succeeds then expr2 is evaluated; otherwise expr3 isevaluated. The value produced by the whole expression isthe value produced by whichever of expr2 or expr3 isselected. Hence one can write code such as

k: = (if i > j then i else j)

One of the most unusual and yet useful features of Icon isthe concept of generators. These are expressions which mayproduce more than one value. For example, the controlstructure

expri | expr2

generates the sequence of results for exprx followed by thatfor expr2 .So 112 has result sequence {1,2 } , and if onewrites

this will succeed if x = 1 or x = 2. The familiar operation

i to j by k

also fits naturally into the concept of a generator. In Icon,generators are completely general and may occur in any

computation. They provide conciseness and enormousexpressive power.

An Icon expression is evaluated in such a way that itsucceeds if at all possible: this is called goal-directed evalua-tion. If generators are part of an expression, then values inthe result sequence are tried until the expression succeeds.If later it is found that this expression is part of a largerexpression that has failed, backtracking will take place totry other values in the result sequence in an attempt tomake the whole expression succeed.

Icon also provides a large repertoire of string-handlingfacilities. The high-level string scanning facility of Iconestablishes a subject that is the focus for any string process-ing operations. Scanning operations apply to the subjectand a given position in the subject. Matching functionschange this position and produce the substring of thesubject that they match. Such facilities, together withprocedures and generators, enable Icon to offer patternmatching facilities similar to SNOBOL4 but in a much morenatural yet controlled way.

This book provides a lucid introduction to Icon forexperienced programmers. Part I covers the basic featuresof Icon which are similar in nature to other programminglanguages. Part II covers advanced features includinggenerators, goal-directed evaluation and string scanning.Part III is devoted to programming techniques withemphasis on data structures. The fourth part of the bookgives some welcome illustrative programs. The authors, whowere involved in the design of the language, are expert Iconprogrammers and it is a valuable exercise to study theircode. Novices may find Icon programming a difficultexercise; their code is often difficult to follow and un-necessarily (and sometimes grossly) inefficient. This is notan uncommon problem with the language: a small piece ofcode can result in an exceptional amount of needless work.Icon appears to have sacrificed efficiency in an attempt tosave programmer time. This is not really a criticism! As theauthors say, Icon is an excellent language for 'one-shot'programs and for speculative efforts in which a proposedsolution is more heuristic than algorithmic. It also excelsfor very complicated programs.

The text is equipped with a comprehensive index anduseful appendices including instructions on how to runIcon programs. The book uses Version 5 of the languageand one appendix describes how this is run under Version7 of the UNIX operating system. Details of other imple-mentations have been published in a series of Icon News-letters which are available from the Department ofComputer Science at Tucson.

V.J. RAYWARD-SMITH

168 Software & Microsystems, Vol. 2, No. 6, December 1983