🦋 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 6 September 2022.
nine lizmat: CompUnit::RepositoryRegistry.file-for-spec 07:14
lizmat nine: thanks 09:49
lizmat clickbaits rakudoweekly.blog/2022/10/03/2022-...g-to-core/ 11:30
tbrowder \o/ 12:00
tbrowder can anyone show how to dynamically create a Callable object? i would like to be able to create formatter callables to use with DateTime objects. 12:03
lizmat before RakuAST lands, EVAL is really the only option, if I understand you correctly 12:04
lizmat afk for a few hours& 12:06
tbrowder lizmat: thnx, i'll look into that 12:15
frost already read the weekly news, lizmat++ 13:05
tonyo tbrowder: do you have a syntax you're trying to get specifically? 14:01
you can do stuff like: 14:03
m: class A { method gist { "a!" } }; my $b = class :: is A { method gist { "b!" } }; A.new.say; $b.say
camelia a!
b!
tbrowder tonyo: i'll put it in a gist. are you gonna be around a few more minutes? 14:06
tonyo yea 14:10
day is just starting
[Coke] TIL about 'tmux capture-pane', nifty 14:28
tbrowder tonyo: the gist: gist.github.com/tbrowder/ac1857907...c27e9f15cc 14:35
tonyo tbrowder: that should already work with a few tweaks, you just want that in a class form? 14:36
actually, that should just work (thought self was referring to class instance)
tbrowder i have solved my immediate problem by generating the code with a raku program. it's a known set i need for now, but to be able to create them dynamically would be cool! 14:38
tonyo m: class A { method info { "A.info" }; }; my $f = sub ($s) { sprintf "got:%s", .info given $s }; say $f(A.new);
camelia got:A.info
tonyo tbrowder: ^ 14:39
El_Che will Vadim course be recorded? (aka no time now, but maybe interesting later)?
is it me or it's been a while since the last raku release? 14:41
tonyo if you want to do it with a class at runtime, given you'll know what formatter you want on object instantiation: 14:43
m: class A { has $.num = 0; has $!formatter; method formatter() { $!formatter() }; submethod TWEAK(|) { $!formatter = self.num < 10 ?? sub { "<10" } !! sub { ">=10" }; } }; A.new(:num(10)).formatter.say; A.new(:num(5)).formatter.say; 14:44
camelia >=10
<10
[Coke] El_Che: if I remember correctly, jdv had an issue running Blin that blocked the release. 14:45
El_Che I see
[Coke] I had tried a bit to get Blin setup, but I think the directions had some assumptions I missed. 14:46
tbrowder tonyo: very helpful, i'll give it a try, thank you soooo much!
[Coke] jdv: is there a ticket or gist somewhere with the issue you faced? 14:48
(ignore that, will move to the -dev channel
El_Che [Coke]: I find it interesting as well :) 14:59
tonyo tbrowder: any time 15:53
El_Che [Coke]: I expect a executive summary :) 15:56
[Coke] . 16:19
[Coke] sees an IRC disconnect that does NOT correspond to a local ISP issue. wow.
Nemokosch hahaha 16:20
[Coke] (I am up to over 200 ISP drops in the last 10 days or so; they finally seem to have stopped around midnight last night) 16:26
Rog What’s the default precedence level for user-defined infix ops? 16:54
Specifically relative to infix:<+> 16:55
Ah looks to be looser
[Coke] . 19:41
jdv boo 19:47
Nemokosch seems like -5 is not a <number> token, and eventually not a <value> token in the grammar of Raku 20:08
quite shocking news imo
I wanted to fix the "arrow return can't be a negative value" issue but I can't destroy half of the known universe on the way... 20:09
moritz channel your inner Thanos and do it! :-) 20:22
Nemokosch :DDD 20:24
guifa_ Nemokosch: that was designed to be part of raku's oddly consistent state. -1 is actually negating prefix + value 20:34
tellable6 guifa_, I'll pass your message to Nemokosch
Nemokosch I subconsciously misread it, as if that was a temporary phase, there is a reason why... 20:45
it's oddly inconsistent if you expect to be able to pass negative constants as function return values 20:47
there even is a "signed integer" token, it's just not a part of numish and consequenty number or value 20:49
[Coke] Blin is using v6.d.PREVIEW - that's out of date, yes? 21:05
ok, trying to run Blin with a checkout of Blin next to a checkout of whateverable with "raku -I../whateverable bin/blin.p6" ... I get the same Issue reported here: github.com/Raku/whateverable/issues/386 21:08
guifa_ Nemokosch: I think it should be eventually solvable. RakuAST in particular would make inserting a negative value there extremely easy 21:22
tellable6 guifa_, I'll pass your message to Nemokosch
gfldex By carefully stealing ideas from PWC submissions, today I learned that :nth takes a Range. This is very useful indeed! 21:56
Xliff m; raku -e 'my $dt = DateTime.now; my $d1 = $dt.earlier( days => $dt.day.pred ); my $sdow = $d1.day-of-week; my @m = (1...$d1.days-in-month); $sdow.say; @m.unshift(" ") for ^$sdow; @m = @m.map({ " " ~ .fmt($_ eq " " ?? "%2s" !! "%02d") ~ " "}).rotor(7, :partial); @m.unshift: <Sun Mon Tue Wed Thu Fri Sat>.map( *.fmt("%4s") ); .say for @m' 22:42
Hmmm...
m: raku -e 'my $dt = DateTime.now; my $d1 = $dt.earlier( days => $dt.day.pred ); my $sdow = $d1.day-of-week; my @m = (1...$d1.days-in-month); $sdow.say; @m.unshift(" ") for ^$sdow; @m = @m.map({ " " ~ .fmt($_ eq " " ?? "%2s" !! "%02d") ~ " "}).rotor(7, :partial); @m.unshift: <Sun Mon Tue Wed Thu Fri Sat>.map( *.fmt("%4s") ); .say for @m'
camelia ===SORRY!=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> raku -e⏏ 'my $dt = DateTime.now; my $d1 = $dt.ea
expecting any of:
infix
infix stopper
postfix
statement …
Xliff m: my $dt = DateTime.now; my $d1 = $dt.earlier( days => $dt.day.pred ); my $sdow = $d1.day-of-week; my @m = (1...$d1.days-in-month); $sdow.say; @m.unshift(" ") for ^$sdow; @m = @m.map({ " " ~ .fmt($_ eq " " ?? "%2s" !! "%02d") ~ " "}).rotor(7, :partial); @m.unshift: <Sun Mon Tue Wed Thu Fri Sat>.map( *.fmt("%4s") ); .say for @m 22:43
camelia 6
( Sun Mon Tue Wed Thu Fri Sat)
( 01 )
( 02 03 04 05 06 07 08 )
( 09 10 11 12 13 14 15 )
( 16 17 18 19 20 21 22 )
( 23 24 25 26 27 28 29 )
( 30 31 )
Xliff A raku Calendar in one line... :)
Wonder if anyone can make it shorter?
gfldex I'm not sure if a calendar with less then 12 months would help much. :-> 22:44
Xliff It's a single month, silly. :p 22:48
It can quickly be adapted to do the whole year with very little in the way of change. 22:49
But then it wouldn't be wise to leave it as a one liner.
gfldex m: $_ = now.Date.truncated-to('month'); $_ = $_ ..^ .later(:1months); put <Su Mo Tu We Th Fr Sa>; .put for (|(' ' xx (.[0].day-of-week)), |$_».day».fmt('%.2d')).rotor(7, :partial); 23:26
camelia Su Mo Tu We Th Fr Sa
01
02 03 04 05 06 07 08
09 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Xliff gfldex: dommit! *shakes fist*
Well done. 23:27
I'm going to steal it.
gfldex Sharing is caring!
Xliff :)
gfldex It's wrong tho. .day-of-week starts at Monday. 23:31
Xliff Yup. It's why I use ^$sdow 23:32