|Static type-checking with dynamic scoping firstname.lastname@example.org (1991-01-14)|
|Static type-checking with dynamic scoping email@example.com (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 firstname.lastname@example.org (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 email@example.com (1991-01-21)|
|From:||firstname.lastname@example.org (John Gateley)|
|In-Reply-To:||email@example.com's message of 14 Jan 91 14:55:30 GMT|
|Date:||Tue, 15 Jan 91 11:31:17 CST|
Is it possible to do static type checking with dynamic scoping?
Well, not really. Consider the following program:
procedure foo (x:int) ...;
procedure bar (x:string) ...;
procedure baz (...) ... x ...;
What type will baz's x have, int or string? One solution that may be
possible is to construct the call graph and make sure that all bindings of x
which reach a given use have the same type. There are some drawbacks to this
solution - it is a "whole program" strategy, separate compilation is not
allowed (without lots of work). It also cannot correctly type check some
programs which are nevertheless legal. For example, the use in baz may be
limited to the x:string binding, but the call graph (constructed at compile
time) may reflect a call from foo which is never taken.
A more restrictive solution is to treat variables as global - assign them
types at the global level. Then all bindings of the variable has to match
One thing that really messes life up is 1st-class functions. They make the
call graph impossible to construct at compile time.
Are you sure you really want dynamic binding?
Return to the
Search the comp.compilers archives again.