Open librasteve opened 2 months ago
use Physics::Measure :ALL; class UnitBase { has $.units; has $.value; }; sub to-raku-unit($x) { my $u = Metamodel::ClassHOW.new_type(name => $x.units.defn.tc); $u.^add_parent(UnitBase); $u.^compose; $u.new(units => $x.units, value => $x.value); }; say to-raku-unit(42s).WHAT
(Sec)
plan is to use this MOP approach to setup Measure subtypes
suggestion from Voldenet per https://discord.com/channels/538407879980482560/633753286209699870/1236710944164544583
Well, I'm suggesting a bit of a change in structure of Physics::Unit::CreateUnit by wrapping created types into newly created types inheriting from Unit [17:07] APP Raku bridge: I'm not sure how much of a change would it be to the library
[17:08]
APP
Raku bridge: since Unit allows users to define new types
[17:08]
APP
Raku bridge: though .WHAT would work as expected
[17:09]
APP
Raku bridge: erm, Physics::Unit.CreateUnit