🦋 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.
tigerpaws newbie question: are there any tools to reformat a module? and to list all the contents (classes, methods, subs) of a module? 01:36
rba melezhik: Please ping me regarding Blin machine access. 06:36
tellable6 rba, I'll pass your message to melezhik
suman Is there a way to access how much memory variable is taking in raku? 07:14
Something like size(@list)
cpan-raku New module released to CPAN! Shelve6 (0.2) by 03ROBERTLE 07:25
MasterDuke suman: i think the only way is by doing a heapsnapshot profile 07:34
suman MasterDuke Does it show the size of the variable or object? You suggest to run MoarVM profiler? 07:38
MasterDuke i haven't used it all that much, you'd need to ask timotimo, nine, or jnthn for expert help 07:39
but yes, `raku --profile=somefilename.mvmheap -e 'say "hi"'` 07:40
but it has it's own viewing/analyzing program, it doesn't create a web page 07:41
p6-app-moarvm-heapanalyzer 07:42
suman my @list = [10, 10, 31, 28, 46, 08:08
say @list
It gives list of lists. Can I combine into a single list? 08:09
m: 'my @list = [10, 10, 31, 28, 46, 08:10
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in single quotes; couldn't find final "'" (corresponding starter was at line 1)
at <tmp>:1
------> 3'my @list = [10, 10, 31, 28, 46,7⏏5<EOL>
expecting any of:…
suman m: 'my @list = [10, 10, 31, 28, 46, 22, 27, 28, 42, 31, 8, 27, 45, 34, 6, 23], [1..100];say @list' 08:13
camelia WARNINGS for <tmp>:
Useless use of constant string "my @list = [10, 10, 31, 28, 46, 22, 27, 28, 42, 31, 8, 27, 45, 34, 6, 23], [1..100];say @list" in sink context (line 1)
MasterDuke m: my @list = [10, 10, 31, 28, 46, 22, 27, 28, 42, 31, 8, 27, 45, 34, 6, 23], [1..100]; say |@list 08:14
camelia [10 10 31 28 46 22 27 28 42 31 8 27 45 34 6 23][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71…
suman MasterDuke Still two lists side by side,can I combine into just a single list 08:17
MasterDuke m: my @list = [10, 10, 31, 28, 46, 22, 27, 28, 42, 31, 8, 27, 45, 34, 6, 23], [1..100]; say flat gather .take for @list 08:20
camelia (10 10 31 28 46 22 27 28 42 31 8 27 45 34 6 23 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 …
suman MasterDuke Thank you
MasterDuke np 08:21
SmokeMachine m: [,] 08:53
camelia Potential difficulties:
Useless use of [,] in sink context
at <tmp>:1
------> 3<BOL>7⏏5[,]
SmokeMachine m: say [,]
camelia ()
SmokeMachine m: say [[,],]
camelia [()]
SmokeMachine m: say [[[,],],] # why is it wrong? 08:54
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in bracketed infix; couldn't find final ']' (corresponding starter was at line 1)
at <tmp>:1
------> 3say [[[,]7⏏5,],] # why is it wrong?
timotimo It is interpreting the whole thing as one operator 09:26
sarna if I have a sub that takes one argument with the @ sigil, what is $_ bound to in the sub body? 09:31
oh, seems like it doesn't get bound to anything, no matter the arguments 09:33
moritz m: $_ = 'abc'; sub f(@a) { say $_ }; f([1, 2])
camelia (Any)
konvertex Given a naive recursive fib script, running it twice yields these timing results: from 340s on the first run, down to 39s on the second. Why aren't the optimizations kicking in on the first run? Is this some form of PGO that's only available after a successful run? What's happening here? 10:22
lizmat can't tell without a gist 10:25
konvertex Just looking at github.com/drujensen/fib/blob/master/fib.p6 10:28
konvertex But reduce it to fib(40), otherwise it takes forever. :) 10:28
This is on 2020.05.1. 10:29
lizmat well, if you profile for N = 30, you will see that it actually calls fib() 2692537 times 10:36
konvertex And replacing `Int $n` with `int $n --> int` slows down the first run by a factor of 3, but the second run is then 30 times faster on my end. 10:37
lizmat and for n=35 this has gone up to 29860703 aka, more than 10x more 10:38
so, that's what you get with a naive algorithm ? 10:39
sarna lizmat: I think they're running it again with the same argument 10:41
konvertex Yes, I'm not expecting c perf numbers here, just wondering why two runs, with the same inputs, result in significantly different timings.
lizmat sarna: yes, there is no caching of any kind in that algorithm 10:41
.oO( those who do not cache are doomed to calculate it again and again and again)
10:42
konvertex But raku seems to cache the profiling data somewhere, eh?
jnthn No, the profiling data is based on what's observed run to run 10:44
(If you mean the profiling data used for runtime optimization, that is)
konvertex Just to be clear, I'm doing this, no file editing in between: 10:46
~/testing/raku$ timev raku fib.raku
102334155
339.78 s, 92228 kb
~/testing/raku$ timev raku fib.raku
102334155
39.28 s, 91688 kb
jnthn Is it random if it manages to optimize it or not? 10:47
konvertex Long runtime only happens with a new file, once. 10:48
So I assumed that there's some cache data floating around somewhere.
jnthn Please can you make an issue for it? I'd like to try and repro it at some point. 10:49
SmokeMachine timotimo: and is that a bug? 11:34
timotimo if there is no "use" statement, it's unlikely to be caching 11:37
that kilobytes number is the total amount of memory used?
i mean maximum rss
hm, i guess fibonacci doesn't have deep recursion, just very wide 11:38
can you run it with "time" to see if it's user or system time?
also it's not likely the cause, but --stagestats can tell us if it's for some reason taking a long time to compile or really just running 11:40
Prince213 Hi, can I export something when a tag is *not* given? 11:44
lizmat Prince213: providing your own EXPORT sub would allow you to do that
docs.raku.org/language/modules#ind...sub_EXPORT 11:45
Prince213 Ok, I'll try that 11:47
timotimo konvertex: got a bit of time to work with me?
rir From raku.org: (Object orientation) declarator class class Classes are declared using the class keyword, typically followed by a name.
What other than a name is allowed? 11:48
timotimo ::
rir Are there the class-is-finalized and reopening-class phrasings? 11:51
timotimo there is "augment class foo"
rir Yes. And can that be disallowed?
timotimo you are only allowed to use "augment" if you "use MONKEY-TYPING" 11:52
jnthn One can also deny such changes through meta-programming, I guess. 11:53
sarna or setting a linter rule, right? 11:53
jnthn Alternatively, write a role instead of a class, since roles are immutable. :)
timotimo you can also get around needing "use MONKEY-TYPING" using the meta programming 11:54
rir Thanks timo, jonathan. I go to RTM. 12:01
Oh, and sarna, thanks. Yours was just not in the direction I was thinking--so especially worthwhile. 12:03
sarna you're welcome :)
konvertex: I can't reproduce this on 2020.05.1, with `time raku fib.raku` 12:04
timotimo oh
konvertex: do you have a RAKU_LIB or PERL6_LIB in your environment?
MasterDuke doesn't repro here either 12:05
MasterDuke timotimo: but yeah, that's likely the culprit 12:07
timotimo not sure what exactly would make it faster the second time 12:08
sarna Make Your Raku Scripts Faster With This One Weird Trick 12:15
konvertex Sorry for the delay, everyone. Upgrading my fedora machines atm, all EOL. Will try to reproduce it in the new environment after a quick reboot.
timotimo: yes, max rss kb. timev is just an alias: timev='/usr/bin/time -f "%e s, %M kb"'. Elapsed real time. And no, no such env vars on my end. 12:16
timotimo OK, --stagestats would also give us a specific output if something were doing that
konvertex Maybe it will fix itself. Maybe some weird swap issue, hm? Uptime is 312 days.
Back in a sec. 12:17
melezhik AlexDaniel` rba I've made an in experiment running rakudist on aws. minimal configuration require at least 2 t2.small instances 2 GB , 2 CPU each 13:00
tellable6 2020-05-18T06:36:58Z #raku <rba> melezhik: Please ping me regarding Blin machine access.
melezhik so let decide where do we start from that 13:01
raku-bridge <tmtvl> Does the old HOP-style memoization not work in Raku? 13:02
<tmtvl> m: {my @fib; sub fib ($n) { return $_ with @fib[$n]; return @fib[$n] = $n if $n < 2; return @fib[$n] = fib($n - 1) + fib($n - 2);};}; say fib(35);
lizmat and another Rakudo Weekly News hits the Net: rakudoweekly.blog/2020/05/18/2020-...-upgraded/ 13:03
MasterDuke m: {my @fib; sub fib ($n) { return $_ with @fib[$n]; return @fib[$n] = $n if $n < 2; return @fib[$n] = fib($n - 1) + fib($n - 2);};}; say fib(35); # don't think you can invoke camelia over the bridge
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
fib used at line 1
raku-bridge <tmtvl> Yep, that's what I get on 2020.02 as well... the right way to solve it is to just use Memoize, the dumb way to solve it would be something like gist.github.com/tmtvl/e9d1d78885fc...3dfd0e518b 13:07
konvertex Well, well, that took longer than expected. Good news: can't reproduce the 10x slowdown on the first run any longer. Sorry for the noise, everybody! 13:15
MasterDuke i wonder if it's possible for the bridge bots to catch 'm:' messages and say them literally to the channel, not prefixed by user? 13:16
sarna wouldn't it be simpler for camelia to accept `<something> m:`? 13:24
raku-bridge <tmtvl> I should just not be lazy and hop on ERC. I have Emacs open 24/7 anyway.
sarna m: my @list = [3,4,5]; say [1,2,@list] # I'd like it to be [1,2,3,4,5] - how would I do that? 14:14
camelia [1 2 [3 4 5]]
jnthn [1,2,|@list] 14:15
tadzik m: my @list = 3, 4, 5; say [1, 2, @list] 14:16
camelia [1 2 [3 4 5]]
tadzik hrm
sarna ah, that's the thing :D I forgot which operator it was, and it wasn't in the docs under "flattening" 14:20
thanks jnthn :))
sarna ((my $foo, my @bar), my @baz) = [[1,2,3],4,5]; say "foo: $foo, bar: {@bar}, baz: {@baz}" # why doesn't this dwim? 14:35
evalable6 foo: 1 2 3, bar: 4, baz: 5
sarna oh my, I forgot m: and it worked anyway! love these bots
suman m: my $rev_comp = ("ATTCGGCATTGCA" ~~ tr/ATCG/TAGC/).flip; say $rev_comp; 14:36
camelia Cannot modify an immutable Str (ATTCGGCATTGCA)
in block <unit> at <tmp> line 1
suman I did not get this error message 14:37
suman m: ("ATTCGGCATTGCA" ~~ tr/ATCG/TAGC/).flip.say 14:47
camelia Cannot modify an immutable Str (ATTCGGCATTGCA)
in block <unit> at <tmp> line 1
[Coke] m: my $s = "ATTCGGCATTGCA"; ($s ~~ tr/ATCG/TAGC/).flip.say 14:51
camelia TGCAATGCCGAAT
[Coke] m: "ATTCGGCATTGCA".trans('ATCG' => 'TAGC').flip.say 14:53
camelia TGCAATGCCGAAT
skids Hrm. 15:30
m: "ATTCGGCATTGCA" ~~ TR/ATCG/tagc/.say;
camelia taagccgtaacgt
skids m: my $r = ~"ATTCGGCATTGCA" ~~ TR/ATCG/tagc/; $r.say; 15:31
camelia False
skids m: my $r = "ATTCGGCATTGCA" ~~ TR/ATCG/tagc/; $r.say;
camelia False
[Coke] you're setting r to the result of the smartmatch, not the string.
skids m: m: "ATTCGGCATTGCA" ~~ (my $r = TR/ATCG/tagc/); $r.say; 15:33
camelia taagccgtaacgt
skids Wow that just looks backwards but OK. 15:34
skids m: my $rev_comp = (TR/ATCG/TAGC/ with "ATTCGGCATTGCA").flip; say $rev_comp # The more idiomatic way. 15:45
camelia TGCAATGCCGAAT
skids m: my $rev_comp = TR/ATCG/TAGC/.flip with "ATTCGGCATTGCA"; say $rev_comp # or maybe this depending on how your brain functions 15:47
camelia TGCAATGCCGAAT
poohman hello all, 16:19
m:my $a =";;;;;;;";my @a=split(";",$a); for @a ->$b {if $b eq "" say "empty"} 16:21
evalable6 (exit code 1) 04===SORRY!04=== Er…
poohman, Full output: gist.github.com/17fc15e7a4ede2ba5b...d5b8d1b049
poohman m:my $a =";;;;;;;";my @a=split(";",$a); for @a ->$b {if $b eq "" {say "empty"}}
evalable6 empty
empty
empty
empty
empty
empty
empty
empty
poohman in the above example is $b eq "" the idiomatic way? 16:22
poohman or do we have a cleaner way to check 16:22
?
timotimo that's fine 16:23
m: say ";;;;;;;;".split(";", :skip-empty)
camelia ()
timotimo if you want that
poohman timotimo - im trying to checking if a csv from excel has an empty row 16:24
so its a check basically
[Coke] m:my $a =";;;;;;;";my @a=split(";",$a); for @a ->$b { say "empty" unless $b }
evalable6 empty
empty
empty
empty
empty
empty
empty
empty
timotimo what if the cell in excel had a ; in it?
[Coke] You should be using the CSV module for any CSV stuff. 16:25
too many edge cases.
poohman timotimo - mine wont - but I get the point
poohman let me look at the csv module then 16:26
[Coke] if you have an array and want to know if any of the elements has a value, you could: 16:26
m: my @a = "","","","",""; say "empty" unless @a.first(* ne "") 16:27
camelia empty
[Coke] m: my @a = "","","3","",""; say "empty" unless @a.first(* ne "")
camelia ( no output )
[Coke] saves you an explicit iteration loop, will stop as soon as it finds any value (don't have to keep checking if the first cell has a value) 16:28
poohman cool
dakkar m: my @a = "","","3","",""; say "empty" if all(|@a) eq ''
camelia ( no output )
timotimo i find using "any" more idiomatic
m: say so "1,2,,3,4".split("").any eq "" 16:29
camelia True
timotimo m: say so "1,2,0,3,4".split("").any eq ""
camelia True
dakkar `unless any() ne` is too many negations for my brain 😜
timotimo er, oops?
haha
m: say so "1,2,,3,4".split(",").any eq ""
camelia True
timotimo m: say so "1,2,0,3,4".split(",").any eq ""
camelia False
poohman cool - but ill have a look at the csv module now 16:31
thanks all
[Coke] timotimo: any speed issues with using Junctions (esp on big arrays?)
timotimo: also, is "any" smart enough to stop checking when it finds one?
timotimo it will be, but it could be that before that happens something else already greedily evaluated the list 16:32
m: say (1, 2 ... *).first(* > 20)
camelia 21
timotimo m: say so (1, 2 ... *).any(* > 20)
camelia Too many positionals passed; expected 1 argument but got 2
in block <unit> at <tmp> line 1
timotimo er, yes
m: say so (1, 2 ... *).any() > 20
OK, don't any, then
camelia (timeout) 16:33
suman stackoverflow.com/questions/618757...ne-in-raku 17:49
timotimo m: .say for "florble".comb(3) 18:04
camelia flo
rbl
e
timotimo i would assume you're getting a newline that's at the end of the input file 18:05
lizmat spurt "out.txt", "test.txt".IO.comb(3).join("\n") # my solution
timotimo since comb gives you three characters rather than "three letters"
lizmat pretty much like an ascii deal to me
poohman my $aoh = csv(in => $fh, headers => { $^h.lc ~ $i++ }); 19:02
this is from the Text::CSV module documentation
what is this $^h?
lizmat docs.raku.org/language/variables#i...LEX_ACCENT 19:04
poohman ^^ 19:05
poohman thanks liz ill have a look
tigerpaws Hi. I have a problem with forward declarations: annot change REPR of Tensorflow::Native::TF_Status now (must be set at initial declaration) 19:14
at /home/mike/projects/raku-tensorflow/lib/Tensorflow/Native.pm6:110
------> TF_Status is repr('CPointer') is export⏏ {
I tried everything from 'class TF_Status {...} to 'class TF_Status is repr('CPointer') is export {...}' and still get hhe same error 19:15
I need forward references for all these structs (in NativeCall) because they refer to each other all the time 19:16
lizmat tigerpaws: that's a known issue: you must set the REPR in the stub
and *not* set it in the final declaration 19:17
tigerpaws Ah. NOT set it in the final declaration. Got it. What about the 'is export' ?
lizmat m: class A is repr("VMArray") { ... }; class A { }; dd A.REPR 19:18
camelia "VMArray"
lizmat tigerpaws: you mean exporting a class ?
you don't have to do anything for that, as classes are by default "our" and will thus export by default 19:19
tigerpaws yes. At least that's what GPTrixie produced for the api I am converting. Maybe GPTrixie doesn't need to do that?
lizmat I wouldn't know 19:20
tigerpaws OK Thanks lizmat.. My next error says Undeclared name: 19:22
PointerStr used at line 179
on an attribute in a class: ... Pointer[PointerStr], ...
lizmat I have no idea, I don't think PointerStr is in core 19:24
tigerpaws OK. Maybe it was at one time. In any case, I don't see what difference it makes...
Geth ¦ problem-solving: lizmat assigned to jnthn Issue Only allow IO::Path.open to create an IO::Handle github.com/Raku/problem-solving/issues/196 19:31
tigerpaws Another problem with my NativeCall stuff: In the NativeCall docs it says Pointer[MyCStruct] is is pointer to a a user defined type. But I have Pointer[TF_Function] where TF_Function is a class defined CPointer. 20:09
And raku complains there's no acceptable method for TF_Function. It shouldn't be trying to call TF_Function, should it? 20:10
===SORRY!=== Error while compiling /home/mike/projects/raku-tensorflow/lib/Tensorflow/Native.pm6 20:11
An exception occurred while parameterizing Pointer
at /home/mike/projects/raku-tensorflow/lib/Tensorflow/Native.pm6:527
Exception details:
Cannot resolve caller ACCEPTS(Bool:U: Tensorflow::Native::TF_Function); none of these signatures match:
(Bool:D: Mu \topic, *%_)
(Bool:U: \topic, *%_)
in method parameterize at /usr/share/perl6/core/sources/8660F65A7B3492675BB3B2058DB30E411A4C4E54 (NativeCall::Types) line 80
tigerpaws method TF_GraphGetFunctions(TF_Graph $g # Typedef<TF_Graph>->«TF_Graph»* 20:12
,Pointer[TF_Function] $funcs # Typedef<TF_Function>->«TF_Function»**
,int32 $max_func # int
,TF_Status $status # Typedef<TF_Status>->«TF_Status»*
) is native(LIB) returns int32 is export { * }
[Coke] for big pastes, please use a service like gist.github.com 20:29
tigerpaws OK, I guess this means that Pointer will not accept TF_Function. No need fir further help.
[Coke] (nice thing about that is you can include all the source if you need to)
ok
tigerpaws @Coke, sorry, it started out smaller, and then grew. Thanks. 20:30
Geth ¦ problem-solving: lizmat assigned to jnthn Issue Writing BOMs for *all* utf16 encodings github.com/Raku/problem-solving/issues/197 20:42
Doc_Holliwood m: sub f { my $x = Nil; $x }; say f 20:54
camelia (Any)
Doc_Holliwood wtf?
skids docs.raku.org/type/Nil 20:58
[Coke] m: Nil.sort.flip.reverse # should this complain about Str or just keep returning Nil? 21:04
camelia Use of Nil in string context
in block <unit> at <tmp> line 1
skids .flip "Coerces the invocant (or in sub form, its argument) to Str" so thereby calls Nil.Str so it's documented to fail, in a roundabout way. 21:18
melezhik rba I pinged you ... 21:19
rba melezhik: pong 21:21
melezhik )))
skids (well OK even more roundabout... Seq.Str is documented via List.Str to Stringify the elements of the (Nil,) sequence that .sort generates.) 21:22
ragekagemage Anyone around that can help me poke around in the guts of moarvm and nqp? I'm trying to get moarvm to work correctly on openbsd without using the --no-jit flag, currently nqp core dumps as soon as it tries to use a jit enabled moarvm. 21:30
El_Che ragekagemage: in case you don't get an answer here, have a look at #raku-dev as well 21:50
jnthn ragekagemage: Does it core dump because of memory (executable) permissions needing different handling to other platforms? If so, you might want to look at github.com/MoarVM/MoarVM/blob/mast...six/mmap.c and its usage at github.com/MoarVM/MoarVM/blob/mast...ile.c#L167 21:57
I'm assuming that it follows POSIX calling conventions, but if not, there can be bother there too. 21:58
melezhik tyil[m], I saw this - github.com/rakudo/rakudo/blob/mast...elines.yml ... Interesting ... I've done a lot of stuff like this at my current @job 22:52
what is the reason of moving entire rakudo cicd towards Azure Devops? 22:53