Book review: The Icon Programming Language

Post on 21-Sep-2016

214 views 0 download

Transcript of 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