unit type for addition to std lib [was Re: D Language 2.0]

BCS none at anon.com
Tue Jan 19 15:07:52 PST 2010


First:

I've updated my units type to d2.0 and cleaned it up a bit.

http://www.dsource.org/projects/scrapple/browser/trunk/units/si2.d

I'm offering this for inclusion in Phobos and/or Tango and am willing to 
license it as needed to make that work.

If anyone shows any interest at all I'll start an bugzillil ticket.

-------
Hello Chad,

> One other nit then.  What if I want to extend it to add more types of
> units?

A generally extendable type is overkill in my opinion.

> 
> I've had occasion to use odd units like "tiles" or "pixels" or
> "sectors" and things like that when writing games.

I don't have a good answere to that one but...

>  Then there's
> money. 

Money when? Now? At some point in the future? And what interest rate are 
you using? I actually considered that one when I wrote my lib and quickly 
decided that it's WAY to complex.

> Also all of the imperial units that I don't care about, as
> well as the more obscure physical units.

My lib has every SI unit I could fine and all the units I found that I recognised. 
The current vertion can have a new unit added as a single line of code.

>  I don't expect any of this
> to come out of the box, but it'd be nice to be able to easily add new
> types of units by defining what kind of quantity they describe
> (perhaps as a compile time string) and what the scaling factor is to
> another known unit (unless it's axiomatic).

That's (almost) exactly what I have.

> 
> At any rate I'd love to have guarantee that my units are correct.
> This kind of stuff has cost me soooo much debugging and frustration in
> the past.
> 





More information about the Digitalmars-d mailing list