»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or rakudo:, or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_logs/perl6 | UTF-8 is our friend!
Set by moritz on 22 December 2015.
00:04 Exodist left 00:05 Exodist joined, devmikey left 00:28 Cabanossi left 00:29 Cabanossi joined 00:30 lookatme joined
lookatme morning 00:30
00:31 bwisti left 00:51 kybr left 00:53 kybr joined 00:57 Cabanossi left 00:59 Cabanossi joined 01:00 mr-foobar left 01:01 mr-foobar joined 01:25 rubio_terra_ joined 01:28 wamba left 01:29 mr-foobar left
rubio_terra_ p6: my @a = 1,2; my @b[2;2] = ((1,2),(3,4)); constant @aa = 1,2; constant @bb[2;2] = ((1,2),(3,4)); 01:30
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing initializer on constant declaration
at <tmp>:1
------> 3(3,4)); constant @aa = 1,2; constant @bb7⏏5[2;2] = ((1,2),(3,4));
rubio_terra_ Why can't I declare a multi-dimensional array constant?
Is this by design?
01:32 mr-foobar joined
geekosaur I think there's still a fair amount of NYI with respect to shaped arrays at present 01:36
rubio_terra_ hmm 01:38
lookatme m: my @b[2;2] = ((1,2),(3,4)); 01:43
camelia ( no output )
lookatme m: my @b[2;2] = ((1,2),(3,4)); say @b[0][1]; 01:44
camelia Partially dimensioned views of shaped arrays not yet implemented. Sorry.
in block <unit> at <tmp> line 1
rubio_terra_ p6: my @a[2;2] = ((1,2),(3,4)); say @a[0;1]; 01:46
camelia 2
01:46 ilbot3 left 01:48 ilbot3 joined, ChanServ sets mode: +v ilbot3
rubio_terra_ m: constant @a = ((1,2),(3,4)); say @a[1;1]; 01:49
camelia 4
rubio_terra_ This works for me. :)
No need to use a shaped array.
01:55 mcmillhj joined 01:56 sufrostico left 01:57 Cabanossi left 02:00 Cabanossi joined, mcmillhj left, mr-foobar left 02:03 mr-foobar joined 02:05 spider-mario left
lookatme I think this is still a shaped array. 02:06
02:11 mcmillhj joined
rubio_terra_ It may be. But at least it works that way. 02:11
geekosaur actually "shaped" means the shape is part of the type. although in the case of a constant there may well not be much difference 02:13
02:13 giraffe joined 02:14 giraffe is now known as Guest89848 02:16 mcmillhj left
lookatme m: constant @a = ((1,2),(3,4)); say @a.shape; 02:17
camelia No such method 'shape' for invocant of type 'List'
in block <unit> at <tmp> line 1
lookatme m: my @a = ((1,2),(3,4)); say @a.shape; 02:18
camelia (*)
lookatme Oh, it's different
m: constant @a = "123123"; say @a; 02:19
camelia (123123)
02:22 ggoebel left 02:29 noganex joined 02:32 noganex_ left 02:46 mr-foobar left
BenGoldberg m: constant @a = ((1,2),(3,4)); dd @a 03:01
camelia ((1, 2), (3, 4))
BenGoldberg m: constant @a = ((1,2),(3,4)); say @a.WHAT
camelia (List)
BenGoldberg m: my @a[42]; dd @a
camelia Array.new(:shape(42,), [Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any])
BenGoldberg Oooh. 03:02
m: constant @a := Array.new: :shape(42,), ((1,2),(3,4)); dd @a;
camelia Array.new(:shape(42,), [(1, 2), (3, 4), Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any])
BenGoldberg m: constant @a := Array.new: :shape(42,), ((1,2),(3,4)); say @a.WHAT; 03:03
camelia (Array)
BenGoldberg m: constant @a := Array.new: :shape(42,), ((1,2),(3,4)); say @a.shape;
camelia (42)
BenGoldberg rubio_terra_, Multi dimensioned array constant ^ 03:04
m: constant @a := Array.new: :shape(2,2), ((1,2),(3,4)); say @a.shape;
camelia (2 2)
BenGoldberg m: constant @a := Array.new: :shape(2,2), ((1,2),(3,4)); dd @a;
camelia Array.new(:shape(2, 2), [1, 2], [3, 4])
BenGoldberg m: constant @a := Array.new: :shape(2,2), ((1,2),(3,4)); say @a[1][1];
camelia Partially dimensioned views of shaped arrays not yet implemented. Sorry.
in block <unit> at <tmp> line 1
BenGoldberg m: constant @a := Array.new: :shape(2,2), ((1,2),(3,4)); say @a[1;1];
camelia 4
03:05 mr-foobar joined 03:14 rubio_terra_ left 03:20 karabas joined
karabas p6: say reduce(&[<],0,0,1); say [<] 0,0,1 03:21
camelia True
False
03:23 skids left
kybr may this seems crazy, but is there an equivalent to clang-format for perl6? i write mostly c++ and i started forcing all my code to a particular standard on writes. 03:23
03:24 lizmat left
karabas p6: say reduce(&[<],0,0); say [<] 0,0 03:27
camelia False
False
karabas p6: say reduce(&[<],0,0,1); say [<] 0,0,1
camelia True
False
03:32 pilne left
BenGoldberg kybr, I think what you want is Perl6::Tidy 03:41
03:42 Cabanossi left 03:43 Cabanossi joined 03:47 zoll left
kybr BenGoldberg: cool. i see it here: github.com/drforr/perl6-Perl6-Tidy but `zef install Perl6::Tidy` fails: No candidates found matching identity: Perl6::Tidy 03:52
but cool. it's good to know that i'll be able to use it eventually. 03:53
04:10 lookatme left, lookatme joined 04:22 aindilis` joined 04:23 aindilis left 04:24 andrzejku joined 04:36 BenGoldberg left 04:40 Cabanossi left 04:43 Cabanossi joined 04:46 karabas left 04:52 xtreak joined, test joined 04:53 test is now known as Guest24676 04:55 Guest24676 left 04:57 test1 joined, nadim joined, test1 left 04:58 test1 joined, test1 left 05:04 nadim left 05:05 andrzejku left 05:13 andrzejku joined 05:15 nadim joined 05:22 khw left 05:37 xtreak left 05:38 xtreak joined 05:39 xtreak_ joined 05:42 xtreak left 05:44 dolmen joined, dolmen is now known as Guest92653 05:55 Cabanossi left 05:58 Cabanossi joined 06:11 ufobat joined 06:22 nadim left 06:32 domidumont joined 06:38 domidumont left, domidumont joined 06:51 lizmat joined 06:52 nadim joined, Guest92653 left 07:06 pecastro left 07:14 TreyHarris left 07:15 TreyHarris joined 07:18 darutoko joined, saison joined 07:23 pecastro joined
saison Hi, if i have a class that contains an array, is it possible to override the [] operator like you can in c++? 07:23
I managed to override the + operator, but couldn't get the [] index working :)
moritz saison: yes, see docs.perl6.org/language/subscripts#Custom_types 07:28
saison moritz: thanks! 07:30
07:36 dakkar joined, abraxxa joined 07:37 xtreak_ left, mr-foobar left, xtreak joined 07:39 Guest92653 joined, parv joined, xtreak left 07:40 xtreak joined 07:41 spider-mario joined 07:42 mr-foobar joined 07:46 wamba joined 07:47 domidumont left 07:51 saison left 07:55 Cabanossi left 07:57 Cabanossi joined 07:58 zakharyas joined 08:01 domidumont joined 08:16 andrzejku left 08:17 alexk joined
alexk camelia: help 08:17
camelia alexk: Usage: <(rakudo-moar|p5-to-p6|prof-m|star-m|debug-cat|nqp-js|rakudo-jvm|nqp-moarvm|nqp-jvm|nqp-q|r-j|sm|star|nom|nqp-m|p6|m|p56|rakudo|nqp-mvm|r-m|r-jvm|j|rj|perl6|rm|r|nqp)(?^::\s(?!OUTPUT)) $perl6_program>
moritz m: say 42 08:26
camelia 42
08:40 xtreak left, xtreak joined 08:41 xtreak left, xtreak joined 08:48 dwarring left 08:55 Cabanossi left 08:57 Cabanossi joined 08:59 pmurias joined 09:05 xtreak left 09:08 parv left 09:09 aindilis` left 09:10 aindilis joined 09:14 xtreak joined 09:23 imcsk8_ joined, imcsk8 left 09:24 mr-foobar left 09:25 mr-foobar joined 09:30 Guest92653 left, Guest92653 joined 09:31 Guest92653 left, lookatme left
alexk m: for ^500_000 { @ = 'a,b,c;d,e'.split(/<[,;]>/) }; say now - INIT now; 09:31
camelia (timeout)
alexk m: for ^100_000 { @ = 'a,b,c;d,e'.split(/<[,;]>/) }; say now - INIT now; 09:32
camelia 7.44574168
alexk m: use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.run(q|my @a; for my $i (1..500_000) { @a = split(/[,;]/, 'a,b,c;d,e,f')}|); say now - INIT now;
camelia 5===SORRY!5=== Error while compiling /home/camelia/site#sources/FC133D3E7EC3B0CBE238C296893894C9AB745A05 (Inline::Perl5)
An exception occurred while evaluating a constant
at /home/camelia/site#sources/FC133D3E7EC3B0CBE238C296893894C9AB745A05 (Inl…
09:33
alexk m: for ^500_000 { @ = 'a,b,c,d,e'.split(',') }; say now - INIT now; 09:34
camelia 6.61846318
alexk m: use nqp; for ^500_000 { @ = nqp::split(',', 'a,b,c,d,e') }; say now - INIT now; 09:35
camelia 3.2061412
alexk m: for ^400_000 { @ = 'a,b,c;d,e'.split(/<[,;]>/) }; say now - INIT now; 09:36
camelia (timeout) 09:37
timotimo m: for ^400_000 { @ = 'a,b,c;d,e'.split(",", ";") }; say now - INIT now
camelia Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5;' (indicated by ⏏)
in block <unit> at <tmp> line 1
jnthn I think split can also take an array of things to split on, to avoid the overhead of the regex engine 09:38
timotimo m: for ^400_000 { @ = 'a,b,c;d,e'.split([",", ";"]) }; say now - INIT now
camelia (timeout)
09:41 Cabanossi left 09:42 Cabanossi joined, rindolf joined 09:46 robertle joined
alexk m: for ^500_000 { @ = <a b c d e> }; say now - INIT now; 09:46
camelia 2.704391
nine On the one hand it's scary how advertisement is now so smart that I suddenly see lots of ads for KLM flights to Amsterdam on phoronix.com. On the other hand, how stupid is bombarding someone with ads for a product they already bought?
alexk m: use nqp; for ^500_000 { @ = nqp::split(',', 'a,b,c,d,e') }; say now - INIT now; 09:47
camelia 3.2437390
timotimo nine: you just bought this washing mashine. how about a second one? 09:49
alexk m: use nqp; for ^500_000 { nqp::split(',', 'a,b,c,d,e') }; say now - INIT now;
camelia 0.40678281 09:50
jnthn fwiw, nqp::split is marked as pure, and it's entirely possible one that loop gets hot then it's just not doing the split at all 09:52
'cus it can see the result is dead
m: use nqp; for ^500_000 { $ = nqp::split(',', 'a,b,c,d,e') }; say now - INIT now;
camelia 0.4182325
jnthn That makes sure it is being used (though it appears it actually was, I guess it was being returned and sunk) 09:53
Tad surprised it wasn't pulled out entirely though
09:55 andrzejku joined
alexk jnthn: the point int the example above is that the most time spent in the array assignment @ = ... 09:55
jnthn Yeah
It's going to cost something 'cus it has to allocate a Scalar container per item 09:56
timotimo and if you put the declaration of the scalar outside, it'll become a lexical access, which isn't cheap either 09:57
nine timotimo: yeah, who gets by without a high availability washing machine cluster these days?
jnthn Was just saying that if you have statements in void context, especially nqp:: ops, you need to be careful benchmarking because we do have stuff that will rip out instructions that are pure and produce an unused result 09:58
alexk m: use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.run(q|my @a; for (1..500_000) { @a = split(/[,;]/, 'a,b,c;d,e,f')}|); say now - INIT now; 10:05
camelia 5===SORRY!5=== Error while compiling /home/camelia/site#sources/FC133D3E7EC3B0CBE238C296893894C9AB745A05 (Inline::Perl5)
An exception occurred while evaluating a constant
at /home/camelia/site#sources/FC133D3E7EC3B0CBE238C296893894C9AB745A05 (Inl…
alexk m: use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.run('print 42;'); 10:09
camelia 5===SORRY!5=== Error while compiling /home/camelia/site#sources/FC133D3E7EC3B0CBE238C296893894C9AB745A05 (Inline::Perl5)
An exception occurred while evaluating a constant
at /home/camelia/site#sources/FC133D3E7EC3B0CBE238C296893894C9AB745A05 (Inl…
10:09 TEttinger left
jsimonet .tell Zoffix So the error is generated internally and not by my operation 3.3/0 => (33/10)/0 => ((33/0)/10)? Maybe the exception could be catched and generate another one which present 3.3 to the end user? 10:10
yoleaux jsimonet: I'll pass your message to Zoffix.
10:10 Zoffix joined
Zoffix . 10:10
yoleaux 10:10Z <jsimonet> Zoffix: So the error is generated internally and not by my operation 3.3/0 => (33/10)/0 => ((33/0)/10)? Maybe the exception could be catched and generate another one which present 3.3 to the end user?
Zoffix jsimonet: there's no 3.3 tho 10:11
jsimonet: the error is generated by .gist call on Rat that has 33 in numerator and zero in denominator
nine Darn...camelia's perl does not seem to be compiled with -fPIC anymore 10:12
Zoffix No catching is needed. Just a better exception can be through, like we do in Rational.ceiling: github.com/rakudo/rakudo/blob/nom/...pm#L73-L76 10:13
s/through/thrown/;
jsimonet Zoffix: my bad, ok thank you :) 10:15
Zoffix m: say (3.3/0).Int 10:17
camelia Attempt to divide by zerowhen coercing Rational to Int
in block <unit> at <tmp> line 1
Zoffix
.oO( you had one job... )
jsimonet I can thy to find and fix it :)
Zoffix jsimonet: the missing space is the `$_ with $.details` in this commit should be `" $_" with $.details`: github.com/rakudo/rakudo/commit/e2...fbf645597c 10:19
nine m: EVAL 'print "hello world"', :lang<Perl5> 10:20
camelia hello world
nine alexk: fixed it^^^
Zoffix jsimonet: And the poor error for the "division by 33" I think can be improved by doing the same exception throwing code as here github.com/rakudo/rakudo/blob/nom/...pm#L73-L76 but in method Str instead: github.com/rakudo/rakudo/blob/nom/...nal.pm#L86 10:21
alexk nine++
m: use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.run(q|my @a; for (1..500_000) { @a = split(/[,;]/, 'a,b,c;d,e,f')}|); say now - INIT now; 10:22
camelia 0.8041398
nine m: EVAL q|my @a; for (1..500_000) { @a = split(/[,;]/, 'a,b,c;d,e,f')}|, :lang<Perl5>; say now - INIT now; 10:23
camelia 1.0882945
nine m: EVAL q|my @a; for (1..500_000) { @a = split(/[,;]/, 'a,b,c;d,e,f')}|, :lang<Perl5>; say now - INIT now;
camelia 0.899915
nine I guess it's a bit higher as it measures the time to load Inline::Perl5, too 10:24
10:24 xtreak left
alexk nine: that's ok - just to get an idea how fast perl5's split is ... 10:26
nine ~ crazy fast? ;) 10:27
alexk yeah - especially compared to perl6's regex split ... 10:28
timotimo it's not news that perl6 regexes have gigantic overhead for start/stop 10:29
nine There's so much left to do in the compiler...
jnthn There always will be. :-) 10:30
Given the number PhDs earned each year coming up with shiny new optimization techniques :)
nine We could for example statically optimize a split(/[,;]/, 'a,b,c;d,e,f') to 'a,b,c;d,e,f'.split((',', ';')) 10:34
timotimo yeah if regexes kept around some more info about their contents 10:37
that'd also be nice for stuff like ~~ m/"foo"/ being turned into a .contains call 10:38
(same with starts-with and ends-with if there's a ^ or $)
(except some newline handling shenanigans
i guess)
10:38 Kaffe left
Zoffix ? what sort of shinanigans? 10:39
Perl 6's $ isn't magical like Perl 5, is it?
m: say "foo\n" ~~ /foo$/ 10:40
camelia Nil
timotimo ah, that's nice
10:53 mr-foobar left 10:57 mr-foobar joined, vendethiel left 10:59 vendethiel joined
sacomo hi all 11:03
11:09 zakharyas left
Juerd I used any() in method arguments for the first time. It's amazing how that let me express my thoughts in code with almost no translation 11:11
And especially, no annoying loop to distract me from what I was doing. 11:12
11:17 rurban joined 11:23 AlexDaniel left
Juerd Is there a way to filter output from put and say, similar to Perl 5's TIEHANDLE? 11:23
11:23 mr-fooba_ joined 11:24 mr-foobar left
timotimo you can override $*OUT, if you use "but" and a role you'll "keep" whatever was set before 11:28
i.e. if that was already a "magical" thing
11:29 emeric joined
Juerd Hm, overriding is a start. But how do I hijack the output to modify it? And can I still access the original $*OUT to prevent recursion? 11:35
timotimo you can make your role parametric and stash the original $*OUT in the parameter
my $*OUT = $*OUT but ChangedFrom[$*OUT];
lizmat timotimo: that won't work 11:36
m: my $*OUT = $*OUT; note $*OUT
camelia (Any)
lizmat it's a trap I got into recently myself
m: temp $*OUT = $*OUT; note $*OUT 11:37
camelia IO::Handle<IO::Special.new("<STDOUT>")>(opened)
timotimo ah, of course
that's better
m: role SaysParameter[$foo] { say $foo.perl ~ " is the parameter; }; temp $*OUT = $*OUT but SaysParameter[$*OUT] 11:38
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in double quotes; couldn't find final '"'
at <tmp>:1
------> 3p $*OUT = $*OUT but SaysParameter[$*OUT]7⏏5<EOL>
expecting any of:
postfix
timotimo m: role SaysParameter[$foo] { say $foo.perl ~ " is the parameter"; }; temp $*OUT = $*OUT but SaysParameter[$*OUT]
camelia IO::Handle.new(path => IO::Special.new("<STDOUT>"), chomp => Bool::True, nl-in => $["\n", "\r\n"], nl-out => "\n", encoding => "utf8") is the parameter
timotimo m: role SaysParameter[$foo] { say $foo.perl ~ " is the parameter"; }; temp $*OUT = $*OUT but SaysParameter[$*OUT]; say $*OUT.perl ~ " is the modified one"
camelia IO::Handle.new(path => IO::Special.new("<STDOUT>"), chomp => Bool::True, nl-in => $["\n", "\r\n"], nl-out => "\n", encoding => "utf8") is the parameter
IO::Handle+{SaysParameter[IO::Handle]}.new(path => IO::Special.new("<STDOUT>"), chomp => Bool::True,…
timotimo cool. 11:39
11:40 Cabanossi left
Juerd m: temp $*OUT = $*OUT but role { method print { die 42 } }; print "doesn't die" 11:42
camelia Too many positionals passed; expected 1 argument but got 2
in method print at <tmp> line 1
in block <unit> at <tmp> line 1
timotimo it's not guaranteed that the print sub translates to a print call on the $*OUT
11:43 Cabanossi joined
lizmat m: temp $*OUT = $*OUT but role { method print(|) { die 42 } }; print "doesn't die" 11:43
camelia 42
in method print at <tmp> line 1
in block <unit> at <tmp> line 1
timotimo currently the IO::Handle class isn't very friendly to subclass
oh, well, i guess that's that :)
Juerd Ooh, what is | called?
lizmat basically it's short for an unnamed capture
timotimo anonymous capture
Juerd And why does this work? :) 11:44
lizmat because sub print calls $*OUT.print ?
Juerd I mean, why does it work with (|) but not without?
lizmat because then you have a method that doesn't accept any parameters except the object 11:45
hence the "expected 1 but got 2"
Juerd Ah, right. Brain's still stuck in Perl 5 land regarding arguments sometimes
11:45 ufobat left
timotimo if you had used @_, it would have worked, no? 11:46
lizmat I believe you want sub print(*@_) { } then
Juerd And the 1 but got 2 thing doesn't fully register because the invocant is counted too :)
Ran into that a few times, can't get used to it :(
lizmat yeah, actually, that feels like an LTA error message
because the error message *does* know it's about a method 11:47
11:48 noganex left 11:50 noganex joined
Juerd Hah, the "$*OUT but" thing actually works 11:50
m: role x[$p] { method print(Str:D $x) { $p.print($x.subst(" ", "-", :global)) } }; temp $*OUT = $*OUT but x[$*OUT]; print "first test"; say "second test"; put "third test";
camelia first-testsecond-test
third-test
Juerd And all this because I need a feature in ansi escape sequences that doesn't exist: restore previous color. 11:51
So I'll just parse the string, keep a stack and pop that with a custom ansi-ish escape. 11:52
There's not inverse 'when', is there? 11:54
I have a few ugly "when $_ !~~ ..."
I guess I could do "when none ..." 11:55
moritz
.oO( unwhen )
11:59
jnthn m: for 'foo', 'bar' { when !/a/ { say 42 }; default { say 0 } } 12:00
camelia 42
0
jnthn Since /a/ in boolean context evaluates against $_ then you can just negate the result 12:01
m: for 'foo', 'bar' { when not /a/ { say 42 }; default { say 0 } }
camelia 42
0
jnthn Or that if you prefer it longer :)
12:11 Cabanossi left 12:12 araraloren joined 12:13 Cabanossi joined 12:19 zakharyas joined 12:22 lucasb joined
Juerd jnthn: That works for regexes, not for classes :) 12:24
s/classes/types/
jnthn ah, you didn't even mention a regex :) 12:25
moritz for types, none(Str) works
Juerd moritz: I think it works for everything?
jnthn Not sure why I conclueded that :)
moritz Juerd: presumably, yes
12:29 ufobat joined 12:38 brabo left, brabo joined 12:44 astj left 12:45 astj joined 12:47 astj left, astj joined 12:50 mcmillhj joined 12:54 xtreak joined, astj left 12:57 Cabanossi left 12:58 astj joined, Cabanossi joined
rindolf Hi all! github.com/shlomif/perl6-examples/...shlomif.p6 is really slow - why? And what can be done about it? 12:59
13:00 astj left, ufobat left
rindolf github.com/shlomif/project-euler/b...43_v2.bash - this equivalent program in bash and perl 5 is much faster 13:02
moritz rindolf: donate to www.perlfoundation.org/perl_6_core_...pment_fund 13:05
jnthn Perhaps use native types in factor
13:06 xtreak left 13:08 astj joined
rindolf jnthn: ah 13:08
13:08 raschipi left
jnthn But yeah, otherwise there's no much for it except letting the optimizer get better at dealing with non-native integer stuff 13:09
rindolf jnthn: docs.perl6.org/type.html - do you mean "int"? 13:10
jnthn Yes
rindolf jnthn: ok
13:10 xtreak joined
perlpilot rindolf: btw, no need for parens around your conditionals. (I only mention it because it looks weird to me now :) 13:12
13:12 astj left
rindolf perlpilot: ok 13:12
13:12 rurban left
rindolf jnthn: ok - converted to "int" - it is still very slow - github.com/shlomif/perl6-examples/...shlomif.p6 - hit reload 13:19
13:31 cdg joined 13:34 xtreak left
lucasb rindolf: maybe drop the "return" word 13:35
is that still a thing in rakudo or it has been optimized?
13:36 rurban joined 13:37 alexk left
perlpilot rindolf: Here's that shell+P5 version converted to shell+P6: gist.github.com/perlpilot/434bea65...09e4bf6dc6 by my timing, it's slightly faster than the P5 version, but that's probably noise. 13:38
rindolf perlpilot: i see 13:39
lucasb perlpilot: maybe you like the style, but I'm just pointing out that you don't need the extra backslash at "... | factor | \" :) 13:40
perlpilot rindolf: btw, did you try profiling your pure Perl 6 version? 13:41
13:41 skids joined
rindolf perlpilot: i did 13:41
perlpilot lucasb: nah, I just copied rindolf's and changed stuff. He had the \ :)
lucasb ah :)
13:41 spider-mario left 13:42 Cabanossi left
Juerd Is there a way to determine whether an exception is a built-in Perl 6 exception type? 13:42
13:43 Cabanossi joined, spider-mario joined 13:44 astj joined
perlpilot Juerd: I doubt it. 13:44
moritz Juerd: not really; that's rarely a useful distinction
perlpilot Juerd: I guess you could grep rakudo/src/core/Exception.pm to see if it appears there 13:45
Juerd moritz: I think it is. The built-in ones indicate programming errors, whereas the ones I add are mostly user errors.
moritz maybe you can look at CORE:: if it's in there somewhere
Juerd perlpilot: Yep, did do that. They all just inherit from Exception only
Of course, I can decorate my own exceptions. Was just curious if I had to 13:46
lucasb maybe differentiate the ones that are under the "X::" namespace and those that are not 13:47
Juerd lucasb: That's harder because smart matching doesn't do prefixes or wildcards :) 13:48
perlpilot lucasb: sure, that would be by convention though ... nothing stopping someone from violating that convention. (might really matter when it's a 3rd party lib that does so)
Juerd In my current use case, the difference between X::AdHoc and everything else is good enough
13:48 astj left
Juerd Where I'm assuming that all "die Str" are user input errors, and the rest are unexpected. 13:49
lizmat we have some die's still in core though :-( 13:51
Juerd Oh :(
I'll probably create my own exception type with some syntactic sugar then
lizmat it appears freenode is going to do something new: freenode.net/news/freenode-live 13:52
perhaps something for #perl6 people to show up for? freenode.net/news/freenode-live-exhibit
13:54 ufobat joined
lizmat afk for a bit& 13:54
13:54 lizmat left
rindolf perlpilot: the Perl 5 translation of my p6 code is also slow - github.com/shlomif/project-euler/b...shlomif.pl 14:00
perlpilot: thanks!
14:02 bob777 joined 14:06 bob777 left 14:08 cdg left 14:16 dakkar left, dakkar joined 14:28 domidumont1 joined 14:30 domidumont left 14:31 rurban left 14:47 ChoHag left
araraloren Can anyone use MAC help me ? What's the value of $*KERNEL under OSX ? 14:50
gdonald darwin (16.6.0) 14:53
araraloren gdonald, thanks 14:54
15:01 nadim left 15:04 donaldh joined 15:09 cdg joined, geekosaur left 15:10 geekosaur joined, mr-fooba_ left 15:12 mr-foobar joined 15:14 cdg left 15:20 bwisti joined
hythm hello perl6, I'm working in a file parsing program, wrote Grammar actions class with a hash attribute, and wrote the action method that is called after each line to insert into the hash. I can print the hash content from the method, but when I print it from MAIN it's empty. 15:21
what am i missing? here is the code gist.github.com/hythm7/f80b2d291df...437b72fcef
timotimo i suggest you leave out passing "my %logs" to LogActions.new (so that a new hash gets created for you in the actions class) and then grab it out using the action class' .logs method 15:23
moritz hythm: you seem to be doing a weird mixture of passing around hashes but also modifying a shared hash. I suggest you settle for one paradigma (preferrably returning data instead of mutating it in place)
15:24 astj joined
hythm timotimo makes sense, trying that now 15:25
moritz, i think you are right, this weird mixture is probably due to not fully understand this part of passing data yet, i need to read more on that 15:28
15:29 domidumont joined, astj left 15:30 astj joined 15:31 domidumont1 left, AlexDaniel joined 15:33 astj left 15:34 astj joined 15:41 Cabanossi left, hoelzro left 15:42 mr-foobar left, hoelzro joined, mr-foobar joined 15:43 Cabanossi joined 15:48 dakkar left 15:53 cdg joined, donaldh left 15:54 abraxxa left, ChoHag joined
Zoffix araraloren: note that $*KERNEL is an object, not a string. 15:56
m: $*KERNEL.^methods.say
camelia (BUILD name version release hardware arch archname bits signals signal Str gist auth signature desc)
15:59 araraloren left, araraloren joined
moritz m: say $*KERNEL.^name 16:03
camelia Kernel
16:05 astj left, ChoHag left 16:06 zakharyas left 16:08 zakharyas joined 16:12 rurban joined, Cabanossi left, mr-foobar left, Cabanossi joined 16:13 mr-foobar joined 16:14 domidumont left
araraloren .tell Zoffix Got it, thanks! 16:14
yoleaux araraloren: I'll pass your message to Zoffix.
Zoffix . 16:15
yoleaux 16:14Z <araraloren> Zoffix: Got it, thanks!
araraloren m: say $*KERNEL
camelia linux (4.4.70.18.9.default)
16:15 domidumont joined
araraloren m: say $*KERNEL.WHAT 16:15
camelia (Kernel)
araraloren m: say "maybe linux ?" if $*KERNEL ~~ /^linux/ 16:16
camelia maybe linux ?
araraloren Night!
Good night.
Zoffix m: say "maybe linux ?" if $*KERNEL.name eq 'linux';
camelia maybe linux ?
16:16 araraloren left, astj joined 16:22 mcmillhj left 16:26 mr-foobar left 16:28 domidumont left 16:31 mr-foobar joined 16:33 lizmat joined, robertle left 16:41 mr_ron joined 16:42 Cabanossi left, Cabanossi joined 16:46 setty1 joined
mr_ron I am interested in learning a bit about garbage collection. Yesterday I showed a MoarVM memory panic on #perl6-dev - irclog.perlgeek.de/perl6-dev/2017-...i_14893012 . I reproduced it on my system and it looks like the concatenation just keeps gobbling memory, never frees and eventually runs out. In this case when memory runs out shouldn't the GC try to recover some? 16:46
ugexe if memory runs out what memory would the GC use to recover memory? 16:47
mr_ron The total string length is 7_000_000 characters and the ulimit is 1 GB 16:48
16:50 ChoHag joined 16:52 zakharyas left, andrzejku_ joined
mr_ron I guess I am not clear on whether the problem is a memory leak of some kind or a GC failure 16:52
16:54 andrzejku left
ugexe if you run with `perl6-valgrind-m` it might give you some insight 16:56
16:57 mr-fooba_ joined, andrzejku joined 16:58 mcmillhj joined, mr-foobar left 16:59 andrzejku_ left
mr_ron never ran valgrind before but just installed and trying ... 17:02
ugexe gist.github.com/ugexe/f0b471d176de...804f5bca09 <- this is the summary I got from it, although I'm not sure what to extrapolate from it 17:03
17:06 robertle joined
hythm timotimo when I understood that part of not passing %log to the Actions class and made the change in the gist, but what I dont understand is how to grab %logs out, If I used LogActions.new.logs it will be empty because it creates a new object. 17:07
timotimo right, you will want to store your LogActions.new in a variable, pass it to the parse call and later grab $my-log-actions.logs to get the hash 17:08
hythm aaah
right
thanks
17:11 ChoHag left, mr-fooba_ left 17:13 mr-foobar joined
hythm worked :) 17:13
mr_ron ugexe: your gist seems to show 10GB of heap usage. Looks like a problem. No? 17:16
17:22 Util joined
ugexe i just reran after building with a rakudo built from HEAD and it was `2,093,230,194 bytes allocated` with the same number allocs and frees 17:26
approx the same anyway
mr_ron If I set a "ulimit -v 1024000" the in use at exit goes way up to 1/2 GB. Maybe the in use at exit if it runs to completion allows for freeing some extra memory. 17:29
ugexe probably samcv's recent commits in moarvm are responsible for the reduced bytes allocated github.com/MoarVM/MoarVM/commits/master 17:30
timotimo is working on something 17:31
mr_ron doing rakudobrew build moar now .. don't know if that will get those commits ...
ugexe no no, rakudobrew build moar-blead 17:32
mr_ron thx
ugexe and if you ever want to update moar-blead, always do `rakudobrew nuke moar-blead` before doing `rakudobrew build moar-blead` again 17:33
timotimo mr_ron: what real-world code are you trying to simulate with this repeated concatenation benchmark? 17:34
ugexe he is tryign to learn about garbage collection 17:35
timotimo ah
mr_ron There is no real world use case. Perl 5 has no problems here. For large cases p6 is much slower and runs out of memory. 17:36
Cannot build Rakudo with backend 'moar-bleed': this backend does not exist.
ugexe blead, not bleed
mr_ron thx
timotimo i just put in something very similar to what we have for bigints that causes GC to run more often when huge objects are created 17:37
the thing is that the GC-managed portion of the MVMString is the same size no matter how many characters are in it 17:38
so we have to teach the GC to count some extra for such big objects
anyway, 500_000 still takes ages
memory usage sawtooths like crazy 17:39
17:40 cdg_ joined, lucasb left
timotimo 500000: 586.6925867 17:41
462.79user 118.04system 9:46.97elapsed 98%CPU (0avgtext+0avgdata 5392876maxresident)k
so "only" 5 gigs 17:42
17:42 cdg left
timotimo running it without that stuff to see how many iterations it survives and when it reaches the same memory usage 17:44
ugexe its significantly faster and uses less memory if you type the $x and $y to str
timotimo interesting
ugexe 5.5s vs 0.2s for me on 50k 17:46
timotimo oh wow
can you --profile that at all?
ugexe just add --profile?
timotimo yeah
mr_ron you mean my - yes what do you want "--profile"d
s/my/me 17:47
ugexe m: for (50_000) -> $limit {my str $x; my str $y = "x" x 100; $x ~= $y for (1..$limit); say "$limit: ", now - ENTER now}
camelia 50000: 0.062815
timotimo i think it touched the 5 gigs just now, but htop didn't refresh often enough to see
at like 370k 17:48
ugexe m: for (50_000) -> $limit {my Str $x; my Str $y = "x" x 100; $x ~= $y for (1..$limit); say "$limit: ", now - ENTER now}
camelia 50000: 6.2019572
timotimo yeah, it takes 410k to reach the same amount of ram that it tops out at with my patch 17:49
um, what 17:51
with str instead of Str it finishes using just 80368maxresidentk
17:51 eyck left
timotimo that's 80 megs 17:51
17:56 gdonald left
mr_ron is "MoarVM version 2017.07-6-ga739fc8" blead? 17:58
ugexe yes
my $x; my str $y; is all that is needed 18:01
timotimo seems so 18:02
18:05 rackstraw joined
mr_ron "my str $y" works for me but with blead and a count of 100_000 (without str $y) valgrind shows "in use at exit 2 GB" with the MoarVM panic 18:05
18:05 |oLa| joined 18:06 rackstraw left
mr_ron I need to move on to other things right now but but thank you both for all of the insights. 18:07
timotimo 99% time spent in collapse_strands
mr_ron timotimo: was your biting thing a MoarVM issue or an RT ticket?
timotimo: was your bigint thing a MoarVM issue or an RT ticket? 18:08
18:08 gdonald joined
timotimo i can push it as a branch 18:08
ugexe "💩 " x 100 triples the time with Str, but it stays the same with str too 18:09
mr_ron I'll review the logs tomorrow and try and decide if an RT ticket still makes sense. Thanks again. 18:11
Juerd Is $foo.+method supposed to call multiple candidates of multi methods? 18:12
If not, I think the documentation is inaccurate.
If so, I think it's broken.
18:13 mr-foobar left, ChoHag joined 18:14 mr-foobar joined
timotimo For any method name, there may be some number of candidate methods that could handle the request: typically, inherited methods or multi variants. The ordinary "dot" operator dispatches to a method in the standard fashion. There are also "dot" variants that call some number of methods with the same name: 18:15
$object.+meth(@args) # calls all methods (1 or more, die if none) 18:16
ugexe m: role Bar { method xxx($a) { say $a * 2 } }; class Foo { method xxx($a) { say $a } }; my $foo = Foo.new; $foo does Bar; $foo.+xxx(1) 18:17
camelia 2
1
jnthn .? and .+ and .* are just about the MRO 18:24
.+ and .* will call a candidate that it finds at each level of the MRO 18:25
Multi-dispatch is orthogonal to this. In each class with multi candidates, there is a proto method that dispatches to the appropriate candidate
The proto if not present being produced by cloning the one in a parent class, if relevant 18:26
Or making a new one with an empty candidate list otherwise
18:32 ChoHag left
Juerd Thanks for the explanation, I'll file a doc bug 18:33
18:34 AlexDaniel left 18:37 nadim joined, _4d47 joined
Juerd Done: github.com/perl6/doc/issues/1421 18:38
nine I don't get this. I have a BOOTStr (i.e. a P6Str) in NQP. I unbox_s it, yet it still remains nqp::isstr? How do I get at the darn string? 18:46
timotimo but if you have nqp::isstr it already is a string? 18:47
nine Apparently not. The isstr op seems to check for P6str: GET_REG(cur_op, 0).i64 = obj && REPR(obj)->ID == MVM_REPR_ID_P6str ? 1 : 0; 18:48
jnthn nine: nqp::isstr takes an object, so if you nqp::isstr(nqp::unbox_s($s)) then it will box the result of the unbox
nine Also if I $err.print() it, it complains about the string being NULL
jnthn nqp::isnull_s(nqp::unbox_s($s)) will tell you if a null string got boxed, if that's what you're after
nine Ah isnull_s! 18:49
Zoffix nine: ah, right, I should've mentioned the latest code in nqp for that area isn't doing much :} along with needing nqp::isnull_s instead of nqp::isnull that nqp::can($error, 'message') is always false 18:51
nine Zoffix: yeah, because it's not the $error but $error's payload we need to check 18:52
Fix pushed 18:54
Zoffix huh :|
18:55 _4d47 left
Zoffix I don't get how that works. 18:56
nine Does it at least work?
Zoffix You didn't test? :)
nine I did with the one test case :) 18:57
Zoffix Ok then :)
I thought $error was nqp-type exception, not Exception.pm6 exception 18:58
timotimo maybe through the P6EX mechanism?
Zoffix timotimo: where is it?
Geth ecosystem: 3abfcbdb8b | (Tony O'Dell)++ (committed using GitHub Web editor) | META.list
Add YAML::Parser::LibYAML
Zoffix I see this github.com/rakudo/rakudo/blob/nom/...#L343-L355 19:00
Well, I'm disappointed such an easy fix eluded me last night :)
nine++
nine Well it's a small fix, but the isnull_s thing made it not exactly easy 19:02
jnthn++ # without that hint, I'd still scratch my head :)
Juerd What would be an idiomatic way to call multiple candidates of a multi method? 19:03
19:03 mr_ron left 19:05 mr_ron joined 19:06 |oLa| left 19:11 mr-fooba_ joined
Zoffix nine: that makes me feel even worse, because both the nqp::null was added by my hand AND last night I found out it was supposed to be nqp::null_s, but because changing that alone didn't fix the original problem I never commited it :P 19:11
19:11 dct joined 19:13 mr-foobar left
Zoffix Juerd: call why? 19:14
m: multi x(Int) { say "Int" }; multi x(Cool) { say "Cool" }; multi x(Any) { say "Any" }; $_(42) for &x.cando(\(42))
camelia Int
Cool
Any
Zoffix I've no idea what you're trying to do 19:15
Juerd I have a bunch of objects, and am doing things based on a role
19:16 nhywyll joined
Juerd I built it the wrong way around, and instead of having methods in the roles, I was trying to do a multi method somewhere else 19:16
It did make me curious if that could have worked. Apparently, it could :)
Hm, I can't do it with methods in the roles because that wouldn't compose...
Meh.
Some objects will do multiple roles 19:17
19:17 darutoko left
Juerd I currently do this: gist.github.com/Juerd/b26ab3fbb704...1b9ba429ad 19:21
ugexe m: role Bar { method xxx($a) { say $a * 2 } }; role Baz { method xxx($a) { say $a * 3 }; }; class Foo { method xxx($a) { say $a } }; my $foo = Foo.new; ($foo does Bar) does Baz; $foo.+xxx(1)
camelia 3
2
1
19:22 pecastro left
Juerd I don't understand why that works 19:22
19:24 |oLa| joined
nine Zoffix: well, all's well that ends well :) 19:26
hythm m: class TestActions { method TOP ($/) { say so "abc" ~~ /abc/ } }; TestActions.new.TOP($/) 19:27
camelia Cannot assign to a readonly variable ($/) or a value
in method TOP at <tmp> line 1
in block <unit> at <tmp> line 1
hythm I understand that it's trying to assign $/ which is already in TOP scope, but how to match against regex inside grammar actions method? 19:28
jnthn Call the parameter something else 19:29
Zoffix m: class TestActions { method TOP ($foo) { say so "abc" ~~ /abc/ } }; TestActions.new.TOP($/) 19:30
camelia True
jnthn (Also, it's a bit of a code smell to be doing parsing in the actions, that would ideally have been taken care of in the grammar.)
Zoffix And access stuff via $foo<bar> instead of $<bar>
jnthn Juerd: Works because each mixin is a new level of inheritance
shopping & 19:31
Juerd jnthn: I thought roles didn't do inheritance. Apparently they sometimes do?
19:33 khw joined, pecastro joined 19:35 cpage_ left
ugexe consider the difference with `($foo does Bar) does Baz` and `$foo does (Bar,Baz)` 19:35
Juerd Hmm 19:36
hythm Thank you jnth and zoffix, that fixed the problem. looking now onto making grammar take care of that match better 19:39
19:46 pecastro left 19:52 ufobat left 20:00 lizmat left 20:02 Morfent joined, spider-mario left 20:12 TEttinger joined
jnthn Juerd: The role itself is composed rather than inherited. The `does` trait (in class C does R { }) composes the role into the class. The `does` infix operator performs a runtime mixin, meaning it creates an anonymous subclass of the type of the LHS, composes the role into that subclass, and then changes the type of the object to that new anonymous subclass. 20:19
class C does R1 does R2 { } will detect conflicts between R1 and R2; $x does (R1, R2) will do similar (it only creates one anon subclass and composes the roles into both) 20:20
Juerd I didn't know the difference between 'does' as a trait and 'does' as an infix was so big 20:21
20:22 rurban left
jnthn They're both composing roles into something, just in one case it's the class being declared (compile time) and in the other case into an individual object (runtime). 20:25
And the latter is done by the very same mechanism as the first, it's just an anonymous subclass they're being composed into 20:26
But it runs the same composition code otherwise :)
bbiab 20:27
20:29 mr_ron left
Juerd When is a package defined? I'm getting "The following packages were stubbed but not defined", but I have classes for them. 20:32
I'm able to work around my circular dependencies with 'augment' but it feels icky :D 20:37
20:43 dct left
nadim goood evening, can someone, who preferably knows html, have a look at this file drive.google.com/open?id=0B2cpZf_W...XdvX0hKSkE it's a rendering of a data dump, three actually 20:45
I'd like to know if it is possible to avoid the blue border around the button once it is clicked
also when an element of the structure is folded, it is not easy to see that it is folded, don't really know how to make folded data look like folded data, ideas welcome 20:46
20:49 Morfent left 20:50 Morfent joined 20:52 Mrofnet joined, Morfent left 20:59 spider-mario joined 21:00 mr-fooba_ left, pecastro joined 21:01 Mrofnet left, Mrofnet joined 21:05 mr-foobar joined 21:06 skids left 21:07 Mrofnet left, TEttinger left 21:09 eyck joined 21:10 mcmillhj left, Cabanossi left 21:12 Cabanossi joined 21:15 mr-foobar left, mcmillhj joined, mr-foobar joined 21:20 mcmillhj left 21:28 g41j1n joined 21:29 mr-fooba_ joined, mr-foobar left 21:50 lizmat joined 21:58 mcmillhj joined 22:02 setty1 left 22:03 mcmillhj left 22:09 emeric left 22:14 mcmillhj joined, mr-fooba_ left 22:16 cdg_ left 22:18 mcmillhj left 22:20 mr-foobar joined 22:24 mr-foobar left 22:28 mr-foobar joined 22:29 nhywyll left 22:31 gdonald left 22:34 cpage_ joined 22:43 BenGoldberg joined 22:44 gdonald joined 22:47 cpage_ left 22:49 cpage_ joined 22:52 pmurias left 23:09 zoll joined 23:19 itaipu joined 23:35 TEttinger joined 23:39 skids joined 23:40 rindolf left 23:46 AlexDaniel joined 23:54 pilne joined 23:56 Cabanossi left 23:57 Cabanossi joined