jjm*_*elo 4 perl6 whateverable
SourceBaby显然是Whateverable机器人之一,运行在#perl6和其他IRC频道,它能够找到Perl 6功能的来源.但是,语法很难弄清楚.要定位lazy-if,这是一种方法Any,你必须做(如在链接中).
s: Any, "lazy-if", \(1)
Run Code Online (Sandbox Code Playgroud)
我一直试图谷歌指示,但我找不到它们.它也不在Whateverable机器人的官方列表中.有人可以帮忙吗?
小智 9
它也不在Whateverable机器人的官方列表中.
那是'因为它不是一个可以使用的机器人.还有其他几个社区的机器人不属于Whateverables,包括huggable和buggable机器人.
向机器人寻求帮助可以提示您在哪里寻找:
<Zoffix> SourceBaby: help
<SourceBaby> Zoffix, Use s: trigger with args to give to sourcery
sub. e.g. s: Int, 'base'.
See http://modules.perl6.org/dist/CoreHackers::Sourcery
Run Code Online (Sandbox Code Playgroud)
该CoreHackers::Sourcery模块只是Code对象.file和.line方法的核心功能的薄包装.他们报告的例程的定义位置的所有程序和核心程序,他们有这个特殊的SETTING::字符串,显示位置rakudo的来源(或其他编译器,你正在使用):
say "{.file}:{.line}" with Any.^lookup: "lazy-if"
# SETTING::src/core/Any.pm6:472
Run Code Online (Sandbox Code Playgroud)
和机器人是一个简单包装的CoreHackers::Sourcery的sourcery程序.这就是触发机器人时所做的一切.你实际上是在键入任意Perl 6代码,它将作为args插入到该例程中然后逐渐消失.
两种呼叫形式是:
:(Callable:D \to-lookup, Capture \args?)
:(Mu \object, Str:D \method-name, Capture \args?)
Run Code Online (Sandbox Code Playgroud)
第一个是1-2 arg表单,通常用于子程序:
<Zoffix> s: &say
<SourceBaby> Zoffix, Sauce is at https://github.com/rakudo/rakudo/blob/d1d31fd57/src/core/io_operators.pm6#L10
Run Code Online (Sandbox Code Playgroud)
第二个是2-3个arg表单,通常用于对象上的方法:
<Zoffix> s: $*ERR, 'print'
<SourceBaby> Zoffix, Sauce is at https://github.com/rakudo/rakudo/blob/d1d31fd57/src/core/IO/Handle.pm6#L604
Run Code Online (Sandbox Code Playgroud)
两种形式的最后一个arg都是Capture你想要调用callable的参数.它是可选的,在这种情况下,您将获得多个例程的proto位置.所以通常你会指定args来获取特定候选人的位置:
<Zoffix> s: $*ERR, 'print', \(1, 2, 3)
<SourceBaby> Zoffix, Sauce is at https://github.com/rakudo/rakudo/blob/d1d31fd57/src/core/IO/Handle.pm6#L609
Run Code Online (Sandbox Code Playgroud)