C++ Logo

std-proposals

Advanced search

Re: [std-proposals] On the standardization of mp-units P3045R1

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Thu, 27 Jun 2024 18:52:54 +0000
> In your specific example, this would be less likely because you've included the full unit name in your alias. However, not everyone wants to do this --- often, people want to give it a more generic alias, like `temperature`. Preventing this constructor from a single value (even when `explicit`), and making sure that every option forces the user to name the unit explicitly at the callsite, preserves unit safety, and reduces cognitive load.

I think you focused too much on the alias part, while the important part is a fully named type. In many codes bases the rule to explicit type out your types are a thing.
If I can fully type out the type that I want, why shouldn’t I be able to use it?
Why exactly do I need a separate gadget to create that type?
Talking about a mental effort, it is not enough to know the type that you want, you also need to lookup the right gadget (whose name has nothing to do with the type you are trying to construct) in order to construct your type,… what? Why?

This doesn’t have the confusing problem that “30 * deg_C” feels wrong, because it is wrong, it’s not a multiplication why do you write it as a multiplication?

Received on 2024-06-27 18:52:57