.de Ds
.DS
.ft B
.ss 9
..
.de De
.DE
.ss 4
.ft R
..
.sv 1.25i
.LP
.ce 100
\fBExperimental Extensions to Version 5 of Icon\fR
.sp 2
Ralph E. Griswold and William H. Mitchell
.sp 1
Department of Computer Science, The University of Arizona
.sp 1
March 3, 1983
.sp 2
.PP
A number of experimental extensions have been made to Version 5 of
Icon.
This version is called Version 5x for reference.
.PP
The extensions in Version 5x, which are described below, are
upward-compatible ones and should not interfere with programs
that run properly on Version 5.
.NH
PDCO Invocation Syntax
.PP
Version 5x contains the procedure invocation syntax that is
used for programmer-defined control operations (see TR 82-8 and
TR 82-16).
.PP
In this syntax, when braces are used in place of parentheses to
enclose an argument list, the arguments are passed as a list
of co-expressions. That is,
.Ds
p{\*1, \*2, \*(el, \*n}
.De
is equivalent to
.Ds
p([create \*1, create \*2, \*(el, create \*n])
.De
There is always at least one co-expression in the list:
.Ds
p{\^}
.De
is equivalent to
.Ds
p([create &null])
.De
.NH
Invocation Via String Name
.PP
In the Version 5x interpreter (but not compiler), a string-valued expression that corresponds to the
name of a procedure or operation may be used in place of the
procedure or operation in an invocation expression. For example,
.Ds
"image"(x)
.De
produces the same call as
.Ds
image(x)
.De
and
.Ds
"-"(i,\*bj)
.De
is equivalent to
.Ds
i - j
.De
.PP
In the case of operations, the number of arguments determines
the operation. Thus
.Ds
"-"(i)
.De
is equivalent to
.Ds
-i
.De
Since \fBto-by\fR is an operation, despite its reserved-word syntax,
it is included in this facility with the string name \fB...\fR .
Thus
.Ds
"..."(1,\*b10,\*b2)
.De
is equivalent to
.Ds
1 to 10 by 2
.De
Similarly, range specifications are represented by \fB":"\fR, so that
.Ds
":"(s,i,j)
.De
is equivalent to
.Ds
s\^[i:j]
.De
.PP
Defaults are not provided for omitted or null-valued arguments in this
facility. Consequently,
.Ds
"..."(1,\*b10)
.De
results in a run-time error when it is evaluated.
.PP
The subscripting operation also is available with the string name
\fB[\^]\fR. Thus
.Ds
"[\^]"(&lcase,\*b3)
.De
produces \fBc\fR.
.PP
String names are available for all the operations in Icon, but not for
control structures. Thus
.Ds
"|"(\*1,\*b\*2)
.De
is erroneous.
.PP
String names for procedures are available through global identifiers.
Note that the names of functions, such as \fBimage\fR are global
identifiers. Similarly, any procedure-valued global identifier may be
used as the string name of a procedure. Thus in
.Ds
global q

procedure main()
   q := p
   "q"("hi")
end

procedure p(s)
   write(s)
end
.De
the procedure \fBp\fR is invoked via the global identifier \fBq\fR.
.NH
Integer Sequences
.PP
To facilitate the generation of integer sequences that have no limit,
the function \fBseq(i,\*bj)\fR has been added. This function has the
result sequence {\^i, i+j, i+2j, \*(el }. Omitted or null values for \fBi\fR
and \fBj\fR
default to 1. Thus the result sequence for \fBseq()\fR is
{\^1, 2, 3, \*(el }.
