ufcs and integer params
Marco Leise
Marco.Leise at gmx.de
Wed Jul 18 00:30:11 PDT 2012
Am Sun, 15 Jul 2012 19:17:11 +0200
schrieb Philippe Sigaud <philippe.sigaud at gmail.com>:
> > On Sunday, July 15, 2012 05:30:55 Jay Norwood wrote:
> > > I see from this other discussions that it looks like 2.059 ( or
> > > maybe 2.060) does support something like 3.cm(). Not sure from
> > > the discussion if it would also accept 3.cm as in the xtext/xtend
> > > example.
>
> Hi Jay,
>
> I had a little fun with coding a units (SI units) system in D and pushed an
> incomplete version on Github a few weeks ago:
>
> https://github.com/PhilippeSigaud/Units
>
> It allows things like:
>
> auto distance = 100.km;
> auto speed = 120.km/hour;
>
> auto timeToDestination = distance/speed; // timeToDest is a time (seconds)
>
> The version on Github is grossly limited (it's just a sketch), but it gives
> an idea of what's possible. My goal is to code a generic unit system
> generator, given user inputs such as a list of units and sub-units.
>
> cheers,
>
> Philippe
Sounds fun. I mean, it makes me happy to see code written like this instead of
Distance distance = new Kilometers(100);
Speed speed = Speed.fromDistanceByTime(new Kilometers(120), new Hours(1));
:D
--
Marco
More information about the Digitalmars-d-learn
mailing list