----------------------------------------
> Date: Mon, 7 Jan 2008 01:59:01 -0800
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: Introducing Cobra
> 
> I hate to drag this incredibly interesting yet simultaneously tedious 
> conversation into the realm of the practical but...
> 
> 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? I don't mean just 
> having an integer typecast to "altitude" but somehow call it "altitude 
> in meters" without being so verbose? And for bonus points it would be 
> nice if it could prohibit the involvement of any other units of distance 
> in the calculation so we don't accidentally mix our altitude in meters 
> with our rate of descent in feet per second during our retro-rocket 
> timing calculations.
> 

One could do it with classes for feet and meters and custom typecast and 
arithmetic opertors defined (in C++).  That way if you do mix them, the proper 
operator is called which will convert them before adding.  That wouldn't stop 
someone from writing AccelerationMetersSeconds EarthAccel=32  (which is really 
acceleration due to gravity on earth in feet/s/s), but nothing can.

Thats the closest I can think of at least.

Gae
_________________________________________________________________
Make distant family not so distant with Windows Vista® + Windows Live™.
http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to