»ö« 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.
reino4477 how can I use generics? I've not found anything in the doc-ion. 01:39
timotimo it looks like this: 01:47
m: role GenericRole[::Type, $value] { has Type $.foo; method do-the-thing { say $value; say $.foo.^name; say Type.^name } }; class A does GenericRole[Str, 99] { }; A.new(foo => "yo").do-the-thing() 01:48
camelia 99
Str
Str
reino44771 how about a class?
timotimo nope, only roles
timotimo but you can use roles as if they were classes in something we call "punning" 01:48
m: role GenericRole[::Type, $value] { has Type $.foo; method do-the-thing { say $value; say $.foo.^name; say Type.^name } }; GenericRole[Str, "fooooo"].new(foo => "yo").do-the-thing() 01:49
camelia fooooo
Str
Str
timotimo ^- no class any more
reino44771 thx
timotimo using a role like that acts the same way as if you had written class :: does TheRole[the, arguments] {}, i.e. it mixes the role into an empty class and gives you that class
BenGoldberg m: sub foo {...}; role R[$s] { method s{$s} }; constant C = R[&foo.signature]; dd C.s; 02:24
camelia Signature $s = :()
BenGoldberg m: sub foo {...}; role R[$s] { method s{$s} }; constant C = R[:()]; dd C.s; 02:25
camelia ===SORRY!===
QAST::Block with cuid 7 has not appeared
BenGoldberg wonders, why 7?
Todd__ Hi All, I just got clipped by github.com/retupmoca/P6-Net-SMTP/issues/16 05:01
# perl6 -v This is Rakudo version 2017.06 built on MoarVM version 2017.06 implementing Perl 6.c.
Is there an newer RPM out there somewhere for Fedora? I do I have to compile from scratch?
zoll Todd__: could you not use zef to update only Net::SMTP? 05:03
Todd__ Did not think of that. I will try
llfourn Todd__: didn't we establish the bug isn't in Net::SMTP? 05:03
NeuralAnomaly: status 05:04
NeuralAnomaly llfourn, [✘] Next release is today. Since last release, there are 23 new still-open tickets (0 unreviewed and 0 blockers) and 61 unreviewed commits. See perl6.fail/release/stats for details
Todd__ I am already at the latest version. Timo said the issue was in Rakudo and that he had fixed it.
zoll BTW, Todd__, timo mentions a simple fix by editing the file.
Todd__ I was not smart enough to know what he meant 05:05
llfourn Todd__: The next release should be soon, someone will release new rpms after that I guess. 05:06
zoll change "$self.conn.nl-in = "\r\n";" to "$self.conn.nl-in = ("\r\n");"
zoll <-- untested 05:06
llfourn $self.conn.nl-in = "\r\n",; # this actually 05:07
Todd__ I am trying to download the clone from git
zoll ah. thank you, llfourn
Todd__ Poop! Type check failed in binding to parameter '@seps'; expected Positional but got Str ("\r\n") 05:11
Any words of wisdom?
ugexe ["\r\n"] 05:12
otherwise probably ("\r\n",)
llfourn Todd__: did you make the change?
Todd__ llfourn. Any idea on the time table for the next release so I can inform my customer? (Should I add a couple of weeks just in case?) 05:13
Do you want me to change it to `["\r\n"]` or `("\r\n",)`
llfourn either should work 05:14
Todd__ I changed it to ("\r\n") without the comma
llfourn that won't work
Todd__ Do yo have a preference? 05:15
llfourn ("\r\n",)
ugexe++ # what I said initially was wrong too 05:16
Todd__ It looks like it worked. I have to check something
It worked. Thank you! What did I do? 05:17
ugexe you sent a pr with the changes 05:20
but rakudo now takes a list of line separators and not a single string. 05:22
m: say "\r\n".WHAT; say ("\r\n",).WHAT 05:23
camelia (Str)
(List)
llfourn Todd__: btw I don't know when rpms get release after there is a release. It seems to be pretty fast. 05:24
zoll (...,).WHAT produces better output for someone who is learning perl6 than $x.WHAT (given $x = (...,)) 05:25
ugh, never mind. that also produces same output 05:27
I used .perl instead of .WHAT
ugexe if you need something slightly more verbose... `perl6 --target=ast -e '("\r\n",)'` 05:34
Todd__ At the risk of bing laughed off this form, I can only find perl5 examples on google. 05:35
What am I doing wrong here. I want the result to be "ghi". I am trying to do a "greedy" subsitution. 05:36
perl6 -e 'my $x="abc/def/ghi"; $x ~~ s{*./}{}; say $x'
Quantifier quantifies nothing
llfourn perl6 -e 'my $x="abc/def/ghi"; $x ~~ s:g!.*"/"!!; say $x' 05:38
zoll Why is "()" is a list but (3) is Int-but-not-list per rakudo? Yet "(,)" is a syntax error and "(3,)" is a list?
Todd__ thank you! 05:39
llfourn Todd__: you'll have to add s:g:i etc to get ignorecase etc too 05:40
Todd__ Is there a way to do it with {} brackets?
zoll llfourn: why does "/" need to be quoted? 05:41
Todd__ perl6 -e 'my $x="abc/def/ghi"; $x ~~ s/.*\///; say $x'
llfourn because Todd__ wants to match it literally
Todd__ saves the back slash and gets you out of \\\/\/\/\\\/ hell
ugexe m: say "hello " ~ (1 ?? 2 !! 3); # because parens arent just used for positional 05:42
camelia hello 2
Todd__ s is subsitute. g is global? i is case insensitive?
llfourn in p6 regex non-metacharaters have to be quoted
Todd__: yep
zoll ok. "/" is a metacharacter.
llfourn you have to quote it either way 05:43
timotimo yo
llfourn I don't think "/" is used for anything
timotimo need me for something?
llfourn you can still leave alphanumeric characters as non-quoted 05:44
Todd__ If I am "greedy", is ther a reason to use 'g'? 05:45
llfourn g is for global? 05:46
Todd__ perl6 -e 'my $x="abc/afg/ahi"; $x ~~ s:g/a/r/; say $x' rbc/rfg/rhi 05:47
seems to be global
perl6 -e 'my $x="abc/Afg/ahi"; $x ~~ s:g:i/a/r/; say $x' rbc/rfg/rhi
timotimo m: my $a = "abc/afg/ahi"; say $a.substr($a.rindex("/")) 05:48
camelia /ahi
timotimo m: my $a = "abc/afg/ahi"; say $a.substr($a.rindex("/") + 1)
camelia ahi
timotimo ^- do it without regex, it'll be a few hundred times faster
alternatively you can do a match instead of a substitution and match "the other thing" 05:49
timotimo m: my $x = "abc/afg/ahi"; $x ~~ m/.* \/ <( .* /; say $/.Str 05:49
camelia ahi
timotimo alternatively, use split
m: my $x = "abc/afg/ahi"; say $x.split("/").tail 05:50
camelia ahi
Todd__ Are {} out in Perl6 (I use them a lot in Perl 5)
timotimo you'll want to consider what happens when there are no / in there at all, btw
timotimo m: my $x = "foobarbaz"; say $x.substr($x.rindex("/") + 1) 05:51
camelia Use of Nil in numeric context
in block <unit> at <tmp> line 1
oobarbaz
timotimo this is problematic
my example with the m/ / will also not work if there's no / in there
timotimo m: my $x = "foobarbax"; say $x.split("/").tail 05:51
camelia foobarbax
timotimo this however works 05:52
llfourn I'm not sure if you can use {} to do something like s{foo}{bar} 05:54
If I try it tells me to use assignment syntax 05:55
zoll timotimo: can you explain why "xy".split( '' ) returns two empty strings before & after each letter?
timotimo sure
AlexDaniel m: $_ = ‘abcdefg’; s{cd} = ‘OH’; .say
camelia abOHefg
timotimo there's an empty string at the beginning and at the end of "xy"
AlexDaniel llfourn: ↑
timotimo it's a generalization from what you get when your split characters are at the beginning and end of the string 05:56
m: "axaya".split("a").perl.say
camelia ("", "x", "y", "").Seq
timotimo if that were not the case, you wouldn't get the same thing back when you join it again
llfourn AlexDaniel: thanks
AlexDaniel llfourn: this looks so weird though :) 05:57
llfourn it is pretty weird 05:58
given that I'm not assigning anything
but trying to to string replacement
AlexDaniel hm… that's an interesting point :)
timotimo it feels a bit like an assignment to me
the weird thing about it is that it's thunky
m: $_ = "whoa dude what"; s{" ") = <! ? , . : ;>.pick; say $_ 05:59
camelia 5===SORRY!5=== Error while compiling <tmp>
Couldn't find terminator }
at <tmp>:1
------> 3$_ = "whoa dude what"; s{" "7⏏5) = <! ? , . : ;>.pick; say $_
expecting any of:
double quotes
infix stopper
timotimo m: $_ = "whoa dude what"; s{" "} = <! ? , . : ;>.pick; say $_
camelia whoa;dude what
timotimo m: $_ = "whoa dude what"; s{" "} = <! ? , . : ;>.pick; say $_
camelia whoa:dude what
timotimo m: $_ = "whoa dude what"; s{" "} = <! ? , . : ;>.pick; say $_
camelia whoa;dude what
timotimo oh, forgot the :g
m: $_ = "whoa dude what is happening"; s:g{" "} = <! ? , . : ;>.pick; say $_
camelia whoa.dude,what:is?happening
timotimo m: $_ = "whoa dude what is happening"; s:g{" "} = <! ? , . : ;>.pick; say $_
camelia whoa!dude;what,is.happening
AlexDaniel I like this also: 06:00
timotimo m: $_ = "whoa dude what is happening"; s:g{" "} = $/.target; say $_
camelia whoawhoa dude what is happeningdudewhoa dude what is happeningwhatwhoa dude what is happeningiswhoa dude what is happeninghappening
AlexDaniel m: my $x = ‘abcdefg’; $x ~~ s「cd」 = ‘OH’; $x.say
camelia abOHefg
llfourn ohh
so you can actually use it without $_ being set 06:01
timotimo yeah because ~~ sets $_ for you
llfourn ^ I don't always find the above to be the case
AlexDaniel well, I guess so… it just felt like it should work, and turns out it does :)
llfourn m: my $a = "foo"; say $a ~~ .uc 06:02
camelia False
llfourn m: my $a = "foo"; say $a.uc ~~ .uc
camelia True
llfourn nvm I guess I got confused somewhere
timotimo i'm not sure we're actually helping Todd__ at all :) 06:03
llfourn Todd__: in conclusion you can do. my $x = "foo"; $x ~~ s{foo} = "bar". Which is like s/foo/bar. 06:04
AlexDaniel looking at it again, I think the assignment syntax is much clearer
llfourn I like it now that I know you can do it on stuff other than $_ 06:05
(well know I know that ~~ actually sets $_ consistently) 06:06
Todd__ I understand. Thank you! 06:09
Todd__ bye bye 06:29
nadim Good morning, what's the role of the 'provides' section in META6.json ? 08:23
stmuk_ I see the go people are arguing about their language naming on twitter 08:32
zoll Go got nothing on Perl 6, I say.
stmuk_: got a link?
tyil[m] zoll: they got popularity 08:33
and speed :'3
zoll my point was about the name.
stmuk_ zoll: see rob poke's thread 08:34
errr rob pike even
nadim m: my $s = 1 ; my $s2 = 2 ; $s := $s2 if $s2.defined ; say $s 09:08
camelia 2
nadim m: my $s = 1 ; my $s2 = 2 ; $s = $s2 if $s2.defined ; say $s
camelia 2
nadim m: my $s = 1 ; my $s2 = 2 ; $s [R//]= $s2 ; say $s
camelia 2
nadim m: my $s = 1 ; my $s2 = 2 ; $s [R//]:= $s2 ; say $s 09:09
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix := instead
at <tmp>:1
------> 3my $s = 1 ; my $s2 = 2 ; $s [R//]:=7⏏5 $s2 ; say $s
nadim isn't it possible to use [R//] with := ?
Geth doc: 1b8b5bc028 | (Elizabeth Mattijsen)++ | doc/Language/setbagmix.pod6
Fix 2 typos
10:37
lizmat looking at the documentation in docs.perl6.org/language/setbagmix , I would want to write a lot there, but this would need more community feedback 10:38
that we won't be able to get before the R* release
so afaiac , I won't be touching doc anymore until after the R* release
afk& 10:39
geekosaur wonders if there's somewhere in the documentation to put the description of how process groups work; it's not strictly perl 6 and it's unix specific but I think this is the second time someone's been confused by it 13:00
also it's amazing how many people don't get the idea that a multitasking system has more than one process running at the same time 13:02
BenGoldberg geekosaur, Multitasking is just an illusion. 13:18
geekosaur that's exactly what people think... 13:27
your computer would never work at all if it worked the way everyone thinks it does
(there was also a time when that was literally true, but computers have had multiple CPU cores for how long now?) 13:28
geekosaur and even when it was true because the computer only had one CPU, what process was current on the CPU changed by the millisecond. trust me, humans do not track what process is current by the millisecond 13:32
most of them would insist the other processes are not current even though they're on the cpu; the "current process" is whatever they are interacting with on the terminal and somehow that process knows to keep all the others running or stop them if it receives a signal or etc. 13:33
if computers actually worked that way, *every* programmer would get it wrong.
timotimo so, if we open our source files and set \n=finish\n as separator, we could totally accept perl6 source files that end in a binary blob 13:36
geekosaur it's the return of __END__!
timotimo the END is back 14:00
araraloren evening 14:10
araraloren I know use grammar we can define a recursive regex, is there any other way can do this? 14:11
Such like my regex A { 1 | <&A> }; 14:12
Oh I know
my regex A { 1 <&A>? }; can do this, sorry 14:13
timotimo does somebody want to make "my ($a, $b, $c);" faster? :) 14:22
spreadLink hello~ 15:17
nadim Hi, I am going to make a change to my favorite module (Data::Dump::Tree) as it has now three different environments, Termina, terminal with NCurses and HTML, of course they don't handle color the same way which forces me to stop dealing with Str but have some ColorStr type. i wonder if by, a very unlikely chance someon has seen such a class somewhere. Not difficult to write but I rather no re-invent. 15:26
araraloren Terminal color ? 15:30
Do you mean Terminal::ANSIColor ? 15:31
nadim No, I mean a Str class that also caaries color attributes with it 15:32
lizmat role HasColor { has $.color }; my $a = "foo" but HasColor ? 15:33
nadim a bunch of them and they shall concatenate while keeping the color, and, let's dream, can render itself in multiple environments 15:34
but that was a good idea for a single string.
lizmat m: role Color[$color] { method color { $color } }; my $a = "foo" but Color["red"]; dd $a.color # using parameterized roles 15:35
camelia Str $color = "red"
nadim I guess I should also have an operator to create them, ColorStr.new: :color(...), :str<...> ; is going to be tiresome very quickly
lizmat: I like the approach 15:36
colomon Is there a Windows MSI out there for a recent Rakudo? All I’ve found so far are Rakudo Stars from April or earlier. 15:42
colomon is building a new Windows 10 VM beause his old one blew up :\
aha! rakudo.org/downloads/rakudo/ 15:46
oh, wait, those aren’t MSIs
perl6.org 15:47
colomon grumpily gives up and installs R* 2017.04 15:48
Morfent can you compile rakudo on windows? 15:50
colomon I don’t know that I can — especially with most of my development tools not installed yet — but somebody can, obviously.
jnthn still develops on Windows as far as I know. 15:51
Morfent ah
compiling it takes hardly any time to do, so if you can't find the msis it's not a problem after getting the dependencies installed 15:54
araraloren Yeah, you can I make a MyStr has a terminal width 15:55
nadim, you can inherit from Str 15:56
MasterDuke colomon: the next R* is going to be based on 2017.07, which should be released today, so there should be a new R* sometime after 16:33
colomon ooooo 16:34
MasterDuke i think stmuk_ usually waits a week or so 16:35
ugexe i use rakudobrew on windows, but yeah you need a compiler and perl installed 17:04
Voldenet Is it a good idea to subtype "Stringy:D" for its every use case and then move constraint checking into a type? 17:06
I'm sure it's very elegant and tidy, but wouldn't it kill performance to re-check this a lot?
Voldenet m: subset S of Stringy:D where { .chars > 0 }; Str $t = "some text"; (sub (S $a) { $a.say })($a); 17:09
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3S of Stringy:D where { .chars > 0 }; Str7⏏5 $t = "some text"; (sub (S $a) { $a.say
expecting any of:
infix
infix stopper
Voldenet m: subset S of Stringy:D where { .chars > 0 }; my Str $t = "some text"; (sub (S $a) { $a.say })($a);
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$a' is not declared
at <tmp>:1
------> 3 = "some text"; (sub (S $a) { $a.say })(7⏏5$a);
Voldenet m: subset S of Stringy:D where { .chars > 0 }; my Str $t = "some text"; (sub (S $a) { $a.say })($t);
camelia some text
Voldenet m: subset S of Stringy:D where { .chars > 0 }; my Str $t = ""; (sub (S $a) { $a.say })($t);
camelia Constraint type check failed in binding to parameter '$a'; expected S but got Str ("")
in sub at <tmp> line 1
in block <unit> at <tmp> line 1
ugexe where *.chars 17:10
still flawed though 17:12
m: my $buf = "x".encode; say $buf ~~ Stringy; say $buf.chars
camelia True
Cannot use a Buf as a string, but you called the chars method on it
in block <unit> at <tmp> line 1
ugexe m: my $buf = "x".encode; say $buf ~~ Stringy; say $buf.?chars # I feel like this *should* work but it doesnt
camelia True
Cannot use a Buf as a string, but you called the chars method on it
in block <unit> at <tmp> line 1
Voldenet m: subset S of Stringy:D where *.chars; my Str $a = "a"; sub b(S $a) { $a }; for ^10000 { b($a) }; (now - BEGIN now).say 17:14
camelia 0.0762509
Voldenet m: subset S of Stringy:D where *.chars; my S $a = "a"; sub b(S $a) { $a }; for ^10000 { b($a) }; (now - BEGIN now).say
camelia 0.07377091
Voldenet doesn't look like a smashing difference
ugexe m: my $buf = "x".encode; say $buf ~~ Stringy; say $buf.Stringy; # cause this doesn't really make sense 17:16
camelia True
x
ugexe er that wasnt what i thought it was gonna say
yes it did 17:17
Voldenet m: "".encode.Stringy.chars.say 17:18
camelia 0
Voldenet m: "ó".encode.Stringy.chars.say 17:19
camelia 1
ugexe m: my $buf = "x".encode; my $buf2 = Buf.new($buf); say $buf.perl; say $buf2.perl; say $buf ~~ Stringy; say $buf2 ~~ Stringy; say $buf.Stringy; say $buf2.Stringy 17:21
camelia utf8.new(120)
Buf.new(120)
True
True
x
Cannot use a Buf as a string, but you called the Stringy method on it
in block <unit> at <tmp> line 1
ugexe that doesn't make sense though 17:22
Voldenet Huh... that's quite magical 17:24
ugexe well i guess it sort of does since the former you *know* its utf8 but the later is just known to be a Buf
Voldenet m: say "x".encode.WHAT 17:25
camelia (utf8)
Voldenet m: say Buf.new("x".encode).WHAT
camelia (Buf)
geekosaur yes, utf8 is a Buf[uint8] with extra abilities
Voldenet Well, it makes sense now. Not all "Buf" objects can be used as a string
m: say Buf.new("x".encode).Stringy 17:26
camelia Cannot use a Buf as a string, but you called the Stringy method on it
in block <unit> at <tmp> line 1
Voldenet m: say Buf.new("x".encode).decode.Stringy
camelia x
ugexe seems like Buf.Stringy should be calling something like { self."{::T}"::Stringy }
al2o3-cr p6: say "hello perl"; 17:47
camelia hello perl
nine colomon: jnthn usually develops on Linux, too these days. 17:48
AFAIK we don't have anyone doing development on Windows regularily. 17:49
karlsson p6: $_ = '① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳'; s:nth(4,8,12...*)/(.)/$0,/; .say 18:05
camelia ① ② ,③ ④ ,⑤ ⑥ ,⑦ ⑧ ,⑨ ⑩ ,⑪ ⑫ ,⑬ ⑭ ,⑮ ⑯ ,⑰ ⑱ ,⑲ ⑳
karlsson Is this error? 18:07
lucasb m: $_ = '(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20)'; s:nth(4,8,12...*)/(.)/$0,/; .say 18:10
camelia (1) ,(2) ,(3) ,(4) ,(5) ,(6) ,(7) ,(8) ,(9) ,(10), (11,) (1,2) (,13) ,(14), (15,) (1,6) (,17) ,(18), (19,) (2,0)
lucasb idk why the output changed between evaluations
oh, sorry. I copy and pasted in the terminal... 18:11
didn't know those were unicodey 18:12
samcv how do i create a channel using stdin 23:21
zengargoyle echo -e "foo\nbar\n" | perl6 -e '$*IN.Supply.tap(*.say)' 23:30
^^ seems to do something.. :)
zengargoyle m: $*IN.lines.map: *.say; 23:36
camelia »Wann treffen wir drei wieder zusamm?«
»Um die siebente Stund‘, am Brückendamm.«
»Am Mittelpfeiler.«
»Ich lösche die Flamm.«
»Ich mit«

»Ich komme vom Norden her.«
»Und ich vom Süden.«…
zengargoyle m: $*IN.lines.Supply.tap: *.uc.say; 23:37
camelia »WANN TREFFEN WIR DREI WIEDER ZUSAMM?«
»UM DIE SIEBENTE STUND‘, AM BRÜCKENDAMM.«
»AM MITTELPFEILER.«
»ICH LÖSCHE DIE FLAMM.«
»ICH MIT«

»ICH KOMME VOM NORDEN HER.«
»UND ICH VOM SÜDEN.«…
zengargoyle m: $*IN.lines.Supply.Channel
camelia ( no output )
zengargoyle m: $*IN.lines.Supply.Channel.perl.say
camelia Channel.new
samcv hm 23:46
timotimo m: my $chan = Channel.new; start { $chan.send($_) for $*IN.lines }; react { whenever $chan { say "received $_" } } 23:55
m: my $chan = Channel.new; start { $chan.send($_) for $*IN.lines; $chan.close() }; react { whenever $chan { say "received $_" } }
camelia (timeout)received »Wann treffen wir drei wieder zusamm?«
received »Um die siebente Stund‘, am Brückendamm.«
received »Am Mittelpfeiler.«
received »Ich lösche die Flamm.«
received »Ich mit«
received
received …
23:55
received »Wann treffen wir drei wieder zusamm?«
received »Um die siebente Stund‘, am Brückendamm.«
received »Am Mittelpfeiler.«
received »Ich lösche die Flamm.«
received »Ich mit«
received
received »…