[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic vs. static typing



"Anton van Straaten" <anton@appsolutions.com> writes:

> I'm saying that type-checking is a computation that can span the
> entire execution lifecycle of a program, and if we recognize and
> understand that, we can develop systems that can make better use of
> type information at all stages of that lifecycle, and do so
> flexibly, without having to be shackled by it.

As an (almost) existence proof of this, consider adaptively optimizing
JITs such as are used in Java. I don't know if any of them actually
use this particular strategy I'm about to describe but they easily
could given the other things they do.

Imagine a particular call site to the method foo which is defined in
the interface Fooable. At the moment there is only one class loaded
that implements Fooable so the JIT can optimize out the method
dispatching at the call site instead emiting code that jumps directly
to the foo method on that one class. However if a new class is loaded
that implements Fooable the JIT will need to go back and put in the
full dispatching code (or otherwise patch up the code so it will
behave correctly if an instance of the new class ever ends up being
the object at that call site.)

-Peter

-- 
Peter Seibel                                      peter@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp