-
-
Save FCO/b23b055ada6ef458a8c3c1d29e39aa91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit class MetamodelX::Protocol is Metamodel::SubsetHOW is Metamodel::ClassHOW; | |
method new_type(:$name!) { | |
my $type; | |
$type := callwith :$name, :refinee(Any), :refinement{ .^methods>>.name.any eq $type.^methods>>.name.all } | |
$type | |
} | |
method compose(\type) { | |
die "A Protocol must have only stub methods!" if type.^methods.grep: not *.yada; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my package EXPORTHOW { | |
package DECLARE { | |
use MetamodelX::Protocol; | |
constant protocol = MetamodelX::Protocol; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MacBook-Pro-de-Fernando:Protocol fernando$ perl6 -Ilib -MProtocol -e ' | |
protocol Bla { method bla { ... } } | |
my Bla $a = 42 | |
' | |
Type check failed in assignment to $a; expected Bla but got Int (42) | |
in block <unit> at -e line 6 | |
MacBook-Pro-de-Fernando:Protocol fernando$ perl6 -Ilib -MProtocol -e ' | |
protocol Bla { method bla { ... } } | |
my Bla $a = class { method bla {} }.new | |
' | |
MacBook-Pro-de-Fernando:Protocol fernando$ perl6 -Ilib -MProtocol -e ' | |
protocol Bla { method bla { ... }; method ble {} } | |
my Bla $a = class { method bla {} }.new | |
' | |
===SORRY!=== Error while compiling -e | |
A Protocol must have only stub methods! | |
at -e:4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment