Re: Static type-checking with dynamic scoping

Chuck Lins <Chuck_Lins.SIAC_QMAIL@gateway.qm.apple.com>
15 Jan 91 11:39:48

          From comp.compilers

Related articles
Static type-checking with dynamic scoping roberto@cernvax.cern.ch (1991-01-14)
Static type-checking with dynamic scoping gateley@rice.edu (1991-01-15)
Re: Static type-checking with dynamic scoping Chuck_Lins.SIAC_QMAIL@gateway.qm.apple.com (Chuck Lins) (1991-01-15)
Re: Static type-checking with dynamic scoping brm@Neon.Stanford.EDU (Brian R. Murphy) (1991-01-15)
Re: Static type-checking with dynamic scoping barmar@think.com (1991-01-16)
Re: Static type-checking with dynamic scoping brm@Neon.Stanford.EDU (Brian R. Murphy) (1991-01-17)
Re: Static type-checking with dynamic scoping mac@eleazar.dartmouth.edu (1991-01-21)
| List of all articles for this month |
Newsgroups: comp.compilers
From: Chuck Lins <Chuck_Lins.SIAC_QMAIL@gateway.qm.apple.com>
Keywords: types, design
Organization: Compilers Central
Date: 15 Jan 91 11:39:48

[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.
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.