使用 SourceBaby 的语法和正确方法是什么,它是 Perl 6 相关频道中使用的机器人之一?
What is the syntax and correct way of using SourceBaby, one of the bots used in the Perl 6 related channels?
SourceBaby 显然是 Whateverable 机器人之一,运行 在 #perl6 和其他 IRC 频道中,它能够 locate the source of Perl 6 functions。但是,语法有点难以理解。要找到 lazy-if
,这是 Any
的一个方法,您必须这样做(就像在 link 中一样)。
s: Any, "lazy-if", \(1)
我一直在尝试 google 寻求说明,但就是找不到。 It's not in the official list of Whateverable bots, either。有人可以帮忙吗?
It's not in the official list of Whateverable bots, either.
那是因为它不是 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
CoreHackers::Sourcery
module is just a thin wrapper around core functionality of Code
object's .file
and .line
methods. They report the location of routine's definitions for all routines and for core routines they have this special SETTING::
string that shows the location in rakudo
's 源代码(或您使用的任何编译器):
say "{.file}:{.line}" with Any.^lookup: "lazy-if"
# SETTING::src/core/Any.pm6:472
并且该机器人是 CoreHackers::Sourcery
's sourcery
routine 的薄包装。这就是您触发机器人时所做的一切。您实际上是在键入任意 Perl 6 代码,这些代码将作为参数插入到该例程中,然后进行评估。
两种调用形式为:
:(Callable:D \to-lookup, Capture \args?)
:(Mu \object, Str:D \method-name, Capture \args?)
第一个是通常用于子例程的 1-2 arg 形式:
<Zoffix> s: &say
<SourceBaby> Zoffix, Sauce is at https://github.com/rakudo/rakudo/blob/d1d31fd57/src/core/io_operators.pm6#L10
第二个是 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
两种形式的最后一个参数都是 Capture
个参数,您希望使用这些参数来调用可调用对象。它是可选的,在这种情况下,您将获得多例程的原型位置。所以通常你会指定参数来获取特定候选人的位置:
<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
SourceBaby 显然是 Whateverable 机器人之一,运行 在 #perl6 和其他 IRC 频道中,它能够 locate the source of Perl 6 functions。但是,语法有点难以理解。要找到 lazy-if
,这是 Any
的一个方法,您必须这样做(就像在 link 中一样)。
s: Any, "lazy-if", \(1)
我一直在尝试 google 寻求说明,但就是找不到。 It's not in the official list of Whateverable bots, either。有人可以帮忙吗?
It's not in the official list of Whateverable bots, either.
那是因为它不是 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
CoreHackers::Sourcery
module is just a thin wrapper around core functionality of Code
object's .file
and .line
methods. They report the location of routine's definitions for all routines and for core routines they have this special SETTING::
string that shows the location in rakudo
's 源代码(或您使用的任何编译器):
say "{.file}:{.line}" with Any.^lookup: "lazy-if"
# SETTING::src/core/Any.pm6:472
并且该机器人是 CoreHackers::Sourcery
's sourcery
routine 的薄包装。这就是您触发机器人时所做的一切。您实际上是在键入任意 Perl 6 代码,这些代码将作为参数插入到该例程中,然后进行评估。
两种调用形式为:
:(Callable:D \to-lookup, Capture \args?)
:(Mu \object, Str:D \method-name, Capture \args?)
第一个是通常用于子例程的 1-2 arg 形式:
<Zoffix> s: &say
<SourceBaby> Zoffix, Sauce is at https://github.com/rakudo/rakudo/blob/d1d31fd57/src/core/io_operators.pm6#L10
第二个是 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
两种形式的最后一个参数都是 Capture
个参数,您希望使用这些参数来调用可调用对象。它是可选的,在这种情况下,您将获得多例程的原型位置。所以通常你会指定参数来获取特定候选人的位置:
<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