[comp.lang.icon] Dynamic typing

Paul_Abrahams%Wayne-MTS@UM.CC.UMICH.EDU (11/19/90)

 
To respond to various points:
 
(1) Finding a representation of dynamic types is more difficult when (a) the
types involve mutual recursions, not just one, and (b) your language has
structural equivalence rather than name equivalence (like Modula-3). 
Structurally equivalent types should have the same representation even if
their declarations use different names.  In fact, it's an interesting job
for an Icon program (given, say, a textual representation of a collection of
Modula-3 type declarations). 
 
(2) Of Jerry Nowlin's three examples, the one I find most interesting is the
third, in which global variables of arbitrary types are dumped to a file and
read back in again by another program (or another execution of the same
program, I gather).  The first two could be done with variant records,
subclasses, or what have you since there are only a small, finite number of
choices.  The third one involved a kind of inverse of `image' that
transforms an image into a value for almost any type at all (but not for
procedures, I'd guess).
 
(3) My box type in SPLASH isn't overloaded in the sense that x+y adds x and
y even if x and y are boxes containing numbers.  It will probably have an
extraction operator that extracts the variable or value contained in a box,
but I haven't figured out how to do this because I only want to permit the
extraction in a context where the type of the box's contents has been
proclaimed (using something like the Modula-3 TYPECASE statement).  But
TYPECASE doesn't work well when you have complex nested types.
 
(4) There isn't a necessary connection between compile-time typing and
operator overloading, but languages with dynamic typing generally don't seem
to have operator overloading except in the weak sense of things like
overloading + to work both on integers and reals.  In fact, Icon probably
could have been designed to use overloading more extensively and even to
make it available to users, with type declarations used in parameter lists
solely for the purpose of overload resolution.  Then you wouldn't have
different operators for lexical versus numerical comparison.  I won't try to
argue very strongly that it would be better that way, but it's an
interesting possibility that as far as I know no language designers have
considered.
 
(5) I probably should reiterate that a lot of the design of SPLASH was
inspired by Icon, and SPLASH has a lot of Icon features in it (especially
the central notions of generators and of failure as a possible outcome of
expression evaluation).  The current state of it is that the definition is
about 50 pages long and, I'd estimate, about 60% complete (which doesn't
imply that the final version will be 80 pages long).
 
Paul
 
abrahams%wayne-mts@um.cc.umich.edu