🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
cpan-raku New module released to CPAN! Data::Record (0.0.3) by 03KAIEPI 00:12
cpan-raku New module released to CPAN! Data::Record (0.0.4) by 03KAIEPI 02:45
cpan-raku New module released to CPAN! Data::Record (0.0.5) by 03KAIEPI 03:24
Kaiepi ok done spamming releases now lol
Geth doc: 7e6082b87e | Coke++ | doc/Language/modules.pod6
remove doubled .
04:07
doc: 6d5adefaad | Coke++ | xt/words.pws
learn new words
linkable6 Link: docs.raku.org/language/modules
cpan-raku New module released to CPAN! Data::Record (0.0.6) by 03KAIEPI 07:05
Kaiepi m: say (a => 1, b => 2, c => 3) Z| (a => 4, b => 5) 09:00
camelia (any(a => 1, a => 4) any(b => 2, b => 5))
Kaiepi m: say (a => 1, b => 2, c => 3) <<|>> (a => 4, b => 5)
camelia (a => any(1, 4) b => any(2, 5) Nil)
Kaiepi m: say (1,2,3) <<+>> (4,5) 09:01
camelia (5 7 7)
Kaiepi m: say (a => 1, b => 2, c => 3) <<|<< (a => 4, b => 5)
camelia (a => any(1, 4) b => any(2, 5))
Kaiepi m: say (a => 1, b => 2, c => 3) >>|>> (a => 4, b => 5)
camelia (a => any(1, 4) b => any(2, 5) Nil)
Kaiepi is there already a way i can generate (a => any(1, 4), b => any(2, 5), c => 3) from these? 09:02
thundergnat Kaiepi: not easily in a single operation (that I can think of) Could do something like 11:26
m: say ({}.append: |(a => 1, b => 2, c => 3), |(a => 4, b => 5)).map: { .key => any(|.value) }
camelia (b => any(2, 5) a => any(1, 4) c => any(3))
chloekek Set up CI for a bunch of Raku community modules using Nix and GitHub Actions. ☺ 11:27
chloekek TIL you can put next in map to skip it. 12:41
p6: say (1, 2, 3).map({ $_ %% 2 ?? next() !! $_ })
camelia (1 3)
chloekek p6: say (1, 2, 3).map({ $_ %% 2 ?? Empty !! $_ })
camelia (1 3)
chloekek p6: say (1, 2, 3).map({ $_ %% 2 ?? last() !! $_ }) 12:42
camelia (1)
lizmat m: sub foo { last }; for ^100 { .say; foo } 12:45
camelia 0
lizmat next/last/redo are dynamic, not lexical
chloekek Yep. 12:46
p6: sub f($l, @xs) { @xs.map({ $_ == 3 ?? last($l) !! 0 }) }; l: for ^10 { say f(l, ^$_) } 12:48
camelia ()
(0)
(0 0)
(0 0 0)
Altreus That seems like a great way to have bugs 13:37
If other code is anything to go by, putting secret nexts in a function will seem like a good idea to a lot of people 13:38
And then you'll call it from outside of a nextable construct and get an error you have *no idea* how to work around
Personally I would have made those things lexical 13:39
lizmat as always, there are tradeoffs 13:43
fwiw, I think Raku inherited that behaviour from Perl 13:44
vrurg Altreus: OTOH, I use a construct `$.for_children: { next unless .ready; #`{ do something with ready children } }` – for lock-protected iteration.
lizmat the code of ... in the setting uses this feature extensively
chloekek Altreus: Just don’t write or call bad code. ;)
chloekek What is wrong when moar --version prints “This is MoarVM version built with JIT support” without a version number? 14:00
Ah, git was not available during configure.
Altreus chloekek: I shant 14:10
Altreus can zef install a specific branch from github? 14:27
not important, just QOL
Altai-man_ Altreus, if you clone and do `zef install .`... 14:28
Altreus yeah :) 14:29
I cloned and used raku -I
Just wondered if it had the feature
Altai-man_ Altreus, I think zef is rather agnostic to a lot of things like ecosystems, fetching protocols and so on, so probably writing a zef plugin could do. 14:30
Kaiepi i think being able to call `next` from a routine called from a loop is useful, just not very often a good idea 14:35
earlier i had a pretty big block of code that was repeated in a loop, but the logic didn't allow for it to only be in the loop once, so i wrote it out into a routine 14:36
[Coke] you could do something like next if long-routine and have it return a boolean. 14:48
Altreus well that was my thought 15:04
The function itself could return information about what to do, but the loop is the only thing that can actually be nexted 15:05
Which means you could end up writing a long routine you can't use outside of a loop, which seems silly to me
You might as well return a boolean or something, and then you can do anything with it
Coupling a function to a loop seems daft
mind you, I don't know what the use-cases are, so I'm ready to be convinced 15:06
Just enough rope to hang yourself, right?
lizmat it's the module that ... currently uses
basically figure out a lambda that will produce the next value, and have it do a "last" if it is supposed to be done
Altreus The operator that makes a "virtual function"?
oh 15:07
the generator
lizmat m: dd 1,2,4 ... 100
camelia (1, 2, 4, 8, 16, 32, 64).Seq
Altreus Why not a Last object 15:07
A terminator
Seems very similar to Failures to me
lizmat you should ask TimToady :-)
lizmat this is ~ 10 year old code now, am currently refactoring it to use iterators 15:08
Altreus It seems ideal to have a value whose semantics mean "end of whatever it was"
lizmat and making it 4x to 15x as fast (preliminary benchmarks)
Altreus: that would be IteratioEnd :-)
Altreus I have the answer! 15:09
lizmat which comes with its own set of issues:
Altreus What if you put an IterationEnd in a list 15:09
lizmat m: my @a = 1,2,3,IterationEnd,5,6; dd @a 15:09
camelia Array @a = [1, 2, 3, IterationEnd, 5, 6]
lizmat m: my @a = 1,2,3,IterationEnd,5,6; .say for @a 15:09
camelia 1
2
3
Altreus That seems like a more sensible "don't do that" than calling a function with a last in it
Altreus If you're allowed to say "Don't do that" then put it there 15:10
lizmat putting IterationEnd in a list is a case of DIHWIDT
Altreus that's a new initialism on me 15:10
Altreus I suppose it could show up in a variable 15:11
But that's exactly as dangerous as last showing up in a function
Altreus I guess the "don't do that" is putting last in a function unless you *really* have to 15:11
thundergnat Altreus: there are certain instances where I find being able to have a next or last in a map statement is quite useful. rosettacode.org/wiki/Magnanimous_numbers#Raku for instance. 15:42
Altreus but a map is nextable - although knowing that and including it in the rules for next is probably a lot harder than just allowing dynamic nexts 15:43
thundergnat Could it be written differently? for sure, but that fits the way I think
I may be misunderstanding your point... 15:44
jdv79 how come just "accessing" a promise seems to kick it off? 15:46
jnthn jdv79: A Promise has no concept of being "kicked off"; typically by the time you have it, whatever's behind it is already scheduled or underway. 15:50
jdv79 i'm trying to golf it atm but i had some promises in a datastructure and when i pulled them out they ran. i map'd 2 times and they ran 2 times. it seemed odd. 15:51
maybe i did something dumb
Altreus jnthn: this GPW talk is very helpful! 16:38
jnthn++
Altreus in fact I think I know what to do 17:12
just from this talk :)
[Coke] Nice. 17:13
jdv79 what talk was this? 17:27
chloekek Is there a fast way to find the index of a byte in a Blob, a la memchr? 17:31
ryn1x p6: try { start { die "died in thread" }; sleep 1; CATCH { say "reporting error"; exit 0; } } 17:38
camelia Unhandled exception in code scheduled on thread 4
died in thread
in block at <tmp> line 1
ryn1x how can I bubble up an error from another thread? 17:39
is that even possible?
lizmat ryn1x: if the error is not caught, the job will finish ? 17:43
ryn1x the job on the thread will not finish, but the main program calling it can continue... 17:45
i can give the user a friendly error message to report and an option to return to the main menu
the exit 0 in the example would happen only if the user chose to quit instead of return to the main menu in reality 17:48
ryn1x the example is very over simplified... i am actually launching other executables... not just using start blocks... but the behavior and errors are the same 17:54
[Coke] you can wrap the threads in a catch so they don't die, and then the main thread can check status and keep going.
lizmat or just "try start { }" :-) 17:55
ryn1x p6: try { try start { die "died in thread" }; sleep 1; CATCH { say "reporting error"; exit 0; } } 17:57
camelia Unhandled exception in code scheduled on thread 4
died in thread
in block at <tmp> line 1
ryn1x p6: try start { die "died in thread"; CATCH { say "reporting error"; exit 0;} } 18:05
camelia reporting error
ryn1x i guess that could work, but I have to do it everywhere a new thread it launched instead of around all of them
ryn1x p6: try start { die "died in thread"; CATCH { say "reporting error"} }; say "hi from main thread" 18:07
camelia reporting error
hi from main thread
chloekek When I see Raku libraries from NASA all I can think of is $rocket-fuel ⚛️-= 1; 18:45
lizmat And another Rakudo Weekly News hits the Net: rakudoweekly.blog/2020/03/30/2020-...f-reached/ 18:47
chloekek lizmat⚛️++
lizmat
.oO( I feel radiant :-)
chloekek We need something to use the ☣ character with 18:49
lizmat m: dd "☣".uninames
camelia ("BIOHAZARD SIGN",).Seq
lizmat hehe
synthmeat thanks, lizmat, i love these 19:03
lichtkind which celebration if 6.e named after? 19:09
chloekek The obvious one would be Easter, but I am not certain. 19:18
genevino oh wow, there's a blue butterfly in the topic 19:23
chloekek It used to be »ö« but then it matured. :) 19:24
genevino it probably matured in exactly the moment when the caterpillar thought life is over 19:26
8) 19:27
stoned75 commit: releases say Bag.new-from-pairs: 'butter' => 0.22, 'sugar' => 0.1, 'sugar' => 0.02; 20:09
committable6 stoned75, gist.github.com/c682ee687457093839...39b44b05fb 20:10
stoned75 commit: releases say Mix.new-from-pairs: 'butter' => 0.22, 'sugar' => 0.1, 'sugar' => 0.02;
committable6 stoned75, gist.github.com/31556863c7c9914381...92168f6906 20:11
Altreus jdv79: www.youtube.com/watch?v=GdU5XUck8O...4&t=7s 20:44
GPW 2019 20:45
on react, supply, whenever
jnthn: If you have a moment could you tell me if this looks reasonable? github.com/shuppet/p6-api-discord/...#L180-L213 20:52
maybe if I could spell discord 20:53
jdv79 Altreus: oh i thought jnthn's missing talk from this year was up. saw the concurrency one already. thanks. 20:57
Doc_Holliwould Stackoverflow is down. We will all die 21:02
Altreus These sentences seem unrelated, but both true 21:03
chloekek barely ever visits Stack Overflow. 21:07
jdv79 i end up there via googling a lot - that's about it 21:08
chloekek I find that Google got worse over the years when it comes to providing accurate and complete solutions to programming problems. 21:09
Altreus that's probably because people got worse at it 21:10
chloekek For PostgreSQL I stopped using it altogether and bookmarked the index of the documentation.
Altreus eh it is bothersome that it indexes a random version of each document page
chloekek Now I get accurate and complete results for the latest versions, instead of incomplete or wrong SO answers and blog posts, or links to docs of older versions.
Altreus rather than e.g. /latest/
Grinnz stack overflow is a pretty decent way to provide google results that smarter people can fix later 21:11
whether they do that, is another matter
chloekek It’s sometimes useful when documentation for something is missing or impenetrably confusing. 21:13
jdv79 i find many useful solutions on so on a regular basis - idk 21:14
Altreus like postgres? :D
low blow, PG has decent docs most of the time
jdv79 some of the pg docs are a bit difficult to read sometimes 21:15
chloekek Just had an epiphany, I always wondered what I should call my variable for a string with JSON in it, and an object that is parsed JSON (in contrast with a validated and more specific data structure), can’t call both $json 21:16
So I came up with $raw for the string passed to from-json, and $rare for the value returned by from-json ☺
jdv79 i don't get rare 21:17
chloekek It’s less raw than raw, but not quite cooked
Altreus sounds cooked to me 21:18
chloekek my $raw = '{ "foo": "123" }'; my $rare = from-json($raw); my $cooked = Foo.new(bar => +$rare<foo>);
jdv79 hopefully there are better names in situ for both but i guess if not
would $well be something to do with a Factory/Repository/IOC/something else complex? 21:19
Altreus put the raw statement in from-json and never have an unparsed variable at all :)
jdv79 that was my first thought - why have a name if you can get away without one 21:20
chloekek The raw one is a parametr. 21:22
Grinnz I tend to reserve $json for the actual string of json, since once you've decoded it to a data structure, it's not actually anything to do with JSON anymore 21:25
JSON is a string format
Altreus Also true!
Grinnz (technically more than that if you're in javascript, but) 21:26
Altreus Except for the incompatibilities 21:27
chloekek Is it possible to slip a hash slice into named arguments?
Altreus I'm sure I've done |(%hash<...>:kv) before
Grinnz Altreus: afaik all of the weird stuff is actually because that's how it works in regular javascript syntax
chloekek p6: sub f(:$x, :$y) { say $x, $y; }; my %h = :x(1), :y(2), :z(3); f(|%h<x y>:p);
camelia Too many positionals passed; expected 0 arguments but got 2
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
Altreus what's :p now 21:28
pairs
Is that different from kv?
chloekek %h<x y>:p returns a list of pairs, but I need a hash.
p6: sub f(:$x, :$y) { say $x, $y; }; my %h = :x(1), :y(2), :z(3); f(|%(%h<x y>:p));
camelia 12
chloekek Hmm that works.
Altreus magique
chloekek p6: sub f(:$x, :$y) { say $x, $y; }; my %h = :x(1), :y(2), :z(3); f(|%(%h<x y>));
camelia Unexpected named argument '1' passed
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
chloekek Kinda ugly.
Altreus um 21:29
chloekek Maybe I can define a :h adverb that returns a hash.
Altreus p6: sub f(:$x, :$y) { say $x, $y; }; my %h = :x(1), :y(2), :z(3); f(|(%h<x y>:p));
camelia Too many positionals passed; expected 0 arguments but got 2
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
Altreus p6: sub f(:$x, :$y) { say $x, $y; }; my %h = :x(1), :y(2), :z(3); f(|(%h<x y>:kv));
camelia Too many positionals passed; expected 0 arguments but got 4
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
Altreus welp
I guess I haven't done that before :)
jdv79 being only one char less - is it worth more syntax at that point? 21:37
oh, i'm not looking - 3 less. not bad. 21:39
ZaheerIsRight is perl 6 a good first language? 21:41
Altreus Can't be worse than PHP
chloekek p6: sub f(:$x, :$y) { say $x, $y; }; my %h = :x(1), :y(2), :z(3); f(|%h);
camelia Unexpected named argument 'z' passed
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
ZaheerIsRight lol 21:42
Altreus also it's raku now
I think it's bedtime
ZaheerIsRight sorry
chloekek ZaheerIsRight: It depends: why does the pupil want to learn programming? 21:43
ZaheerIsRight just for fun 21:43
Grinnz mst: looks like some vhosts need updating ^
mst eventually yes 21:44
chloekek ZaheerIsRight: Plausible. I’ve had nothing but fun with Raku. 21:45
rbt Is there anything for memory profiling? Specifically, memory taken by each Class (sum of objects for class) at a given point in time (when called)? 21:52
MasterDuke rbt: look at the Telemetry class/snapper module (docs.raku.org/type/Telemetry), or the heap profiler (--profile-kind=heap) 21:54
rbt Thanks 21:54
MasterDuke for the latter you'll need github.com/jnthn/p6-app-moarvm-heapanalyzer to process the resulting output file 21:55
rbt Anyone have commit access to DBIish? Getting this 1 liner pushed would be helpful: github.com/raku-community-modules/...h/pull/178 22:01
lizmat rbt: merged it 22:06
rbt Thanks! 22:07
lichtkind are parametric coles gone? 22:18
lizmat lichtkind: you mean roles? no 22:23
m: dd Rat.^roles
camelia (Rational[Int,Int], Real, Numeric)
lizmat would be an example of the use of the parametrix role Rational in the rat class
*Rat 22:24
lichtkind lizmat: thanks i aked becasue i cant find them in docs
hugs
lizmat hugs back
lichtkind: then maybe make a documentation issue :-)
MasterDuke docs.raku.org/language/objects#Par...ized_roles 22:29
lizmat MasterDuke++
sleep&
lichtkind MasterDuke++ oh man its too late 22:36
yes 22:37
tbrowder can anyone give me a link to a good, detailed video or slide presento of using comma for debugging modules? thnx 23:23