»ö« 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.
kjk it seems a captured group is lost when interpolating a variable into a regex: p6: my $p = 'ab(.+)ef'; 'abcdef' ~~ rx/<{$p}>/; $/[0] 00:15
p6: my $p = 'ab(.+)ef'; 'abcdef' ~~ rx/<{$p}>/; $/[0]
camelia ( no output )
kjk p6: my $p = 'ab(.+)ef'; 'abcdef' ~~ rx/<{$p}>/; say $/[0]
camelia Nil
kjk p6: 'abcdef' ~~ rx/ab(.+)ef/; say $/[0] 00:16
camelia 「cd」
kjk is that expected behavior?
Xliff m: my @a = <a b c de>; say @a.map( .tc ); 00:23
camelia No such method 'tc' for invocant of type 'Any'
in block <unit> at <tmp> line 1
Xliff m: my @a = <a b c de>; say @a.map( *.tc );
camelia (A B C De)
MasterDuke p6: my $p = 'ab(.+)ef'; 'abcdef' ~~ rx/<$p>/; say $/[0]
camelia Nil
kjk btw, what's the difference between rx/<$p>/ vs rx/<{$p}>/ ? 00:26
MasterDuke <$p> should interpolate $p and interpret it as a regex 00:28
<{$p}> should run $p as code and match (i.e., proceed to the rest of the regex) based on what it evaluates to 00:29
kjk gotcha, thanks MasterDuke 00:30
MasterDuke if i remember correctly
kjk though I'm still puzzled why the captured group is lost
MasterDuke hm, i might have that slightly wrong. <{ }> runs the code inside and then interpolates the result of that into the regex 00:31
MasterDuke m: say "foo" ~~ /<{' o ** 2 '}>/ 00:33
camelia 「oo」
pilne i must again confess my lovehate of perl6 for ruining every other language out there for me...
pilne everything else feels like i'm fighting my brain to get code out in a way that appeases the runtime 00:34
perl6 doesn't always do what I want, but it's my fault still at this point cuz i just guess based on what i've already learned 99% of the time :D
tushar p6: my $p = rx/ab(.+)ef/; 'abcdef' ~~ $p; say $/[0]; 00:35
yoleaux 2 Oct 2016 12:31Z <perlawhirl> tushar: like this? gist.github.com/0racle/abbc0d2f7c7...7aacc7a5f8
camelia 「cd」
kjk p6: 'abcdef' ~~ rx/<{'ab(.+' ~ ')ef' }>/; say $/[0] 00:37
camelia Nil
tushar @kjk.. can you please explain your regular expression pattern that you used in your last try? Also, can you please briefly explain what are you trying to achieve? 00:42
tushar If you merely try to capture a group of words.. your last example can be rewritten as p6: 'abcdef' ~~ rx/ab(.+)ef/; say $/[0] 00:43
'abcdef' ~~ rx/ab(.+)ef/; say $/[0]
p6: 'abcdef' ~~ rx/ab(.+)ef/; say $/[0]
camelia 「cd」
ugexe m: "abcdef" ~~ rx/$<foo>=<{"ab(.+" ~ ")ef"}>/; say $/; # a named capture will get its 0 match set though...? 00:50
camelia 「abcdef」
foo => 「abcdef」
0 => 「cd」
MasterDuke committable6: releases "abcdef" ~~ rx/$<foo>=<{"ab(.+" ~ ")ef"}>/; say $/; 00:57
committable6 MasterDuke, ¦releases (23 commits): «「abcdef」␤ foo => 「abcdef」␤ 0 => 「cd」»
kyan Hi, in a loop like for $code.split("", :skip-empty) -> $char { …, can I have it so the value is assigned to $char and $_, without having to separately write $_ = $char;? 01:32
MasterDuke kyan: i don't think that's possible 01:40
kyan MasterDuke: Ok, thanks! Figured I'd ask, since it might be hiding somewhere in all the cool features :) 01:41
audiatorix Hey folks 01:42
how difficult would it be to change array/list deconstruction
audiatorix as it stands now, `my (@a, $b) = (1, 2), 3;` doesn't have the expected result 01:43
I see why it doesn't, just wondering why that is how it is, or if there's no particular reason, how big of a change it would be 01:44
Xliff m: my %h = ( a >= 1, b => 2, c => 3); my @a; @a.push: %h; @a.push: %h; dd @a; 02:43
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix >= instead
at <tmp>:1
------> 3my %h = ( a >=7⏏5 1, b => 2, c => 3); my @a; @a.push: %h;
Xliff m: my %h = ( a => 1, b => 2, c => 3); my @a; @a.push: %h; @a.push: %h; dd @a;
camelia Array @a = [{:a(1), :b(2), :c(3)}, {:a(1), :b(2), :c(3)}]
Xliff m: my %h = ( a => 1, b => 2, c => 3); my %a; %a<a>.push: %h; %a<a>.push: %h; %h<b>.push: %h; dd %a; 02:44
camelia Cannot resolve caller push(Int: Hash); none of these signatures match:
(Any:U \SELF: |values is raw)
in block <unit> at <tmp> line 1
Xliff m: my %h = ( a => 1, b => 2, c => 3); my %a; %a<a>.push: %h; %a<a>.push: %h; %a<b>.push: %h; dd %a;
camelia Hash %a = {:a($[{:a(1), :b(2), :c(3)}, {:a(1), :b(2), :c(3)}]), :b($[{:a(1), :b(2), :c(3)},])}
AlexDaniel- audiatorix: somehow I don't think there's a good well-thought-out reason why 03:01
audiatorix: in fact, I'd love to see a ticket for this, if there's no ticket already
audiatorix: *even if* it is supposed to be this way, I think it'd be a good idea to show a warning saying that $b is kinda useless there
and maybe with some clues on how to make that work 03:02
in fact, what the hell is this?
m: my ((@a), $b) = [1, 2], 3; dd @a; dd $b
camelia Mu
Int $b = 3
AlexDaniel- ok we got $b right, but where did [1, 2] go? 03:03
AlexDaniel- I'd expect normal destructuring to work there 03:06
pilne m: my (@a, $b) = (1, 2), 3; 03:09
camelia ( no output )
pilne m: my (@a, $b) = (1, 2), 3; say @a 03:10
camelia [(1 2) 3]
pilne i see it too, but it is definitely a "gotcha" unless i too am missing something
BenGoldberg m: ((my @a), my $b) = (1, 2), 3; dd @a; 03:13
camelia Array @a = [(1, 2), 3]
BenGoldberg m: ((my @a), my $b) = [1, 2], 3; dd @a; 03:14
camelia Array @a = [[1, 2], 3]
pilne :m ((my @a), my $b = ((1, 2), 3; dd @a; dd $b;
AlexDaniel- I don't think there's anything missing
pilne did i blow it up?
AlexDaniel- one way or another, but it's a bug
pilne no i typod
m: ((my @a), my $b = ((1, 2), 3; dd @a; dd $b;
camelia 5===SORRY!5=== Error while compiling <tmp>
Cannot use variable $b in declaration to initialize itself
at <tmp>:1
------> 3(my @a), my $b = ((1, 2), 3; dd @a; dd $7⏏5b;
expecting any of:
argument list
term
pilne m: my ((@a), $b) = ((1, 2), 3); dd @a; dd $b; 03:16
camelia Mu
Int $b = 3
Geth doc: W4anD0eR96++ created pull request #1600:
Fix broken link to ACCEPTS
03:35
Geth doc: 708d7ae73f | (Alex Wander)++ (committed using GitHub Web editor) | doc/Language/operators.pod6
Fix broken link to ACCEPTS

mentioned in #1599
03:44
synopsebot Link: doc.perl6.org/language/operators
Geth doc: dc6564869d | (Aleks-Daniel Jakimenko-Aleksejev)++ (committed using GitHub Web editor) | doc/Language/operators.pod6
Merge pull request #1600 from W4anD0eR96/patch-3

Fix broken link to ACCEPTS
duff anyone here!? 04:07
I'm looking to learn Perl, and not sure if I should start learning Perl 5 or Perl6 04:08
Anyone have any advice?
I have programmed in python, java, C languages, pretty much everything else 04:09
TEttinger hi duff 04:10
duff Hi
AlexDaniel- duff: any project you have in mind? It really depends on what you are going to use it for
duff I don't know. Perl seems like a fun language to code in. Just looking to "learn perl", whatever that may mean. 04:11
TEttinger perl5 and perl6 are rather different languages, though both are good for text handling. perl 6 will do much better than perl 5 on Unicode-heavy text, like anything with emoji or non-English languages
duff Hobbyist
Ok
I'm pretty much tired of coding in python and looking for another language. Ruby didn't do it for me.
TEttinger perl 6 has a powerful grammar system with few competitors in other areas 04:12
duff Thought I'd try perl, just trying to figure out if I should use Perl 5 and it's massive modules/library or go with the future.
TEttinger the grammars are one way that sub-languages can be built inside perl6, if that's an interest of yours
duff that sounds pretty cool actually
AlexDaniel- duff: well, technically use can use perl5 and python modules from perl6 via Inline::Perl5 and Inline::Python 04:13
duff Is 5 ever going to be deprecated? Or will they split forever as two separate languages
AlexDaniel- duff: they already did. These are two completely separate languages now 04:13
TEttinger I haven't used perl6 or perl5 enough to give a recommendation, though I did use some NQP (not quite perl) when I was trying to implement a language on the same VM as Perl 6
duff Ok
AlexDaniel- although similar in some ways
s/use/you/ :)
duff If you wanted to use a language to code in as your primary, over a number of years, would you go with 6? Is it that much improved, or just "different". Are there any major improvements in Perl6 that make it an absolute must? 04:14
pilne getting perl5 outta the core of linux distros will be even more painful than transitioning from python 2 to 3 was for most (all?) distros :D
duff I don't know Perl 5, so I don't know if Perl 6 is correcting mistakes or fixing bad design
AlexDaniel- duff: that's an interesting question to ask on #perl6 :)
pilne neither, it's fixing the growing pains of a scripting language becomming a general purpose language
duff Ok I see 04:15
pilne considering it's origins and what it has adapted to, perl5 is fucking incredible
duff I heard it's incredibly fast, and blows languages like python out of the water. Is this true?
TEttinger no
pilne but perl6 took those experiences from developing perl5 (and looking at other languages), to make perl6
duff But has a steeper learning curve, so all those start-up babies choose an easier language like python
Ok
pilne perl5 can be quite fast, but just like to make fast python, yer getting into black magic
perl6 is currently working on improving it's performance 04:16
TEttinger perl6 is getting faster as more people work on it
it's a main goal
duff Is Perl6 complete enough to make serious projects with? Is it stable enough?
Or still a long way out
?
pilne it has a great architecture for achieving great speeds from what I can tell, it just needs some tweaking (that is completely outta my brain-level)
TEttinger I think the JIT compiler is less than excellent currently, but at least there is one, which python and lua default to not using (PyPy and LuaJIT are JIT compilers for python and Lua that do an amazing speedup) 04:17
AlexDaniel- duff: it is stable enough, but there are some rough edges here and there. Whether you're going to notice them or not really depends on what you're going to use it for
duff Ok, thanks guys. I'm going to do some research and see which one really fits me. 04:18
Take care
TEttinger Ruby may have a JIT now? it may be why it isn't painfully slow parsing comments of all things 04:18
pilne there's no harm in learning both either :D espeically with inline::perl5
i think they are working on a JIT based on eclipse ORM for ruby
pilne err eclipse OMR 04:19
developer.ibm.com/open/2017/03/01/...hats-next/
AlexDaniel- that was a really hard question actually. Someone comes and asks if they should use X or something you've put a lot of hours into
and go come up with an unbiased answer… 04:20
pilne i *love* working in perl6 for things i'm doing locally
like, idgaf if it has spinup time personally
AlexDaniel- yoleaux: time 04:21
.time
argh
pilne i also *like* perl5, not as much as perl6, but a lot (: i've always kept my toes in it, ruby and python, without much preference for them, always "liked" reading good perl5 code the most out of them, i'm wierd though.
AlexDaniel- anyway, I think we have a stagnated build on docs.perl6.org 04:22
pilne but perl6 makes it very hard for me to "enjoy" the syntax/semantics of other languages
AlexDaniel- yeah… 04:22
that's true
pilne and after way too many years dicking around with code in at least a half-dozen languages, i've come to really "respect" how much an enjoyable syntax/semantics matter in terms of my blood pressure (: 04:23
i'm a hobbysit/dabbler by trade in programming
AlexDaniel- pilne: I feel you
pilne completely non-tech job for bills and health insurance (other than being the dude who they see if they can get to fix the computer problem without having to call our outsourced tech support, lol)l 04:24
AlexDaniel- ah ok, now it's updated! 04:25
pilne but yeah, perl6 is the first thing i've been stupidly excited by since i really started to understand what made lisps and haskell special (not that i'm any good in those languages,just the moment when what they are doing "clicked")
AlexDaniel- pilne: have you tried Prolog? 04:27
pilne i have read some things about it 04:30
never written code
AlexDaniel- pilne: it's a very enjoyable mind-bending thingie. Try it maybe :) 04:33
(not very practical though, but very fun)
AlexDaniel- m: my ((@a), $b) = [1, 2], 3; say @a.^name; dd $b 04:34
camelia VMNull
Int $b = 3
AlexDaniel- right…
pilne: RT #126857
synopsebot RT#126857 [open]: rt.perl.org/Ticket/Display.html?id=126857 [BUG] Bogus array subsignature in declaration `my ([$a]);` binds variable to VMNull
piojo Does anyone here work on the MongoDB driver? 04:36
tyil I dont work on it, but I have a project using it 09:58
buggable New CPAN upload: Config-1.2.2.tar.gz by TYIL cpan.metacpan.org/authors/id/T/TY/...2.2.tar.gz 10:06
piojo tyil: what's your experience? Does it work well? 10:38
tyil it gets the job done, it lets me put stuff in a database :p 10:39
github.com/scriptkitties/perl6-Shi...ers/V1.pm6 this file does some inserting into MongoDB
my only remaining issue with it was that I cant find any clear doc on how to insert a proper timestamp 10:40
piojo tyil: you mean an arbitrary time, or a "last modified" timestamp for data modifications? 10:55
tyil either, I can store a timestamp as a string just fine, but MongoDB supports storing them as ISODate objects too 10:58
piojo tyil: I haven't looked at what it's doing under the hood, but I did successfully translate the mongodb example about inserting a last-modified timestamp as you change the data: 11:00
my BSON::Document $req .= new: ( update => 'users', updates => [ ( q => (guid => $user,), u => ('$set' => (:meaning(42),), '$currentDate' => (lastModified => True),),), ],); 11:01
tyil interesting
Geth ecosystem: Tyil++ created pull request #374:
Remove App::MPD::AutoQueue, now available on CPAN
11:53
ecosystem: 1f6dd69e98 | (Patrick Spek)++ | META.list
Remove App::MPD::AutoQueue, now available on CPAN
ecosystem: c5fca77d50 | (Patrick Spek)++ (committed using GitHub Web editor) | META.list
Merge pull request #374 from Tyil/master

Remove App::MPD::AutoQueue, now available on CPAN
teatime oh, I just realized... there could totally be a module to generate bash/zsh completions, for users who use the getopt-like MAIN stuff 12:06
[Coke] finds a weird issue where he is using proc::async to ssh -t to a box to test something, then using Test to say ok/not ok.... the output starts getting indented so that each line is indented to where the last one ended. 12:24
timotimo you're getting \n without \r but your terminal is set to not go back to beginning of line without \r? 12:24
[Coke] taking test out of it, if I dd the test names, I see the same behavior. each line indented 4 more. weird. 12:27
(and I have to run stty sane) 12:28
guessing it's an interaction between proc async and ssh -t 12:30
[Coke] Yup. (I need the -t for the interaction with the remote server, but that's what triggers the terminal weirdness.) 12:34
timotimo mhm 12:35
[Coke] oh, sweet, I can rewrite the test a smidge to not need the -t. :) 12:38
pilne ok, so rakudobrew is out the window, which version is currently reccomended for "people playing with the language"? 2017.7? 12:54
[Coke] compiler only, then whatever the latest monthly release is 12:55
which is every month, so 2017.09
I believe the common wisdom regarding rakudobrew is that if you do choose to use it, don't do "rakudo build nom" unless you wipe it out first 12:56
but if you do individual releases, that's fine. I've been bit by the "build nom" thing more than once.
pilne ty, and i take it the general way to run zef is installed to userland and not as root? 13:07
piojo pilne: yes, zef installs itself. so zef is installed the same way it installs all the other modules 13:12
but be ready to "rm -r ~/.zef" several times per hour if you're using it a lot. It's not that reliable.
(Or maybe that's just on windows) 13:13
pilne tyvm 13:18
pilne while this is hardly a "painful" install, hopefully something like rakudobrew can be made to work sometime down the line, tools like that are nice for managing environments (: 13:22
HoboWithAShotgun m: say √4 13:25
camelia 5===SORRY!5===
Argument to "say" seems to be malformed
at <tmp>:1
------> 3say7⏏5 √4
Bogus postfix
at <tmp>:1
------> 3say 7⏏5√4
expecting any of:
infix
infix stopper
postfix
s…
HoboWithAShotgun hey i am disappointed
piojo pilne: oops, I misread what you wrote--zef is usually *not* run as root 13:44
never mind, I just misread twice. I guess it's time to log off!
raschipi . 13:59
[Coke] : 14:07
timotimo huh, what's wrong with the perl6 syntax checker atom package? 14:14
/bin/sh: scl: line 1: syntax error: unexpected end of file /bin/sh: error importing function definition for `BASH_FUNC_scl' /bin/sh: module: line 1: syntax error: unexpected end of file /bin/sh: error importing function definition for `BASH_FUNC_module'
buggable New CPAN upload: TimeUnit-0.1.0.tar.gz by ATROXAPER cpan.metacpan.org/authors/id/A/AT/...1.0.tar.gz 14:26
atroxaper My first... 14:27
pilne ty (:
raschipi atroxaper: gimme repo link...
atroxaper Oh... Forget link it in readme... github.com/atroxaper/p6-TimeUnit/b.../README.md 14:28
raschipi atroxaper: make it accept named arguments, so we can do (:42seconds) 14:29
atroxaper Like NANOSECONDS.from(:42minutes) ? 14:30
raschipi The upper case letters also look like a code smaell. 14:32
They are usually used in Perl6 to mean something unusual is going on, so it looks like very out of place in your interface
smell*
Are you copying this interface from somewhere? 14:33
atroxaper I'm a Java developer :) It is like Java TimeUnit. I'm used to it.
kerframil timotimo: possibly related: github.com/atom/atom/issues/13733. as a side-note, launching sh where bash-specific features are used (BASH_FUNC_* indicates the use of a function exported by way of the environment) could backfire badly where /bin/sh is something other than bash. 14:34
atroxaper raschipi: It's like Java constants. Hm... Do you think 'all-lower-letters' are better?
raschipi In debian /bin/sh is very likely to be /bin/dash, and on FreeBSD it's /bin/tcsh 14:35
atroxaper: We call 'all-lower-letters' kebab-case and it's the usual way of doing it in Perl6. If you do something differenty than that people will spend time trying to figure out why and then get angry because there's no reason. So you should use it. 14:37
timotimo kerframil: oh yeah, i've had KDE plasma unable to start up because my login shell is fish 14:38
atroxaper raschipi: I just see that docs.perl6.org/language/5to6-nutshell#constant (DEBUG). Of course I fully agreed about community code style. I will fix it. Thanks. 14:39
kerframil timotimo: that's sad 14:40
timotimo it is!
i've followed the advice of #fedora-kde and changed shells to bash and just set konsole to launch fish for me
kerframil probably blind sourcing of shell code, rather than executing it in the actually-targetted shell. or something like that.
timotimo and/or missing hashbang 14:41
raschipi It should be possible to set login shell to Powershell or Rc, yet these bugs where scripts don't specify the shell they need are common. 14:42
timotimo i remember a big period where things were broken on ubuntu preview versions because they turned /bin/sh into dash
kerframil indeed. I'm glad they did it. sh means sh, the Shell Command Language. no one should have any expectations beyond that. 14:44
a shakedown was overdue, in my opinion 14:45
raschipi In Debian and it's alternatives the link is configurable, so it might be dash or bash, varying by system. So the testing is ongoing. 14:46
timotimo i'm also glad 14:48
Geth doc/master: 7 commits pushed by (Luca Ferrari)++, (Rafael Schipiura)++
raschipi Of course the fix everywhere bashisms were used was just to change the shebang, so in the end it didn't make much difference. 14:51
raschipi I mean it didn't make much difference regarding the original objective of the change, which was to use a faster shell. 14:54
kerframil too bad, as there are some great linting tools these days. shellcheck, for instance. 14:55
raschipi shellsheck is a pain fo me to use because it doesn't know about assossiative arrays and complains about every use saying I shouldn't do math, so any useful output gets complety buried in the shaff, because I use assossiative arrays extensivley 14:58
kerframil it should know all about associative arrays, as long as a bash-targetting shebang is present. that makes sense, as associative arrays are obviously not a feature of sh. 15:01
raschipi Executed it again, every time I use the assossiatives I get "SC2102: Ranges can only match single chars (mentioned due to duplicates)." You know how to fix that? 15:03
kerframil hmm. can you pastebin a test case?
AlexDaniel- is also interested 15:04
raschipi I will, just a sec. 15:08
raschipi Oh, the errors I was getting went away after an update, it's fixed. That error I pointed above is unrelated and I should actually fix that. 15:17
kyan m: sub foo( --> Nil) { say "blah" } 15:18
camelia ( no output )
raschipi I didn't test the new version because I was on vacation, only saw the update in my computer at home.
kyan m: sub foo(--> Nil Str $var) { say "$var" }
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed return value (return constraints only allowed at the end of the signature)
at <tmp>:1
------> 3sub foo(--> Nil 7⏏5Str $var) { say "$var" }
kyan (aha, this has been fixed since the version I have installed! It was saying "Type 'Nil' is not declared", which I had a feeling was a mistake.) 15:19
AlexDaniel- kyan: \o/ 15:24
didn't really expect anyone to notice that fix so fast :)
atroxaper raschipi: do you like so github.com/atroxaper/p6-TimeUnit ? :) 15:33
kerframil raschipi: cool 15:34
raschipi 'beep-after(5, hours)' should be 'beep-after(:5hours)', I think. 15:35
kerframil raschipi: if you do find any bugs, though, let the maintainer know. he's a decent fella.
atroxaper raschipi: beep-after(5, hours) is not my code. it is a sample how you can write your code with time-unit 15:36
raschipi kerframil: I will, thanks for the help.
raschipi atroxaper: The way I would do  Perl6 interface like that would be 15:43
raschipi m: multi beep-after(:$minutes) { say "$minutes minutes" }; multi beep-after(:$seconds) { say "$seconds seconds" }; beep-after(:5minutes); beep-after(:3seconds); 15:44
camelia 5 minutes
3 seconds
timotimo but then you can't just combine it! :)
atroxaper sub beep-after($time, TimeUnit $unit) { sleep(seconds.from($time, $unit); beep(); }; beep-after(5, minutes); 15:47
atroxaper I think is good enough, no? 15:47
beep-after($minutes, minutes), yes ^^ 15:48
kyan m: my $a = 'b'; $_ := $a; sub foo() { say $a =:= $_; }; foo; 15:56
camelia False
kyan How can I make a sub inherit $_ from the enclosing block? 15:57
kyan (Replacing $_ with $b in that snippet, and putting "my " in front of the first instance, is inherited by the sub.) 15:59
moritz kyan: it inherits the value in $_, but not the container 16:00
you can access $OUTER::_ I guess, but please don't write to it
that's generally bad API design in Perl 6
m: my $a = 'b'; $_ := $a; sub foo() { say $a =:= $OUTER::_; }; foo; 16:01
camelia True
kyan Ok, thanks!
kyan It would be nice to be able to use the "given" keyword with sub declarations, something like sub foo() given $? { ... 16:05
moritz what would that do?
buggable New CPAN upload: TimeUnit-0.1.1.tar.gz by ATROXAPER cpan.metacpan.org/authors/id/A/AT/...1.1.tar.gz 16:06
kyan Erm, s/$?/$_ in my example. I'm thinking, since "given" sets $_ for a batch of "when" statements, it could set $_ for the sub to whatever it was set to in the caller... 16:08
Could also write sub foo() given "a" { ... to have $_ set to "a" in the sub
moritz kyan: or you can just write sub foo($_) { ... } 16:09
and have $_ set to the parameter that was passed to the sub 16:10
kyan That requires it to be specified on each call to foo, though. It's nice to be able to write "foo;" without any parens or arguments to call it
moritz that's not how Perl 6 does things 16:12
we are a bit more explicit about when we pass $_ to subs or methods
so that people don't have to keep a list of things in their head of which function works on $_ and which doesn't
which works pretty well in the core language 16:13
kyan Heh, fair enough. I guess I'm just too used to Bash, where functions mostly inherit the current state :P
Thanks!
(Is there a document somewhere that describes the differences between $_ and a "normal" variable, btw? I feel like that might help me out...) 16:15
raschipi $_ is a normal variable... 16:16
kyan Normal variables seem to get inherited by subs, though, whereas $_ doesn't — I feel like there might be a conceptual distinction I'm missing? 16:16
moritz kyan: both normal variables and $_ are inherited from the outer scope, though not from the caller 16:17
timotimo many blocks get their own $_
m: say (-> { say "hi" }).perl
camelia -> { #`(Block|50214056) ... }
timotimo m: say ({ say "hi" }).perl
camelia -> ;; $_? is raw { #`(Block|55969136) ... }
moritz m: my $a = 42; $_ = 23; sub f() { say (:$a, :$_).perl }; f(); { my $a = 1; my $_ = 2; f() } 16:18
camelia Potential difficulties:
Redeclaration of symbol '$_'
at <tmp>:1
------> 3$a, :$_).perl }; f(); { my $a = 1; my $_7⏏5 = 2; f() }
(:a(42), :_(Any))
(:a(42), :_(Any))
timotimo there, it has an optional $_ argument
kyan Oh, I think I get what you mean, it's like it's a normal variable but entering a sub creates a new $_ in the sub's scope? 16:19
moritz be careful in the sub vs. block distinction 16:19
m: sub f($a) { }; say &f.signature.perl 16:20
camelia :($a)
moritz no magic with $_ afaict
kyan Hmm. I guess I'll just keep working on the code and see if it becomes clear. (Sorry I'm kinda slow on the draw.) Thanks for your help! :) 16:21
raschipi kyan: What happens is that blocks that don't have any other signature will have just one parameter, called $_ 16:29
kyan Ohhhhh! I see. Thanks :D 16:30
HoboWithAShotgun how di create a sequence using an arbitrary code block to build the next item
ugexe m: my $block = { $^a + $^b }; say $block(1, 2)
camelia 3
HoboWithAShotgun again, i saw that in a video 16:31
ugexe map or gather/take would both work 16:31
wander m: $_ = 42; { .say } 16:32
camelia 42
HoboWithAShotgun i am trying to get this
gather { take $seed; until f($seed) < 1e-5 { take $seed = g($seed); }
jnthn m: say (1, 1, -> $a, $b { $a + $b } ... *)[^10]
camelia (1 1 2 3 5 8 13 21 34 55)
wander m: { .say }("hi")
camelia hi
HoboWithAShotgun into a sequence, but i am stuck at $seed ... ^0
i dont know how to put the function in there 16:33
basically the +1
jnthn Maybe something like: $seed, &g ... { f($_) < 1e-5 } 16:34
jnthn wanders home...bbl 16:36
wander m: my $seed = 0; sub g($seed) { $seed + 1 }; sub f($seed) { e**(-$seed) }; say $seed, &g ... { f($_) < 1e-5 };
camelia (0 1 2 3 4 5 6 7 8 9 10 11 12)
HoboWithAShotgun ah, nah. 16:38
raschipi m: my $seed = 127; say my @a = $seed, {$_ %% 2 ?? $_/2 !! $_*3+1} ... 4
camelia [127 382 191 574 287 862 431 1294 647 1942 971 2914 1457 4372 2186 1093 3280 1640 820 410 205 616 308 154 77 232 116 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4]
HoboWithAShotgun i think the original syntax is clearer
ugexe m: my $seed = 0; my $a := gather { take $seed; until $seed > 10 { take $seed = ($seed + 1) } }; say $a.perl
camelia (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11).Seq
HoboWithAShotgun that's what i have ugexe 16:38
ugexe but mine works, and you have f($seed) and g($seed) 16:39
e.g. maybe thats where your problem is
HoboWithAShotgun yes, i want the series of f1(x) until f(2(x) reaches a treshold 16:41
raschipi syntax error 16:42
ugexe m: say 1e-5.Int 16:48
camelia 0
kyan What's the right way to write a variable declaration of a List of Pairs? (e.g. my List $foo; versus my List of Pairs $foo) 16:51
ugexe list cant be typed
kyan Oh, interesting. 16:52
ugexe well, parameterized according to the error message.
kyan What's the right way to write something that acts kinda like that, but only lets pairs in? ;P 16:53
(making a subset of List I'd think might work (?) but seems like the wrong way to do it...) 16:54
ugexe my Pair @a;
kyan Oh! Ok. That's... surprisingly simple. Thanks!
ugexe note its an array, not a list though 16:55
kyan Cool, I'm not totally clear on the difference but I suspect that problem can be resolved by reading the docs :) Thanks! 16:56
mienaikage !p6mod bang on DuckDuckGo is now live 16:58
Geth doc: fluca1978++ created pull request #1601:
Fix "head2" POD title section.
17:25
Geth doc: 2a56726229 | (Luca Ferrari)++ | doc/Language/syntax.pod6
Fix "head2" POD title section.

That was my fault on PR merged by commit 135102b39481aa. There was an extra space between "head" and "2" leading to the wrong rendering of the section title.
17:27
synopsebot Link: doc.perl6.org/language/syntax
doc: 263c847f17 | Altai-man++ (committed using GitHub Web editor) | doc/Language/syntax.pod6
Merge pull request #1601 from fluca1978/method-precedence-drop

Fix "head2" POD title section.
Geth doc: W4anD0eR96++ created pull request #1602:
[WIP] Try to fix intro of non-string keys of Hash
18:04
rindolf mienaikage: nice 18:18
timotimo cool!
pmurias m: ("foo" => 10000000000000000000).BagHash.grab(1) 18:57
camelia Cannot unbox 64 bit wide bigint into native integer
in block <unit> at <tmp> line 1
pmurias ^^ seems like a bug?
Geth doc: fb1c89b28e | (David Warring)++ | doc/Language/nativecall.pod6
document newly introduced pointer increment and array referencing
19:12
synopsebot Link: doc.perl6.org/language/nativecall
geekosaur I think that's in a class of known bugs? 19:13
Geth doc: 927ddba17a | (Zoffix Znet)++ (committed using GitHub Web editor) | doc/Type/Failure.pod6
Fix typo
19:15
synopsebot Link: doc.perl6.org/type/Failure
audiatorix AlexDaniel-: any idea where the logic for destructuring lies?
AlexDaniel- pmurias: yes, seems like a bug 19:17
pmurias: please rakudobug if there's no ticket already
audiatorix: I think it depends on what you're looking for exactly. There are some bits and pieces in different places. Here for example: github.com/rakudo/rakudo/blob/25c8...5024-L5031 19:23
audiatorix: if you grep for sub-signature and maybe even subsignature you'll find some relevant pieces 19:24
audiatorix Thanks
raschipi mienaikage++ ddg++ 19:33
smls m: role R { multi method a (:$r!) { "R" } }; class A does R { multi method a { "A" } }; say A.new.a(:r) 19:37
camelia R
smls m: role R { multi method a (:$r!) { "R" } }; class A does R { multi method a (:$a) { "A" } }; say A.new.a(:r)
camelia A
smls ^^ bug?
AlexDaniel- smls: maybe not. I think both multies fit your arguments, and it makes sense that A is called first 19:41
smls AlexDaniel-: In the first version, both multies also fit the arguments. 19:42
AlexDaniel- smls: oh… 19:43
smls AlexDaniel-: And isn't :$r! a more specific fit for argument :r, than an implicit *%_ ?
AlexDaniel- smls: maybe you're right 19:45
HoboWithAShotgun i just learned about the WHY keyword. but that's a special case right? i mean i can't somehow access arbitrary comments via introspection 20:54
timotimo no, only pod comments that are attached to things 20:57
i.e. #| or #= comments
tyil is pod in perl 6 the same as in perl 5? I should start learning it and use it in my code 20:58
timotimo a bit different 20:59
tyil alright, I'll make sure to attach "perl 6" to any pod-related query as well :p 20:59
raschipi You can search for 'pod6' 21:00
tyil is there a utility to compile pod6 into a manpage? 21:03
raschipi Yes, perl6
tyil how would I invoke it to compile the pod6 from a perl script? 21:04
raschipi Use the --doc option. 21:05
tyil nvm, it was lower on the page
I should read before asking simple stuff ;~; 21:06
raschipi There's no problem with that, it's fine. 21:07
HoboWithAShotgun m: my @a = <1 2 3>; say @a.grep( * ~~ "2" ); 21:09
camelia (2)
HoboWithAShotgun m: my @a = <1 2 3>; say @a.grep( *.Int ~~ 2 ); 21:10
camelia Cannot use Bool as Matcher with '.grep'. Did you mean to use $_ inside a block?
in block <unit> at <tmp> line 1
HoboWithAShotgun why is this? why doesn't this dwim?
m: my @a = <1 2 3>; say @a.grep( *.Int == 2 ); 21:11
camelia (2)
HoboWithAShotgun argh
m: say "2" ~~ 2
camelia True
raschipi m: my @a = <1 2 3>; say @a.grep( {.Int ~~ 2} ); 21:12
camelia (2)
geekosaur I thought this was a listed/known trap
HoboWithAShotgun yeah i know
raschipi HoboWithAShotgun: It does exactly what you mean, you just meant the wrong thing.
HoboWithAShotgun bo it's still odd. if *.Int ~~ 2, and 2 ~~ "2", then *.Int must ~~ "2" too 21:13
geekosaur 'every dwim comes with a wat' 21:14
gfldex HoboWithAShotgun: that may be your opinion but the 2 .ACCEPT methods you are calling seam not to agree
geekosaur iirc here the 'wat' ends up being even more confusing; this case 'works' but others become incomprehensible 21:15
AlexDaniel- soooo… if you want it to DWIM, then…
m: my @a = <1 2 3>; say @a.grep( 2 ~~ *.Int );
camelia (2)
raschipi m: ( *.Int ~~ 2 ).WHAT; ( *.Int == 2 ).WHAT;
camelia ( no output )
AlexDaniel- this seems to work?
raschipi m: say ( *.Int ~~ 2 ).WHAT, ( *.Int == 2 ).WHAT;
camelia (Bool)(WhateverCode)
AlexDaniel- geekosaur: so what's the DWIM here then?
HoboWithAShotgun gdflex: there is no flaw in my argument. if x = y and y = z then z = x 21:16
HoboWithAShotgun and if perl thinks otherwise then perl is wrong 21:16
geekosaur raschipi just showed it, I think. the ~~ 'consumes' the WhateverCode
in effect it's using thw WhateverCode smartmatcher instead of the Int smartmatcher
but if you make it not do that then there are other cases you expect WhateverCode to smartmatch that won't 21:17
AlexDaniel- for example? 21:17
HoboWithAShotgun yeah, *. onward :) thx for the explanation
geekosaur I am struggling to remember this whole thing, I do recall I think TimToady explaining it at some point 21:18
gfldex ~~ on a Callable matches on the boolean result of invocation 21:19
geekosaur possibly something like using 'given' to match types?
raschipi HoboWithAShotgun: Smartmatch is explicitly NOT commutative
HoboWithAShotgun best to stay away from *, unless for when you are sure what you do
geekosaur ^
AlexDaniel- is it this? docs.perl6.org/language/traps#Topi..._Operators 21:19
geekosaur er. I meat for raschipi's remark
AlexDaniel- nah, not really 21:20
but the same “flip to LHS” remark applies
raschipi G'night people.
geekosaur a ~~ b can't mean the same thing as b ~~ a, because it has to pick one side to invoke .ACCEPTS on
gfldex m: my @a = <1 2 3>; my $result = { "2" }.().Bool; say @a.grep( $result ~~ 2 );
camelia Cannot use Bool as Matcher with '.grep'. Did you mean to use $_ inside a block?
in block <unit> at <tmp> line 1
geekosaur if nothing else, that error message tries hard but is still LTA 21:22
and, aaargh. yes, I think gfldex has the right of it; it's not WhateverCode per se, it's that the closure produced by WhateverCode is a Callable 21:23
HoboWithAShotgun m: ( * * * * *)(1 2 3) 21:24
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3( * * * * *)(17⏏5 2 3)
expecting any of:
infix
HoboWithAShotgun m: say ( * * * * *)(1 2 3)
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3say ( * * * * *)(17⏏5 2 3)
expecting any of:
infix…
geekosaur and you can't automatically 'promote' the closure to include the smartmatch without breaking something else? so it applies immediately matching the Callable, and you have therefore applied the immediate result of that as the grep expression 21:25
HoboWithAShotgun m: say sub { * * * * * }(1 2 3)
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3say sub { * * * * * }(17⏏5 2 3)
expecting any of:
in…
gfldex m: say { * * * * * }.(|(1 2 3)) 21:27
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed double closure; WhateverCode is already a closure without curlies, so either remove the curlies or use valid parameter syntax instead of *
at <tmp>:1
------> 3say { * * * * * }7⏏5.(|(1 2…
HoboWithAShotgun say ( * * * * * )(1, 2, 3)
evalable6 6
HoboWithAShotgun say ( * * * * *)(1, 2, 3)
evalable6 6
HoboWithAShotgun oh i forgot the commas abbove 21:28
HoboWithAShotgun m: sub f($x) { $x+1 }; my $x = 1; say ($x, f($x), f(*) ... 10) 21:39
camelia Cannot resolve caller Numeric(Whatever: ); none of these signatures match:
(Mu:U \v: *%_)
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
HoboWithAShotgun sub f($x) { $x+1 }; my $x = 1; say (1, 2, 3 ... 10) 21:40
m: say "ustillthere?"; 21:41
camelia ustillthere?
HoboWithAShotgun m: say (1, 2, 3 ... 10) 21:43
camelia (1 2 3 4 5 6 7 8 9 10)
AlexDaniel- HoboWithAShotgun: I created this: github.com/perl6/doc/issues/1603 21:48
HoboWithAShotgun: re “ustillthere”, you forgot “m:”
HoboWithAShotgun yeah i know :) 21:54
how do you do aspect orientation in perl6?
Xliff m: say '}' ~~ / '}' 21:57
camelia 5===SORRY!5===
Regex not terminated.
at <tmp>:1
------> 3say '}' ~~ / '}'7⏏5<EOL>
Unable to parse regex; couldn't find final '/'
at <tmp>:1
------> 3say '}' ~~ / '}'7⏏5<EOL>
expecting any of:
infix stopper
Xliff m: say '}' ~~ / '}' /
camelia 「}」
Xliff m: say '{' ~~ / '{' /
camelia 「{」
Xliff m: say '{' !~~ / '{' /
camelia False
HoboWithAShotgun can you have custom traits? 22:16
timotimo yup! 22:17
HoboWithAShotgun and what can you do with it? can i have it so that I say "my $var is debug" and have it do something wheneber something happens to that variable, like getting assigned to 22:19
timotimo i think you'll need to use a proxy for that purpose 22:22
rather than a trait
HoboWithAShotgun same for subs :)
timotimo that's easier
geekosaur hm. can a trait wrap a variable in a Proxy? 22:24
or, I guess, replace it with 22:25
HoboWithAShotgun yes, reading what a proxy is, that is what's needed apparently
cause if you have calls to that in your code you're better off explicity printing the variable 22:26
timotimo m: multi sub trait_mod:<is>(Variable:D $self is raw: :replaced!) { $self = my Str $ }; my Int $test is replaced; $test = "hi"; 22:26
camelia 5===SORRY!5=== Error while compiling <tmp>
Can only use the : invocant marker in the signature for a method
at <tmp>:1
------> 3rait_mod:<is>(Variable:D $self is raw: :7⏏5replaced!) { $self = my Str $ }; my Int
timotimo m: multi sub trait_mod:<is>(Variable:D $self is raw, :replaced!) { $self = my Str $ }; my Int $test is replaced; $test = "hi";
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed parameter
at <tmp>:1
------> 3rait_mod:<is>(Variable:D $self is raw, :7⏏5replaced!) { $self = my Str $ }; my Int
timotimo m: multi sub trait_mod:<is>(Variable:D $self is raw, :$replaced!) { $self = my Str $ }; my Int $test is replaced; $test = "hi"; 22:27
camelia 5===SORRY!5=== Error while compiling <tmp>
Cannot assign to an immutable value
at <tmp>:1
timotimo m: multi sub trait_mod:<is>(Variable:D $self is rw, :$replaced!) { $self = my Str $ }; my Int $test is replaced; $test = "hi";
camelia 5===SORRY!5=== Error while compiling <tmp>
Can't use unknown trait 'is replaced' in a variable declaration.
at <tmp>:1
------> 3f = my Str $ }; my Int $test is replaced7⏏5; $test = "hi";
expecting any of:
TypeObject
timotimo not like that clearly
HoboWithAShotgun i'm not a debugger person. what i'd love to have would be some nice way to make the program print debugging information without cluttering the code with print statements 22:29
could you maybe make it so these pod comments be printed as they occur? 22:30
possibly interpolated in the right scope?
timotimo you mean like "use trace"? :)
someone started work on active comments or something like that 22:31
where you'd put more # in a row and when the "comment output level" is higher than the number of # then the code gets run
HoboWithAShotgun thats neat!
timotimo i'm not sure how far they got or what it's called 22:32
HoboWithAShotgun TBD ...
timotimo i can't find it on the modules page 22:33
HoboWithAShotgun multi sub trait_mod:<is>(Variable:D $self is raw: :smaller!) { $self = --$self }; my Int $test is smaller=10; $test.say; 22:38
m: multi sub trait_mod:<is>(Variable:D $self is raw: :smaller!) { $self = --$self }; my Int $test is smaller=10; $test.say;
camelia 5===SORRY!5=== Error while compiling <tmp>
Can only use the : invocant marker in the signature for a method
at <tmp>:1
------> 3rait_mod:<is>(Variable:D $self is raw: :7⏏5smaller!) { $self = --$self }; my Int $t
HoboWithAShotgun i have no idea what i'm doing :) 22:39
timotimo yeah, has to be a , instead of the : after raw
and the "is raw" is the part that doesn't work
but be aware that traits are applied at compile time, as soon as the name is parsed
so the "= 10" will not be known at the point your trait is run
HoboWithAShotgun m: multi sub trait_mod:<is>(Variable:D $self is raw, :smaller!) { $self = --$self }; my Int $test is smaller=10; $test.say;
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed parameter
at <tmp>:1
------> 3rait_mod:<is>(Variable:D $self is raw, :7⏏5smaller!) { $self = --$self }; my Int $t
HoboWithAShotgun ah allright 22:40
timotimo yes, needs to have a $ there
HoboWithAShotgun m: multi sub trait_mod:<is>(Variable:D $self is raw, :smaller!) { say $self }; my Int $test is smaller=10; 22:41
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed parameter
at <tmp>:1
------> 3rait_mod:<is>(Variable:D $self is raw, :7⏏5smaller!) { say $self }; my Int $test is
timotimo m: multi sub trait_mod:<is>(Variable:D $self is raw, :$smaller!) { say $self }; my Int $test is smaller=10; 22:41
camelia Variable.new(name => "\$test", scope => "my", var => Int, block => -> gnatur { #`(Block|59330296) ... }, slash => Perl6::Grammar.new() #`[140477191271040])
HoboWithAShotgun better rtfm :)
where do i find this? 22:42
timotimo uhhh, hmm 22:44
timotimo i mean, you can look at the classes like Variable and the other traits that exist 22:48
it's all in rakudo/src/core/
Herby_ \o 22:59
HoboWithAShotgun lol. "In general this requires solving the halting problem, which even Perl 6 compiler writers have trouble with." 23:04
from the docs about wantarray 23:05
.tell zoffix i saw your video ( www.youtube.com/watch?v=paa3niF72Nw ), that was very enjoyable. why not make a few more? 23:07
yoleaux HoboWithAShotgun: I'll pass your message to zoffix.
timotimo zoffix has been encouraging people to give a talk at the torronto perl mongers via hangouts or similar 23:08
inviting i guess? 23:09
pilne when using nativecall, does the c code execute at (near?)c-speeds? or is it a glue functionality (and not a hotspot eliminator?) 23:20
geekosaur it's glue 23:28
pilne ty 23:29
timotimo the glue recently got improved to make it thinner 23:34
you can compare speeds between the last monthly release and current development version of rakudo 23:35
if you have some nativecall-heavy benchmark
timotimo signs off
pilne naahhhh i was just curious, all this dev stuff really is over my head, i'm just a huge fanboy/cheerleader (: 23:37
b2gills .tell kyan `.split("", :skip-empty)` is better written as `.comb()` 23:43
yoleaux b2gills: I'll pass your message to kyan.