Raku Conference Day 2 on Youtube: www.youtube.com/watch?v=BL9-XdC9WYI 🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 14 August 2022.
habere-et-disper Can one use with with a hash? 09:54
Something like:
m:  my %bar = <a 1>; say {a} with %bar
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
a used at line 1
habere-et-disper Okay I think I got it... 09:57
m: my %bar = <a 1>; say .<a> with %bar
camelia 1
Nemokosch .<a> and it should be fine
or .{'a'}
habere-et-disper Thanks discord-raku-bot !
Nemokosch 😁 09:59
habere-et-disper I am enjoying the extra allowance of whitespace in raku, but I can't get it here: 10:10
and have to use
or am I missing some more magic?
Whoops:
`/ < :Separator > /` versus `/ <:Separator> /`
Nemokosch what is the goal? 10:17
leont Having a very weird dispatch related issue. But I guess you could say I'm stress testing it given it involves multi methods, conversion types and capture arguments. 10:20
Nemokosch well, consider opening a rakudo issue if it's suspicious enough 10:21
I remember samewith didn't work with caching, for example 10:22
lizmat tonyo: rak 0.0.14 fell into a black hole it seems, 0.0.15 (only doc changes) uploaded and now visible 10:25
tonyo: still wondering what happened to 0.0.14
Nemokosch did you not get a mail? 10:30
it may even end up in spam
lizmat no mail, checked my spam 10:36
in any case, the upload was successful and it said that it would get indexed: if there was something wrong with it, it would have said it at upload, no ? 10:37
Nemokosch iirc I did get mails after supposedly succesful uploads 10:50
and I only noticed it later that it didn't just fail randomly
tbrowder howdy! 10:53
i'm trying to load a module with 'require' and test for sucess per the docs but not having any luck. i'm using the syntax shown in the docs: 10:55
my $m = 'Foo'; require ::($m); if $m ~~ Failure { die "$m not loaded" } 10:57
i don't bail there, but the module isn't loaded and my prog fails later when attempting to access it. hm, i'll try to test that at the require point. docs may need a little tweak... 10:59
habere-et-disper @discord-raku-bot: Experimenting with readability. Not sure if it helps here. 11:03
Nahita tbrowder: hi, if `require` fails to find the module, it will `fail` and since it's in sink context, the program will die at that point, no? Also `$m` is a defined String so it's not a Failure? Documentation shows `try` require'ing with lookup and then checking ::($m) ~~ Failure 11:09
leont Nemokosch: I will open a ticket as soon as I narrowed it down. It's tricker than I thought 11:12
tellable6 leont, I'll pass your message to Nemokosch 11:13
habere-et-disper Is there a recommended way to iterate within a method chain? 11:20
Voldenet m: my $m = "Foo"; if (try require ::($m)) === Nil { die "$m not loaded" } 11:22
camelia Foo not loaded
in block <unit> at <tmp> line 1
Voldenet habere-et-disper: *iterate* meaning what, something like .map? 11:30
(^10).map({ $_ * 3 }).say 11:33
evalable6 (0 3 6 9 12 15 18 21 24 27)
Voldenet alternatively 11:34
m: (^10).&{ gather { for $_ { take $_ * 3 } } }.say
camelia (0 3 6 9 12 15 18 21 24 27)
Voldenet there's even more ways to do that 11:40
leont I really need to write a solution for the enum issue I mention, because I just hit it for the third time this week 11:58
*mentioned at the conference
habere-et-disper @Voldenet++ Map does a single pass. I'm looking to do multiple passes... 12:35
m: my %VOWELS = < A 1 E 2 I 3 O 4 U 5 >.pairup; say <AEIOU>.comb.map( *.subst( .key, .value ) with %VOWELS )
camelia ===SORRY!=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> .comb.map( *.subst( .key, .value ) with ⏏%VOWELS )
tbrowder nahita: thanks. the syntax (....) and " 12:36
die does what i need
(try require ::($m)) === Nil and die "FATAL: msg"; 12:38
i don't grok it but it works. to me the whole try/CATCH blurb in the docs needs a rework. not many practical examples for my use. 12:39
i 12:49
Voldenet >(try require ::($m)) === Nil and die "FATAL: msg"; 13:17
this syntax is fancy and confusing way to write `if (try require ::($m)) === Nil { die "$m not loaded" }`
lizmat just realized that the next App::Rak version will have 90+ options 13:44
CIAvash `try require ::('Test'); die "FATAL: $_" with $!`? 13:45
s/'Test'/$m/
leont Oh FFS. Apparently I can't pre-declare an enum, and taking it out of the class it's currently in means it will leak over the main namespace instead of just that class.
leont «Circularity detected in multi sub types», that is a new error! 14:19
tbrowder Voldenet: thanks, yes, and that’s golfing code to me, but writing it that does look more natural. 14:56
but that’s part of the charm of Raku! 14:57
Voldenet uhm, in many langs you can use && for ifs, but in all of them it's an ugly hack 15:50
Nemokosch Shell vibe 15:56
`or die`
ugexe leont: could you do `{ my enum ...; class Foo { ... } } }`? 16:51
leont My problem with the current behavior is that the values leak out. I do need the type to be out there. 16:52
I can't get one behavior without the other
ugexe it shouldnt leak out of that outer lexical scope in my example though 16:54
m: { my enum XX <a b c>; class Foo { method bar { say a } } }; say a; 16:55
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
a used at line 1
ugexe m: { my enum XX <a b c>; class Foo { method bar { say a } } }; Foo.new.bar;
camelia a
ugexe although yeah even if that does what you want its still a workaround 16:56
leont I'm probably going to try to write a trait to make it not do that 16:57
It's easy enough to sabotage the exporting of values, but in the original scope it's rather hardcoded at the moment 16:58
ugexe yeah, and i guess my example doesn't get you the e.g. XX
CIAvash leont: yeah I have problem with enums exporting values by default as well. Maybe I should open an issue for it. This is what I did in my module: codeberg.org/CIAvash/APISports-Foo...od#L70-L78 17:00
leont CIAvash: this seems to work for exports pastebin.com/JU1LyC4r 17:03
CIAvash interesting 17:08
leont Should maybe release that as a module, but was distracted by other projects 17:10
habere-et-disper I was expecting the following two to be equivalent: 19:07
m: say 1..10 X**2
camelia (1 4 9 16 25 36 49 64 81 100)
habere-et-disper m: say 1..10 X²
camelia ((1 2) (2 2) (3 2) (4 2) (5 2) (6 2) (7 2) (8 2) (9 2) (10 2))
habere-et-disper I am thinking wrong?
japhb habere-et-disper: The first one is X'ing the infix **, the second is trying to X a postfix, with no second array. So instead it sees the superscript 2 as the only element of the second array, not as the postfix operator. 19:55
habere-et-disper @japhb++ I think clarity lies in seeing ** as infix and superscript 2 as postfix when cross requires(?) infix 20:00
Nemokosch so why did the second succeed exactly? 20:24
habere-et-disper @discord-raku-bot: This one has caught me out before. I think implicitly there is a default list constructor (comma) implied. So... 20:33
m: say ( (1..10) X² ) eqv ( (1..10) X,² )
camelia True
leont «Impossible coercion from 'Composer' into 'Composer': method COERCE returned an instance of Composer» that is not a very helpful error (but the problem was PEBCAK of course) 20:41