»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'perl6: say 3;' or rakudo:, niecza:, std:, or /msg camelia perl6: ... | irclog: irc.perl6.org | UTF-8 is our friend!
Set by sorear on 25 June 2013.
masak `collect { for 1..3 -> $x { my $y = accept 1..3; my $z = accept 1..3; next if $x + $y + $z > 4; take "$x$y$z" }` # results in <111 112 121 211> 00:01
hm, that's not very convincing.
in this case, it *could* be written as for loops :)
trying again. 00:02
the use case I had in mind for this was something like the following:
`collect { my @result; for 1..$N -> $x { for 1..$N -> $y { @result[$x][$y] = accept some_calulated_alternatives() } }; take @result.clone }` 00:03
maybe this helps: gather/take : coroutines :: collect/accept : backtracking 00:05
masak in the case of `take` control flow *returns to the caller* for as long as the caller doesn't require the next one to be calculated. 00:10
in the case of `accept`, control flow *splits into several parallel universes* of computation, running them all separately, each with its own lexpad, stack, etc. 00:11
TimToady if it's parallel, it's not backtracking; sounds like a race to me 00:12
TimToady and gather/take can already handle the backtracking in a lazy context 00:13
masak hm, I meant parallel more in the sense of "aside each other".
masak but yeah, I guess there's nothing to prevent them from actually running in parallel, as long as the results come out in the expected order. 00:14
a bit like hyper.
I'm currently trying to make my code work with gather and some recursion. 00:15
TimToady anyway, I think STD has demonstrated that lazy lists are already sufficient for backtracking, so this would need to enable something more
logic variables, or some such
"here's the constraints, please solve" 00:16
TimToady and presumably return solutions lazily 00:17
masak *nod*
anyway, I'm not suggesting anything should be added to the language/spec as such.
this is a perfect example of something that should be experimented with in module space. 00:18
...but I do note how often I end up inventing nice features that end up depending on CPS transform :>
if I make it to YAPC::EU this year, my submitted talk will be about CPS transforms :) 00:19
colomon Carsonville - Port Saniliac? 00:27
colomon decides that is unlikely and backlogs
TimToady cycles per second, obviously :) 00:27
masak colomon: "Continuation Passing Style" 00:30
colomon masak++
masak colomon: basically, treating control flow as a first-class entity.
colomon jnthn: rakudo commit 408ebb9738d468cb996a8b70ea9eae4629a5b1a7 is the one that broke panda on moar. (Unsurprising, I suppose. But I confirmed it just to be sure.) 00:50
masak 'night, #perl6 01:23
colomon \o 01:24
BenGoldberg .tell masak Your "accept" operator sounds a lot like the "amb" nondeterministic choice operator. Take a look at <rosettacode.org/wiki/Amb#Perl>, in particular the first perl5 solution. 02:43
yoleaux BenGoldberg: I'll pass your message to masak.
TimToady I believe he mentioned amb, in fact 02:44
BenGoldberg Oh, nevermind then. 02:44
:) 02:45
avuserow (re Proxy sugar) I'd love to add something like smls++'s idea to Audio::Taglib::Simple. And certainly makes sense to try that in module-space first (or exclusively) 03:47
masak antenoon, #perl6 08:48
yoleaux 02:43Z <BenGoldberg> masak: Your "accept" operator sounds a lot like the "amb" nondeterministic choice operator. Take a look at <rosettacode.org/wiki/Amb#Perl>, in particular the first perl5 solution.
masak yes, it might very well be the same as "amb".
biggest difference is that "amb" isn't scoped, but you'd have to scope an "accept" inside of a "collect".
FROGGS hehe, three answers within five minutes :o) 11:00
(#perl6)++ # p6u
jnthn :) 11:06
timotimo we're all right 11:08
colomon o/
FROGGS jnthn: I have a nice problem when switching to a slang btw 11:11
jnthn: when I want to say the match, like in a token: .* { say $/ }, I get: 11:12
Cannot find method 'substr': no method cache and no .^find_method
though I can .DUMP the match, and it looks fine
I can also do: say $/.orig.substr($/.orig.from, ...), which is the same as the code that explodes in the setting 11:13
I guess that the creation of the cursor in FOREIGN_LANG is to blame... but I'm not sure 11:14
jnthn FROGGS: Might be that you're getting a NQP string leaking out 11:17
FROGGS my $s := nqp::findmethod(self, 'orig')(self); say nqp::isstr $s 11:47
1
\o/
jnthn++
now I just need to fix it :o)
masak I have a feeling that running `prove -e perl6` isn't so good for optimization. 14:48
because the runtime needs to start afresh with each new test file, even though the implementation code tested is the same all the time. 14:49
info pertinent to good optimization doesn't carry over from .t file to .t file
moritz it would be much better if it automatically precompiled and cached those files 14:52
masak sure. 14:53
but that still doesn't adress JITting. 14:54
colomon++ commented here: github.com/perl6/specs/commit/ca66...nt-6594349
colomon \o
masak I'm not sure either what to do with the wording. someone is welcome to give it a second go.
I just copy-pasted a paragraph from infix:</> without any changes. 14:55
masak if this one needs changing, maybe the original does, too. 14:55
colomon that explains the oddity. ;)
no
no!
well… maybe
but it never makes sense for / to return an Int, and it certainly makes sense for % to return one. 14:56
moritz for a % of fractions? 14:57
moritz not more than a / of fractions, IMHO 14:57
colomon Int / Int should return Rat (or Num)
Int % Int should return Int always
Rat % Rat should probably return Rat (or Num) 14:58
moritz agreed
% isn't diffy at all
colomon FatRat % FatRat should be a FatRat
colomon has a 5 year old begging him to bake sugar cookies.
moritz it's curious how persuasive children can be, no? :-) 14:59
colomon when he's climbing on my back it certainly makes it hard to ignore him
masak I think Rat % Rat should return Rat, not Num 15:00
at least I can't see a case where it'd have to be Num
colomon masak: it's there 15:02
I thought about it carefully this morning. :)
essentially it boils down to Rat + Rat, and that definitely can return a Num
m: say 1/5 % 1/7 15:03
camelia rakudo-moar 28d672: OUTPUT«0.0285714285714286␤»
colomon m: say (1/5 % 1/7).perl
camelia rakudo-moar 28d672: OUTPUT«0.0285714285714286e0␤»
colomon :( 15:04
n: say (1/5 % 1/7).perl
camelia niecza v24-109-g48a8de3: OUTPUT«<1/35>␤»
moritz % is like /, except that it also subtracts stuff aftewards
masak but Rat - Rat returns a Rat, no?
moritz so the denominator can grow, and thus overflow the magical 64 bit limit
masak ok, fairynuff
moritz I think Rat - Rat can also overflow 15:05
masak yes
because subtraction is addition of something of opposite sign
so, "most of the time" it should return a Rat
colomon n: say ((1/5) % (1/7)).perl 15:05
camelia niecza v24-109-g48a8de3: OUTPUT«<2/35>␤»
moritz p6: my $large = 2**62; my $d = 1/$lage - (1/($large - 1)); say $d; say $d.WHAT 15:06
camelia rakudo-{parrot,jvm,moar} 28d672: OUTPUT«===SORRY!=== Error while compiling /tmp/tmpfile␤Variable '$lage' is not declared. Did you mean '$large'?␤at /tmp/tmpfile:1␤------> my $large = 2**62; my $d = 1/$lage⏏ - (1/($large - 1)); say $d; say $d…»
..niecza v24-109-g48a8de3: OUTPUT«===SORRY!===␤␤Variable $lage is not predeclared at /tmp/tmpfile line 1:␤------> my $large = 2**62; my $d = 1/⏏$lage - (1/($large - 1)); say $d; say $␤␤Unhandled exception: Check failed␤␤ at /home/…»
moritz p6: my $large = 2**62; my $d = 1/$large - (1/($large - 1)); say $d; say $d.WHAT
camelia rakudo-jvm 28d672: OUTPUT«-4.70197740328915E-38␤(Num)␤»
..rakudo-{parrot,moar} 28d672: OUTPUT«-4.70197740328915e-38␤(Num)␤»
..niecza v24-109-g48a8de3: OUTPUT«-4.70197740328915E-38␤Num()␤»
colomon n: say ((1/(2**62)) % (1/(-1+2**62))).perl
camelia niecza v24-109-g48a8de3: OUTPUT«0.00000000000000000021684043449710088680149056017398834228515625␤»
dalek ecs: 5cad811 | (Konrad Borowski)++ | S03-operators.pod:
Int % Int should give Int, not Rat.
15:23
xfix I tried improving it slightly.
Except it still doesn't handle `FatRat` properly. 15:24
[Coke] CPS is obviously "Cookies per Second" (cookieclicker) 15:42
colomon and son now have a batch of sugar cookie dough cooling in the fridge 15:44
colomon hopes this turns out better than every single time I've tried to make sugar cookies before. :) 15:53
masak [Coke]: I like that. 15:57
[Coke]: I'll try to remember that for my endangered YAPC::EU talk.
cognominal r: say(nqp::eqaddr((class A {}), Nil)) 16:31
camelia rakudo-{parrot,jvm,moar} 28d672: OUTPUT«0␤»
cognominal n: say(nqp::eqaddr((class A {}), NQPMu)) 16:32
camelia niecza v24-109-g48a8de3: OUTPUT«===SORRY!===␤␤Undeclared name:␤ 'NQPMu' used at line 1␤␤Unhandled exception: Check failed␤␤ at /home/p6eval/niecza/boot/lib/CORE.setting line 1502 (die @ 5) ␤ at /home/p6eval/niecza/src/STD.pm6 line 1147 (P6.comp_un…»
cognominal nqp: say(nqp::eqaddr((class A {}), NQPMu))
camelia nqp-{moarvm,parrot}: OUTPUT«1␤»
..nqp-jvm: OUTPUT«(signal )#␤# There is insufficient memory for the Java Runtime Environment to continue.␤# pthread_getattr_np␤»
cognominal How do I test class equality in nqp? 16:34
cognominal nqp::eqaddr does not cut it. 16:35
cognominal or more likely (class A {}) does not return A 16:37
nqp: class A {}; say(nqp::eqaddr(A, NQPMu)) 16:39
camelia nqp-jvm: OUTPUT«(signal )#␤# There is insufficient memory for the Java Runtime Environment to continue.␤# pthread_getattr_np␤# An error report file with more information is saved as:␤# »
..nqp-{moarvm,parrot}: OUTPUT«0␤»
cognominal indeed
ren1us is there any particular reason why i wouldn't be able to have a list of lists? 17:39
colomon it's a datastructure, LoL 17:40
ren1us so? still an object 17:41
at least i assume so
because it looks like my sublists are all getting flattened together when i try to access elements
vendethiel ren1us: you can have one, you just need to itemize them
or something, it looks like nobody's actually able to tell me what is happening or, more importantly, why it's happening 17:42
timotimo or have a list of arrays 17:43
or an array of arrays
m: my @a; @a[1][1] = "hi!"; say @a.perl
camelia rakudo-moar 28d672: OUTPUT«Array.new(Any, [Any, "hi!"])␤»
jnthn ren1us: How are you constructing it?
m: my @a = [1,2], [3,4]; say @a[1] 17:44
camelia rakudo-moar 28d672: OUTPUT«3 4␤»
ren1us this is probably a syntactical calamity that i should be ashamed of even thinking of, but:
my @rules = (<visited pt1>, <goal pt1>) => (<finished>), (<visited pt1>, <adjacent pt2>, <not, visited, pt2>) => (<visited, pt2>);
if i say @rules, i get something that looks like the proper structure. but if i just do @rules[0], i get "visited" 17:45
timotimo accessing the list will cause its flattening rules to become active
you could say:
you have activated my trap card! mwahahahaha
i'm kind of surprised it would flatten through the pair, though 17:46
m: my @test = ("hey", "how") => "are", "you"; say @test.perl; say @test[0];
camelia rakudo-moar 28d672: OUTPUT«Array.new($("hey", "how") => "are", "you")␤$("hey", "how") => "are"␤»
ren1us o.O looks like my install's doing bizarre things again 17:47
timotimo huh, can you try to golf it down to a simple one-line piece of code that breaks for you locally and works in the evalbot?
that would be quite interesting
xfix Could Perl 6 grammars be used to make a syntax highlighter? That could be interesting use of them. 17:48
timotimo in theory, of course it could
xfix (but this probably would be too strict for dealing with invalid code)
timotimo however, syntax highlighters benefit greatly from ... yes
i wonder how one could build a ruby slippers parser with grammars 17:49
that would probably be a quite fantastic module to have
though to be honest i don't have any experience with using any of those
xfix It would be fun to have Perl 6 grammar to parse grammars (like ANTLR) that parse programs.
And there is grammar for Perl 6 grammars in STD.pm6 too, so it's even better. 17:50
ren1us p: my @rules = (<test line>, <another test>, <yay>) => "sup", "bleh"; say @rules[0]; 17:54
camelia rakudo-parrot 28d672: OUTPUT«$(("test", "line"), ("another", "test"), "yay") => "sup"␤»
ren1us just gives me "test" locally
ren1us of course, this is the same install that yells at panda, saying it can't find $*EXECUTABLE or something 17:55
so i hesitate to trust it
ren1us p: my @rules = (<test line>, <another test>, <yay>) => "sup", "bleh"; say @rules[0].key; 17:57
camelia rakudo-parrot 28d672: OUTPUT«test line another test yay␤»
ren1us well that's actually really unfortunate 17:58
timotimo m: say $*PERL 17:59
camelia rakudo-moar 28d672: OUTPUT«Perl 6␤»
timotimo m: say $*VM; 17:59
camelia rakudo-moar 28d672: OUTPUT«moar (2014.5.18.g.6.b.19.b.4.b)␤»
timotimo why the many dots there? o_O
ren1us: what does perl6 --version look like? 18:00
This is perl6 version 2014.05-138-g609fb8f built on MoarVM version 2014.05-15-gcdf5c71
is mine, for reference
ren1us This is perl6 version 2014.01 built on parrot 5.9.0 revision 0 18:01
which should be blatantly wrong
ATH=$PATH:$HOME/.perl6/rakudo-star-2014.04/install/bin <--- taken from my ~/.bashrc 18:02
PATH=*
timotimo well what does "which perl6" say?
ren1us ah, i never removed my old version from like... january 18:03
/usr/local/rakudo-star-2014.01/install/bin/perl6
there we go, fixed everything 18:05
timotimo why was that wrong in january? o_O 18:06
ren1us it probably was just a hiccup on my end then too 18:07
timotimo well, i don't recall things being very strange that late 18:09
i've been around for ~1.5 years and rakudo has always been pretty good
what you found there seems like a pretty big problem
ren1us i find that most simple things i do tend to turn out weird 18:10
timotimo you're very valuable, in that case :) 18:11
to us, that is
you, on the other hand, will be annoyed quite a bit :D
ren1us it's okay, i'm usually annoyed anyway
cognominal I am making a branch to make nqp more palatable for the newcomer. Tested only on moar with the nqp test suit so far. github.com/cognominal/nqp/commits/...model-info 18:16
ren1us well, not everything works. still can't bootstrap panda 18:18
colomon ren1us: wait, what can't bootstrap panda? 18:32
colomon ren1us: the bleeding edge latest Rakudo-moar is broken and cannot bootstrap panda, if that's what you're trying to do. 18:33
ren1us pastebin.com/HuctLHLg 18:35
colomon If that's the case, going back to Rakudo's 9644b265bba2d54900e0ce59a3376eeadfdb43f2 commit works.
]oh, no, that's a completely different error than the one I've been getting
ren1us: is that the panda that came with that r*? 18:37
ren1us no, it's the panda that comes from cloning the git repo 18:38
colomon oh, panda latest probably isn't compatiable with r* from April anymore
there's a tag in panda's git for the last version that would work with that.
I think this is it? github.com/tadzik/panda/releases/tag/2014.04 18:39
ren1us i'll check it in a moment, trying to hunt down where something's sneaking into my $PATH 18:41
colomon www.concertwindow.com/shows/6736-p...o-festival # probably not our pmichaud ;) 18:52
ren1us colomon: worked perfectly 18:59
colomon \o/ 19:00
ren1us m: my $pair = (<this is>, <a list>, <of four>, <sublists>) => "Or is it?"; say $pair.key; 19:03
camelia rakudo-moar 28d672: OUTPUT«this is a list of four sublists␤»
ren1us is there a good way to do that without having the key list flattened?
jnthn [<this is>], [<a list>], ... 19:04
Or (<this is>, <a list>, <of four>, <sublists>).tree => "Or is it?" 19:05
ren1us oh wow, those both work. that's awesome. 19:08
jnthn phew, I didn't try them before suggesting... :) 19:09
ren1us i'm curious. what do .tree and the extra []s do?
just flag it as "Don't flatten me, I like being complicated!"? 19:10
masak [] is an array constructor 19:11
.tree (as far as I grok it) takes parcels and makes arrays out of them, recursively
jnthn The key to it is that there are items and lists, and items never flatten and lists do - unless you use soemthing like .tree which enforces a context where they won't. [...] says "I want an array, and I mean it as a single item". 19:16
ren1us so something like [<hello world>] is making an array of a list so the list has a buffer between itself and the parent list and doesn't get assimilated into the collective? 19:18
masak right. the <> are only there to get you the list-quoting environment. 19:20
jnthn A better way to understand it is that when you write "my $a = 42" then $a is a Scalar container and it holds a 42. [<hello world>] makes an array and puts it in a container.
masak the [] take care of non-flattening/item context.
jnthn It's really all about scalars
masak like Rust's `mut` keyword. 19:21
jnthn [<hello world>] is really like Array.new(<hello world>).item which is really like (my $anon = Array.new(<hello world>)
)
At the end of the day, in a context where something might flatten, the question is always "is it in a scalar"? If yes, it won't flatten. 19:22
It's a relatively simple rule at the heart of it. Just means learning which things give you items. [...] is one of those things that does. 19:23
ren1us the reasoning makes sense, but the use of an array to fake it just feels kinda dirty
jnthn It's not the array that matters, really...it's the item. It's just that [<a b>] is nice to type :) 19:24
masak <a b>.item would work too, I guess.
jnthn r: my @a = <a b>.item, <c d>.item; say @a[1]
camelia rakudo-{parrot,jvm,moar} 28d672: OUTPUT«c d␤»
jnthn Right.
masak right.
jnthn hey. :P
masak quantum entanglement. it happens, on #perl6. 19:26
ren1us that feels much cleaner. i might just add a postfix operator to call .item or something 19:29
masak r: sub postfix:<!>(@list) { @list.item }; say (<this is>!, <a list>!, <of four>!, <sublists>!).perl 19:36
camelia rakudo-{parrot,jvm,moar} 28d672: OUTPUT«===SORRY!=== Error while compiling /tmp/tmpfile␤Calling 'postfix:<!>' will never work with argument types (str)␤ Expected: :(@list)␤at /tmp/tmpfile:1␤------> is>!, <a list>!, <of four>!, <sublists>⏏[3…» 19:37
masak oh, right. 19:37
r: sub postfix:<!>(\list) { list.item }; say (<this is>!, <a list>!, <of four>!, <sublists>!).perl
camelia rakudo-{parrot,jvm,moar} 28d672: OUTPUT«($("this", "is"), $("a", "list"), $("of", "four"), "sublists")␤»
jnthn hehe...it even caught your opertor mis-use at compile time there :D 19:39
masak yes :) 19:43
vendethiel m: sub postfix:<$>(\list) { list.item; }; say (<this is>$, <a list>$, <of four>$, <sublists>$).perl 19:57
camelia rakudo-moar 28d672: OUTPUT«($("this", "is"), $("a", "list"), $("of", "four"), "sublists")␤»
vendethiel $()-ish
timotimo yeah, postfix dereferencing is in perl5 now 19:58
zengargoyle what is `\list`? a form of sigilless variable or some sort of capture/parcel/whatever thing? 20:02
timotimo sigil-less variable 20:04
it's meant to signify "neither list nor item semantics are applied, if they weren't there before"
timotimo if you put something into a $var, you'll get it turned into a scalar container if it isn't one; if you put something into a @var, it'll be turned into a flattening container type of thing 20:04
if you use \, you'll get whatever is on the right side of the = 20:05
zengargoyle cool, gotcha. i've seen it a few times in places and sorta guessed that's what it was.
timotimo it's also a nice way to have mathematical formulas look nicer 20:06
m: my \ℕ = (1, 2, 3); say ℕ
camelia rakudo-moar 28d672: OUTPUT«1 2 3␤»
pippo o/ #perl6 20:20
timotimo hey there pippo
pippo Some one can direct me on how to use the when construct?
vendethiel pippo: when is basically `if $_ ~~` 20:21
pippo vendethiel: Thsnk you very much! 20:22
vendethiel: Thank you very much!
timotimo combines well with things that set $_ ("contextualizers") like for, CATCH, given, ...
jnthn m: my $does-pippo-know-how-when-works = 'no'; given $does-pippo-know-how-when-works { when 'yes' { say 'good, go drink' }; when 'no' { say 'look, like this!' } } 20:23
camelia rakudo-moar 28d672: OUTPUT«look, like this!␤»
jnthn m: my $does-pippo-know-how-when-works = 'yes'; given $does-pippo-know-how-when-works { when 'yes' { say 'good, go drink' }; when 'no' { say 'look, like this!' } }
camelia rakudo-moar 28d672: OUTPUT«good, go drink␤»
timotimo and it also combines well with succeed and proceed 20:25
vendethiel hasn't done perl 6 in a while now ...
cognominal can't figure out what is nqp::p6bindattrinvres
vendethiel but has convinced his internship ... "manager" ? to take a look
jnthn colomon: What it says :D 20:26
oops
cognominal: ^^
bind attribute, and take the invocant as the result :)
nqp::bindattr(...) evaluates to the bound value rather than the invocant.
jnthn bindattrinvres is mostly used to get nicer code-gen on some hot paths without introducing a temporary var. 20:27
And makes the code look nicer too
cognominal thanx
pippo jnthn: thank you for the example :-). Is there the possibility to have a when that is matched if all previous are not? 20:27
jnthn default { } 20:28
pippo TY!
carlin_ NativeCall on the JVM doesn't seem to like trait_mod:<is>(&foo, :native('libfoo')); hackery 20:30
works fine on moar though 20:31
timotimo carlin_: perhaps it needs to go into a BEGIN block? 20:40
jnthn Probably tells us there's some r-j bug, though...
carlin_ dies in a BEGIN block too 20:48
it works with sub foo is native(...); but with trait_mod:<is> it dies with "This representation can not unbox another" 20:49
raiph .tell xfix I'm trying to encourage a little cleanup of gh/perl6; github.com/perl6/bench-scripts; last update by xfix 1 year ago; does it make sense to move scripts into japb/perl6-bench then delete repo? if so, would you be willing to do that? 21:05
yoleaux raiph: I'll pass your message to xfix.
xfix I don't care bench-scripts anyway. That was a random change to make them work in newest releases. 21:06
yoleaux 21:05Z <raiph> xfix: I'm trying to encourage a little cleanup of gh/perl6; github.com/perl6/bench-scripts; last update by xfix 1 year ago; does it make sense to move scripts into japb/perl6-bench then delete repo? if so, would you be willing to do that?
xfix I doubt that anyone works on these now.
I just fixed the script to be able to compare the performance of Perl 6 1.5 years before. I doubt they work now. 21:07
raiph do you have privs to remove that repo?
xfix I don't.
raiph thx
xfix Only the last commit was my work.
raiph .tell pmichaud I'm trying to encourage a little cleanup of gh/perl6; please delete github.com/perl6/bench-scripts, /reports, and /nqpbook (for a bit more detail see questhub.io/realm/perl/quest/53457...d24e00006d and irclog.perlgeek.de/perl6/2014-06-08#i_8840143) 21:10
yoleaux raiph: I'll pass your message to pmichaud.
raiph .tell moritz I'm trying to encourage a little cleanup of gh/perl6; please search for 'moritz' in questhub.io/realm/perl/quest/53457...d24e00006d TIA 21:11
yoleaux raiph: I'll pass your message to moritz.