This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
00:23 jgaz left
jack9 nqp 02:26
can a parameter be both positional and named 02:32
Nemokosch Could you give an example? 03:06
jack9 sub f(<pos-or-named>$x) { $x } f(1) # 1 f(:x(1)) # 1 03:10
@Nemokosch 03:11
rf jack9: multi sub 03:14
m: multi sub f(:$x) { say $x }; multi sub f($x) { say $x }; f(4); f(:x<abc>);
camelia 4
abc
rf m: multi sub f(:$x) { say $x }; multi sub f($x) { f(:$x) }; f(4); f(:x<abc>); 03:15
camelia 4
abc
jack9 looks cumbersome but ok
jaguart m: multi sub f(:$x) { say $x }; multi sub f($x) { say $x }; f(4); f(:x<abc>); 03:16
camelia 4
abc
jaguart m: multi sub f(:$x) { say $x }; multi sub f($x) { say $x }; f(4); f(:yabc>);
camelia ===SORRY!=== Error while compiling <tmp>
Missing required term after infix
at <tmp>:1
------> lti sub f($x) { say $x }; f(4); f(:yabc>⏏);
expecting any of:
prefix
term
rf You may be able to use slurpies
jaguart m: multi sub f(:$x) { say $x }; multi sub f($x) { say $x }; f(4); f(y:<abc>);
camelia ===SORRY!=== Error while compiling <tmp>
Unsupported use of y///. In Raku please use: tr///.
at <tmp>:1
------> }; multi sub f($x) { say $x }; f(4); f(y⏏:<abc>);
jaguart argh
m: multi sub f(:$x) { say $x }; multi sub f($x) { say $x }; f(4); f(:y<abc>); 03:17
camelia 4
Cannot resolve caller f(:y(Str)); none of these signatures matches:
(:$x)
($x)
in block <unit> at <tmp> line 1
jaguart so even though you passed in one arg (a pair) it was NOT matched against the multi with 1 arg
rf Yes
I am trying to understand how it does this, but I think it will be awhile. 03:18
Moar code is plentiful
jaguart we need to be able to create sigs that say 'and no named args' somehow
rf m: multi sub f(:$x) { say $x }; multi sub f($x) { f(:$x) }; f(4); f((x => 123)); 03:19
camelia 4
x => 123
rf If you wrap in parens it counts as a pair.
jaguart yeah - but when writing utils you dont really want to hamstring the caller 03:20
rf m: multi sub f(:$x) { say $x }; multi sub f($x) { f(:$x) }; f(4); f: x => 123;
camelia ===SORRY!=== Error while compiling <tmp>
Bogus statement
at <tmp>:1
------> sub f($x) { f(:$x) }; f(4); f: x => 123;⏏
expecting any of:
prefix
term
rf m: multi sub f(:$x) { say $x }; multi sub f($x) { f(:$x) }; f(4); f: (x => 123);
camelia WARNINGS for <tmp>:
4
Useless use of constant value x => 123 in sink context (line 1)
Useless use of "x => 123" in sink context (line 1)
rf m: multi sub f(:$x) { say $x }; multi sub f($x) { f(:$x) }; f(4); f: :x<abc> 03:21
camelia WARNINGS for <tmp>:
4
Useless use of constant value :x<abc> in sink context (line 1)
Useless use of ":x<abc>" in sink context (line 1)
rf m: multi sub f(:$x) { say $x }; multi sub f($x) { f(:$x) }; f(4); f: :x<abc>; 03:22
camelia WARNINGS for <tmp>:
4
Useless use of ":x<abc>" in sink context (line 1)
Useless use of constant value :x<abc> in sink context (line 1)
rf I'm gonna quit while im ahead hahaha
jaguart even `multi sub (Pair:D $p )` doesnt seem to work
rf You have to wrap, same reason 1, 2, 3, 4 can be interpreted as args rather than a list iirc
03:58 rf left 06:00 jaguart left, jaguart joined
Nemokosch Yes, I think this is plain old syntactic ambiguity 07:56
So it's not like Pairs are reinterpreted as named arguments - this calling syntax is for named arguments 08:03
09:09 dakkar joined 13:20 discord-raku-bot left 13:38 jgaz joined 13:56 rf joined 16:12 Heptite left 16:13 discord-raku-bot joined 16:25 stevied_test left 16:28 discord-raku-bot left, discord-raku-bot joined 16:49 stevied_test joined 17:35 dakkar left 18:22 Heptite joined 18:56 NemokoschKiwi joined 19:00 NemokoschKiwi left 19:56 ab5tract joined 20:31 ab5tract left
stevied can someone point me the docs for handling args for a raku command line script? can't find it 20:47
looking for how to do getopt, specifically
ok, just found it: docs.raku.org/language/create-cli 20:48
21:08 rf left 21:13 rf joined
Nemokosch Getopt::Long6 is pretty good, too 21:25
and it integrates with sub MAIN reasonably well
22:02 rf left 22:18 guifa_ left 22:25 deoac joined
deoac I would like to create a regex like this: `^ h <foo> e <foo> l <foo> l <foo> o <foo> $` 22:27
`I tried 'Hello'.comb.join(<foo>)` without success
Any ideas? 22:28
Nemokosch hm, not sure you can generate such a regex just yet. However, this time around, it is actually close, RakuAST code generation reached the experimental stage 22:35
for now, the "stable solution" would involve EVAL
jaguart m: ("rx/ " ~ "Hello".comb.join(<foo>) ~ " /").EVAL 22:41
camelia ( no output )
jaguart m: ("rx/ " ~ "Hello".comb.join(<foo>) ~ " /").EVAL.raku
camelia ( no output )
jaguart m: ("rx/ " ~ "Hello".comb.join(<foo>) ~ " /").EVAL.raku.say 22:42
camelia rx/ Hfooefoolfoolfooo /
jaguart would be cool if the evalbot did $_.say if there was no output...
deoac Thanks, I'll give it a shot! 22:50
Nemokosch m: ("rx/ " ~ "Hello".comb.join('<foo>') ~ " /").EVAL.raku.say 23:00
probably the quotes help
by default, <foo> would be like word quoting, more or less like 'foo' in this case 23:01
deoac Bingo!  Exactly what I needed. 23:05