I need to have a role with a little bit of special functionality implemented through a Metamodel
class of mine inheriting from Metamodel::ParametricRoleHOW
. One way to apply it is by using a trait. But I want a nice syntax sugar like we can do with classes:
special Mine {
...
}
Ok, I add the following into my module:
my package EXPORTHOW {
package DECLARE {
constant special = My::Metamodel::SpecialRoleHOW;
}
}
and everything runs smoothly... No, it is not:
class Foo does Mine {
...
}
and I end up with:
Could not instantiate role 'Mine':
A very brief inspection of Actions.nqp
revealed that roles have special handling, but only and only when role
keyword is used for package declaration. Hence, I conclude that the only way to have the syntax sugar – is to mixin my own rule into the main grammar and simulate the role declaration. Luckily, package_def
relies upon $*PKGDECL
and it makes such simulation possible.
Am I right in the conclusion? Or a simpler way exists to achieve the goal?
An export declaration is a type of form submitted at the port, providing details about the goods that are bound for export. The export declaration is required each time goods are exported to a country outside the EU, and the document is used by the customs authority to control exports.
A Shipper's Export Declaration is a document that must accompany International Shipments from the USA. This document serves as a record of US exports and is used to compile trade statistics. For loads, if the shipments are shipped to multiple destinations, each shipment requires a Shipper's Export Declaration.
A customs declaration is an official document that lists and gives details of goods that are being imported or exported. In legal terms, a customs declaration is the act whereby a person indicates the wish to place goods under a given customs procedure.
In the USA an export declaration must be filed when any single commodity being shipped is over 2500 USD. Therefore if you have multiple commodities less than 2500 you do not need to file an export declaration. HOWEVER, if any of the items require an export license or permit you will need to file the export declaration.
The requested functionality is not yet possible. But AFAIK, Jonathan Worthington is working on code which would derive a package type from its metaclass. Not sure as to how far is he on this though.
Meanwhile, the desired functionality could be achieved through run time extending of Perl 6 grammar. I have it done for OO::Plugin module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With