Date: Thu, 27 Jun 2024 13:44:32 -0500
On Wed, Jun 26, 2024 at 3:17 PM Mateusz Pusz via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> During the discussion in the SG6 it was raised that that `30 *
> absolute<deg_C>` feels wrong, and I tend to agree with that. This was the
> only usage of `absolute` so, if multiply syntax should not use it, the
> `absolute` can be removed. After that, `30 * delta<deg_C>` looks like a
> hack and not a feature.
>
> I am looking for some other solutions that would help here. Maybe we
> should:
> - disallow the multiply syntax for offset units (K, deg_C, deg_F),
> - change `delta` to be a functor and call it as `delta<deg_C>(20)` which
> produces a `quantity`
> - re-add `absolute` to create a `quantity_point` with the same syntax
> (e.g., `absolute<deg_C>`)
>
> With the above, we would end up with the following helpers:
>
> ```cpp
> quantity q1 = 40 * m;
> quantity q2 = delta<m>(40);
> quantity_point q3 = absolute<m>(40);
> quantity q4 = 40 * deg_C; // Compile-time error
> quantity q5 = delta<deg_C>(40);
> quantity_point q6 = absolute<deg_C>(40);
>
FWIW, I like this, but mainly because it's moving toward something
that *syntactically
looks* like what's familiar to me (the `absl::Duration` model). Your
example:
quantity q5 = delta<deg_C>(40);
quantity k1 = delta<deg_K>(40);
quantity eighty = q5 + k1; // or how would I write this? I wouldn't
need an explicit cast just to go from Δ°C to Δ°K in the same representation
type, would I?
looks an awful lot like:
absl::Duration x = absl::Hours(24);
absl::Duration y = absl::Seconds(60);
absl::Duration day_and_minute = x + y; // OK
Now, it's totally *not* the same model at all: `Duration` is a concrete
type, `quantity` is a CTAD template. But it *looks* vaguely familiar, which
I (like most users) *assume* is a good thing. Of course if the similarity
is actually seriously misleading, then that's very bad. But I don't know
enough about mp-units to know if it's really *seriously* misleading.
How do you feel about it? Aren't the two ways to create a quantity too much?
>
Supporting two different plausible syntaxes for the same thing isn't bad.
Compare `true_type()` and `true_type::value`. I'd be much more concerned if
two *similar* syntaxes meant *different* things.
my $.02,
Arthur
std-proposals_at_[hidden]> wrote:
> During the discussion in the SG6 it was raised that that `30 *
> absolute<deg_C>` feels wrong, and I tend to agree with that. This was the
> only usage of `absolute` so, if multiply syntax should not use it, the
> `absolute` can be removed. After that, `30 * delta<deg_C>` looks like a
> hack and not a feature.
>
> I am looking for some other solutions that would help here. Maybe we
> should:
> - disallow the multiply syntax for offset units (K, deg_C, deg_F),
> - change `delta` to be a functor and call it as `delta<deg_C>(20)` which
> produces a `quantity`
> - re-add `absolute` to create a `quantity_point` with the same syntax
> (e.g., `absolute<deg_C>`)
>
> With the above, we would end up with the following helpers:
>
> ```cpp
> quantity q1 = 40 * m;
> quantity q2 = delta<m>(40);
> quantity_point q3 = absolute<m>(40);
> quantity q4 = 40 * deg_C; // Compile-time error
> quantity q5 = delta<deg_C>(40);
> quantity_point q6 = absolute<deg_C>(40);
>
FWIW, I like this, but mainly because it's moving toward something
that *syntactically
looks* like what's familiar to me (the `absl::Duration` model). Your
example:
quantity q5 = delta<deg_C>(40);
quantity k1 = delta<deg_K>(40);
quantity eighty = q5 + k1; // or how would I write this? I wouldn't
need an explicit cast just to go from Δ°C to Δ°K in the same representation
type, would I?
looks an awful lot like:
absl::Duration x = absl::Hours(24);
absl::Duration y = absl::Seconds(60);
absl::Duration day_and_minute = x + y; // OK
Now, it's totally *not* the same model at all: `Duration` is a concrete
type, `quantity` is a CTAD template. But it *looks* vaguely familiar, which
I (like most users) *assume* is a good thing. Of course if the similarity
is actually seriously misleading, then that's very bad. But I don't know
enough about mp-units to know if it's really *seriously* misleading.
How do you feel about it? Aren't the two ways to create a quantity too much?
>
Supporting two different plausible syntaxes for the same thing isn't bad.
Compare `true_type()` and `true_type::value`. I'd be much more concerned if
two *similar* syntaxes meant *different* things.
my $.02,
Arthur
Received on 2024-06-27 18:44:48