Xref: utzoo comp.lang.misc:7598 comp.object:3333 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!uwvax!daffy!saavik.cs.wisc.edu!quale From: quale@saavik.cs.wisc.edu (Douglas E. Quale) Newsgroups: comp.lang.misc,comp.object Subject: Re: Type Systems and Dynamic Binding Message-ID: <1991Apr19.132239.9252@daffy.cs.wisc.edu> Date: 19 Apr 91 13:22:39 GMT References: <27313:Apr1623:30:0391@kramden.acf.nyu.edu> <1991Apr16.183750@ece.arizona.edu> <1991Apr17.173651.23103@visix.com> Sender: news@daffy.cs.wisc.edu (The News) Distribution: world,local Organization: University of Wisconsin -- Madison Lines: 35 In article <1991Apr17.173651.23103@visix.com> amanda@visix.com (Amanda Walker) writes: > >However, you can certainly *implement* dynamic typing in C, with as >low an overhead as you can get in any other language. > This is not true. A C implementation of dynamic typing will be slower. A compiler for a dynamic language can take advantage of its knowledge of datatype representations to generate faster code. Two simple examples: 1) tag operations for type discrimination A compiler for a dynamically typed language can dedicate a register to hold a bitmask that will speed type tag operations. A C program would either use an immediate value or a global variable, either of which is slower and bulkier on many architectures. 2) generic arithmetic Suppose the dynamic language includes generic arithmetic on integers of arbitrary size. In lisp this would give two types of integer, fixnum and bignum. A lisp compiler can add two fixnums inline and branch on the overflow flag to a bignum routine if the sum of the fixnums is too large. C blithely ignores integer overflow. In addition, some CPU architectures have special instructions to speed tagged arithmetic (notably the Sparc). I would be surprised if C compilers were able to use that instruction for generic arithmetic. ... and there are numerous other type representation hacks that an implementation of a dynamically-typed language system can exploit. -- Doug Quale saavik.cs.wisc.edu