summaryrefslogtreecommitdiff
path: root/doc/faq.htm
blob: ad3d10df9f696a9976dbf966c6ccf0a48acec0fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
    <TITLE>Icon Programming Language FAQ</TITLE>
    <LINK REL="STYLESHEET" TYPE="text/css" HREF="istyle.css">
    <LINK REL="SHORTCUT ICON" HREF="shortcut.gif">
</HEAD>
<BODY>
<!-- Archive-name: comp-lang-icon-faq-->
<P><IMG SRC="wwwcube.gif" WIDTH="128" HEIGHT="144" ALT="" ALIGN=RIGHT>
<H1>Frequently Asked Questions about the Icon programming language</H1>
<A HREF="http://www.cs.arizona.edu/icon/faq.htm">
www.cs.arizona.edu/icon/faq.htm</A>
<BR>Last updated April 12, 2010<BR>
<!-- $Id: faq.htm,v 1.57 2010/04/12 20:39:24 gmt Exp $ -->

<P><STRONG>Learning about Icon</STRONG><BR>
<A HREF="#whatsicon">A1. What is Icon?</A><BR>
<A HREF="#whatgood">A2. What is Icon good for?</A><BR>
<A HREF="#features">A3. What are Icon's distinguishing characteristics?</A><BR>
<A HREF="#library">A4. What is the Icon program library?</A><BR>
<A HREF="#intro">A5. Where can I learn more about Icon?</A><BR>
<A HREF="#examples">A6. Where are some simple examples?</A><BR>
<A HREF="#documentation">A7. How about comprehensive documentation?</A><BR>
<P><STRONG>Implementations</STRONG><BR>
<A HREF="#platforms">B1. What platforms support Icon?</A><BR>
<A HREF="#getstarted">B2. How do I get started with Icon?</A><BR>
<A HREF="#unicode">B3. Is there a Unicode version of Icon?</A><BR>
<A HREF="#iconc">B4. What happened to the compiler?</A><BR>
<P><STRONG>Administration</STRONG><BR>
<A HREF="#iconproject">C1. What is the Icon Project?</A><BR>
<A HREF="#updates">C2. How often is the on-line material updated?</A><BR>
<A HREF="#lineage">C3. Where did Icon come from?</A><BR>
<A HREF="#futures">C4. Where is Icon going? </A><BR>
<P><STRONG>Support</STRONG><BR>
<A HREF="#ugroup">D1. Is there a users' group for Icon?</A><BR>
<A HREF="#techsupport">D2. How do I get technical support?</A><BR>
<P><STRONG>Programming</STRONG><BR>
<A HREF="#evread">E1. Why doesn't <CODE>read()</CODE> work with <CODE>every</CODE>?</A><BR>
<A HREF="#strinv">E2. Why doesn't string invocation such as <CODE>"foo"()</CODE> work?</A><BR>
<A HREF="#callc">E3. How can I call a C function?</A><BR>
<A HREF="#rwpipe">E4. Can I open a bidirectional pipe?</A><BR>

<P><HR><H2>Learning about Icon</H2>

<H3><A NAME="whatsicon">A1.</A> What is Icon?</H3>
<P>
Icon is a very high level general-purpose programming language with
extensive features for processing strings (text) and data structures.
Icon is an imperative, procedural language with a syntax that is
reminiscent of C and Pascal, but with semantics at a much higher level.
<P>
Icon has a novel expression-evaluation mechanism that integrates
goal-directed evaluation and backtracking with conventional control structures.
It has a string scanning facility for pattern matching that avoids the tedious
details usually associated with analyzing strings.
Icon's built-in data structures include sets and tables with associative
lookup, lists that can be used as vectors or stacks and queues, and records.
<P>
Icon is a strongly, though not statically, typed language.
It provides transparent automatic type conversion:
For example, if an integer is used in an operation that requires a string,
the integer is automatically converted to a string.
<P>
Several implementations of Icon have high-level graphics facilities with
an easily programmed window interface.
<P>
Icon manages storage automatically.
Objects are created as needed during program execution and space is
reclaimed by garbage collection as needed.
The sizes of strings and data structures are limited only by the amount
of available memory.

<H3><A NAME="whatgood">A2.</A> What is Icon good for?</H3>
<P>
As a general-purpose programming language with a large computational
repertoire, Icon can be used for most programming tasks.
It's especially strong at building software tools, for processing text,
and for experimental and research applications.
<P>
Icon is designed to make programming easy;
it emphasizes the value of programmer's
time and the importance of getting programs to work quickly.
Consequently, Icon is used both for short, one-shot tasks and for
very complex applications.

<H3><A NAME="features">A3.</A>
What are Icon's distinguishing characteristics?</H3>
<P>
<UL>
     <LI> A high-level, general-purpose programming language
     <LI> Friendly line-oriented syntax (no semicolons needed)
     <LI> Emphasis on programmer productivity
     <LI> Usually interpreted
</UL><UL>
     <LI> Evolved from programming languages (vs. scripting languages)
     <LI> Procedural control flow plus generators and goal-directed evaluation
</UL><UL>
     <LI> Values have types; variables are typeless, accept any value
     <LI> Static scoping: global or (procedure) local
     <LI> Automatic garbage collection
</UL><UL>
     <LI> All integers have arbitrary precision
     <LI> Uses strings (not chars) as basic text datatype
     <LI> Has lists that function as arrays, queues, and stacks
     <LI> Also has sets, tables, records (structs), reals (doubles), more
     <LI> No second-class "primitive types"
</UL><UL>
     <LI> Not "object-oriented" (no classes, inheritance, or instance methods)
     <LI> No exception catching
     <LI> No concurrency (no threads, monitors, semaphores, or synchronization)
     <LI> Has co-expressions (coroutines)
</UL><UL>
     <LI> Basic least-common-denominator system interface (a la ANSI C)
</UL><UL>
     <LI> Procedural graphics (event-driven paradigm available but not mandated)
     <LI> Retained windows (programs are never called to repaint)
     <LI> Simple GUI builder that can re-edit its generated code
     <LI> Turtle graphics package
</UL><UL>
   <LI> Large library of contributed procedures and programs
</UL>

<H3><A NAME="library">A4.</A> What is the Icon program library?</H3>
<P>
The library is a collection of programs and procedures written in Icon.
User contributions form a significant portion of the library.
<P>
Library procedures effectively augment the built-in functions
available to an Icon program.
A wide variety of procedures currently exists, and most
graphically-based programs are built around library procedures.
The <A HREF="http://www.cs.arizona.edu/icon/library/src/procs/core.icn">core</A>
and <A HREF="http://www.cs.arizona.edu/icon/library/src/gprocs/graphics.icn">
graphics core</A> modules are the most carefully vetted.
<P>
The programs in the library range from simple demonstrations to
handy tools to complex graphical applications.
<P>
The library is a resource for both new and experienced programmers.
In addition to their basic utility,
its programs and procedures serve as examples of how things can be
written in Icon.
<P>
The library is indexed at
<A HREF="http://www.cs.arizona.edu/icon/library/ipl.htm">
www.cs.arizona.edu/icon/library/ipl.htm</A>.


<H3><A NAME="intro">A5.</A> Where can I learn more about Icon?</H3>
<P>
Here are some good places to start.
<UL>
<LI> Ralph Griswold's overview:
	<A HREF="http://www.cs.arizona.edu/icon/docs/ipd266.htm">
	www.cs.arizona.edu/icon/docs/ipd266.htm</A>
<LI> Dave Hanson's introduction:
	<A HREF="http://www.cs.arizona.edu/icon/intro.htm">
	www.cs.arizona.edu/icon/intro.htm</A>
<LI> Bill Mitchell's introduction and slides:
	<A HREF="http://www.mitchellsoftwareengineering.com/icon/">
	www.mitchellsoftwareengineering.com/icon</A>
<LI> John Shipman's tutorial:
	<A HREF="http://www.nmt.edu/tcc/help/lang/icon/">
	www.nmt.edu/tcc/help/lang/icon</A>
</UL>
<P>
For the graphics facilities:
<UL>
<LI> The Icon Project Overview: 	
	<A href="http://www.cs.arizona.edu/icon/ftp/doc/ipd281.pdf">
	www.cs.arizona.edu/icon/ftp/doc/ipd281.pdf</A>
</UL>

<H3><A NAME="examples">A6.</A> Where are some simple examples?</H3>
<P>
For some simple text-based programs, see any of those
introductory documents in the preceding question.
For some simple graphics programs, see
<A HREF="http://www.cs.arizona.edu/icon/gb/progs/progs.htm">
www.cs.arizona.edu/icon/gb/progs/progs.htm</A>.
<P>
Many more examples, typically larger, are found in the
Icon program library; see the indexes of
<A HREF="http://www.cs.arizona.edu/icon/library/cprogs.htm">Basic Programs</A>
and <A HREF="http://www.cs.arizona.edu/icon/library/cgprogs.htm">
Graphics Programs</A>.

<H3><A NAME="documentation">A7.</A> How about comprehensive documentation?</H3>
<P>
Two books define the Icon language.
The core language is covered in
<A HREF="http://www.cs.arizona.edu/icon/lb3.htm">
<CITE>The Icon Programming Language (third edition)</CITE></A>,
by Griswold and Griswold.
Graphics facilities are described in
<A HREF="http://www.cs.arizona.edu/icon/gb/">
<CITE>Graphics Programming in Icon</CITE></A>
by Griswold, Jeffery, and Townsend.
These books contain both tutorial and reference material.
<P>
Icon's internals are detailed in
<A HREF="http://www.cs.arizona.edu/icon/ibsale.htm">
<CITE>The Implementation of the Icon Programming Language</CITE></A>
by Griswold and Griswold.
Although considerable changes have occurred since Version 6,
described in the book, the basic structure of Icon remains the same.
Two technical reports,
<A HREF="http://www.cs.arizona.edu/icon/docs/ipd112.htm">IPD112</A> and
<A HREF="http://www.cs.arizona.edu/icon/docs/ipd239.htm">IPD239</A>,
describe subsequent changes.
<P>
Printed copies of the
<CITE>Language</CITE> and <CITE>Graphics</CITE> books
are available from Jeffery Systems
(<A HREF="http://unicon.org/books/">http://unicon.org/books/</A>).
All three books can be downloaded at no charge from the Icon books page, 
<A HREF="http://www.cs.arizona.edu/icon/books.htm">
www.cs.arizona.edu/icon/books.htm</A>.
<P>
The <CITE>Icon Programming Language Handbook</CITE>,
by Thomas W. Christopher, is available on the web at
<A HREF="http://www.tools-of-computing.com/tc/CS/iconprog.pdf">
www.tools-of-computing.com/tc/CS/iconprog.pdf</A>.
<P>
An on-line index to the Icon program library is found at
<A HREF="http://www.cs.arizona.edu/icon/library/ipl.htm">
www.cs.arizona.edu/icon/library/ipl.htm</A>.
<P>
There is a large amount of additional information at the
Icon web site,
<A HREF="http://www.cs.arizona.edu/icon/">www.cs.arizona.edu/icon</A>,
including complete sets of back issues of the
<A HREF="http://www.cs.arizona.edu/icon/inl/inl.htm">
<CITE>Icon Newsletter</CITE></A> and
<A HREF="http://www.cs.arizona.edu/icon/analyst/ia.htm">
<CITE>Icon Analyst</CITE></A>.

<P><HR><H2>Implementations</H2>

<H3><A NAME="platforms">B1.</A> What platforms support Icon?</H3>
<P>
The current implementation of Icon is a Unix implementation.
This includes Linux, BSD, Solaris, Macintosh, and the
<A HREF="http://www.cygwin.com/">Cygwin</A> environment under Windows.
Version 9.5 of Icon has been tested on all these platforms.
<P>
Older versions are available for Windows and some other systems.
An alternative Java-based implementation for Unix,
<A HREF="http://www.cs.arizona.edu/icon/jcon/">Jcon</A>,
is also available.
<P>
None of these environments includes a window-based development environment.
While Icon programs can open windows and use graphics,
programming is done using Unix editors and other tools from a command shell.

<H3><A NAME="getstarted">B2.</A> How do I get started with Icon?</H3>
<P>
The current version of Icon for Unix can be downloaded from
<A HREF="http://www.cs.arizona.edu/icon/current/">
www.cs.arizona.edu/icon/current</A>.
Source and binary packages are available, each with the
complete Icon program library.
<P>
For older implementations, start at
<A HREF="http://www.cs.arizona.edu/icon/implver.htm">
www.cs.arizona.edu/icon/implver.htm</A>.
Jcon is at <A HREF="http://www.cs.arizona.edu/icon/jcon/">
www.cs.arizona.edu/icon/jcon</A>.

<H3><A NAME="unicode">B3.</A> Is there a Unicode version of Icon?</H3>
<P>
No.
Icon is defined in terms of 8-bit characters, and changing this presents
several design challenges that would likely break existing programs.
Also, modifying the C implementation is probably infeasible,
but a Unicode version of Jcon might be possible.

<H3><A NAME="iconc">B4.</A> What happened to the compiler?</H3>
<P>
For a while, Unix distributions included both an interpreter and a compiler.
The compiler was an interesting research project but it has not been
maintained and is no longer supported.
The interpreter is much easier to use and is generally quite fast enough,
even for production applications.

<P><HR><H2>Administration</H2>

<H3><A NAME="iconproject">C1.</A> What is the Icon Project?</H3>
<P>
The Icon Project is a name used by the group that
distributes and supports the Icon programming language.
The project maintains the Icon web site at
<A HREF="http://www.cs.arizona.edu/icon/">www.cs.arizona.edu/icon</A>.
A non-commercial organization, the project is supported by the
Department of Computer Science at the University of Arizona.

<H3><A NAME="updates">C2.</A> How often is the on-line material updated?</H3>
<P>
The Icon implementation is now in maintenance mode, with new releases
produced only when necessary.  This typically happens every few years when a
change in the Gnu tools cause the source to stop building.

<H3><A NAME="lineage">C3.</A> Where did Icon come from?</H3>
<P>
Icon is the latest in a series of high-level programming languages designed
to facilitate programming tasks involving strings and structures.
The original language, SNOBOL, was developed at Bell Telephone Laboratories
in the early 1960s.
SNOBOL evolved into SNOBOL4, which is still in use.
Subsequent languages were developed at the University of
Arizona with support from the National Science Foundation.
Although it has similar objectives and many similar capabilities,
Icon bears little superficial resemblance to SNOBOL4.
<P>
Icon implementations were developed by faculty, staff, and students
at the University of Arizona,
with significant contributions from volunteers around the world.
An <A HREF="http://doi.acm.org/10.1145/155360.155363">Icon history</A>
by Ralph and Madge Griswold appears in the preprints
of the second History of Programming Languages Conference (HOPL-II),
ACM SIGPLAN Notices, March 1993 (Vol 28, No 3).
<P>
The name Icon is not an acronym, nor does it stand for anything in
particular, although the word <CITE>iconoclastic</CITE> was mentioned
when the name was chosen.
The name predates the now common use of <CITE>icon</CITE>
to refer to small images used in graphical user interfaces.
This sometimes misleads people into thinking
that Icon is designed to create or manipulate icons,
but there's no good solution to that problem.

<H3><A NAME="futures">C4.</A> Where is Icon going? </H3>
<P>
We continue to use Icon on a daily basis, but no significant changes
are planned.
We expect to support the Unix version for the foreseeable future,
and to distribute ports to other systems as supplied by volunteers.
<P>
The Unicon project is developing an object-oriented language based on Icon.
For more information, see
<A HREF="http://unicon.sourceforge.net/">
unicon.sourceforge.net</A>.


An earlier object-oriented extension to Icon, Idol,
can be found in the Icon program library.

<P><HR><H2>Support</H2>

<H3><A NAME="ugroup">D1.</A> Is there a users' group for Icon?</H3>
<P>
There is no official Icon users' group, but the Usenet newsgroup
<A HREF="news:comp.lang.icon">comp.lang.icon</A>
is dedicated to issues relating to the Icon language.

<H3><A NAME="techsupport">D2.</A> How do I get technical support?</H3>
<P>
The Icon Project is not a commercial organization, and its capacity for
providing technical support is limited. Please use the appropriate resource
when you need assistance:
<UL>
<LI>
For <STRONG>programming</STRONG> questions,
submit a query to the Usenet newsgroup
<A HREF="news:comp.lang.icon">comp.lang.icon</A>.
<LI>
For <STRONG>porting</STRONG> assistance
or <STRONG>Unix</STRONG> problems, contact
<A HREF="mailto:icon-project@cs.arizona.edu">icon-project@cs.arizona.edu</A>.
<LI>
For general information and additional documentation, visit the Icon web site:
<A HREF="http://www.cs.arizona.edu/icon/">www.cs.arizona.edu/icon</A>.
</UL>

<P><HR><H2>Programming</H2>

<H3><A NAME="evread">E1.</A>
Why doesn't <CODE>read()</CODE> work with <CODE>every</CODE>?</H3>
<P>
<CODE>every s := read() do {...}</CODE>
doesn't loop because <CODE>read()</CODE> produces a single value and
then fails if resumed.
Other "consumer" procedures such as <CODE>get()</CODE> and <CODE>pop()</CODE>
work the same way.
Use a <CODE>while</CODE> loop with these procedures, and save
<CODE>every</CODE> for use with generators such as <CODE>!x</CODE>
or <CODE>key(T)</CODE>.

<H3><A NAME="strinv">E2.</A>
Why doesn't string invocation such as <CODE>"foo"()</CODE> work?</H3>
<P>
String invocation works if the procedure is present;
the catch is that the linker removes unreferenced procedures.
To ensure a procedure's presence, reference it in the
<CODE>main()</CODE> procedure.
A simple reference suffices, as in
<CODE>refs := [foo, bar, baz]</CODE>;
it's not necessary to actually call it.
<P>
(Why does the linker remove unreferenced procedures?
To <EM>significantly</EM> reduce the memory requirements of
programs that use the library.
There was a time when this mattered.)

<H3><A NAME="callc">E3.</A> How can I call a C function?</H3>
<P>
You can't call an arbitrary C function, but you can load and call one
that is written to Icon's specifications.
A tutorial appears in
<a href="http://www.cs.arizona.edu/icon/analyst/backiss/IA36.pdf">
Icon Analyst 36</a>.
Some examples can be found in the
<A HREF="http://www.cs.arizona.edu/icon/library/ccfuncs.htm">
<CODE>cfuncs</CODE></A> and
<CODE>packs/loadfuncs</CODE> directories of the Icon program library.
<P>
The <A HREF="http://www.cs.arizona.edu/icon/jcon/">Jcon</A> implementation
allows Icon programs to call Java code that is written to Jcon specifications.

<H3><A NAME="rwpipe">E4.</A> Can I open a bidirectional pipe?</H3>
<P>
No, this is not possible.
Although the concept is simple &mdash; 
write a line to a program via a pipe, then read that program's output
&mdash; it probably wouldn't work.
Most I/O libraries don't write anything to a pipe until
they've filled a buffer, and the most likely consequence would be
a deadlock, with each program waiting for the other to send more data.

<P><HR>
<SMALL>
This FAQ is edited by Gregg Townsend.
It includes contributions from
Ralph Griswold, Cliff Hathaway, Clint Jeffery, Bob Alexander,
and Todd Proebsting.
</SMALL>
</BODY>
</HTML>