From: tchrist@convex.COM (Tom Christiansen)
Newsgroups: comp.lang.icon
Subject: Re: should I use ICON for a specific problem ?
Date: 9 Apr 92 20:02:08 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Realtime Development, Colorado Springs, CO
Originator: tchrist@pixel.convex.com
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.

From the keyboard of rantapaa@s6.math.umn.edu (Erik E. Rantapaa):

At the risk of raising Richard's ire, I'm going to clarify 
a couple of Erik's points.

:>>2. multidimension arrays should be available   (nawk-synax:  array[1,2])
:
:--- Perl loses here.  Only singly dimensioned arrays are supported, but
:multi-dimensional arrays can be simulated, e.g. array["1,2"].

Not precisely correct: simulated multi-dimensional arrays via index
concatenation are directly supported syntactically you can say $array{$x}
or $array{$x, $y} or $array{$x, $y, $z}, etc.

:>>5. same loops as for, do and while in C should be available (not the 
:>>   same syntax is needed ...)
:
:+++ Perl has loops with equivalents for 'continue' and 'break'.

Furthermore, since loops can be labeled, you can name which loop
you want to break or continue, something you can't do in C.  There's
also a third form of loop control, redo, which is like continue
without doing the 3rd for of the for loop (the re-init portion).
Furthermore, there's a "foreach elt (list)" looping construct as well.

:>>6. total computer-readable documentation is needed (I don't want to buy a
:>>   book of a thing, that maybe don't do it ...)
:
:+++ Perl comes with lots of free documentation -- in texinfo format.

You can also use the online man page, which is nearly booklength.
Also, the book examples are available on-line, as is all of 
comp.lang.perl from all time, as well as various database and
retrieval methods for perusing it.

:Perl has its roots in the Unix utilities sed, ed, grep, sh and, yes, awk.
:(Yes, yes is a Unix utility; no, it's not related to Perl :) My knowledge
:of genealogical terminalogy is not that great, so maybe someone else can
:fill in what relationship Perl, awk and Icon have with each other.

The current list of tools from which perl derives something of its
eclectic nature includes but is not limited to the Bourne shell, csh, 
awk, sed, tr, cpp, C (classic and ANSI), BASIC-PLUS, Pascal, Ada, Lisp,
APL, Fortran, Algol, egrep, nroff, /bin/test, vi, and emacs.  Seriously.

:Perl arrays function for the most part just like awk's.

Well, Perl has two kinds of things you might call arrays, but are perhaps
better characterized as lists and tables.  Lists one uses numeric indices
on as well as push and pop kinds of operations, whereas tables are generic
hash tables employing arbitrary indices.  Both data structures dynamically
resize internally to avoid performance degradations.  Tables can also be
bound directly to dbm files for rapid-access persistent data.

:In general, Icon has better support for data structures than Perl does.
:It's not real easy to implement 'recursive' data structures in Perl, although
:it can be done (although usually a way is found to get around it.)

True enough.  The major hurdle is lack of syntactic sugar.  You can
make a table of pointers to lists of pointers to lists of pointers
to tables, but the dereferencing requires a temporary variable for
each dereference.

:Icon wins with the arbitrarily large integers.

Perl has arbitrarily large integers, rationals, and floats 
available via the libbig (bigfloat, bigint, bigrat) library package, 
with normal arithmetic operations on them supported via library
routines.  Of course, these haven't a change of being as fast
as binary machine floats, since they're stored as strings.

:>Question #4:  Does Icon have subroutines?  If by this you mean that you can
:>define your own procedures, then yes.  If you mean, "does it let you use
:>labels," then the answer is "no."
:
:Perl has labels like C does.  Icon has more powerful subroutines, however.
:They are, in fact, more like co-routines, something I wish Perl had.

Well, perl labels are a little neater than C's because of the way you can
use them to label loops and as operands for loop-control statements, as
previously explained.

Subroutines in perl can also be called indirectly; recursion is 
supported; they can be autoloaded; they can live in protected 
namespaces (somewhat like file statics in C); they can for 
good or evil be overridden via dynamic scoping.

--tom