Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!think.com!mintaka!spdcc!iecc!compilers-sender From: Chuck_Lins.SIAC_QMAIL@gateway.qm.apple.com (Chuck Lins) Newsgroups: comp.compilers Subject: Re: Static type-checking with dynamic scoping Keywords: types, design Message-ID: <9101151934.AA27600@internal.apple.com> Date: 15 Jan 91 16:39:48 GMT Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: Chuck Lins Organization: Compilers Central Lines: 33 Approved: compilers@iecc.cambridge.ma.us [in <3818@cernvax.cern.ch> roberto@cernvax.cern.ch (roberto bagnara) asks] roberto> is it possible to do static type-checking when roberto> you've [got] dynamic binding? Unless I seriously misunderstand his question, I believe the answer is a qualified yes. There will still be situations where a run-time check is necessary. Consider for example the hierarchy (TFoo is at the top) TFoo --> TBar --> TBaz | |--> TFrob TFrobboz (a separate hierarchy not rooted at TFoo) The compiler can certainly detect that variables typed to one of the subclasses TBar, TBaz, TFrob are definitely also of class TFoo and that they are never TFrobboz's. The run-time checks are required when you have variables of type/class TFoo and wish to distinguish between TBar, TBaz, and TFrob. In other words, the dynamic type is different from the static type. For example, calling a method of TBaz when the static type is TFoo or TBar. The implementation of (and theory behind) the notion of 'type extension' is discussed in the paper: N. Wirth, "Type Extensions", ACM TOPLAS, Vol 10(2), April 1988, 204-214. I presume there's something similar in the work done by various folks (Ralph Johnson's name comes to mind) on typed Smalltalk. The terminology may be different, but I think the concepts are similar. -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.