🦋 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.
szqdsegrhrdgdrg hi 00:55
Perl7 is out !
Python is dead
Ruby is dead
Raku is dead
Perl7 is out !
cpan-raku New module released to CPAN! Tomty (0.0.12) by 03MELEZHIK 01:28
El_Che szqdsegrhrdgdrg eloquence convinced me 09:07
lizmat clickbaits rakudoweekly.blog/2020/10/12/2020-...irst-year/ 09:54
Altreus clicks 10:12
Damn! Baited
lizmat :-) 10:16
Altreus liz is a master ... never mind 11:12
lizmat master elipsis ? 11:13
:-(
:-) rather :-)
cpan-raku New module released to CPAN! Date::Names (2.1.1) by 03TBROWDER 11:15
tbrowder note Date::Names now has eleven languages including a second Norwegian one 11:18
Altreus a bit dotty perhaps 11:22
kawaii Do subroutines have any awareness of _where_ they were called from? I.e. if my application has a frontend UI, but also an API - is there a smart way of knowing which module called my routine so that I can adjust the log output accordingly? 12:26
moritz kawaii: the caller() function can provide such information 12:42
though I don't know how expensive it is
might be better design to do that through some other mechanism 12:43
tadzik a dynamic $*LOGGER or something along those lines may be a bit more controllable and predictable 12:44
kawaii moritz: yes I was thinking of just setting a bool in the signature like $api and using that to determine where it came from :)
tadzik if your routine needs to be aware of its surroundings to log sensibly then it's likely doing a bit too much :)
Geth_ ¦ problem-solving: lizmat self-assigned Aleks-Daniel Jakimenko-Aleksejev (aka AlexDaniel) is a toxic influence and should be banned from Rakudo github.com/Raku/problem-solving/issues/238 12:47
Altreus Is there a Log4Raku or something like that? 13:09
lizmat modules.raku.org/search/?q=Log 13:15
timotimo there's a logging framework that seemed pretty sophisticated but i only looked at the readme so far
[Coke] IWBNI cpan-raku gave me a URL to *something* on cpan. 13:20
timotimo agreed; what would you like? 13:25
i think cpan-raku may react faster than most places update? certainly modules.raku.org
moritz kawaii: also, if your API is a class, you could add an "origin" attribute or so 13:29
[Coke] timotimo: if we can't link to the actual module, maybe to the author? 13:30
Altreus likewise, I found LogP6 which looks too complex to grasp at a glance
[Coke] if we can construct a link that *will* work, use that, even if it takes a minute for it to show up live. Most people are seeing the links in review, after all
timotimo mh 13:31
kawaii `Log::Timeline` looks good, and I'm already using Cro in my project so I think I'll investigate that option 13:32
timotimo it's a bit more special-cased to handle "nested" blocks that are timed, and events that are just points in time, and you can add a datastructure to them 13:34
Altreus I have a feeling that's always the case for logs but we've never noticed before 13:38
i'm interested in the concept
lizmat it's the module that powers one of the paid features of Comma :-) 13:39
timotimo it's very fun to look at
[Coke] how do we look at CPAN releases of Raku modules? 14:14
is metacpan.org/author/TBROWDER/releases sufficient to also see Raku? (those look like Raku in that particular folder) 14:15
in ../COKE/... they are definitely p5, though 14:16
why do I see things in metacpan.org/author/COKE/releases that I don't see in pause.perl.org/pause/authenquery?A...lete_files ?? 14:18
(was going to delete some very old things from CPAN, but pause doesn't have them.) 14:19
ggoebel zef appears to use the json files here: github.com/ugexe/Perl6-ecosystems/ 14:30
which are generated by github.com/ugexe/Perl6-App--ecogen
guifa o/ 14:37
The libarchive module is giving me some install problems and I’m tryignt o trouble shoot it so I can submit a PR (be it documnentation or code). 14:38
I’m getting the error Cannot locate native library '(null)': dlopen(libarchive.13.dylib, 10): image not found 14:42
ggoebel what version of macos? ...colomon recently mentioned issues with dynamic libraries. let me see if I can track that down. 14:43
guifa ggoebel: I’m on 10.15.6 14:45
I think the last time I did this install I was on 10.15.[≤4] and it worked okay, but it’s been a while
ggoebel colabti.org/irclogger/irclogger_lo...10-03#l326 14:46
backlogging it now
his workaround was to copying the offending *.dylib to /usr/local/lib 14:47
guifa Ah yikes. Okay, so it’s definitely not just Libarchive
guifa tries to remember where homebrew said it had to install libarchive because, hooray, macOS doesn’t like files going in certain places 14:48
guifa ggoebel++ you’re a lifesaver 14:51
ggoebel your welcome. but really... colomon++ 14:52
guifa also thanks colomon__++ :-)
colomon__ is wondering what he did 15:03
Ah, my muddling about with GTK::Simple a week ago. 15:04
guifa imgur.com/a/FPZmREG <— yay, my updater script actually worked as expected once I fixed Libarchive 15:14
guifa releases DateTime::Timezones update 15:25
ggoebel guifa++ 15:29
Xliff Is there a mechanism to use a portion of a CArray as another CArray? 16:45
timotimo must be CPointer 16:46
Xliff How would that work?
timotimo nativecast the array to a pointer and increment the pointer, also make sure the array is kept alive by a reference
Xliff I mean in C it would be: int i[10]; *new_i; new_i = i + 5; new_i[0] == i[4] 16:47
Xliff Or would that be i[5]... haha 16:48
timotimo &i[5] or i + 5
Xliff Yeah. Long day. 16:49
timotimo i[5] will be of type int, but you want int*
Xliff At any rate, can we simulate that with NativeCall?
timotimo yeah
Xliff Is it in the docs somewhere?
timotimo m: use NativeCall; my $a = CArray[int].new(1, 2, 3, 4, 5); my $p = nativecast(CPointer[int], $a); say $p.dereference; say ($p + 3).dereference 16:50
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared name:
CPointer used at line 1. Did you mean 'Pointer'?
timotimo m: use NativeCall; my $a = CArray[int].new(1, 2, 3, 4, 5); my $p = nativecast(Pointer[int], $a); say $p.dereference; say ($p + 3).dereference
camelia No such method 'dereference' for invocant of type
'NativeCall::Types::Pointer[int]'
in block <unit> at <tmp> line 1
timotimo m: use NativeCall; my $a = CArray[int].new(1, 2, 3, 4, 5); my $p = nativecast(Pointer[int], $a); say $p.deref; say ($p + 3).deref
camelia 1
No such method 'deref' for invocant of type 'Int'
in block <unit> at <tmp> line 1
timotimo that's not the one, hold on
m: use NativeCall; my $a = CArray[int].new(1, 2, 3, 4, 5); my $p = nativecast(Pointer[int], $a); say $p.deref; say ($p.add(3)).deref 16:51
camelia 1
4
timotimo m: use NativeCall; my $a = CArray[int].new(1, 2, 3, 4, 5); my $p = nativecast(Pointer[int], $a); say $p.deref; say ($p.add(3)).deref; $p.add(3) = 99; .say for $a[^5]
camelia 1
Cannot modify an immutable NativeCall::Types::Pointer[int] (NativeCall::Types::P...)
in block <unit> at <tmp> line 1

4
timotimo mhh hu? 16:52
m: use NativeCall; my $a = CArray[int].new(1, 2, 3, 4, 5); my $p = nativecast(Pointer[int], $a); say $p.deref; say ($p.add(3)).deref; $p.add(3)[0] = 99; .say for $a[^5]
camelia 1
Cannot modify an immutable Int (4)
in block <unit> at <tmp> line 1

4
timotimo that's not what i was expecting
Xliff Yeah. 16:56
m: use NativeCall; my $a = CArray[int].new(1, 2, 3, 4, 5); my $p = nativecast(Pointer[int], $a); say $p.deref; say ($p.add(3)).deref; $p.add(3).deref = 99; 16:57
camelia 1
Cannot modify an immutable Int (4)
in block <unit> at <tmp> line 1

4
timotimo i mean, you can easily-ish turn the pointer to an array and assign to the array's first slot 16:59
that's not fun to type out, of course
jdv79 shouldn't type constrained parms win in multi over "non-constrained" or less narrowly constrained? 17:05
i'm a bit confused how named params factor in general i guess might be it 17:06
Xliff jdv79: Yes. However I've run into issues where params you'd think were more constrained lost to a more permissive variant 17:08
I have yet to get it to a golfable problem that's not tied to a Significantly Larger effort.
timotimo named parameters will only rule out candidates if they already match 17:09
jdv79 m: gist.github.com/jdv/d9b0c26ac52478...2c47bdea71 17:10
camelia 2
1
2
2
2
jdv79 i would have expected something more like 0␤1␤2␤4␤4␤
timotimo having 2 there is probably because that's the first one with nameds that fit 17:11
try switching :$a and :$a, :$b around
Xliff repl.it/@Xliff/LinearGranularTasks...#main.raku 17:13
I think this will work, for now.
timotimo Pointer.new($b + 5) <- i would suggest $b.add(5) instead 17:14
jdv79 ah, so order of declartion matters - somehow i missed that in the docs i read
timotimo and of course what you get back from $b[4] is a writable
so you could bind that to a scalar and assign to that
Xliff timotimo: That blows up in repl.it 17:15
timotimo yeah, :$a and :$a, :$b are the same specificity according to the multi dispatch rules (because nameds don't enter into it in the first step)
but i'm not exactly sure why the first doesn't get 0
Xliff timotimo: Was .add introduced later than 2020.07?
timotimo oh i think i misread that
jdv79 so why does the 0 arity one never get called? i think that's my last confusion. 17:16
timotimo Xliff: 2017-10-18 last touched that method
jdv79 tried reversing the order to no luck...
timotimo i've got to AFK for a bit
Xliff No such method 'add' for invocant of type 'NativeCall::Types::Pointer' 17:17
timotimo maybe the roast tests can be of interest here, but i haven't looked yet
Xliff So I'll use the + variant until I can find a better way.
This looks to be a usable workaround 17:18
jdv79 oh, that's not all - also why does a single named datetime param not hit the sig with datetimes and instead hits the "unconstrained" named sig...
timotimo Xliff: it should come from TypedPointer
jdv79 timotimo: thanks
Xliff timotimo: OK. This is the result... 17:19
timotimo Xliff: please check why method ^parameterize in NativeCall/Types.rakumod doesn't seem to give TypedPointer for Pointer[uint8]
m: use NativeCall; my $p = Pointer[uint8].new; say $p.^name
camelia NativeCall::Types::Pointer[uint8]
timotimo m: use NativeCall; my $p = Pointer[int8].new; say $p.^name
camelia NativeCall::Types::Pointer[int8]
timotimo m: use NativeCall; my $p = Pointer[int8].new; say $p.^roles
camelia ((NativeCall::Types::Pointer::TypedPointer[int8]))
timotimo m: use NativeCall; my $p = Pointer[uint8].new; say $p.^roles
camelia ((NativeCall::Types::Pointer::TypedPointer[uint8]))
timotimo oh, it does
m: use NativeCall; my $p = Pointer[uint8].new; say $p.add(1)
camelia NativeCall::Types::Pointer[uint8]<0x1> 17:20
Xliff Pointer.new($b.add(5)) --> "Default constructor for 'NativeCall::Types::Pointer' only takes named arguments"
timotimo you said you have 2020.07?
yeah, you don't put it into Pointer.new
it already returns a Pointer
Xliff I have fresh blead of the week.
It's repl.it that's got 2020.07
timotimo raku don't often have "copy constructors"
Xliff OK, that works! 17:21
I wonder if I can augment CArray
timotimo it's a class like any other, but not a P6opaque, so you can't add attributes 17:22
rir CArray, I seem to be missing a trick. Starting with the timespec/clock_get_time and following the CArray section on the same page ( docs.raku.org/language/nativecall#...nativecall ), I could not get a CArray[timespec] to work with the native function. Searching all of Github, I didn't find one example of a CArray of CStruct written. Any help out here? 18:05
[Coke] already submitted this for a contest, be curious if anyone had feedback on github.com/coke/matt-parkers-maths...rime-pairs to make it more "natural" for Raku. (Looking at it, I'd probably switch the MAIN to a unit sub since it's the whole file.) 18:08
AlexDaniel [Coke]: .tail instead of [*-1], destructuring for $left and $right instead of accessing $_, yes for a unit sub. check-path is recursive, how about putting gather outside your first call? 19:52
AlexDaniel that is, you can `take` no matter how deep you are 19:53
AlexDaniel [Coke]: the code seems to be doing depth-first search so it makes sense to describe it as such in the comments. Describing it this way may also give clues on how to optimize it 20:01
[Coke]: `next if @path.first($next)` is needlessly O(n) while you could've used an array with boolean markers 20:03
AlexDaniel another way is to use a more generic approach – describe your edges and vertices by using objects, then you can have “already used” field in each object 20:05
AlexDaniel [Coke]: as for optimizing it, the slowest and most obvious part is when you hit the same vertex more than once from slightly reordered initial steps. That is, if you've already found solutions (or figured out that there are no solutions) for a certain combination of remaining vertices, you're currently checking them all over again anyway 20:08
usually that's very easy to solve for tasks that just ask for the shortest path to finish (or the number of possible paths), but from the top of my head I don't know how to do that in cases when you must hit every vertex 20:09
also looking at it now you can just `take` your @path when you hit the finish without any additional logic 20:10
MasterDuke could it be something `for %paths{$last}.values (-) @path -> $next {`? 20:11
AlexDaniel that's probably still significantly slower than just checking an array of bools or checking a field of an object 20:12
I definitely wouldn't do it that way in a competition, which you can probably tell I used to enjoy back in the day :) 20:14
AlexDaniel doing something like that might also stress GC a bit too much, it depends. But a few ms wasted on something as simple as that can really lose you some points :) 20:15
can't help it x) the task itself reads almost like something straight from one of the competitions 20:16
another interesting part is optimizing the tree generation itself ( `($min..$max).combinations(2).grep(*.sum.is-prime)` ) 20:21
AlexDaniel maybe a good idea to generate the primes first and then generate the edges starting with known primes 20:22
MasterDuke m: (1..9).combinations(2).grep(*.sum.is-prime).elems.say; say now - INIT now 20:23
camelia 14
0.00493635
AlexDaniel for 1..9 yes, but for 1..9 you can probably bruteforce the whole thing too
MasterDuke m: (1..900).combinations(2).grep(*.sum.is-prime).elems.say; say now - INIT now # what's an actually useful range? 20:24
camelia 59678
2.5261464
AlexDaniel that being said, on a competition I would've probably written something that's relatively slow-ish, and then just feed it all possible inputs, create a lookup table, and submit the lookup table as a solution x)
2.5s is already too slow, the limit is usually 1s 20:25
MasterDuke ^^^ drops to 0.5s on my gmp branch 20:28
though it was only 1.7s locally on master 20:29
AlexDaniel MasterDuke: the gmp branch… is working? :O
that's fantastic news
MasterDuke it only fails a single spectest because 2**10000000000 doesn't die anymore 20:30
AlexDaniel that's amazing 20:31
what does it do instead?
I guess, hangs while trying too hard? :)
that test can be thrown away, 2**1000000000 behaves the same way I don't see a good reason why anything larger should be different 20:32
in fact maybe it's actually wrong to throw an exception at an arbitrary point, just adds an edge case where one doesn't have to exist 20:34
MasterDuke `my $a = 2**10000000000; say $a > 4` # outputs `True` almost instantly 20:37
MasterDuke but the branch still needs a little cleanup. it's not using the gmp we build unless i LD_PRELOAD it, and i'm using a signal handle and setjmp+longjmp to handle abort()s from gmp, which i don't believe is threadsafe 20:39
*signal handler
MasterDuke but otherwise it's faster and ~500 fewer lines of code in bigintops.c 20:40
lizmat MasterDuke++ # hard work and progress!
Altai-man MasterDuke++ # very impressive! 20:41
MasterDuke 90% done. now just the remaining 90% to finish... 20:43
AlexDaniel MasterDuke: how much faster? Did you by any chance notice any difference running the spectest? 20:46
MasterDuke i don't think there's much difference in a spectest. i just did an assortment of math operations in a loop and noticed a measurable difference 20:49
AlexDaniel okay
MasterDuke stringification is dramatically faster
MasterDuke `my ($a; $b; $c; $s); for 66..2_000 -> $e { $a = 23**$e; $b = 7**$e; $c = $a % $b; $c *= $c; $c += $a; $c -= $b; $s = $c.is-prime }; say $s; say now - INIT now` takes 10s on gmp branch, 30s on master 20:55
yeah, no change in spectest time 20:58
AlexDaniel MasterDuke: btw I think there's third chunk of 90% for switching to gmp rats :) But that's for later
[Coke] MasterDuke++ 21:28
Xliff Huh, 23:47
This is an odd error... "Can only store CPointer attribute in CPointer slot in CStruct" 23:48
m: use NativeCall; class A is CStruct { has Pointer $.a }; my $a = A.new; $a := Pointer
camelia 5===SORRY!5=== Error while compiling <tmp>
'A' cannot inherit from 'CStruct' because it is unknown.
at <tmp>:1
Xliff m: use NativeCall; class A is repr<CStruct> { has Pointer $.a }; my $a = A.new; $a := Pointer
camelia ( no output )
Xliff m: use NativeCall; class A is repr<CStruct> { has Pointer $.a }; my $a = A.new; $a := Pointer[uint8].new(1) 23:49
camelia ( no output )