🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2894

Dynamic typing -- To Have and Have Not (was Runti

#2894
From: David Gudeman
Date: Tue, 05 Mar 1991 21:36
70 lines
4112 bytes
In article  <1991Mar5.182130.15091@engage.enet.dec.com> grier@marx.enet.dec.com writes:
]   Sorry for the confusion, your "definition" wasn't clear about what
]you meant.

The term "weak typing" has been used for this feature, but it has also
been said that Pascal and C are weakly typed languages, so I didn't
want to used that word.  The word "untyped" has also been used, but I
don't like that term for two reasons.  First, it tends to confuse
people when you say "Icon is an untyped language.  It has ten
different types...".  People assume "untyped" means that a language
has no types, but it really just means that syntactic elements don't
have types.  Another reason I don't like the term "untyped" is that it
implies a sort of scale: (strongly typed ... weakly typed ... untyped)
and this is deceptive.  Weakly typed languages (when they are
distinguished from untyped languages) still have this notion that you
can assign types to identifiers and other (syntactic) expressions.
Languages with runtime polymorphism (or runtime typing) do not have
this concept at all.

]  Over the weekend, I was thinking about it and realized
]that I might have misinterpreted you.  I'd never seen a definition
]of anything called "runtime polymorphism" before, and you didn't
]include any additional information or examples which made what you
]meant clear.

Well, my definition could have been clearer.  I'll make the excuse
that everyone I talk to around here has enough experience with these
sorts of languages that a quick explanation is enough to let them know
what I mean.  I didn't make allowance for different "programming
language cultures".  I used the word "polymorphism" to mean "multiple
types for the same expression", not "multiple functions with the same
name".  However, the term has enough baggage associated with it that
it was a poor choice.  I'm going to arbitrarily change my term...
First:

Static typing: a programming language feature where identifiers and
  other syntactic expressions are assigned types based on information
  that is present in the text of the program -- usually involving
  variable declarations.  Functions and operators always assume that
  the values passed to them are the expected type.  Strong typing and
  weak typing are relative terms that describe the amount of
  information available from the text of the program.

Now instead of "runtime polymorphism":

Dynamic typing: a programming language feature where identifiers and
  other syntactic elements cannot be assigned types.  Any expression
  may (in principle) produce a value of any type when it is evaluated.
  Functions and operators must (in principle) always examine the types
  of their arguments and do something reasonable for any possible type
  (where "something reasonable" includes the possibility of aborting
  the program with an error message).

]   Your definition of "runtime polymorphism" doesn't really make
]sense in a type-safe system.  so clearly what you're talking about
]can only occur in a weakly typed language

Although my suggestion in Part 2 does give a language with dynamic
typing that is type safe in the following sense: syntactic expressions
can be assigned types; and in an expression f(expr) where expr has
type top and f expects some fixed type T, it is guaranteed at runtime
that either (1) f is called with an argument of the correct type, or
(2) a runtime error occurs.  This is just as "type safe" as if expr
was a tagged union and you had to explicitly test the type of the
union before calling f.  It's just that the test is built in to the
language.
--
					David Gudeman
gudeman@cs.arizona.edu
noao!arizona!gudeman
Technical Details
Message-ID: <584@coatimundi.cs.arizona.edu>
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!news.cs.indiana.edu!arizona.edu!arizona!gudeman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!news.cs.indiana.edu!arizona.edu!arizona!gudeman
From: gudeman@cs.arizona.edu (David Gudeman)
Newsgroups: comp.lang.misc
Subject: Dynamic typing -- To Have and Have Not (was Runti
Message-ID: <584@coatimundi.cs.arizona.edu>
Date: 5 Mar 91 21:36:22 GMT
Sender: news@cs.arizona.edu
Lines: 70