Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WHAT needs MOP for creation (v2) #67

Open
librasteve opened this issue May 5, 2024 · 1 comment
Open

WHAT needs MOP for creation (v2) #67

librasteve opened this issue May 5, 2024 · 1 comment

Comments

@librasteve
Copy link
Owner

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

@librasteve
Copy link
Owner Author

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

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

No branches or pull requests

1 participant