Skip to content

Conversation

alanhussey
Copy link
Owner

Adds methods to Measurement to allow them to be converted without explicitly referencing a UnitSystem.

m`48 inches`.as(foot)
m`48 inches`.in.feet

I think I like the "fluent" syntax this provides, but I'm not sure how I feel about the implementation. Defining a new class SystemMeasurement for each instance of UnitSystem is weird.

Another option is to make every Measurement-producing method on UnitSystem give each Measurement a reference to the system. .in and .as would then have to check whether that system was provided (guarding against user-created measurements with no access to system).


This also introduces the possibility of embedding a mini-language in m. m`48 inches in feet` reads very nicely. I'm wary of trying to going even further down this path, however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant