See Also edit
- SNOBOL
- strongly influenced the design of Icon
Documentation edit
- The Icon Programming Language
- went out-of-print, rights reverted to the authors who placed the book in the public domain, and it is available for download in PDF format
Description edit
escargo 2002-10-28:There are several points of similarity between Tcl and Icon, along with many more differences.- Interpreted with a byte-code compiler
- Portable across a range of different systems
- Built-in memory allocation and garbage collection
- Portable graphical tool kit
- High degree of introspection
- Rich built-in data structures (character sets, lists, records, sets, strings, tables)
- Invocation of procedures based on a dynamic string value
- Two memory scopes, global and local
- Strongly typed values, but untyped variables (SS: I don't agree this is a common point between Tcl and Icon).
- Primitives for determining if a variable has a value
- No "go to" statement
- The syntax looks more like C than tcl
- Many, many operators
- Procedures can have local variables that are declared static instead of local so that they retain their values between invocations (for Tcl, see Static variables and variables in namespaces)
- Parameters are passed by value (for primitive types) or reference (for structures)
- No dynamic creation of procedures
- No namespaces
- Pattern matching is a normal extension of expression evaluation
- Backtracking built into the language
- Expressions can yield 0 or more values (not necessarily all at once)
- Generators and co-expressions (co-routines were added to Tcl 8.6)
- Character set limited to 8-bit characters
- Separate compilation of procedures (not a just-in-time compiler)
ulis, 2005-04-22. (following text comprise excerpts from [1])Icon has notions of success and failure that added to the notion of generator permits thing such:
sentence := "Store it in the neighboring harbor" every i := find("or", sentence) do write(i)which writes all the positions at which "or" occurs in sentence. For the example above, these are 3, 23, and 33.Compare Tcl's
% regexp -all -indices -inline or "Store it in the neighboring harbor" {2 3} {22 23} {32 33}Other interesting notion is suspension:
procedure findodd(s1, s2) every i := find(s1, s2) do if i % 2 = 1 then suspend i endis a procedure that generates the odd-valued positions at which s1 occurs in s2. The suspend control structure returns a value from the procedure, but leaves it in suspension so that it can be resumed for another value. When the loop terminates, control flows off the end of the procedure without producing another value.See continuation or coroutine.