Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXPORTHOW::DECLARE and role-like declaration

Tags:

raku

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?

like image 326
Vadim Belman Avatar asked Dec 23 '18 20:12

Vadim Belman


People also ask

What is export declare type?

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.

What is a shipper's export declaration?

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.

What is import and 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.

Is export declaration required?

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.


1 Answers

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.

like image 150
Vadim Belman Avatar answered Oct 26 '22 08:10

Vadim Belman