Related articles |
---|
How to implement dynamic typing? davidbleier@hotmail.com (David Belier) (2010-04-02) |
Re: How to implement dynamic typing? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-04-06) |
Re: How to implement dynamic typing? sleepdev@gmail.com (andy johnson) (2010-04-06) |
Re: How to implement dynamic typing? rpw3@rpw3.org (2010-04-06) |
Re: How to implement dynamic typing? bartc@freeuk.com (bartc) (2010-04-06) |
Re: How to implement dynamic typing? paul.biggar@gmail.com (Paul Biggar) (2010-04-06) |
Re: How to implement dynamic typing? iant@google.com (Ian Lance Taylor) (2010-04-06) |
Re: How to implement dynamic typing? barry.j.kelly@gmail.com (Barry Kelly) (2010-04-07) |
Re: How to implement dynamic typing? torbenm@diku.dk (2010-04-07) |
Re: How to implement dynamic typing? ctalk@ctalklang.org (Ctalk Project) (2010-04-07) |
Re: How to implement dynamic typing? gneuner2@comcast.net (George Neuner) (2010-04-07) |
Re: How to implement dynamic typing? cr88192@hotmail.com (BGB / cr88192) (2010-04-10) |
Re: How to implement dynamic typing? bartc@freeuk.com (bartc) (2010-04-11) |
Re: How to implement dynamic typing? harold.aptroot@gmail.com (Harold Aptroot) (2010-04-11) |
[17 later articles] |
From: | Barry Kelly <barry.j.kelly@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Wed, 07 Apr 2010 03:05:06 +0100 |
Organization: | TeraNews.com |
References: | 10-04-009 |
Keywords: | types |
Posted-Date: | 07 Apr 2010 01:54:27 EDT |
David Belier wrote:
> I still don't understand how to implement dynamic typing. I don't get
> how you are supposed to store the type information with each variable
Generally you would store type information with values, not variables.
> and check it every time using an acceptable amount of resources
The essence of dynamic typing is that many, if not most, operations on
values are subject to overriding at runtime, and discovering which ones
are overridden cannot be determined at compile (or parse) time. That
implies lots of lookups. Thankfully, not everything is overridden all
the time, moreover once something is overridden it tends not to be
re-overridden again - so caching lookups should be very profitable. The
creativity comes into what you cache, how, and what you use as a key
check your caches.
Some random resources:
Design of V8:
http://code.google.com/apis/v8/design.html
Look into the implementation of Smalltalk 80:
http://citeseer.ist.psu.edu/deutsch84efficient.html
Look into Factor, a modern stack oriented concatenative language with a
very competitive implementation:
http://factorcode.org/
Look into LuaJIT, another competitive implementation of a more
traditional OO-style dynamically typed language:
http://luajit.org/
> Note: I have a strong C++ background and know x86 assembler. I can
> imagine a way to implement it doubling memory requirements and making
> the program dead slow in the process so there must be better ways.
I think you may be underestimating how fast, in user perception terms,
even a relatively naive implementation may be on modern machines.
-- Barry
--
http://blog.barrkel.com/
Return to the
comp.compilers page.
Search the
comp.compilers archives again.