🦋 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.
vrurg_ tonyo: if it's not too late. :) github.com/vrurg/raku-Config-BINDish for example. But, basically, pretty much any of my personal repos use .gitignore 04:05
Geth App-Rakubrew: 465c933509 | (Patrick Böker)++ | 6 files
Fix `self-upgrade` on ARM MacOS
09:18
Voldenet > Cannot classify a lazy list onto a Hash[Any,Any] 10:25
I hate how I need to write `classify` for my use case
is `lazy` supposed to always mean `infinite` 10:27
Nemokosch Hash[Any, Any] is really just a worse version of Hash
Voldenet I know, but here I simply wanted to group generated data into buckets without evaluating whole sequence 10:28
so .classify would've worked
guifa Voldenet, wouldn't it need to evaluate the whole sequence as soon as you call %hash<category> ? 10:29
Voldenet Yes it would, but it wouldn't need to store that data a few times 10:30
guifa lazy doesn't mean infinite per se. just means it doesn't eagerly evaluate items 5-100 if you've only requested 0-4
Voldenet I get the point that classify could hang for lazy infinites 10:31
but still, it should let me shoot my foot 10:32
if I wish :P
guifa push %hash{.head}, .tail for @list; # <-- maybe this works?
guifa is afk
lizmat Voldenet: then .eager it ? 11:01
Voldenet I just rewrote things to use gather/take properly 11:04
.lazy is risky to use when things need tons of memory anyway 11:05
tbrowder__ .seen jforget 11:07
tellable6 tbrowder__, I haven't seen jforget around, did you mean jorge?
Nemokosch there is some discrepancy in the lazy terminology 11:19
is-lazy doesn't actually check what it claims to, only a very tight subset of it
it's rather "is it obvious by the definition of this iterator that it is lazy", so it can easily give false negatives 11:20
lizmat well, it's a contract: ask the underlying iterator if it thinks its lazy, and report that 11:21
Nemokosch is-lazy is actually more like is-infinite - except it will also report True if you explicitly mark something lazy
lizmat if the underlying iterator lies, then garbage in, garbage out applies
Nemokosch the iterator doesn't lie, it just doesn't tell you the complete truth 😛 mostly because laziness is usually a more holistic concept so an iterator just genuinely doesn't have a clue about it 11:36
lizmat disagree: the iterator *does* know because it says so (implicitely) with the "is-lazy" method 11:44
thundergnat It can be difficult (and time consuming) to determine if a particular is infinite or not. It uses some heuristics and best guess estimates, and gets it right more often than not, but anything it says is a best guess, and if you deliberately lie to it, it will assume you know what you are doing. 11:50
m: my \Δ = $ = 1; say (flat 0, [1..9], {last if .not; ++Δ; [(.flat X~ 0..9).grep: * %% Δ]} … *).tail; # NOT an infinite iterator
camelia Cannot tail a lazy list
in block <unit> at <tmp> line 1
thundergnat my \Δ = $ = 1; say (flat 0, [1..9], {last if .not; ++Δ; [(.flat X~ 0..9).grep: * %% Δ]} … *).eager.tail; # NOT an infinite iterator 11:51
evalable6 3608528850368400786036725 11:51
tbrowder__ hi, i'm working on another holiday module and need a reality check with a person familiar with the hebrew calendar. anyone here? 11:52
Nemokosch lizmat: this is a bit of a tautology, though 11:53
yes, it says what it knows but it cannot always give the right answer - this is the thing
thundergnat Yep. Exactly my point. 11:54
lizmat well, suppose we also had a "don't know" setting in iterators, how would it be different from "is lazy" semantically ?
Nemokosch m: my $seq1 := 1, 4, 7 ... 10000; dd $seq1; my $seq2 := 1, 4, 7 ... *; dd $seq2; 11:56
uh oh... that's definitely not what I wanted to show 😅 11:57
dd wasn't a good idea here
tbrowder__ from looking at @jforget's Date:📆:Hebrew (and using it), i can get the hebrew date for the first day of Hanukkah and convert it to a Date (Gregorian). the slight wrinkle is the hebrew day starts at sunset so the calculated G date for the H date looks like it needs to be reduced by 1 to get results correct for online data i've found. does that seem correct? 11:58
Nemokosch m: my $seq1 := 1, 4, 7 ... 10000; say $seq1; 11:59
camelia (1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 97 100 103 106 109 112 115 118 121 124 127 130 133 136 139 142 145 148 151 154 157 160 163 166 169 172 175 178 181 184 187 190 193 196 199 202 205 208 211 21…
Nemokosch not because it's not (supposed to be) lazy but because it doesn't know it about itself and reifies the first 100 elements for gist
Nemokosch m: my $seq2 := 1, 4, 7 ... *; say $seq2; 11:59
camelia (...)
Nemokosch on the other hand, this clearly knows about itself that it's lazy and therefore won't reify values for something as mundane as providing a gist 12:00
lizmat my $seq2 := 1, 4, 7 ... *; say $seq2.eager
m: my $seq2 := 1, 4, 7 ... *; say $seq2.eager 12:01
hmmm
Nemokosch that will probably hang
camelia (timeout)
lizmat it should just produce 100 elements ?
Nemokosch I think .eager itself hangs
.eager is so eager it doesn't care when and how it will be consumed 12:02
lizmat yeah, looks like you're right.... I wonder if that isn't a bit LTA
Nemokosch $seq1 would be the middle ground. It doesn't call itself lazy but it's not eager either, in the strict sense 12:03
it's like lenient
thundergnat Technically _all_ iterators are lazy. Whether or not they reify some (or all) elements depends on what you do with them. 12:07
lizmat well, iterators are reactive: they don't do anything unless you ask them to provide a value
thundergnat Exactly. That's what I meant even if I phrased it wrong. 12:08
lizmat gotcha 12:09
Nemokosch And that's what I meant by the holistic stuff 😛 12:10
thundergnat the is-lazy attribute is a hint to the compiler whether it is feasible, or even possible, to go ahead and try to reify the whole list if you perform some operation that may request it. 12:11
If it is-lazy, it won't even try. 12:12
Unless you specifically tell it too.
Nemokosch yep, this makes sense
it's just the name is kind of misleading. There are three levels of laziness, at least 12:13
thundergnat And again, it sometimes gets it wrong when it tries to guess if it is-lazy or not.
thundergnat perhaps is-infinite may have been a better term 12:14
Xliff \o
Nemokosch or one can say: is-lazy is accurate and misnamed for iterators, while it is well-named but inaccurate for iterables
Xliff Does Raku have tools to generate public and private cryptographic keys?
Nemokosch is-infinite won't cut it, by the way, because of the lazy keyword 12:15
thundergnat yeah, that would have a whole other set of semantic difficulties.
Nemokosch Xliff: isn't there something like that around the Digest macroverse? 12:17
Xliff Nemokosch: I know not. That's why I'm asking. :) 12:19
tellable6 Xliff, I'll pass your message to Nemokosch
Xliff Aha! Crypt::RSA! 12:20
However the key generation parameter is in number of digits, and I'm not sure how that relates to bitsize. 12:24
Voldenet >It can be difficult (and time consuming) to determine if a particular is infinite or not. 13:16
It's possible to simply require infinite sequences be marked as such or just execute operations 13:18
in case of classify, I realized that I needed a version of classify that given N categories would generate N iterators, which is a lot different from what classify originally does 13:19
Xliff: to start with `Crypt::RSA` doesn't look like something to be used in production 13:38
if that doesn't scare you, you can use your own random-prime-generator that would return a random prime 13:39
lizmat Voldenet: are you sure you mean iterators, and not supplies? 13:42
Voldenet Yes, the iterator that wasn't infinite but long enough that it didn't fit in the memory 13:44
Voldenet Xliff: that's what I'd use: `use Crypt::OpenSSL::RSA:from<Perl5>; say Crypt::OpenSSL::RSA.generate_key(1024).get_private_key_string();` 13:54
lizmat and yet another Rakudo Weekly News hit the Net: rakudoweekly.blog/2023/03/13/2023-11-ainions/ (yesterday already :-) 14:10
Voldenet (primary issue of Crypt::RSA is that it can pick p and q very close to each other and there's no way to control that behavior) 14:12
[Coke] lizmat++ 14:13
Thank you for this huge run of blog posts!
tbrowder__ lizmat: good weekly, as usual. i would love to see Slang::Forgiven in core! 15:00
that is: allow the topical $_ use with named keys/values 15:04
tbrowder__ worth filing a feature request? 15:05
grondilu can I not put comments at all inside qw{}? 15:17
rf Morning folks 15:17
Nemokosch grondilu - probably not 15:19
thundergnat m: my $var = 'no comment'; say <<a b #`{{a comment!}} $var c d>>; 15:25
camelia (a b no comment c d)
tbrowder__ any seconds on filing rakudo feature request for adding capability of new module Slang::Forgiven to core? 16:04
tonyo vrurg_: i have the changes in master for fez it should _just work_ now 16:18
tonyo if you don't want to install from master lmk and i'll publish 16:27
tonyo vrurg_: i trued up the globber with what git archive would make in bindish and it was very similar (missing just the raw directories in the resulting tar) but for the most part looked reasonable 17:03
lizmat tbrowder: it feels a lot like it is a feature "you think it is a good idea now" :-) 17:47
and what is wrong with adding "$_ := $num" at the top of the body of the loop ? 17:48
you do *not* have to use given to set the topic
Voldenet tbrowder__: in the form `for given @it { when * > 0 { } }` -> `for @it { given $_ { when * > 0 { say "$_ is positive" } } }` it would make more sense probably 18:03
but 18:04
m: for 1, 2, -3 { when * > 0 { say "$_ is positive" } } # why even need that "given" 18:05
camelia 1 is positive
2 is positive
snonux m: say "$_ is positive" if $_ > 0 for 1, 2, -3; 20:12
camelia 1 is positive
2 is positive
tonyo m: (1,2,3,-1,-2,-3).map({ when * > 0 { "$_ is positive" }; default { "$_ is negative" } })>>.&say 20:14
camelia 1 is positive
2 is positive
3 is positive
-1 is negative
-2 is negative
-3 is negative
tonyo i'd probably not put the slang in core given the for when syntax works fine already ^ 20:15
tonyo vrurg: i'm going to release the next fez and then the only thing left in my dist branch would be writing a pure raku gzipper 20:18
anyone having problems with fez's globber/sdist stuff, please update! 20:20
rf tonyo++ 20:24
tbrowder__ ok, thanks for weighing in with good comments. i will try to improve my “foreach” practices. 20:45
vrurg tonyo: I have switched to using --file anyway already. :) 21:18
vrurg tonyo: but hope it would prove to be useful for others. 21:18
guifa before forgiven I'd like to see for { … } else { … }. Damian already hacked that one together a while ago ha 22:44
Nemokosch it doesn't take an AlexDaniel to say: please no 22:45
more barely useful structures that need a whole lot of reasoning to get right, or even decide whether it's semantically clean 22:46
guifa I think for else is really straight forward: if no iterations, then handle the else 22:47
Nemokosch I don't think I've ever found myself wanting to do that. On the other hand, Python's else clause does something else that I did find useful quite often 22:49
guifa what's that?
Nemokosch code that executes when the loop exits "normally", not hitting any break's (or return's, for that matter) 22:50
mind you, I don't find the name else particularly good for that either. I think a for just shouldn't have something called else in the first place 22:51
guifa for { … } otherwise { … } lol 22:52
Nemokosch but when it comes to usefulness, I find the Python choice way more useful than "execute this when the loop turned out to be empty"
guifa hmm, I wonder how I might be able to create a Python-ish style one. I'd definitely do a different name for it though. It's just I don't think there's a good short word to encompass "and if ended without a last statement being called") 22:56
vrurg guifa: you don't need 'otherwise' or alike to handle any control event. 23:58
m: for ^10 { CONTROL { when CX::Last { say "HERE WE DO SOMETHING ON LAST"; .rethrow; }; }; .say; last if $_ == 3; }
camelia 0
1
2
3
HERE WE DO SOMETHING ON LAST
guifa vrurg you've got the goal backwards: the goal is to do something if and only if last is never called
vrurg So, when loop has finished successfully? 23:59