Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!world!iecc!compilers-sender From: brm@Neon.Stanford.EDU (Brian R. Murphy) Newsgroups: comp.compilers Subject: Re: Static type-checking with dynamic scoping Keywords: types, design Message-ID: <9101160042.AA28163@Neon.Stanford.EDU> Date: 16 Jan 91 00:42:07 GMT Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: Brian R. Murphy Organization: Computer Science Department, Stanford University Lines: 31 Approved: compilers@iecc.cambridge.ma.us It seems to me that one could consider (dynamically bound) free variables in a procedure to simply be additional parameters to the procedure. Then standard ML-like type inference could be done. Not being fluent with ML syntax, I give an example in (dynamically scoped) Lisp: (defun f (x) (y x)) ;; y free, bound dynamically Here f might taken to have type: ([y: a->b], a) -> b that is, it takes an argument of type a, a binding of y with type a->b, and returns a value of type b. A place where f is used might look like: (let ((y sub1)) (f 3)) where y has type int -> int and f is applied to ([y:int->int], int) which may be unified with the above, yielding a result of int as well. Keeping track of all of the current bindings and determining which onese were relevant in a particular application would certainly clutter up the type inference, but it shouldn't make it terribly more difficult. -Brian Murphy brm@cs.stanford.edu -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.