From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=BANG_GUAR,BAYES_00, INVALID_MSGID,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public From: shang@corp.mot.com (David L. Shang) Subject: Defintion, again, was Re: Static vs. Dynamic typing again Date: 1997/01/30 Message-ID: <1997Jan30.153758.1713@schbbs.mot.com>#1/1 X-Deja-AN: 213251646 sender: news@schbbs.mot.com (SCHBBS News Account) references: <5covaj$l0@boursy.news.erols.com> organization: MOTOROLA reply-to: shang@corp.mot.com newsgroups: comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object Date: 1997-01-30T00:00:00+00:00 List-Id: In article <5covaj$l0@boursy.news.erols.com> feldmand@erols.com (Damon Feldman) writes: > > >I think it's a bit misleading to say that Smalltalk is dynamically typed > > Statically typed means that types are *determined* at compile time. > Dynamically typed means types are *determined* at runtime. > > Static type *checking* means checking done at compile time. > Dynamic type *checking* means checking at run time, I suppose. > I would like to make more definitions here. Dynamically Typed (con: statically typed). An argument (variable, reference, or formal parameter) is dynamically typed if the type of the object to which the argument can be bound cannot be determined statically (at compile or link time). Examples of dynamically typed arguments are: Untyped without static type inference: the type is not given before run-time. It can be bound to an object of any type at run-time. This is an extreme case of the dynamically typed. The example is a SmallTalk variable. Note that a variable in ML is also untyped, but the exact type of its bound object is inferred (guaranteed!) before run-time. Therefore, an ML variable, though untyped at the time of declaration, but typed at the time before running. It is not dynamically typed by this definition. Polymorphically typed: the type is given at the time the argument is declared. It can be bound to an object of any subtype of the given type at run-time. A Java's variable (non-primitive) falls into this case. Tagged Union: a set of possible types are given at the time the argument is declared. It can be bound to one of the given types at run-time. Dynamic Typing (con: static typing). A type system is a dynamic typing system if new types can be defined/created at run-time. CLOS and Dylan support dynamic typing while C++, Java, Eiffel, and Ada95 are static typing languages. In a dynamic typing system, the class hierarchy can be dynamically expanded by adding new subclasses at the time the programming is running. But the class hierarchy is fixed at runtime in a static typing system. Dynamic Type (con: static type). A type is a dynamic type if its definition can be changed after its creation. Therefore, we can add/delete methods or slots in a dynamic type at run-time. A static type is fixed since it is created. A simulation of dynamic type by dynamic typing system can be done by considering a new type is created whenever the existing type changes. Dynamic Type Checking (con: static type checking): checking the type of a dynamically typed argument at run-time. Dynamic Type Safe: All type errors, if cannot be not prevented from happening at compile time or link time, should be detected at run-time. [ A type error is such an incorrect binding of an object to a name that the type of the object does not conform to the declared type of the name. ] Static Type Safe (stronger): All type errors can be prevented from happening before run-time. Strong Type Safe (further stronger): All type errors can be prevented from happening before the software is released. This is a new definition. By this definition, C++ templates is static type safe but not strong type safe. C++ templates are released to clients in the form of source code. The type error is detected at the time it is used by clients, not at the time the template is designed or developed. My comments: Dynamic type checking is not only for dynamic type safe. It can be used for error prevention and produce a strong type safe language! For how and why, you may refer to my language compariosn document: Transframe, Java & C++: A Critical Comparison http://www.transframe.com, at Research/TransframeLanguage page David Shang