Closed wayland closed 3 years ago
Yeah - this is a bug - I will squish it and add to test! Apologies...
Hi @wayland - on initial diagnosis I have found:
1) 'c' was in Unit.rakumod as a definition of 'speed-of-light' (ie as a unit name and not a prefix name)... this has now been moved out to https://github.com/p6steve/raku-Physics-Constants/blob/master/lib/Physics/MathConstantsWrapper.rakumod
2) The last big refactor was to move 'shorty' prefixes into Physics::UnitPostfix - so you CAN now say my $x = 21.006cm; (ie cm is a raku Postfix operator so no quotes needed). You can also still say my $xx = Length.new(value => 21.006, units => 'centim'); since the long form prefixes are still in place. Looks like I threw the baby out with the bathwater a bit - so need to find a way to bring 'cm' back into the non-Postfix world.
Looks good! I'm pulling in data which contains text like "21.006cm", which is why I ended up with the example that I did.
When are you expecting to release version 0.0.4?
Hi @wayland I have had a thin about this and decided to keep the prefix/unit combinations in a separate module since they export up to 600 operators into your namespace - since this is the obvious place to load the definitions of all the unit objects that are generated it also seems best to me to keep items like 'cm' in this sister module. I considered changing the name of the module from Physics::UnitPostfix to Physics::UnitPrefixPostfix to show that it is needed WHEREVER you want prefix/unit combinations - but that seemed odd(!) Soooo in time honoured fashion, I have been reduced to changing the documentation.
you will need to use Physics::UnitPostfix anytime you want compound units to be defined - even if you do not need the postfix variant of operator - e.g. for my $x = Length.new(value => 21.006, units => 'cm'); my $y ♎️ '5e1 km';
Just in case it's useful, the correct term would probably be "Unit::Affix" (covers prefix, postfix, and infix).
The following fails with an error:
Metres work fine, cm don't.
Version 0.0.3
Thanks for your work on this!