nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
947 stars 135 forks source link

remove named conversion factors #209

Open nholthaus opened 5 years ago

nholthaus commented 5 years ago

Named conversion factors no longer appear in unit definitions, so I don't think we need them anymore if we change the macros around. It would save us a bunch of symbols, and remove an obsolete concept from the public interface.

I made a half-hearted attempt, but reverted when I ran in to trouble in the strong definitions.

JohelEGP commented 5 years ago

Please, remind me what did you mean by "named" conversion factors.

nholthaus commented 5 years ago

what used to be meters etc but is now called meter_conversion_factor

JohelEGP commented 5 years ago

So you mean removing the strong conversion factors and leave only conversion_factor?

nholthaus commented 5 years ago

I mean removing the entire UNIT_ADD_UNIT_TAGS macro

nholthaus commented 3 years ago

so sometimes when you leave an issue open for two years, you don't really know what was going on and discover it wasn't a good idea. This is one of those. Not fully understanding the evolution of strong units didn't help.

This change regresses the error messages, but doesn't improve compile time. The readability gain in the definitions is more than offset by the readability loss to the user.

JohelEGP commented 3 years ago

The readability gain in the definitions is more than offset by the readability loss to the user.

The former can be retained. And I like it.

nholthaus commented 3 years ago

How so, by refactoring the macros some more?

On Thu, Oct 8, 2020, 8:03 PM Johel Ernesto Guerrero Peña < notifications@github.com> wrote:

The readability gain in the definitions is more than offset by the readability loss to the user.

The former can be retained. And I like it.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/nholthaus/units/issues/209#issuecomment-705890133, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOYOHYL4VDRFPQZV3CPNR3SJZHLRANCNFSM4GB43IQA .

JohelEGP commented 3 years ago

By using the unit's conversion_factor member alias.

JohelEGP commented 3 years ago

Basically #256 without the bits that remove the strong conversion factors, thanks to this line:

            abbreviation, ::units::decibel_scale, typename ::units::namespaceName::namePlural<UNIT_LIB_DEFAULT_TYPE>::conversion_factor) /** @} */ \

There are a few redundant UNIT_LIB_DEFAULT_TYPEs, though. The "diamond operator" <> does the job.

JohelEGP commented 3 years ago

so sometimes when you leave an issue open for two years, you don't really know what was going on and discover it wasn't a good idea. This is one of those. Not fully understanding the evolution of strong units didn't help.

I think I remember what happened. With strong units, meters or meters<> (actually meters<double>) could replace (strong) conversion factors. And error messages would've been even better. But strong units were reverted. I didn't put a reference to the comment where this idea spawned back then because I lost track of it.