»ö« 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.
mudman Exactly what does using the ‘@‘ sigil on a variable name imply? 00:01
raschipi Perl6 will use different interfaces when dealing with it.
mudman So, its a “promise” that the thing does the positional role? If so, how strong a promise? 00:02
jnthn m: my @a := 1 00:04
camelia Type check failed in binding; expected Positional but got Int (1)
in block <unit> at <tmp> line 1
raschipi It will refuse to put anything that doesn't implent Positional in there. Because it knows it won't be able to index ("[ ]") into it.
m: my @a := 1 but Positional 00:05
camelia ( no output )
jnthn Also it implies, on a variable declaration, that (by default) an Array container should be created there
And assignment is thus into that container
m: my @a = 1..5; my @b = @a; @b[2]++; say @a
camelia [1 2 3 4 5]
jnthn m: my $a = list 1..5; my $b = $a; $b[2]++; say @a 00:06
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '@a' is not declared. Did you mean '$a'?
at <tmp>:1
------> 3a = list 1..5; my $b = $a; $b[2]++; say 7⏏5@a
jnthn m: my $a = list 1..5; my $b = $a; $b[2]++; say $a
camelia Cannot resolve caller postfix:<++>(Int); the following candidates
match the type but require mutable arguments:
(Mu:D $a is rw)
(Int:D $a is rw)

The following do not match for other reasons:
(Bool:D $a is rw)
(Bool:U $a …
jnthn m: my $a = [1..5]; my $b = $a; $b[2]++; say $a
camelia [1 2 4 4 5]
jnthn So from those two, 1) assinging into @a makes mutable containers for each element, and 2) assignment between @-sigil things is copying, not by reference 00:07
raschipi In this last jnthn example, only one array was created by the [ ]. If there was @-sigiled variables involved, other arrays would be created and asigned. 00:08
raschipi So, to tie into my "uses other interfaces" comment above: if the variable has $, '=' will modify it's container. But if it has @, '=' will copy into the array. 00:17
raschipi mudman, makes sense? 00:24
Voldenet Can I somehow easily set affinity of the thread? 01:06
Voldenet I've thought of using pthread_setaffinity_np on MVMThreadBody's thread (I guess it might work on unix), but that'd be incredibly bruteforce way to do this 01:09
raschipi Voldenet: P6 threads are m:n so that information isn't easily manipulated. 01:10
The threads you see don't correspond to operating system threads. 01:11
Voldenet Oh, so I can't really count on doing stuff on uv_thread_t and expect it to work, eh 01:12
raschipi No, the P6 scheduler can remap the user threads to any operating system threads at any time. 01:13
Voldenet Well, I wish to get some of that stuff in the future, though even libuv devs don't have much love for that approach 01:14
I guess what comes from C, stays in C
raschipi You could try to write a scheduler that keeps these things fixed, they're pluggable. 01:15
raschipi You can provide your own Scheduler implementation that decides what to run, where, when. 01:16
Voldenet Ah, so _theoretically_ I could implement /pure pthreads/ scheduler in native C 01:17
raschipi P6 uses m:n to save memory as I understand it. A user thread that gets blocked stops using a OS thread from the pool. This avoids needing a lot of threads. But I don't know of any motive why it couldn't just launch a new OS thread and keep it 1:1. 01:18
Let them block, Linux can just swap them out. 01:20
Voldenet Yeah, and with OS threads we'd get some fancy features (like affinity bound producer-consumer queues) 01:21
raschipi Especially important when Numa is around. 01:22
raschipi Try to make fork work too. 01:23
There's an alternative Scheduler implementation: github.com/jnthn/p6-test-scheduler 01:24
timotimo raschipi: the scheduler is for tasks, not for threads 01:30
when you create a Thread.new, you'll get what you'd get from pthread_create 01:31
raschipi OK, so it also can't see OS threads?
Voldenet Oh..., so I actually could use pthread_setaffinity_np
timotimo what can't see os threads? 01:33
and what does "see" mean?
raschipi Let me rephrase. What's the difference between 'tasks' and 'threads'? 01:34
timotimo task is a callable that gets pushed into a queue
thread is a pthread plus management datastructures that belong to moarvm, usually also including a libuv event loop
well, callables + arguments i guess 01:35
b2gills $*SCHEDULER.queue(:hint-affinity) 01:36
timotimo b2gills: that only tells it to put the task into the affinity queues 01:37
timotimo affinity queues have the property that the general queue will never steal tasks from them when it's bored 01:39
raschipi It might be enough. 01:41
timotimo the OS is, of course, still free to pingpong that thread between processors
pthread_setaffinity_np with pthread_self (via nativecall) should work if you do Thread.new yourself 01:42
Voldenet Oh wow, it lives! :D 01:44
I got 15% free performance just by setting affinities :P 01:45
timotimo cool 01:49
timotimo what kind of machine is it, ooc? many cores? some NUMA kind of deal? 02:09
timotimo bed & 02:11
mudman [sorry: was called away] raschip: yes thankyou, that’s clear. 02:12
raschipi mudman: ask away if you have any 02:34
mudman well, since you ask…. jnthn’s last example; 02:38
m: my $a = [1..5]; my $b = $a; $b[2]++; say $a
camelia [1 2 4 4 5] 02:39
mudman … the second assignment, $b = $a; assignment b/w two scalars means “make a copy of whatever’s in container $a and put the copy into $b” 02:40
raschipi You need to know there's two containers there. 02:41
mudman … in this case though, there was an array container in $a. So a copy of the container was made - i.e a new array …
raschipi One is an scalar container and the other is an array container created by '[ ]'
What is copied (a new one is created) is the scalar container and bot point ot the array container (which there's only one). 02:42
It's not a deep copy. 02:43
mudman … but the copy is sort-of shallow: i.e. the (now two) arrays are using the same set of scalar containers… yes/no/[you’re crazy]?
raschipi Answered before you asked.
mudman ah.. 02:44
raschipi "(now two) arrays" There's only one array.
raschipi Array don't just pop up, they need to be created. Either by Array.new, [], or the default action on declaring a @ variable. 02:45
mudman well then, I need to think about that for a bit because in my (distorted) view, the assignment from $a to $b could just as well be a bind… let me play with the repl for a bit lest I waste you’r time 02:46
s/you’r/your/ 02:47
raschipi A variable in it's usual state points to a container that points to an object. Binding changes the first level while asignement changes the second. 02:48
mudman Yes, I’m pretty sure I’ve got that… but in the example, didn’t $a and $b end up pointing to the same container? 02:49
… or two seperate containers each pointing to the same object (ie the (singular) array)? 02:50
raschipi In that case there's 3 levels of redirection. From the variables to 2 containers which point to another container (which is the array).
mudman Thankyou, that’s clear (although, I’ve said that before :-) 02:51
raschipi Sometimes you just need to hear it again.
mudman indeed 02:52
raschipi And it's also important the fact that P6 treats an array and a container pointing to an array the same, it auto unboxes. 02:53
mudman yes, as I’ve read… the scalar container will “hide itself” whereas an array or hash container makes no such effort. 02:54
raschipi It's important to chase pointers even when the language doesn't have either pointers or references. 02:57
mudman “to chase pointers” meaning chase down exactly what’s going on here as I’m trying to do? 02:58
raschipi catb.org/jargon/html/C/chase-pointers.html 02:59
araralonre__ Hi 04:02
raschipi hey 04:03
araralonren I used Cro::HTTP::Client simulate search on some site 04:04
I do a post, and get a Response from the .post method 04:05
Then I call the .body-text, and get a Promise
The Promise status is always Planned except when I set CRO_DEBUG=1
sorry CRO_TRACE=1 04:06
araralonren gist.github.com/araraloren/b714822...9ff5cd9b66 04:07
This is the POST method
Thanks 04:08
Voldenet timotimo: a regular xeon, apparently for some workloads logical cpus help a little bit - i've set up my producers and consumers to communicate via physical cores with HT instead of "just let OS plan it", it's pretty obvious why it's faster in that config tho 05:30
lizmat commute to LPW& 07:52
araralonren How can I open a file using Perl6 under windows? 08:06
perl6 -e "say \"result.txt\".IO.lines" # Failed to open file F:\作业\搜索日志\result.txt: No such file or directory 08:07
The file is exists
araralonren :( And `perl6 -e "say \"result.txt\".IO.e"` # This return True 08:12
But I can not open that file
geekosaur o.O 08:17
that sounds like something gone wrong at either nqp or moarvm level, tbh 08:18
araralonren oh 08:21
Voldenet araralonren: the lowest you can get is `use nqp; my $f := nqp::open("result.txt", "r");`... 08:47
...but "open" call is what sets the error, probably 08:49
araralonren :( windows is suck 08:50
Voldenet github.com/MoarVM/MoarVM/blob/mast...ile.c#L454
Voldenet here's where the errors probably occurs, but I have no idea what actually happened 08:50
Voldenet does it break for any file or just this one? 08:51
araralonren yeah, maybe the encode IDK too
yeah every file
Maybe because the path has Chinese letter 08:52
IDK
araralonren Yeah, I test it. It's the path problem, but I wonder why it failed 08:58
Voldenet I was going to suggest perl6 under wsl, but now that I'm trying to run it, it just dies, I'm pretty unsure if it's worth the effort though 09:14
araralonren Hmm, I change the path to English, that's not worth currently :) 09:18
There also some problem when using Perl6 in windows 09:19
Voldenet but yeah, it works under wsl just fine 09:23
after some magic
i.imgur.com/swmdZMK.png 09:24
araralonren Voldenet, yeah, works for me too, but it has some problem. 09:44
I usually using rakudo under msl
Voldenet uhm, it's not full unix yet, has tons of problems ;\ 09:45
geekosaur yeh, and it wouldn't surprise me if autoconverting between utf16 Windows internal representation and utf8 for msl has glitches 09:46
stmuk from pbs.twimg.com/media/DPeBpbFW4AAv62v.jpg 11:41
to pbs.twimg.com/media/DPeW-B1XcAUTipS.jpg 11:42
selling well!
ZzZombo How doable is embedding Perl6 into, say, a C++ application? Or at least compile for a different target virtual machine that is embedded into said program? 12:37
timotimo you can embed a moarvm into any c/c++ program, or in fact anything that can call into C 12:39
jnthn There's not yet a formal API, but it's been done. See Inline::Perl6.
timotimo hold on, Inline::Perl6 actually embeds a perl5 inside perl6
i.e. when the perl5 interpreter finds Inline::Perl6, it'll exec a perl6 that then uses Inline::Perl5 to call the original script
at which point it can then just "do nothing" when Inline::Perl6 is loaded, because the perl6 is already there 12:40
jnthn I don't think it can exec it though, since it's all in the same process :) 12:40
Not to mention that I've seen code setting up MoarVM to run something
But yes, NativeCall will be involved too
Oh, also I see what timotimo meant: it's not quite "exec" so much as "just use MoarVM to invoke perl6.moarvm with a "use TheBinding" and TheBinding uses NativeCall to set up callbacks that can be used from C/C++ land 12:42
ZzZombo ah, I always wondered how exactly do those two work. Do they actually run the respective Perl executables? How do they get info out of them
timotimo Inline::Perl5 binds libperl.so or what it's called
jnthn Yeah, and Inline::Perl6 mostly re-uses Inline::Perl5 for all the heavy lifting, and just has a bit to load libmoar and set that up 12:44
ZzZombo interesting.
Geth doc: 4ca111db51 | (Jan-Olof Hendig)++ | doc/Type/Range.pod6
Added examples to int-bounds and fixed a typo
13:21
synopsebot Link: doc.perl6.org/type/Range
moritz does anybody want to write an advent post about Perl 6 modules on CPAN? 15:16
Geth doc: fc30df5bcb | (Moritz Lenz)++ | doc/Language/modules.pod6
Elaborate a bit on CPAN upload

  * use language "Target Directory" as it is used on PAUSE
  * declare up-front that this is the preferred way of doing things
15:34
synopsebot Link: doc.perl6.org/language/modules
ecosystem: 3f1d3fa39e | (Moritz Lenz)++ | PULL_REQUEST_TEMPLATE.md
Mention CPAN uploads in pull request template
15:38
moritz I think timotimo++ inspired the last commit 15:44
timotimo yeah i think i pointed that out, i might not be the only one (or even the first) 16:07
moritz perlpunks.de/paste/show/5a1998d5.b53.8b # number of modules by source 16:22
AlexDaniel fwiw I think greppable6 supports cpan, github and gitlab, but I'd love to add bitbucket and notabug. I just need someone to upload a module there :) 16:34
SmokeMachine jnthn: hi... im trying to write that test... but i can't find a way to make that work... 16:57
this is my try:
www.irccloud.com/pastebin/02Zcq1m7/
but it times out...
jnthn SmokeMachine: I'd not implement Tappable directly; $*SCHEDULER.cue does not return a Tap object that can be passed to the tap(...) function, though, which is what'll be going wrong 17:06
SmokeMachine I think Im going to use Supply.interval...
jnthn Yeah, that'll do it :)
SmokeMachine that worked for ThreadPoolScheduler but not for CurrentThreadScheduler... :( 17:11
wander I've seen a file of roast named "S05-mass". What is "mass" means? 17:13
timotimo "a whole bunch of tests" 17:14
or "similar tests" 17:15
"a whole bunch of similar tests"
jnthn SmokeMachine: No, I don't think it makes sense there
SmokeMachine: Could try with Supply.on-demand instead
.oO( There's so many tests, it took a whole Maß to write them... )
17:16
wander timotimo: still confuse, what information of the test can I get after reading the name? 17:23
SmokeMachine I tried using .from-list, but that already worked before the fix...
wander to me it seems like "misc" or "mess" 17:24
timotimo yeah 17:25
the major information in this case comes from the folder containing it
wander well :P 17:26
SmokeMachine jnthn: github.com/perl6/roast/pull/358 17:49
jnthn SmokeMachine: Left two small comments 17:51
SmokeMachine jnthn: I wrote a question... 17:53
jnthn Yeah, answered :) 17:54
I understand why the message that goes with a subtest goes at the end, but sometimes I wish it came first :) 17:55
timotimo implement an alternative called "testsub" where the description goes at the front
jnthn Or a multi that takes Str, & :P 17:56
SmokeMachine jnthn: that would make sense... 17:57
I changed to 5 seconds... should I merge it?
tyil is there an easy way to filter a list, ie <1 2 3 4 5 6>.filter(sub($x) { $x % 2 == 0 }) # <2, 4, 6> 18:00
I cant seem t ofind a "filter" routine in the docs
lizmat m: dd <1 2 3 4 5 6>.grep( * %% 2 ) 18:02
camelia (IntStr.new(2, "2"), IntStr.new(4, "4"), IntStr.new(6, "6")).Seq
lizmat m: say <1 2 3 4 5 6>.grep( * %% 2 )
camelia (2 4 6)
tyil oh
nice
thanks :3
jnthn SmokeMachine: It's merged :) 18:13
SmokeMachine :) 18:14
Im doing the same for zip-latest now...
SmokeMachine jnthn: the original tests of zip-latest are different from the docs... it isn't done on any are done: github.com/perl6/roast/blob/master...test.t#L16 18:40
is it ok to change the tests or the docs should be changed? 18:41
SmokeMachine m: react whenever Supply.from-list(^4).throttle(4, 1) { .say } 18:51
camelia (timeout)0
SmokeMachine shouldn't it become done when the original supply become done? 18:52
gagalicious is perl6 more popular than perl5 now? coz perl5 is good enough already and perl6 seems to be in dormant mode forever? 19:03
SmokeMachine looks the $done is never being seted: github.com/rakudo/rakudo/blob/mast...y.pm#L1434 19:05
timotimo gagalicious: where did you get the info about "dormant mode forever"? 19:06
El_Che gagalicious: your statement kind of contradict itself 19:08
timotimo i think perhaps one 5 got switched with a 6 by accident 19:08
El_Che we kind of agreed that Perl isn't like the Highlander 19:09
"There Can Be Only One" does not apply
geospeck Is there any way to get all the methods that an object responds to? For example in Ruby you can call "obj.methods" and it prints all the methods that obj responds to. 19:19
timotimo m: say Str.^methods 19:22
camelia (BUILD Capture Int Num chomp starts-with ends-with substr-eq contains indices index rindex pred succ comb match subst-mutate subst ords lines parse-base parse-names samecase samemark samespace word-by-word trim-leading trim-trailing trim words encode …
geospeck yes, that's what I was looking for. Thank you very much timotimo! 19:23
wander How about "value context"? 20:25
moritz what abouti t?
wander It says it's "sink, Boolean, string, or numeric", so what is "sink"?
moritz void
wander is `given $var { when / pattern / { ...} }' "sink"? 20:26
or I cannot find a direct example of it quickly :3 20:27
moritz $x; 1 20:29
the $x is in sink context
because nothing uses the value
m: 1; 2;
camelia WARNINGS for <tmp>:
Useless use of constant integer 1 in sink context (line 1)
Useless use of constant integer 2 in sink context (line 1)
wander yes, I know these are "void" 20:32
what I meet is "Specifically, a /.../ matches immediately in a value context (sink, Boolean, string, or numeric)"
wander so is there an example of matching in a "sink" context? 20:33
moritz m: 'abc' ~~ /a { say "I'm matching"}/; 20:35
camelia I'm matching
moritz ^^ your example
wander Just around! 20:37
Thank you.
Herby_ o/ 21:01
El_Che >~~{o 21:02
Herby_ rookie question: are grammars helpful if you don't the order of objects in a string? 21:22
sorry, the order of patterns 21:23
teatime can be
Herby_ for example, if I wanted to parse a torrent name: The Walking Dead S05E03 720p HDTV x264-ASAP[ettv] 21:23
I dont know that the title will always come first, or that the season and episode would be before the resolution 21:24
I was looking at trying my hand at porting this python module to p6: github.com/divijbindlish/parse-torrent-name 21:26
since I havent really used grammars much, I thought this might be a good exercise
El_Che Herby_: I don't se why not 21:34
see
the parts have recognizable parts 21:35
so you'll end up with something more reasable than a simple regex 21:36
Herby_ El_Che: thanks 21:37