🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku)
Set by lizmat on 23 May 2021.
00:02 reportable6 left 00:05 reportable6 joined 00:13 bill790 joined 00:19 leah2 left 00:23 kjk left 00:37 Doc_Holliwood left 00:40 Doc_Holliwood joined 00:56 frost joined 01:22 squashable6 left 01:23 squashable6 joined 01:25 Doc_Holliwood left 01:31 tejr left 01:38 tejr joined 01:39 tejr joined 02:05 rassoc left 02:51 neshpion left 03:14 guifa joined 03:46 monkey_ joined 03:48 bill790 left 04:01 monkey_ left 04:05 RandalSchwartz left
guifa Because enums are really special hashes, that means that even if not all values are used, the full collection has to stay in memory at both compile and runtime yeah? 04:14
guifa is trying to figure out best practices for an 8000+ enum system, although not opposed to switching to some sort of specialized package system 04:15
04:18 guifa left 04:19 guifa joined
japhb guifa: Is the problem the memory footprint of the number of enumerations (~ hashes), or the number of enumerants (~ individual keys)? Or is it about deserialization time? 04:31
guifa japhb: enumerants. > 8000, but I imagne a typical use case is to only need a handful of them in any given project 04:33
I'm autogenerating an enum for language codes, but while English => 'en', Spanish => 'es', etc, are probably quite likely to be used, SantaCatarinaAlbarradasZapotec => 'ztn' is probably overkill for most people. 04:35
And i'd hate for the extra weight to be sitting around there unless someone needs it. (OTOH, I don't think I can export only some enum keys and still be fully interoperable with a different module that assumes a full set of keys, or could I?) 04:36
japhb Hmmm. Why do you need all those language keys to be enumerants? (I've got a couple guesses what you're looking for, but my suggestion depends on why you're wanting to do this.) 04:54
guifa I'd like to be able to type check for a language code enum (mainly to allow for, e.g., LanguageTag.new: Language::English, Region::Canada, Script::Latin, but not enforce a given order 04:59
(I've been putting each enum in its own package to allow for the Language::* syntax, to at least avoid massively dumping thousands of symbols in the main scope) 05:00
05:19 guifa left
japhb `my %languages; subset ValidLanguage of Str where %languages; sub foo(ValidLanguage $lang)` ? 05:23
Or even `sub language-code(ValidLanguage $lang) { %languages{$lang} }` 05:24
05:58 ufobat joined 06:02 reportable6 left 06:04 reportable6 joined 06:44 Doc_Holliwood joined, patrickb joined 06:49 stoned75 joined 07:18 DarthGandalf left 07:20 DarthGandalf joined 07:24 xinming left
moon-child tim toady casting shade: 'To the best of my recollection, Perl has never borrowed a PHP feature. We didn't even skip version 6, as they did' 07:33
07:35 Doc_Holliwood left 07:40 Eddward left 07:43 Sgeo left 07:44 dakkar joined 07:49 rassoc joined 08:02 patrickb left 08:15 tejr left 08:29 leah2 joined 08:58 canw joined 09:16 canw left 09:17 sono left 09:22 Altai-man joined 09:25 canw joined 09:30 canw left 09:39 Altai-man left 10:39 linkable6 left, evalable6 left 10:40 evalable6 joined 10:41 linkable6 joined 11:29 brown121407 is now known as smarton 11:30 tejr joined 11:37 lucerne left, greyrat left 12:02 reportable6 left 12:03 Doc_Holliwood joined 12:04 reportable6 joined
Altreus I think that is a joke because the history people see will show that we did, indeed, skip 6 13:01
But I cannot imagine what functionality of PHP can be considered a feature 13:02
lizmat allomorphs ? 13:03
13:04 evalable6 left, linkable6 left
Altreus what does that mean in this context? 13:06
13:06 linkable6 joined 13:07 evalable6 joined
lizmat doesn't PHP just have allomorphs? 13:11
fwiw, I gave up on PHP at version 1.8b5 or so 13:12
Altreus I dunno what an allomorph is in software :D 13:14
I looked it up but only got linguistics answers
lizmat m: dd <42>
camelia IntStr.new(42, "42")
Altreus ah, dualvars in perl 13:15
I'm not sure that arrives at the code layer often enough to be considered a feature tbh 13:16
normally it's transparently equivalent to coercion
lizmat true
I was getting pretty desperate at figuring a PHP feature :-)
rassoc better perf compared to us ;) 13:17
13:18 Eddward joined
lizmat once I spent 3 days trying to figure out why a PHP script didn't do what it should 13:20
turns out I had forgotten a comma somewhere, but the parser didn't complain, just did the wrong thing
I dropped PHP after that: faster or not, 3 days of my life I value more 13:21
but that was about 25 years ago :-) 13:24
13:28 RandalSchwartz joined
Altreus lizmat: ah, much like when you use a . instead of a , when making a hash in perl5 :D 13:35
at least that warns you about odd-sized list; unless you do it twice
lizmat well, the thing was, that it *was* a syntax error 13:37
more like TTIR in Raku
if I remember correctly, it just silently dropped the line with the syntax error 13:38
13:51 Doc_Holliwood left 13:53 Sgeo joined 14:01 ufobat left 14:09 frost left 14:14 squashable6 left 14:15 ufobat joined 14:16 squashable6 joined
jdv php perf has to be impressive. the amount of java-esque "modern" php that gets parsed/compiled/run on every invocation is crazy. kinda like if you did something very moose heavy and it worked well enough under cgi. 14:18
Altreus ah but a lot of people use tricks these days, to cache stuff or simply run it like it was a proper language in the first place 14:24
jdv a very crude sloc of $work's main codebase with deps included is ~6.5M lines of php. note that php lazy loads source files. but still avg response times are tens to hundreds of ms.
14:36 Doc_Holliwood joined 15:09 m6locks left
rassoc can't the same be said about our object model? lotta stuff going on behind the scenes of a innocent Foo.new invocation and the like 15:22
jnthn's blog posts are really enlightening, but also quite scary 15:23
gfldex timo: The impact is not dramatic. source: gist.github.com/gfldex/962e83b4a0b...d30a294210 15:31
15:48 Doc_Holliwood left 15:50 cbk joined 15:57 guifa joined
guifa o/ 15:57
16:04 sono joined 16:17 ufobat left
tonyo which one are you referring to rassoc ? 16:19
16:33 dakkar left 16:34 greyrat joined, lucerne joined 16:39 lucerne left 16:43 lucerne joined
rassoc for the last 2 days i've been going through most of them chronologically, starting from 2010. for some i'm just too stupid 16:47
gfldex: slick, i like the phaser usage! 16:54
gfldex thank you 17:04
With RakuAST macros I believe it would be possible to print the code that is being benchmarked instead of having to resort to .WHY . 17:06
I'm already collecting ideas. :)
timo shift the first measurement out of all the arrays in the END phaser :D 17:07
tonyo you can just Bench .. 17:13
and get a very nice table
timo the reason to have custom code was to not pull in any outside modules for the blog post 17:14
if we're really doing benchmarking, have we all clocked down our CPUs to the lowest setting to make sure thermals and boosting don't make our measurements useless? :D 17:19
rassoc already running at the bare minimum because of all these intel vulnerability fixes :( 17:22
tonyo ah, why not use telemetry? that's in core 17:24
left a comment on that gist gfldex timo showing the output on M1 17:25
timo looks like you're using a rakudo version that doesn't have "next with argument" yet 17:40
that's only like two days old
tonyo i'll rebuild & repost 17:42
sena_kun m: say (0, |(1, 2 ... *)).is-lazy 17:43
camelia True
sena_kun m: my @a = [+] (0, |(1, 2 ... *)); say "fine"
camelia fine
sena_kun m: my @a = [\+] (0, |(1, 2 ... *)); say "hangs"
17:43 evalable6 left
camelia (timeout) 17:43
17:44 evalable6 joined 17:46 Kaiepi left, Kaiepi joined
rassoc m: my @a = [+] (0, |(1, 2 ... *)); # sena_kun 17:49
camelia ( no output )
rassoc arg: "Cannot .sum a lazy list"
sena_kun rassoc, thanks, I was testing the bug report. :) 17:50
tonyo timo: is that on a branch? pulling master and rebuilding nets the same error
sena_kun github.com/rakudo/rakudo/issues/2122 <- here is it if anyone wants to bisect, it's curious...
gfldex tonyo: this is the commit in master: github.com/rakudo/rakudo/commit/25...25f1b2acf8 17:51
17:55 Kaiepi left, Kaiepi joined, stoned75 left 17:57 stoned75 joined 18:03 reportable6 left 18:05 reportable6 joined 18:42 Doc_Holliwood joined
tonyo gfldex: timo: updated gist 18:54
18:56 RandalSchwartz left 19:08 Kaipi joined, Kaiepi left 19:11 cbk left 19:20 abraxxa left 20:20 archenoth joined
guifa What's the best way to check for a warning? 20:43
lizmat CONTROL block ?
m: CONTROL { dd $_ }; warn "foo" 20:44
camelia CX::Warn.new(message => "foo")
MoarVM panic: Trying to unwind over wrong handler
lizmat yeah that last one is a known one
m: { CONTROL { dd $_ }; warn "foo" }
camelia CX::Warn.new(message => "foo")
MoarVM panic: Trying to unwind over wrong handler
lizmat m: sub a() { CONTROL { dd $_ }; warn "foo" }; a
camelia CX::Warn.new(message => "foo")
MoarVM panic: Trying to unwind over wrong handler
lizmat hmmm
guifa okay, I had ben getting the MoarVM panic for a bit and wasn't sure if I was doing something wrong
lizmat anyways...
guifa but it's not just me apparently lol
lizmat m: sub a() { CONTROL { dd $_; .resume }; warn "foo" }; a
camelia CX::Warn.new(message => "foo")
lizmat m: { CONTROL { dd $_; .resume }; warn "foo" } 20:45
camelia CX::Warn.new(message => "foo")
lizmat yeah, you need the .resume
guifa actually I was able to do it okay with CONTROL { when CX::Warn { … } } and that seemed to handle things okay too 20:46
guifa . o O ( maybe that can help for tracking down the panic? )
ugly but 20:49
m: use Test; my $warned = False; { CONTROL { when CX::Warn { $warned = True if .message eq 'foo' ; .resume } }; warn 'foo' }; ok $warned; done-testing()
camelia ok 1 -
guifa none of dies-ok, fails-ok, and throws-like catch warnings, so it looks like that's really the only way. Maybe we should add a warns-like ? 20:51
20:56 Sgeo_ joined, Sgeo left
guifa And at long last, Intl::LanguageTag finally has an update! 21:26
21:38 m6locks joined
japhb guifa: warns-like sounds useful to me. PR it? 22:03
guifa japhb: I can probably toss something together tonight or tomorrow evening. 22:04
rassoc any sexier way to write this list comprehension since we have no .repeated-combinations? [(x,y) | x <- [1..3], y <- [x..3]] 22:33
currently have:
m: say gather for 1..3 -> $x { for $x..3 -> $y { take ($x, $y) }}
camelia ((1 1) (1 2) (1 3) (2 2) (2 3) (3 3))
22:38 linkable6 left, evalable6 left 22:40 linkable6 joined, evalable6 joined 22:43 linkable6 joined, ilogger2_ left 22:44 ilogger2 joined 22:53 Kaipi left, Kaipi joined, Sgeo joined, Sgeo_ left
[Coke] m: given <1 2 3> { |($_ Z $_), |$_.combinations(2) } 23:15
camelia ( no output )
[Coke] m: say given <1 2 3> { |($_ Z $_), |$_.combinations(2) }
camelia 5===SORRY!5=== Error while compiling <tmp>
Unsupported use of bare "say". In Raku please use: .say if you meant
to call it as a method on $_, or use an explicit invocant or argument,
or use &say to refer to the function as a noun.
at <tmp…
[Coke] m: dd given <1 2 3> { |($_ Z $_), |$_.combinations(2) }
camelia 5===SORRY!5=== Error while compiling <tmp>
Unexpected block in infix position (missing statement control word before the expression?)
at <tmp>:1
------> 3dd given <1 2 3>7⏏5 { |($_ Z $_), |$_.combinations(2) }
expecting any of:…
[Coke] . o O (as I try to remember why that works in the REPL...) 23:16
m: say do given <1 2 3> { |($_ Z $_), |$_.combinations(2) }
camelia ((1 1) (2 2) (3 3) (1 2) (1 3) (2 3))
[Coke] arguably shorter but even less clear. 23:17
rassoc feels a bit more cryptic, but thanks for taking a look 23:24
went through blog.lojic.com/2020/12/26/comprehe...julia.html and the above is the only thing that's truly uglier than "idiomatic" raku 23:25
than the provided comprehensions compared to "idiomatic" raku* 23:26
[Coke] m: my \a = (1,2,3); dd (a X a).grep({$_[1]>=$_[0]}) 23:31
camelia ((1, 1), (1, 2), (1, 3), (2, 2), (2, 3), (3, 3)).Seq
[Coke] (without the grep, you'd also get, e.g. (3 1) 23:32
rassoc clever! 23:33
[Coke] I think the gather/take is still very easy to read. :) 23:34
japhb m: my \a = (1,2,3); dd (a X a).grep({[<=] @$_}) 23:35
camelia ((1, 1), (1, 2), (1, 3), (2, 2), (2, 3), (3, 3)).Seq
rassoc @$_, whoa, first time seeing this 23:36
japhb rassoc: just treating $_ as a Positional 23:38
23:41 kjp left
rassoc yeah, figured, just never stumbled upon that. good to know, thanks! 23:42
guess i'll go with (a X a).grep: { .head <= .tail } for now. feels clean
guifa you can also just use @_ too 23:45
m: my \a = (1,2,3); dd (a X a).grep({[<=] @_})
camelia (((1, 1),), ((1, 2),), ((1, 3),), ((2, 2),), ((2, 3),), ((3, 3),)).Seq
guifa hmm
lucs 23:47
Er, camelia still not set up to respond to PM? 23:48
23:52 Doc_Holliwould joined 23:54 Doc_Holliwood left
moon-child still thinks the apl solutions are prettiest of all, barring the one involving double-ended ranges 23:58
especially the ones where you can use 'where'