🦋 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.
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
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
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
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
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
Altreus what does that mean in this context? 13:06
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
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
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
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.
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
guifa o/ 15:57
tonyo which one are you referring to rassoc ? 16:19
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"
camelia (timeout) 17:43
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
tonyo gfldex: timo: updated gist 18:54
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 -
1..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
guifa And at long last, Intl::LanguageTag finally has an update! 21:26
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))
[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
afk
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
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
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'