On 9/24/12 9:36 AM, Philippe Sigaud wrote:
On Mon, Sep 24, 2012 at 2:28 PM, bearophile<bearophileh...@lycos.com>  wrote:
monarch_dodra:


I tried this, and found it neat that it works:

I used this in a small unit library (partially accessible on github),
to obtain code like:

auto distance = 100.km;
auto speed = 130.km/h; // division works, too.

auto timeToDestination = (distance/speed).hour; // distance/speed
gives seconds =>  transformed in hours.

It was a nice exercise in using UFCS and mixins to create your own
unit library (not only IS, but ay kind of unit library).

And, you know what? I *never* used it after coding it. These examples
are cute, they make for nice blog posts for F#, but the real-world
usage is dubious to me (I know they were space-programs crashes)

I quite like the implicit message in units: use the type system to
help you catch errors are compile-time. Add to that a nice syntax and
a showcase for D's generational capabilities and it's quite nice.

But, to my eyes, it's but a toy.

I wouldn't read too much into it. You're a library author, not (I assume) a scientific computing guy. So beyond playing with a few examples, your work on this library is done - you wouldn't be a client of it for the simple reason you don't intensively work with kilometers, speeds, dollars, and such. It's possible that a good and usable library of units could add value to a category of users.


Andrei

Reply via email to