This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
01:02 frost joined
Jodi is there any way to do like 01:28
given 4 {
when 1 or 4 {
say "1 or 4"
is there any way to do like
given 4 {
when 1 or 4 {
say "1 or 4"
it doesnt give any error/warning/whatever but it doesnt work as expected
oh im an idiot, I just need to use `when 1 and 4` for whatever reason 01:30
Kaiepi `1 and 4`'s a bit weird, try `1 | 4` 01:43
Jodi thanks that was it 01:44
May be a stupid question, but how do I actually compile my code instead of just running it through rakudo? Preferably I'd want a binary so it doesn't need to be recompiled each time 01:51
Kaiepi put the bulk of the work in a `.rakumod`, let the `.raku` script put the pieces together 01:53
the module gets precompiled and cached somewhere in the fs 01:54
Jodi Hm?
Kaiepi there isn't a way to compile raku to an executable directly at the moment, but a module as a library should help get rid of some of the precomp time 01:57
past the first run, at least 01:58
03:23 frost30 joined, frost left, frost30 left 04:58 guifa left 04:59 guifa joined 05:33 razetime joined 06:16 razetime left
Nemokosch `when 1 and 4` wasn't right, it just coincidentally gave the same result for this input 07:02
since 1 and 4 evaluates to 4 07:03
that means you need rakudo to run it either way, right? 07:04
Kaiepi yeah 07:07
Nemokosch ☝️ 07:09
pelevesque Does anyone know where I can find a spec for META 07:11
6.json files
Nemokosch seems pretty good
pelevesque Thank you so much. 07:17
Nemokosch the historic specification is broader but not everything is actually implemented in zef 07:19
Why can't I grep using :f 07:33
Why can't I grep using :f?
07:56 frost joined
CIAvash You mean check for file? 08:01
08:03 dakkar joined
Nemokosch yes 08:04
CIAvash `.grep: :f` does not smartmatch against `:f`, `f => True` gets passed to `grep`. So you have to write `.grep: * ~~ :f` or `.grep: *.f` 08:25
Nemokosch I mean, what else is :f if not f => True? What is the possible difference? 08:27
CIAvash If a pair like `:f` is smartmatched, Pair's `ACCEPTS` method calls method `f` on the topic. 08:31
Nemokosch m: 'sadm'.IO ~~ (e => True) andthen .say 08:33
good but that't not what it says on my machine 08:38
``` 08:40
[2] > 'sadm'.IO ~~ (e => True) andthen .say
oh right, because yeah, this is system specific xd 08:42
so yeah, this does work
so I still don't get why this shouldn't work 09:00
does grep eat up named arguments? 09:01
doesn't seem like that and anyway, why should it 09:02
this doesn't smell right either way, I do pass it as a variable, it shouldn't unroll to a named argument 09:03
and as you can see, smartmatching on the pair does work
anyway, I'm gonna double check 09:04
if I really wrote grep(:f) then grep((:f)) should work I guess 09:05
CIAvash all methods take named arguments, grep is no exception. the fact that passing it as a variable works looks suspicious to me, atm 09:22
Nemokosch It really shouldn't; it would be crazy if a variable unrolled to a named argument 09:26
that would mean that you can't pass a Pair to a function
CIAvash actually, no. It works because the variable is passed to grep and is smartmatched, it just so happens that the variable is a pair 09:28
m: my $test = :test; say :test ~~ $test;
camelia True
CIAvash I think 09:29
Nemokosch and that's why it works and should work
matching against a pair is matching against a pair, regardless whether it looks like :f or f => True
Nahita well when a Pair is passed in those notations to a function, it's interpreted as a keyword arg; to make it positional, we quote the key like "f" => True 09:31
Nemokosch that also seems random but anyway, how do you quote :f ? 😄 09:33
Nahita "f" => True
if :"f" worked, that'd be interesting
Nemokosch that's 'bogus statement'
CIAvash quoting works, but makes no difference here since grep smartmatches. 09:38
Nemokosch it does though 09:40
[1] > ('project_paths', 'random')>>.IO andthen .grep('f' => True)
[2] > ('project_paths', 'random')>>.IO andthen .grep(f => True)
Cannot resolve caller grep(List:D: :f); none of these signatures matches:
($: Bool:D $t, *%_)
($: Mu $t, *%_)
in block <unit> at <unknown file> line 1
09:43 discord-raku-bot left, discord-raku-bot joined
anyway, .grep((:f)) also works 09:44
or .grep: (:f) I guess
then I guess I hardcoded :f in grep and that was a fail
lizmat yeah, .grep and .first smart-match conceptually, but have short-cuts builtin for handling regexes and Callables directly for performance 09:45
CIAvash TBH, I don't know what your goal is, or what you consider working or not working 😀
Nemokosch that took a long time to acknowledge 😅 09:46
lizmat is just awake :-) and only backlogged a few lines 09:47
Nahita oh, why does `(:f)` work? 09:48
Nemokosch because that's not a named argument anymore, thank heavens
CIAvash I was just trying to explain why things behaved the way they did
Nahita that's good to know, better than "f" => True
Nemokosch If you remember the right presentation, this is why f(something) and f (something) isn't the same
f (something) would be the same as f((something)) 09:50
CIAvash: "If a pair like :f is smartmatched, Pair's ACCEPTS method calls method f on the topic." - this was insightful indeed 09:52
But not gonna lie, it seems to me that you were also surprised by the discussed output, possibly more surprised than me 😅
talking about these things always helps, though 09:55
eventually, I came up with the right conclusion that :f might have got eaten up as a named argument 09:56
but I probably wouldn't have thought about it in a meaningful way if we don't talk about it
10:47 frost left, frost joined 12:56 frost left 14:22 razetime joined 15:27 razetime left 15:38 razetime joined 16:15 razetime left 17:22 deadmarshal left 17:23 dakkar left 17:44 deadmarshal joined 18:20 Kaiepi left 20:07 Kaiepi joined 20:12 deoac joined
deoac When I try to compile the following line 20:25
[0] > our Int $foo
I get this error:
===SORRY!=== Error while compiling:
Cannot put a type constraint on an 'our'-scoped variable
at line 2
------> <BOL>⏏<EOL>
    expecting any of:
        constraint 20:26
Why can't 'our'-scoped variables be typed?
If I have 'enum Color <red green blue>', is there a way to loop thru members of the enum? 21:08
Nemokosch I think enums have the interface of a Hash 21:10
m: enum Color <red green blue>; dd Color.keys;
yep, `("green", "red", "blue").Seq` 21:11
lizmat m: enum Color <red green blue>; dd $_ for Color.pairs 21:55
camelia :red(0)
lizmat m: enum Color <red green blue>; dd $_ for Color.pairs.sort(*.value)
camelia :red(0)
23:29 MasterDuke joined