Re: What are values with : called?
[email protected] (Joseph Brenner via perl6-users) Mon, 03 Nov 2025 00:55:21 +0000
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <vDiyoq79uPeLqNjek3uJY3khsLLVQf6neDb6Q1v6MO8HoW38OfccNUK6VVi7JUTPJwQBFHUNjHYNXxjEXJncimNIkr8KHx4srJ_y4638KwY=@pm.me> |
ToddAndMargo wrote:
> my Proc $p = run( |@args, :err, :out );
>
> What are the values with the ":" in front of them
> officially called? I take it "thingies with the
> colon in front of them" does not cut it.
They're colon-pairs, though you'll also see them called "adverbs" depending on context.
You could call them adverbs here-- they're flags that turn on different behavior for the output.
https://docs.raku.org/routine/run
If you want to capture standard output or error instead of having
it printed directly you can use the :out or :err arguments, which
will make them available using their respective methods: Proc.out
and Proc.err.
my $proc = run 'echo', 'Raku is Great!', :out, :err;
$proc.out.slurp(:close).say; # OUTPUT: «Raku is Great!»
$proc.err.slurp(:close).say; # OUTPUT: «»
You could see a construct like that used with an argument though, in
which case it's an "adverbial pair":
https://docs.raku.org/syntax/Adverbial%20Pair
Adverbs get used a lot with regular expressions, where the syntax is different:
https://docs.raku.org/syntax/Regex%20adverbs