🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #3477

Re: Dynamic typing (part 3)

#3477
From: David Gudeman
Date: Tue, 26 Mar 1991 22:26
51 lines
2645 bytes
In article  <KERS.91Mar26115416@cdollin.hpl.hp.com> Chris Dollin writes:
]
]   In article  <KERS.91Mar21130048@cdollin.hpl.hp.com> Chris Dollin writes:
]   ]
]   ]Perhaps David should show us some examples where he thinks
]   ]dynamic types are ``essential''...
]
]...I meant that, without dynamic types, the expression of the code would be
]more obscure, or longer, or plain inelegant.

The examples of heterogenous lists posted by others are persuasive,
more so than I would have expected.  Other examples include the
ability to define polymorphic functions easily:

  procedure max(a,b) return if a < b then b else a; end

which is perfectly clear and works for any type that "<" works on.
Statically typed languages either forbid this altogether, or require
extra declarations that obscure the simple meaning.

Another convenience is the ability to use different types to mean
different things.

  procedure string_to_num(s) # returns the integer or float
  # represented by s.  In case of an error, the return value is a
  # string describing the type of error.

Statically typed languages either need a global variable or an
exception handling mechanism to do this.  And with the global variable
method, the programmer can forget to check the value of the global,
leading to undefined behavior.  With the solution above, forgetting to
check the result will eventually lead to a type-error that will
probably be much easier to track down.

]Incidentally, David, are we arguing for dynamic typing (as in Lisp,
]Pop11, etc) or simple absence of mandatory type declarations (as in
]ML)? It makes a difference. 

ML does not have dynamic typing so I'm not arguing for that sort of
scheme.  It gives some of the advantages of dynamic typing, but
probably not the more important ones.  I'm arguing (1) dynamic typing
is useful enough that it should be supported directly by programming
languages, (2) dynamic typing is not "dangerous" in any sense, (3)
static typing is important enough that it should be supported by
programmig languages, and (4) it is not clear the the ability of
static type declarations to catch errors outweighs the number of
errors that occur in the declarations.
--
					David Gudeman
gudeman@cs.arizona.edu
noao!arizona!gudeman
Technical Details
Message-ID: <1162@optima.cs.arizona.edu>
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!lethe!tvcent!comspec!telly!attcan!uunet!cs.utexas.edu!asuvax!noao!amethyst!arizona!gudeman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!lethe!tvcent!comspec!telly!attcan!uunet!cs.utexas.edu!asuvax!noao!amethyst!arizona!gudeman
From: gudeman@cs.arizona.edu (David Gudeman)
Newsgroups: comp.lang.misc
Subject: Re: Dynamic typing (part 3)
Message-ID: <1162@optima.cs.arizona.edu>
Date: 26 Mar 91 22:26:36 GMT
Sender: news@cs.arizona.edu
Lines: 51