相关疑难解决方法(0)

How can classes be made parametric in Perl 6?

Normally in Perl 6, only roles are allowed to be parametric. Here, we'll be attempting to make classes, a kind (referred to from here on out as a metaobject) that isn't normally allowed to be parametric, parametric.

If you try to make a class parametric the naive way, this happens:

bastille% perl6 -e 'class Foo[::T] {}'
===SORRY!=== Error while compiling -e
Unable to parse class definition
at -e:1
------> class Foo?[::T] {}
    expecting any of:
        generic role
Run Code Online (Sandbox Code Playgroud)

But if you …

metaprogramming perl6 parametric-polymorphism raku

7
推荐指数
2
解决办法
84
查看次数