a | b | |
---|
| 0 | + | 15:39 ~/g/code/p6/crypt$ nom handles.pl |
---|
| 0 | + | foo(a, b) |
---|
| 0 | + | bar(A, B) |
---|
| 0 | + | DEBUG: Methods are: |
---|
| 0 | + | (submethod BUILD(User , Mu *%_) { ... }, method bar(User , $arg1, $arg2, Mu *%_) { ... }, method foo(Mu , |$c, Mu *%_) { ... }) |
---|
| 0 | + | Method BUILD: |
---|
| 0 | + | - param '', type: Userall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes |
---|
| 0 | + | - param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no |
---|
| 0 | + | Method bar: |
---|
| 0 | + | - param '', type: Userall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes |
---|
| 0 | + | - param '$arg1', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes |
---|
| 0 | + | - param '$arg2', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes |
---|
| 0 | + | - param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no |
---|
| 0 | + | Method foo: |
---|
| 0 | + | - param '', type: Muall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes |
---|
| 0 | + | - param '$c', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: yes, parcel: no, slurpy: no, optional: no, invocant: no, pos: no |
---|
| 0 | + | - param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no |
---|
| 0 | + | DEBUG: Commands are: |
---|
| 0 | + | ("BUILD" => ().list.item, "bar" => ("arg1", "arg2").list.item, "foo" => ().list.item).hash |
---|
| 0 | + | Commands:("BUILD" => ().list.item, "bar" => ("arg1", "arg2").list.item, "foo" => ().list.item).hash |
---|
| 0 | + | 15:40 ~/g/code/p6/crypt$ perl6 handles.pl |
---|
| 0 | + | foo(a, b) |
---|
| 0 | + | bar(A, B) |
---|
| 0 | + | DEBUG: Methods are: |
---|
| 0 | + | (submethod BUILD(User , Mu *%_) { ... }, method bar(User , $arg1, $arg2, Mu *%_) { ... }, method foo(Mu , |$c, Mu *%_) { ... }) |
---|
| 0 | + | Method BUILD: |
---|
| 0 | + | - param '', type: Userall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes |
---|
| 0 | + | - param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no |
---|
| 0 | + | Method bar: |
---|
| 0 | + | - param '', type: Userall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes |
---|
| 0 | + | - param '$arg1', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes |
---|
| 0 | + | - param '$arg2', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes |
---|
| 0 | + | - param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no |
---|
| 0 | + | Method foo: |
---|
| 0 | + | - param '', type: Muall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes |
---|
| 0 | + | - param '$c', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: yes, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes |
---|
| 0 | + | - param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no |
---|
| 0 | + | DEBUG: Commands are: |
---|
| 0 | + | ("BUILD" => ().list.item, "bar" => ("arg1", "arg2").list.item, "foo" => ("c",).list.item).hash |
---|
| 0 | + | Commands:("BUILD" => ().list.item, "bar" => ("arg1", "arg2").list.item, "foo" => ("c",).list.item).hash |
---|
| 0 | + | 15:40 ~/g/code/p6/crypt$ cat handles.pl |
---|
| 0 | + | #! /usr/bin/env perl6 |
---|
| 0 | + | |
---|
| 0 | + | use v6; |
---|
| 0 | + | |
---|
| 0 | + | class Engine { |
---|
| 0 | + | method foo($arg1, $arg2) { say "foo($arg1, $arg2)"; } |
---|
| 0 | + | } |
---|
| 0 | + | |
---|
| 0 | + | class User { |
---|
| 0 | + | has $!engine handles <foo>; |
---|
| 0 | + | |
---|
| 0 | + | submethod BUILD() { $!engine = Engine.new; } |
---|
| 0 | + | |
---|
| 0 | + | method bar($arg1, $arg2) { say "bar($arg1, $arg2)"; } |
---|
| 0 | + | } |
---|
| 0 | + | |
---|
| 0 | + | my User $u .= new; |
---|
| 0 | + | |
---|
| 0 | + | $u.foo('a', 'b'); |
---|
| 0 | + | $u.bar('A', 'B'); |
---|
| 0 | + | |
---|
| 0 | + | say "Commands:", objCommands($u).perl; |
---|
| 0 | + | |
---|
| 0 | + | sub objCommands($obj) { |
---|
| 0 | + | say "DEBUG: Methods are:\n", $obj.^methods.perl; |
---|
| 0 | + | sub params($method) { |
---|
| 0 | + | say "Method {$method.name}:"; |
---|
| 0 | + | for $method.signature.params { |
---|
| 0 | + | say "- param '{.name}'", |
---|
| 0 | + | ", type: {.type.perl}", |
---|
| 0 | + | ", constraints: {.constraints}", |
---|
| 0 | + | ", type_captures: {.type_captures}", |
---|
| 0 | + | # RAKUDO: NYI 2012-07-15 |
---|
| 0 | + | #", read_only: {.read_only ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", rw: {.rw ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", copy: {.copy ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", named: {.named ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", named_names: {.named_names.perl}", |
---|
| 0 | + | ", capture: {.capture ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", parcel: {.parcel ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", slurpy: {.slurpy ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", optional: {.optional ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", invocant: {.invocant ?? 'yes' !! 'no'}", |
---|
| 0 | + | #", multi_invocant: {.multi_invocant ?? 'yes' !! 'no'}", |
---|
| 0 | + | ", pos: {.positional ?? 'yes' !! 'no'}" |
---|
| 0 | + | ; |
---|
| 0 | + | } |
---|
| 0 | + | |
---|
| 0 | + | $method.signature.params |
---|
| 0 | + | ==> grep { .positional && !.invocant } |
---|
| 0 | + | ==> map { .name.substr(1) } |
---|
| 0 | + | } |
---|
| 0 | + | my %commands = map { $^m.name => params($m) }, $obj.^methods; |
---|
| 0 | + | |
---|
| 0 | + | say "DEBUG: Commands are:\n", %commands.perl; |
---|
| 0 | + | |
---|
| 0 | + | return %commands; |
---|
| 0 | + | } |
---|
| 0 | + | 15:41 ~/g/code/p6/crypt$ perl6 --version |
---|
| 0 | + | This is perl6 version 2012.06 built on parrot 4.5.0 revision 0 |
---|
| 0 | + | 15:45 ~/g/code/p6/crypt$ nom --version |
---|
| 0 | + | This is perl6 version 2012.06-87-g499cc68 built on parrot 4.5.0 revision RELEASE_4_5_0 |
---|
| 0 | + | 15:45 ~/g/code/p6/crypt$ |
---|
... | |
---|