Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add ForeignCode, to wrap foreign code objects.
This means they behave sufficiently Perl 6-like to not blow up:
say Sub.^methods
And similar.- Loading branch information
Showing
4 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Takes a foreign code object and tries to make it feel somewhat like a Perl | ||
| # 6 one. Note that it doesn't have signature information we can know about. | ||
| my class ForeignCode does Callable { | ||
| method arity() { self.signature.arity } | ||
|
|
||
| method count() { self.signature.count } | ||
|
|
||
| method signature(ForeignCode:D:) { (sub (|) { }).signature } | ||
|
|
||
| method name() { (nqp::can($!do, 'name') ?? $!do.name !! nqp::getcodename($!do)) || '<anon>' } | ||
|
|
||
| multi method gist(ForeignCode:D:) { self.name } | ||
|
|
||
| multi method Str(ForeignCode:D:) { self.name } | ||
| } |
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