🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2951

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

#2951
From: Dan Bernstein
Date: Tue, 12 Mar 1991 08:45
45 lines
2840 bytes
I really think we need a Frequently Used Definitions list here...

In article <601@optima.cs.arizona.edu> gudeman@cs.arizona.edu (David Gudeman) writes:
> <type>			a set of values.

Yeah, this is the definition I'm familiar with. Also:

<reference>		a section of program text that refers to a value.

Any language lets you express certain types. In general the expressible
types are a small, fixed set of basic types, plus the transitive closure
of a fixed set of type composition operations upon those basic types. In
C, for example, the basic types are int, double, etc., and the type
composition operations are array, struct, function, etc.

In C, every reference has a value with a fixed, expressible type, known
to the compiler. The value of that reference may change during program
execution, but it is always in that compile-time type. I believe this is
what most people mean by static typing.

Note: If a statically typed language gives you ``the set of expressible
types'' and ``the set of all values'' as basic types, and struct as a
type composition operation, then you can implement runtime polymorphism
in that language. I.e., the set of pairs (type,value) is a type, and you
can restrict yourself to using those pairs. The typing is still static:
in fact, every value in your program has the same type, namely the set
of all (type,value). Typechecking in this context means making sure that
the value inside (type,value) is a member of the given type.

Given this, I fail to see how dynamic typing can be regarded as more
than a syntactic feature. If you're given a program that uses dynamic
typing, you can just convert every reference in the program to refer to
a (type,value) pair, and poof! you have a statically typed program.

(That doesn't mean I have no appreciation for dynamic typing; syntactic
features are often quite worthwhile, and can represent quite a lot of
work. In C, for example, the set of all types is not a basic type, so
you have to create the type for yourself and arrange that every type
definition be accompanied by creation of a member of the type of all
types. Then you have to carry (type,value) pairs everywhere, and handle
all the typechecking. This is still a syntactic conversion from the
original program. It requires no support from the compiler.)

---Dan
You are in a maze of twisty little types, all alike.
Technical Details
Message-ID: <19728:Mar1208:45:2291@kramden.acf.nyu.edu>
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!kramden.acf.nyu.edu!brnstnd
References: <601@optima.cs.arizona.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!kramden.acf.nyu.edu!brnstnd
From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein)
Newsgroups: comp.lang.misc
Subject: Re: Dynamic typing -- To Have and Have Not (was Runti
Message-ID: <19728:Mar1208:45:2291@kramden.acf.nyu.edu>
Date: 12 Mar 91 08:45:22 GMT
References: <601@optima.cs.arizona.edu>
Organization: IR
Lines: 45