RFC: SI Units facility for Phobos
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Jan 5 14:48:55 PST 2011
On 1/5/11 4:06 PM, BCS wrote:
> In conclusion (yes I know this normally goes at the bottom) I think
> we are wanting different and contradictorily things from this
> library.
I almost didn't read the rest thinking that that's all you inserted.
All: there's more, scroll down!
One additional practical matter:
> The way I would like that code to look would be:
>
> void computeFiringSolution(Radians angle)
> {
> auto s = angle.sin(); // only exist for Radians (and Scaler)
> ...
> auto newAngle = std.units.arcsin(s); // returns Radians
> static assert(is(typeof(newAngle) : Radians));
> }
This is nice in theory but would have you essentially wrap by hand an
unbounded number of functions. And for what? So they write angle.sin()
instead of sin(angle.value). I appreciate the additional theoretical
safety, but I don't see how that benefit compensates the cost. I want a
practical library that allows me to work with libraries designed outside
of it.
Anyway, let's not forget that at the end of the day my opinion is one
opinion and my vote is one vote. For the record, my vote is against the
library in its current form for the following reasons:
(a) Poor documentation
(b) Limited expressiveness
(c) Numeric issues as I described (and no amount of rhetoric will set
that straight; FWIW given the obvious question of scaling you need to
prove it works, not me to prove it doesn't)
(d) Unrealized potential (if we approve this, backward compatibility
will prevent more comprehensive libraries having the same aim but a
different design). This argument is to be taken with a grain of salt as
in general it can be easily abused. What I'm saying is that once this
library is in we may as well forget about scaled units a la boost units
(which are the kind I'd want to use).
Going from here I see a few possibilities.
1. Other people deem the library adequate as it is and it gets voted in;
2. You and somebody else agree to work together on this submission;
3. You agree to pass your work to someone who will continue to work
towards a submission;
4. The library is not made part of Phobos but remains of course
available as a third-party library.
Andrei
More information about the Digitalmars-d
mailing list