Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!gatech!purdue!haven!ni.umd.edu!uc780.umd.edu!cs450a03 From: cs450a03@uc780.umd.edu Newsgroups: comp.lang.misc Subject: RE: Dynamic typing (part 3) Message-ID: <15APR91.00191631@uc780.umd.edu> Date: 15 Apr 91 00:19:16 GMT References: <1707@optima.cs.arizona.edu><1991Apr11.053440.13401@comp.vuw.ac.nz> <1991Apr15.015640.4663@comp.vuw.ac.nz> Sender: usenet@ni.umd.edu (USENET News System) Organization: The University of Maryland University College Lines: 53 Brian Boutel writes: >First, let me try to define what I mean ... >- A type is a set of operations. >- a value has type T if it understands all the operations of type T Thus a value can have multiple types? Note that 0, 1, 33, -200 and 2000000000 might all share some types in common, yet not share other types. >- a type violation occurs when there is an attempt to apply to a value an > operation which is not in its type. At run-time, although some values may be computed by the compiler. >- Languages can be classified as untyped, dynamic typed, static typed. >- Untyped means that it is solely the programmer's responsibility to >ensure that no type violation occurs. Failure to ensure this will not >be detected at compile time or by the system at run-time. ... I'm a little foggy here... If a language has some run-time checking, and some compile time checking, and doesn't catch some things, how would you classify it. [e.g. C on a machine that has some arithmetic exception hardware.] >- Dynamic typed means that values/objects contain type information at >run-time, so can detect attempted type violations and respond. This >is fine unless the response is unanticipated. The response is unanticipated? I presume you mean when the programmer did not intend to apply a particular function to some particular datum? >- Static typed means that a type is associated at compile time with >each variable. (In a functional language, which is what interests me, >this normally means with each defined function and by implication its >formal parameters.) It is possible at compile time to ensure that a >value is never bound to a variable of the wrong type, and that only >type-valid operations are performed on variables, thus preventing >type violations. How is this possible? Especially in a machine with finite limits? Note that arithmetic overflow means that addition can produce values which don't have the type for addition. You can't use subtraction to generate a value for a function which does not accept 0, or negative numbers, unless static analysis of the code reveals that this is ok. Multiplication hits the overflow problem even harder. Etc. And that's just basic arithmetic. Raul Rockwell