Re: Modelling Disjoint Subtypes

From: Marshall <marshall.spight_at_gmail.com>
Date: 25 Mar 2007 19:21:17 -0700
Message-ID: <1174875677.357880.100990_at_n59g2000hsh.googlegroups.com>


On Mar 25, 5:24 pm, paul c <toledobythe..._at_oohay.ac> wrote:
> David Cressey wrote:
> > "Marshall" <marshall.spi..._at_gmail.com> wrote in message
> > ///
> >>As an aside, there exists systems in which the storage cost
> >>*at runtime* for type information is zero, because the types
> >>exist only at compile time, and are completely removed
> >>after.
>
> > If you are saying what I think you are saying, then I disagree.
> > ...
>
> I'd disagree too, because if Marshall is right, what would be the point
> of the type in the first place?

The point of static types is the same, whether you erase them at runtime or not: they aide in the rejection of incorrect programs.

> > For example, let's I have
> > float x, a, b;
> > x= a + b
>
> > If I look at the variables x, a, and b at runtime, the type is gone. ...
>
> But I can't agree with that unless you mean the type is gone because you
> are looking at bits in memory, which is a kind of switching of gears.
> One can make anything disappear if one mentally switches gears often enough.

No, that's not what I mean. I mean the types are gone because you *were* storing a representation of the types inside data structures used by the compiler when it was compiling your program, but that when it came time to write stuff out to an executable that would be the program you run, the compiler didn't write out anything for those specific data structures. "Erased" is the common term.

Other systems work differently, and write out type info so that it's available at runtime. Still other systems are hybrid, and write some subset of the info.

If the type info isn't available at runtime, you can't do some things, like ad hoc queries or reflection. Those things are important to a dbms. But there are other kinds of systems for which that isn't an issue. Imagine a physicist writing code to calculate a specific result, that embedded various numbers and their units in the code. The units are checked to make sure the code can never possibly mix Fahrenheit and Celsius, or feet and meters. But once the code passes this check, the units aren't useful any more. At runtime they would serve no purpose.

Marshall Received on Mon Mar 26 2007 - 04:21:17 CEST

Original text of this message