On Jan 7, 2008 2:32 AM, Christopher Smith <[EMAIL PROTECTED]> wrote:
> Tracy R Reed wrote:
> > Gabriel Sechan wrote:
> >> Seriously, though.  A variable *always* has a type, wether the
> >> language does or not.  The type of a variable is the kind of data it
> >> holds.  This is separate from its languae type.  For example, lets
> >> say we have to store today's temperature.  Its type is temperature in
> >> degree's celsius.  Its language type may be scalar in perl, int in
> >> C++, etc.  But its true type is still temperature in degrees
> >> celsius.  Having a language that supports typedefs and declarations
> >> merely documents that for you, rather than forcing you to read the
> >> code to figure it out.
> >
> > Can you somehow encapsulate units in a type so that when we program a
> > completely hypothetical Mars lander it doesn't allow us to
> > accidentally mix meters and feet without doing a type conversion?
> Yes, actually you can. Sadly Martin Fowler wrote up exactly how to do
> this in Analysis Patterns long before the mission, haskell folks do this
> kind of stuff in their sleep, and the boost folks have encoded it in
> their "units" library. With a statically typed language you can even get
> it to produce compile time errors for this kind of fuck up.

By the way, this is not exactly new stuff.  Look at Wikipedia for
Buckingham's Pi theorem.  There is a pointer to the original 1914
Physical Review article.

http://prola.aps.org/abstract/PR/v4/i4/p345_1

    carl
-- 
    carl lowenstein         marine physical lab     u.c. san diego
                                                 [EMAIL PROTECTED]

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to