Re: How to implement dynamic typing?

glen herrmannsfeldt <gah@ugcs.caltech.edu>
Tue, 6 Apr 2010 06:37:46 +0000 (UTC)

          From comp.compilers

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)
[23 later articles]
| List of all articles for this month |
From: glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups: comp.compilers
Date: Tue, 6 Apr 2010 06:37:46 +0000 (UTC)
Organization: California Institute of Technology, Pasadena
References: 10-04-009
Keywords: types
Posted-Date: 07 Apr 2010 01:41:52 EDT

David Belier <davidbleier@hotmail.com> wrote:
> Recently I finished chapter 7 of the dragon book (2nd edition) but 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
> and check it every time using an acceptable amount of resources and
> time. Can someone please name papers or websites to read?


(snip)


The languages that I know of that use dynamic typing are all
interpreted, sort of by definition. In that case the overhead is
usually less than the overhead already there in an interpreter.


For a compiled language there would be a tradeoff, as you say,
between time and space. Space efficient would be a subroutine
call for each evaluation. Time efficient, though still slow,
would be many switch/case constructs, each based on the possible
type at that point.


If, for example, like awk you had only two types (string and
double precision floating point numeric) then it might not be
so bad. Only two choices, and always the possible conversion
to the other type. As the number of types increase, the
combinations grow exponentially...


-- glen



Post a followup to this message

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