»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_log/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 July 2018.
timotimo oh, right 00:00
that happens when it doesn't return
i mean when the "if" condition doesn't trigger
you could have an else { %( ) } for example
needs the space in between, for reasons
Herby_ gotcha, that fixed the error 00:02
Herby_ first time seeing this site, pretty neat: tio.run/#perl6 01:04
timotimo yup, it's cool 01:07
vrurg Hm... How could I find out what causes rakudo to freeze at parse stage?? 01:32
[Coke] the tio site just dies here when I enter code and hit play. 01:39
Could not open . Failed to stat file: no such file or directory
Herby__ releasable6: status 01:58
releasable6 Herby__, Next release in ≈9 days and ≈17 hours. 1 blocker. 0 out of 38 commits logged
Herby__, Details: gist.github.com/5107cab8dc2b45f044...c14858ca54
MasterDuke vrurg: the moarvm debugserver perhaps 02:46
MasterDuke [Coke]: works for me 02:49
moritz good morning 06:33
Geth doc: d3a3cc06c4 | (JJ Merelo)++ | doc/Type/IO/Handle.pod6
Fixes error, closes #2297
06:47
synopsebot Link: doc.perl6.org/type/IO::Handle
El_Che hi moritz 07:06
Geth doc: bollwarm++ created pull request #2298:
doc translation for Chinese
10:59
Voldenet m: for 97 -> $n is copy { say $n ~ elems gather { take $n = $n % 2 == 0 ?? $n/2 !! 3 * $n + 1 while $n > 1 } } 11:05
camelia 1118
Voldenet m: for 97 -> $n is copy { say $n ~ "" ~ elems gather { take $n = $n % 2 == 0 ?? $n/2 !! 3 * $n + 1 while $n > 1 } }
camelia 97118
Voldenet I wish I knew why.
Voldenet order of evaluation isn't specified, right? 11:06
moritz m: for 97 -> $n is copy { say $n ~ "" ~ elems gather { take 0+($n = $n % 2 == 0 ?? $n/2 !! 3 * $n + 1) while $n > 1 } 11:50
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3 0 ?? $n/2 !! 3 * $n + 1) while $n > 1 }7⏏5<EOL>
expecting any of:
postfix
statement end
moritz m: for 97 -> $n is copy { say $n ~ "" ~ elems gather { take 0+($n = $n % 2 == 0 ?? $n/2 !! 3 * $n + 1) while $n > 1 } }
camelia 97118
moritz m: say 97, { $_ %% 2 ?? $_ / 2 !! 3 $_ + } ... 0 11:58
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3say 97, { $_ %% 2 ?? $_ / 2 !! 37⏏5 $_ + } ... 0
expecting any of:
infix
infix stopper
statement end
state…
moritz m: say 97, { $_ %% 2 ?? $_ / 2 !! 3*$_ + } ... 0
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing required term after infix
at <tmp>:1
------> 3say 97, { $_ %% 2 ?? $_ / 2 !! 3*$_ + 7⏏5} ... 0
expecting any of:
prefix
term
moritz m: say 97, { $_ %% 2 ?? $_ / 2 !! 3*$_ + 1} ... 0
camelia (97 292 146 73 220 110 55 166 83 250 125 376 188 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 3…
moritz m: say join '', 97, { $_ %% 2 ?? $_ / 2 !! 3*$_ + 1} ... 0
camelia
moritz m: say join '', flat 97, { $_ %% 2 ?? $_ / 2 !! 3*$_ + 1} ... 0 11:59
camelia (timeout)
moritz m: say elems 97, { $_ %% 2 ?? $_ / 2 !! 3*$_ + 1} ... 0
camelia (signal XCPU) 11:59
lichtkind is the a way to ask if an optional parameter was used or not? 12:08
Voldenet m: sub x(:$optional) { say "optional value was used" if $optional.defined; say "call"; }; x(); x(:optional); x(:optional(42)) 12:16
camelia call
optional value was used
call
optional value was used
call
moritz if you care whether an Any was passed in, you can also use a senteniel value 12:27
m: my $GUARD := Any.new; sub x($o = $GUARD) { say $o === $GUARD ?? 'not passed' !! 'passed' }; say x(); x(Any); x(42); 12:28
camelia not passed
True
passed
passed
uzl good morning! 13:44
m: my %nums = %(flat 'a'..'b' Z 1..2); for %nums.values -> $v is rw { $v += 10 }; say %nums;
camelia {a => 11, b => 12}
uzl m: my %nums = %(flat 'a'..'b' Z 1..2); for %nums.values <-> $v { $v += 10 }; say %nums;
camelia {a => 11, b => 12}
uzl '-> $v is rw' and '<-> $v' achieves the same thing in this example. Are they truly equivalent? Can they be used interchangeably? 13:47
timotimo m: say (-> $a is rw { }).perl; say (<-> $a { }).perl 13:50
camelia -> $a is rw { #`(Block|55888984) ... }
-> $a is rw { #`(Block|56150400) ... }
uzl So both of them are just Blocks? 13:51
timotimo well, yeah, but the important bit is the signature i thought?
uzl I was curious because '<->' wasn't mentioned in docs.perl6.org/language/hashmap#In..._of_values and they seem to achieve the same thing. 13:53
lichtkind why does $m.gist() does fall back to $m.perl even there is a gist method (with 2 optional parameter?) 13:54
moritz lichtkind: sounds like there's an error in there somewhere; can you provide a minimal example to reproduce that? 14:01
m: class A { method perl { 'perl' }; method gist($a?, $b?) { 'gist' }}; A.new.gist()
camelia ( no output )
moritz m: class A { method perl { 'perl' }; method gist($a?, $b?) { 'gist' }}; say A.new.gist()
camelia gist
moritz seems to work
lichtkind moritz, yes i had a typo in it, however looks I also found a bug, because when i opt type contrains it work: multi method gist(Math::Matrix:D: Int:D :$max-chars?, Int:D :$max-rows? --> Str) { 14:16
moritz, i meant when i leave out the Int:D 14:17
timotimo that's because :D constraints and optional parameters don't mix well 14:18
when you don't give it a max-rows, for example, it'll be the default value, which is Int, which doesn't pass the type check against Int:D
lichtkind timotimo, good point thanks but when i give them defaul values then i cant know if I got any params 14:28
timotimo there's a way, but you might not like it 14:29
moritz lichtkind: you could give default values that don't make much sense otherwise, like -42 14:30
lichtkind timotimo, i afraid so and yes moritz true but I still dont like it 14:31
i think i rather drop the :D 14:32
timotimo what you can do is this:
m: class Foo { role SentinelRole { }; constant $sentinel = 42 but SentinelRole; method gimme-an-arg-maybe(Int:D :$foo = $sentinel) { if $foo =:= $sentinel { say "no arg given" } else { say "arg given" } }; Foo.new.gimme-an-arg-maybe(); 14:33
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3iven" } }; Foo.new.gimme-an-arg-maybe();7⏏5<EOL>
timotimo m: class Foo { role SentinelRole { }; constant $sentinel = 42 but SentinelRole; method gimme-an-arg-maybe(Int:D :$foo = $sentinel) { if $foo =:= $sentinel { say "no arg given" } else { say "arg given" } } }; Foo.new.gimme-an-arg-maybe();
camelia no arg given
timotimo m: class Foo { role SentinelRole { }; constant $sentinel = 42 but SentinelRole; method gimme-an-arg-maybe(Int:D :$foo = $sentinel) { if $foo =:= $sentinel { say "no arg given" } else { say "arg given" } } }; Foo.new.gimme-an-arg-maybe(42);
camelia Too many positionals passed; expected 1 argument but got 2
in method gimme-an-arg-maybe at <tmp> line 1
in block <unit> at <tmp> line 1
timotimo m: class Foo { role SentinelRole { }; constant $sentinel = 42 but SentinelRole; method gimme-an-arg-maybe(Int:D :$foo = $sentinel) { if $foo =:= $sentinel { say "no arg given" } else { say "arg given" } } }; Foo.new.gimme-an-arg-maybe(foo => 42); 14:34
camelia arg given
timotimo that's "a default value that doesn't make much sense", and also not easily reachable for your users
lichtkind timotimo, i appreciate your effort greatly but to me its cleaner just ignore the case where people just give me niesensical type object, but my current solution is not clean either because definedness is irrelevant but rather if calue is in certain range since there are also nonesensical ints i have to reject that would make the output of gist idiotic 14:44
timotimo sounds like a "where" clause with a Range 14:46
timotimo there's a helper module for type constraints + where clauses btw 14:46
oh, did i remember wrong? 14:47
perhaps 14:50
lichtkind timotimo, never seen such module 14:54
Herby_ o/ 15:07
lichtkind hai Herby_ 15:23
lichtkind timotimo, you think its worth file an issue for that problem? 15:24
TimToady lichtkind: there's already an issue for it: R#2073 16:05
synopsebot R#2073 [open]: github.com/rakudo/rakudo/issues/2073 [6.d review][@LARRY] Bad propspec: Enum's :D accepts Enum's :U
lichtkind TimToady, thank you Larry 16:06
TimToady the title of which is slightly undergeneralized
donaldh I wrote a short followup to brrt's excellent 'Curious Benchmark' blog - gist.github.com/donaldh/87441392c2...-twist-org 16:18
donaldh Rat and FatRat are _really_ slow 16:19
El_Che weekly: gist.github.com/donaldh/87441392c2...-twist-org 16:25
notable6 El_Che, Noted!
Herby_ donaldh: nice write-up! 16:34
vrurg Is camelia starting new perl6 for every request? I'd like to do a test which would most definitely freeze the compiler.
lichtkind oh btw where I should report tht im new maintainer of module and my fork should be official? 16:36
donaldh Is it possible to include nqp::* calls in perl6 --profile output? 16:38
buggable New CPAN upload: Native-Exec-0.1.tar.gz by CTILMES modules.perl6.org/dist/Native::Exec:cpan:CTILMES 16:53
Geth doc: 7f85492f92 | (Curt Tilmes)++ | doc/Language/5to6-perlfunc.pod6
Add a reference to Native::Exec in the 5to6 section on exec
17:16
synopsebot Link: doc.perl6.org/language/5to6-perlfunc
buggable New CPAN upload: AttrX-Mooish-v0.4.7.tar.gz by VRURG modules.perl6.org/dist/AttrX::Mooish:cpan:VRURG 18:33
lichtkind is softmoth around here sometimes? 18:54
moritz sometimes 19:06
lichtkind thanks 19:12
Geth doc: 3249f65bf3 | Lichtkind++ | doc/Language/pod.pod6
tiny expansion on linking within POD
19:24
synopsebot Link: doc.perl6.org/language/pod
lichtkind can you make in POD6 the heading itself a link? 20:51
lichtkind i know how to overwrite % $var but how to overwrite %$var ? 21:16
lucasb o/ 21:35
rouking Is the experimental cached trait not thread-safe? 21:39
I'm doing problem 14 from Project Euler and caching the result of my collatz-length sub 21:40
but I'm trying to speed it up by using .race before calling .map
rouking I get the error "double free or corruption (!prev)" 21:41
timotimo yeah, it's probably not threadsafe 21:42
rouking That's unfortunate 21:43
timotimo it's easy to build your own i'm sure :)
rouking It would be nice to get the extra speed from not re-computing any of the lengths *and* using multiple cores
I suppose I could, but that seems like a bit much for this 21:44
timotimo perhaps, but it could be a cool module for the ecosystem :)
AlexDaniel don't we have it already?
timotimo oh? 21:45
AlexDaniel github.com/azawawi/perl6-memoize
timotimo i know we have an LRU cache, don't know if it's threadsafe
AlexDaniel eh memoize is not threadsafe as far as I can see…
yeah 21:46
leont How can I introspect the return type of a sub? 22:48
yoleaux 4 Sep 2018 22:52Z <TimToady> leont: no, not a bug, because &foo actually represents the implicit proto, not the multi; try $sub.candidates[0].multi instead
leont I can easily get the arguments using signature, but the return type doesn't appear to be available 22:49
timotimo m: sub foo(Int $a --> Str) { }; say &foo.^methods
camelia (Capture returns of package multi candidates <anon> wrap <anon> soft <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> unwrap yada leave perl <anon> <anon> <anon> cando gist <anon> <anon> onlystar <anon> BUILDALL fire_phasers fire_if_phasers <an…
timotimo m: sub foo(Int $a --> Str) { }; say &foo.^methods>>.name
camelia (Capture of returns onlystar <anon> leave <anon> cando candidates <anon> yada <anon> <anon> <anon> <anon> multi unwrap <anon> <anon> <anon> <anon> <anon> perl package wrap <anon> gist <anon> <anon> soft <anon> BUILDALL phasers add_phaser set_why has-p…
timotimo m: sub foo(Int $a --> Str) { }; say &foo.returns 22:50
camelia (Str)
leont timotimo++ 22:50
leont (this does not appear to be in the documentation of Sub) 22:51
timotimo m: sub foo(Int $a --> Str) { }; say &foo.signature.returns 22:52
camelia (Str)
leont I see. Apparently my mental model of Signature isn't correct 22:54
timotimo not sure if the "returns" "trait" will also set it on the signature 22:55
SmokeMachine m:sub bla() returns Str {}; say &bla.signature.returns 23:28
evalable6 (Str)
tyil m: sprintf("%.6f", 0.5) 23:47
camelia ( no output )
tyil m: sprintf("%.6f", 0.5).say
camelia 0.500000
tyil m: (0.5).sprintf("%.6f").say 23:48
camelia Your printf-style directives specify 0 arguments, but 1 argument was supplied
in block <unit> at <tmp> line 1
tyil how come sprintf doesn't like this? 23:48
timotimo m: (0.5).fmt("%.6f").say
camelia 0.500000
tyil oh
thanks timotimo
timotimo m: ("%.6f").fmt(0.6).say
camelia Your printf-style directives specify 0 arguments, but 1 argument was supplied
in block <unit> at <tmp> line 1
tyil oh
timotimo oh, not like that either?
hah 23:49
tyil interesting
timotimo m: ("%.6f").sprintf(0.6).say
camelia 0.600000
timotimo sorry i forgot to switch sprintf in for that second one
i think this is a job for ... putting my body onto something rectangular and soft, and not move much for multiple hours 23:51