Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!mit-eddie!genrad!decvax!tektronix!tekcrl!tekchips!willc From: willc@tekchips.UUCP Newsgroups: comp.lang.misc Subject: Re: Static typing with Dynamic binding Message-ID: <1060@tekchips.TEK.COM> Date: Tue, 17-Feb-87 16:39:01 EST Article-I.D.: tekchips.1060 Posted: Tue Feb 17 16:39:01 1987 Date-Received: Thu, 19-Feb-87 06:40:50 EST References: <364@oracle.tc.fluke.COM> <814@unc.unc.UUCP> <1040@tekchips.TEK.COM> <588@watcgl.UUCP> Reply-To: willc@tekchips.UUCP (Will Clinger) Distribution: comp.lang.misc Organization: Tektronix, Inc., Beaverton, OR. Lines: 37 I would like to thank Doug Moen and others for their precise definitions. My example wasn't very good, so a number of people still don't see why dynamic scoping is incompatible with static type checking. I'll try again here with the help of the following example: In article <588@watcgl.UUCP> kdmoen@watcgl.UUCP (Doug Moen) writes: >In the (fortunately nonexistent) language "dynamically scoped Ada", >[Will's] example would be written as: > > FOO: function (N: INTEGER) return INTEGER is > import X: INTEGER; > begin > return X + N; > end FOO; > >In general, every variable mentioned in the body of a function in DSAda >must be a formal parameter, a local variable, or an imported variable, >which is inherited from the calling environment. Type declarations aren't enough to support static type checking when the language is dynamically scoped. Yes, the compiler can check that all uses of X within FOO are consistent with the "import" declaration. That's easy. The problem is that the compiler cannot check statically to make sure that FOO will be called only when X is an integer variable in the dynamic calling environment. That is, the compiler cannot tell whether it should believe the declaration. Indeed, it is statically undecidable whether X will denote anything at all when FOO is called. This is the reason that dynamic scoping is incompatible with static type checking. That's not to say that dynamic scoping is incompatible with type declarations. Type declarations can improve performance even though static type checking is impossible. Peace, Will Clinger Tektronix Computer Research Lab