use v6;
package Bizzell::Operators {
multi sub postfix:<seconds> ($a) {
$a;
}
multi sub postfix:<minutes> ($a) {
$a * 60;
}
multi sub postfix:<hours> ($a) {
$a * 3600 * 3600
}
multi sub postfix:<days> ($a) {
$a * 86400;
}
}
sub EXPORT {
Map.new(
'&postfix:<seconds>' => &Bizzell::Operators::postfix:<seconds>,
'&postfix:<s>' => &Bizzell::Operators::postfix:<seconds>,
'&postfix:<minutes>' => &Bizzell::Operators::postfix:<minutes>,
'&postfix:<m>' => &Bizzell::Operators::postfix:<minutes>,
'&postfix:<hours>' => &Bizzell::Operators::postfix:<hours>,
'&postfix:<h>' => &Bizzell::Operators::postfix:<hours>,
'&postfix:<days>' => &Bizzell::Operators::postfix:<days>,
'&postfix:<d>' => &Bizzell::Operators::postfix:<days>
)
}
Now getting the basics of this is easy. I could add "is export" to the definitions in Bizzell::Operators and call it a day, but what would be the easy way of adding the associated aliases that would make this expression:
4days + 8hours + 10minutes - 1second
Turn into the much more elegant:
4d + 8h + 10m - 1s
BTW -- the above does NOT work.
In the end, this is the EXPORT declaration that worked: