🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is still being worked out
Set by lizmat on 12 August 2021.
00:21 greppable6 joined, linkable6 joined 00:22 releasable6 joined, bisectable6 joined, squashable6 joined 00:23 quotable6 joined 00:52 justsomeguy joined 01:05 reportable6 joined 01:21 committable6 joined 01:22 shareable6 joined 01:55 Max joined 01:56 Max is now known as Guest1367 01:57 Guest1367 left 02:39 justsomeguy left 03:39 linkable6 left, evalable6 left, releasable6 left 03:41 linkable6 joined 04:10 frost joined 04:33 neshpion left 04:41 evalable6 joined
mjgardner Realizing this may be a stupid question but I only just started learning, so: I want to exit my MAIN sub in a script with an error message and code but no line numbers. Would it be better/more idiomatic to 1) just say the error to STDERR and exit, or 2) die with a CATCH block that does that? www.irccloud.com/pastebin/TUSlZ1m7 05:08
moritz mjgardner: 2) sounds cleaner 05:23
mjgardner moritz: It seems more verbose though. What are the advantages? 05:24
moritz mjgardner: in time when MAIN grows, there might be more places that need error handling. Having a CATCH neatly encapsulates that in one position 05:28
moon-child sub error($msg) { $*ERR.say($msg); exit 1 } 05:29
mjgardner moritz: That’s a good point. If this is just for a toy program in a blog post, though? 05:33
I’m writing the same toy program in Perl 5 as a comparison, and I don’t want to set up Raku as a straw man that appears more verbose than necessary. 05:37
05:40 releasable6 joined
moritz if it's just for a toy, do as you want :D 05:46
mjgardner Thanks. 05:56
06:03 reportable6 left
CIAvash mjgardner: You can use `note` instead of `$*ERR.say` docs.raku.org/routine/note 06:03
mjgardner CIAvash: Neat! Thanks! 06:05
CIAvash also you can write it as `note .message and exit 1` 06:07
mjgardner That’s more of a golfing move, though. It’s not like `note .message` will ever evaluate to false. 06:18
moon-child well, it's like english. 'note the message and [then] exit'
mjgardner So is every ; as a statement separator. 06:19
moon-child yes
moon-child has, at this point, given up on trying to avoid abusing notation. It's there to be abused! 06:21
mjgardner As it turns out my message (I went with just the note and exit) is kinda long, so putting `and exit 1` at the end of the line gets lost when reading. But thanks for the suggestion. 06:24
06:51 mattil joined 06:56 xinming left 07:04 reportable6 joined 07:16 Xliff left 07:24 Frozenset joined 08:11 matti_ joined 08:14 mattil left
andinus japhb: i see, thanks. unfortunately Terminal::Print doesn't work on obsd, Terminal::QuickCharts is cool, i could combine it with Terminal::UI or Curses to make something 08:54
there was a channel publishing ncurses tutorials on raku, seems like they were taken down recentl 09:09
09:14 evalable6 left, linkable6 left 09:15 evalable6 joined, linkable6 joined 09:31 Sgeo left 09:45 dogbert11 joined 09:47 dogbert17 left
samcv The highlighting on learnxinyminutes.com/docs/raku/ has been broken for at least a year due to the Pygments raku syntax highlighter not supporting =begin and =end without a blank newline after the =end. 10:23
I am going to just change those sections into normal block # comments to fix it. Other alternative would be to modify pygments to fix it. 10:24
Or adding a newline before the =end also works. But I think just adding block comments is the cleanest, otherwise someone may try and remove the extra newline later on 10:25
lizmat agree :-) 10:32
10:33 oodani left 10:34 oodani joined 11:01 ddeimeke left
andinus i have an array of hashes and want to make a change to every "3" hash index of the elements in array, currently i'm looping over @list.end and making the change, is there a better way to do this? 11:11
m: my @list = %(0=> "z",1=> "a", 2=> "b", 3 => "c"),; 11:12
camelia ( no output )
lizmat .<3> = 42 for @list ?? 11:14
andinus makes sense, i was thinking of .map 11:15
also, can i convert that list of hash to a list of lists since the keys are just numbers from 0..5, 11:16
i tried @list.map(*.values)
@list.map(|*.values) actually but it returns the values in random order it seems 11:17
lizmat yes, .keys and .values will return in random order for hashes
codesections andinus: you can do `@list.map(*.sort».values)` 11:28
andinus i'm parsing a csv, it seems hyper is faster than race, it has to do extra work right for ordering? 11:29
i see, thanks codesections, that works
i did @list.map(*.sort.map(|*.values)); needed that slip, it returns a seq otherwise 11:31
Frozenset codesections: did you mean `value` at the end instead of `values`? 11:32
andinus: If keys are all 0..5, I think you can also do a hash slice as `@list>>.{0..5}`
or sans the dot: `@list>>{0..5}` 11:33
codesections Frozenset: .value works for that example code but gets you a list of Str. andinus asked about converting the hashes to a lol – either way works, depending on what you want 11:35
andinus thanks Frozenset, the keys are 0..5, that works 11:37
looks like .value does what i want, it returns the same thing as .map(|*.values); 11:38
and *.sort.map(*.value) too
i'll do >>.{0..5}
codesections m: my @list = %(0=> "z",1=> "a", 2=> "b", 3 => "c"),; say @list»{*} 11:40
camelia ((c a z b))
codesections m: my @list = %(0=> "z",1=> "a", 2=> "b", 3 => "c"),; say @list»{0..3}
camelia ((z a b c))
codesections Interesting to see that ^^^ those two are different
andinus m: my @list = %(0=> "z",1=> "a", 2=> "b", 3 => "c"),; say @list>>{0..*}; 11:41
lizmat codesections: any run will produce different ordering, even within a single process
camelia MoarVM panic: Memory allocation failed; could not allocate 64459440 bytes 11:42
lizmat see algorithmic complexity attacks
andinus: interesting
11:42 linkable6 left
codesections lizmat yeah, I know that in general for .values 11:42
lizmat and .keys and .pairs and .kv: anything that takes an iterator on the hash 11:43
11:43 linkable6 joined
andinus it eats up all memory on my system too, rakudo 2021.02 11:43
codesections yeah. I just wasn't sure if .{*} would have the same semantics as .values or as .{0..5}
lizmat looks like there's no laziness check on the indexing like that 11:44
andinus what is it trying to do? index from 0..Inf?
lizmat yup 11:45
and build a result list of empty containers
andinus ah makes sense, i was wondering why it was eating memory
lizmat m: my %h; %h<a b c> = 1,2,3; dd %h
camelia Hash %h = {:a(1), :b(2), :c(3)}
lizmat that builds a list of 3 empty containers, and then assigns the 1,2,3 list to those containers 11:46
m: my %h = :42a, :666b; dd %h{ <a b>.lazy } # that should probably complain about not being able to index using a lazy list 11:47
camelia (42, 666)
11:47 xinming joined
Frozenset codesections: I see, thanks for the explanation. I thought list of lists but not list of list of lists :ğ 11:47
and with the sort approach I think a care is needed if a key exceeds 10 since it does string comparison 11:48
lizmat then sort on +*.value 11:53
11:55 frost left 11:56 frost left 11:59 squashable6 left 12:02 reportable6 left 12:05 reportable6 joined
CIAvash samcv: or you could tell them to use Chroma instead of Pygments and you would only need to remove one space to get it highlighted correctly 😀 (using the latest commit) 12:13
12:46 Xliff joined 13:01 squashable6 joined
Frozenset Xliff: Your last two Seq examples do give X::Seq::Consumed if you change the variable to be sigilless 13:10
m: my \a = Seq(1, 2, 3); a.^name.say; a.elems.say; .say for a; .say for a;
camelia Seq
The iterator of this Seq is already in use/consumed by another Seq (you
might solve this by adding .cache on usages of the Seq, or by assigning
the Seq into an array)
in block <unit> at <tmp> line 1

Frozenset therefore I don't think "Seq is an Iterable, not an Iterator" is the reason 13:11
so I guess assigning it to a $-sigiled variable has a similar effect as assigning it to a @-sigiled variable 13:12
but I might be wrong altogether 13:14
13:17 Frozenset left 13:24 b2gills left 13:25 xinming left 13:26 xinming joined 13:51 tejr left 13:53 tejr joined 14:04 codesections left 14:19 gordonfish left 15:04 squashable6 left
andinus does adding .race.cache to loops make any difference? 15:17
i have a for loop performing multiple operations on lists of lists (hence .cache)
16:04 evalable6 left, linkable6 left 16:06 linkable6 joined 16:07 squashable6 joined 17:07 coverable6 left, committable6 left, notable6 left, shareable6 left, statisfiable6 left, reportable6 left, bisectable6 left, nativecallable6 left, releasable6 left, linkable6 left, bloatable6 left, tellable6 left, unicodable6 left 17:08 nativecallable6 joined, shareable6 joined, bloatable6 joined 17:09 tellable6 joined, committable6 joined, coverable6 joined 17:10 b2gills joined 17:33 Sgeo joined 17:37 neshpion joined 17:53 gordonfish joined 17:56 gordonfish left, gordonfish joined 18:09 notable6 joined, releasable6 joined 18:10 bisectable6 joined
japhb andinus: Terminal::Print doesn't work on obsd? That's news to me! What doesn't work? Unrecognized terminal or somesuch? 18:26
19:06 evalable6 joined 19:08 unicodable6 joined 19:31 masak_ left, tadzik left 20:05 reportable6 joined 20:08 linkable6 joined 20:10 statisfiable6 joined
moon-child hmm, trying to test, I get 'MoarVM panic: Memory allocation failed; could not allocate 21752 bytes' building rakudo 20:22
El_Che not the last!: git-stars.com/languages/7 20:29
(but below Cobol: sowry)
perryprog Wow we are really low. Even protobuf beats us. 20:34
20:34 matti_ left
perryprog I mean, Cobol beating us makes sense... it's so versatile! pbs.twimg.com/media/Cfd28h6UIAAjYF...name=large 20:35
moon-child El_Che: I don't think that's something ot take seriously 20:44
it lists 'xml' 20:45
and 'v'
and apparently 'no language' is the #5 most popular programming language on github
perryprog GitHub stars are the only thing that matters in determining the programming language to use for a specific application, though.
Ohh, I thought that was sorting language repos by stars, not by usage. Doh. 20:46
moon-child perryprog: aws.amazon.com/blogs/opensource/se...-software/
perryprog Never thought I'd hear the words 'severless' and 'cobol' in the same sentence, much less in the same phrase.
21:01 Manifest0 left
El_Che moon-child: i know both v and people tha program in xml (dir-xml, poor souls) 21:15
21:23 lizmat left 21:24 lizmat joined 21:47 lucasb joined
[Coke] hurm. new failure trying to install cro on OS X (It just hung at one point) 21:47
installed deps-only so I could quickly repeat cro issues - seeing multiple ro] # Check service up attempt 1: connection refused 22:05
22:09 Manifest0 joined
[Coke] it hung after the 4th one 22:12
22:37 RakuIRCLogger joined 22:40 Geth left, Geth joined 23:31 RakuIRCLogger left 23:33 lizmat left 23:34 lizmat joined 23:37 gcd joined 23:40 RakuIRCLogger joined