»ö« 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.
ugexe m: module XXX { sub foo() is export { 42 }; }; import XXX; say foo; my &foo = sub { 43 }; say foo; 00:00
camelia rakudo-moar ee8a25: OUTPUT«Potential difficulties:␤ Redeclaration of symbol &foo␤ at <tmp>:1␤ ------> 3 { 42 }; }; import XXX; say foo; my &foo7⏏5 = sub { 43 }; say foo;␤Cannot invoke this object (REPR: Uninstantiable; Callable)␤ in block <unit> at <tmp> li…»
ugexe first example returns 43 after a warning. second example blows up when trying to call foo() before the re-declaration 00:01
00:06 labster joined 00:12 ZoffixLappy joined
ZoffixLappy m: sub Levenshtein {}; Levenshtei(); 00:13
camelia rakudo-moar ee8a25: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Undeclared name:␤ Levenshtei used at line 1␤␤»
ZoffixLappy Didn't Perl 6 make suggestions for mis-typed sub names?
Oh
m: sub levenshtein {}; levenshtei();
camelia rakudo-moar ee8a25: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Undeclared routine:␤ levenshtei used at line 1. Did you mean 'levenshtein'?␤␤»
ZoffixLappy I wonder how come it didn't work on a caps. It was just off by one letter.
00:14 pierre_ joined
timotimo you're thinking of it wrong 00:14
we're not looking through subs when you've typo'd something that looks like a Type (because upper case first letter) 00:15
ZoffixLappy Ahh
Thanks :-0
*:)
00:18 sufrostico left 00:20 canopus left
timotimo i better be the one to answer to this, as i'm the one who wrote that stuff :) 00:26
00:26 rindolf left 00:27 canopus joined
ZoffixLappy m: my $seq = (1, 1, * + * … * > 100); .say for |$seq.cache; say $_² for |$seq.cache; 00:28
camelia rakudo-moar ee8a25: OUTPUT«1␤1␤2␤3␤5␤8␤13␤21␤34␤55␤89␤144␤1␤1␤4␤9␤25␤64␤169␤441␤1156␤3025␤7921␤20736␤»
ZoffixLappy huh
Oh... never mind
TIL: editing code in your article is not the same as editing code in the file you're attempting to run %)
timotimo :)
00:38 mvorg left
ZoffixLappy m: my $seq = (1, 1, * + * … * > 10); $seq[0..6].join(', ').say; $seq[0..6].map({ $_² }).join(', ').say; 00:43
camelia rakudo-moar ee8a25: OUTPUT«1, 1, 2, 3, 5, 8, 13␤1, 1, 4, 9, 25, 64, 169␤»
ZoffixLappy m: my $seq = (1, 1, * + * … * > 10); $seq.join(', ').say; $seq.map({ $_² }).join(', ').say;
camelia rakudo-moar ee8a25: OUTPUT«1, 1, 2, 3, 5, 8, 13␤This Seq has already been iterated, and its values consumed␤(you might solve this by adding .cache on usages of the Seq, or␤by assigning the Seq into an array)␤ in block <unit> at <tmp> line 1␤␤»
ZoffixLappy I'm curious, why doesn't the first version also give an error? Wouldn't taking a slice count as "iterating"? What difference is there between the two examples? 00:44
gfldex m: my $seq = (1, 1, * + * … * > 10); $seq[0..6].^name.say
camelia rakudo-moar ee8a25: OUTPUT«List␤»
gfldex it actually creates a new List 00:45
ZoffixLappy Sure, but it has to iterate over a Seq to get that List, doesn't it?
gfldex it may clone the original Seq first, what I would not count as iteration. 00:46
ZoffixLappy Ah
Ohh 00:47
m: my $seq = (1, 1, * + * … * > 10); $seq[0..6].join(', ').say; $seq.map({ $_² }).join(', ').say;
camelia rakudo-moar ee8a25: OUTPUT«1, 1, 2, 3, 5, 8, 13␤This Seq has already been iterated, and its values consumed␤(you might solve this by adding .cache on usages of the Seq, or␤by assigning the Seq into an array)␤ in block <unit> at <tmp> line 1␤␤»
ZoffixLappy It does iterate over it, it's just the second slice gives me the .cache (or something similar to that reasoning)
timotimo huh 00:48
ZoffixLappy m: my $seq = (1, 1, * + * … * > 10); $seq.cache.join(', ').say; $seq.cache.map({ $_² }).join(', ').say; 00:49
camelia rakudo-moar ee8a25: OUTPUT«1, 1, 2, 3, 5, 8, 13␤1, 1, 4, 9, 25, 64, 169␤»
ZoffixLappy m: my $seq = (1, 1, * + * … * > 10); $seq.cache.join(', ').say; $seq.map({ $_² }).join(', ').say;
camelia rakudo-moar ee8a25: OUTPUT«1, 1, 2, 3, 5, 8, 13␤This Seq has already been iterated, and its values consumed␤(you might solve this by adding .cache on usages of the Seq, or␤by assigning the Seq into an array)␤ in block <unit> at <tmp> line 1␤␤»
ZoffixLappy That's what I imagine it being similar to.
00:49 kurahaupo left 00:53 kurahaupo joined 00:54 mohae joined, pierre_ left 00:56 rkazak left, kurahaupo left 00:57 pierre_ joined 00:58 mohae_ left 01:01 rkazak joined
ZoffixLappy Rakudo got three language braids, right: Perl 6, Regex, and Quote? 01:04
timotimo m: BEGIN say %*LANG.keys 01:05
camelia rakudo-moar ee8a25: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤An exception occurred while evaluating a BEGIN␤at <tmp>:1␤Exception details:␤ 5===SORRY!5=== Error while compiling ␤ Cannot find method 'keys': no method cache and no .^find_method␤ at :␤»
timotimo hm
ZoffixLappy m: BEGIN say %*LANG
camelia rakudo-moar ee8a25: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤An exception occurred while evaluating a BEGIN␤at <tmp>:1␤Exception details:␤ 5===SORRY!5=== Error while compiling ␤ Method 'WHICH' not found for invocant of class 'Perl6::Grammar'␤ at :␤»
timotimo hehe.
ZoffixLappy :D
timotimo probably need to do nqp ops to it
m: BEGIN for %*LANG { say $_ } 01:06
camelia rakudo-moar ee8a25: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤An exception occurred while evaluating a BEGIN␤at <tmp>:1␤Exception details:␤ 5===SORRY!5=== Error while compiling ␤ Cannot find method 'map': no method cache and no .^find_method␤ at :␤»
timotimo *shrug*
ZoffixLappy Oh well, not overly important.
timotimo too tired to bother
ZoffixLappy Go to bed :)
timotimo i will at some point
gfldex signatures are another language 01:08
ZoffixLappy :o
timotimo um ... they are?
01:08 rkazak left
gfldex i don't know if the grammar is naming them as such but there are enough different rules in sigs to make that distinction valid 01:09
timotimo ah
we were wondering about the language braid, though
gfldex and they show up in 3 different spots that are not so clearly divided by a set of {} 01:10
timotimo in roles' [], in sub's/method's (...) and between -> and {
right?
well, you can also have a signature literal with :( ... )
gfldex in :() and my ( Int, ($, @)) 01:11
timotimo ah
gfldex not sure if you can where clauses in destructuring tho
timotimo we probably parse it, though we may not code-gen it properly 01:12
gfldex m: dd my ($i, ($j, $k where * == 3)) = (1,(2,3)); 01:13
camelia rakudo-moar ee8a25: OUTPUT«(1, $(2, 3))␤»
gfldex m: dd my ($i, ($j, $k where * == 4)) = (1,(2,3));
camelia rakudo-moar ee8a25: OUTPUT«(1, $(2, 3))␤»
gfldex m: dd my ($i, ($j, $k where * == 4)) = (1,(2,3)); say $k
camelia rakudo-moar ee8a25: OUTPUT«(1, $(2, 3))␤(Mu)␤»
gfldex m: dd my ($i, ($j, $k where * == 4)) = (1,(2,3)); say $i, $j, $k
camelia rakudo-moar ee8a25: OUTPUT«(1, $(2, 3))␤1(Mu)(Mu)␤»
timotimo now, should we give an NYI error there?
huh
gfldex at least $j should have a value, better the whole expression should throw up 01:14
timotimo m: my ($i, ($j, $k where * == 4)) = (1,(2,3)); say $i, $j, $k
camelia rakudo-moar ee8a25: OUTPUT«1(Mu)(Mu)␤»
gfldex could you rakudo bug this please? my tea is getting cold :(
timotimo let's see 01:15
gfldex m: dd my ($i, ($j, $k)) = (1,(2,3)); dd $i, $j, $k
camelia rakudo-moar ee8a25: OUTPUT«(1, $(2, 3))␤Int $i = 1␤Mu␤Mu␤»
timotimo what mail address do i use for rakudobug ...
gfldex m: dd my ($i, [$j, $k]) = (1,(2,3)); dd $i, $j, $k
camelia rakudo-moar ee8a25: OUTPUT«(1, [(2, 3),])␤Int $i = 1␤Mu␤Mu␤»
gfldex m: dd my ($i, $k where * == 4) = (1,,3); dd $i, $k 01:16
camelia rakudo-moar ee8a25: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Preceding context expects a term, but found infix , instead␤at <tmp>:1␤------> 3dd my ($i, $k where * == 4) = (1,,7⏏053); dd $i, $k␤»
ZoffixLappy huggable, rakudobug
huggable ZoffixLappy, [email@hidden.address] or use perl6 query on rt.perl.org ; see github.com/rakudo/rakudo/#reporting-bugs
ZoffixLappy timotimo, ^
gfldex m: dd my ($i, $k where * == 4) = (1,3); dd $i, $k
camelia rakudo-moar ee8a25: OUTPUT«(1, 3)␤Int $i = 1␤Int $k = 3␤»
timotimo ZoffixLappy: no i mean, which of *my* email addresses :)
ZoffixLappy :F
timotimo what should i tag that, i wonder 01:17
gfldex i wanted to blog about signatures for quite some time now but I can't come up with a nice RL example 01:18
i think it's a bug because the where clause is simply ignored. It should throw to be useful.
m: sub f { 42 }; my $i where * == 2 = f; 01:19
camelia rakudo-moar ee8a25: OUTPUT«Type check failed in assignment to $i; expected <anon> but got Int (42)␤ in block <unit> at <tmp> line 1␤␤»
gfldex m: sub f { 42 }; my ($i where * == 2) = f;
camelia ( no output )
timotimo i rakudobugged something
01:20 jack_rabbit joined
gfldex .tell TimToady you may want to spend some attention on m: sub f { 42 }; my ($i where * == 2) = f; (backlog: irclog.perlgeek.de/perl6/2016-08-15#i_13023085) 01:21
yoleaux gfldex: I'll pass your message to TimToady.
gfldex do we host irclogs somewhere under perl6.org ?
timotimo we have irc.perl6.org that links to our irclog 01:22
as in redirects
ZoffixLappy m: class { has $!prefix = 'foo'; method has-prefix ($text) { so $text ~~ /^ $_/ given $!prefix; } }.new.has-prefix('foobar').say; 01:24
camelia rakudo-moar ee8a25: OUTPUT«False␤»
ZoffixLappy False? :S
Ah... damned smartmatch aliasing things.
Man, I this is not the first time I get burned by that :/ 01:25
m: class { has $!prefix = 'foo'; method has-prefix ($text) { so /^ $_/.ACCEPTS($text) given $!prefix; } }.new.has-prefix('foobar').say; 01:26
camelia rakudo-moar ee8a25: OUTPUT«False␤»
ZoffixLappy :/
01:27 Actualeyes left
ZoffixLappy m: class { has $!prefix = 'foo'; method has-prefix ($text) { given $!prefix { so $text ~~ /^ $_/ } } }.new.has-prefix('foobar').say; 01:28
camelia rakudo-moar ee8a25: OUTPUT«True␤»
ZoffixLappy That's weird :/ I don't get it
01:29 rkazak joined 01:30 Actualeyes joined
timotimo you do know we have starts-with? 01:32
ZoffixLappy I do now :)
timotimo++ 01:33
But I still don't get why block form of given works, while postfix form doesn't :/
timotimo that's above my paygrade to answer for 3:30am :) 01:34
gfldex class { has $!prefix = 'foo'; method has-prefix ($text) { so { /^ $_/.ACCEPTS($text) } given $!prefix; } }.new.has-prefix('foobar').say;
m: class { has $!prefix = 'foo'; method has-prefix ($text) { so { /^ $_/.ACCEPTS($text) } given $!prefix; } }.new.has-prefix('foobar').say;
camelia rakudo-moar ee8a25: OUTPUT«True␤»
gfldex m: class { has $!prefix = 'foo'; method has-prefix ($text) { /^ $_/.ACCEPTS($text) given $!prefix; } }.new.has-prefix('foobar').say;
camelia rakudo-moar ee8a25: OUTPUT«Nil␤»
ZoffixLappy gfldex, but why?
m: .say given 'foo'; 01:35
camelia rakudo-moar ee8a25: OUTPUT«foo␤»
gfldex bug‽
ZoffixLappy This has $_ correctly
hm
I wonder if the regex get made with the $_ of the block, before it gets a chance to get iterated (or given)
01:36 RabidGravy left 01:37 zacts joined 01:38 wbill joined 01:39 rkazak left
[Coke] . 01:43
ZoffixLappy : 01:44
01:45 cyphase left
ZoffixLappy I find it interesting that so many people use the dot, when attempting to see if they have messages. Why not "a"? Why not "Δ"? :) 01:45
01:45 ilbot3 left
gfldex maybe they have a point? :-> 01:47
01:47 ilbot3 joined
ZoffixLappy gfldex++ 01:47
01:50 cyphase joined, rkazak joined
sena_kun ZoffixLappy, someone saw it and repeated(like me, for example). Then someone else saw how previous person did it and thought "So that's how you do it"... That's how tradition works. (: 01:52
ZoffixLappy I think it has more to do with semantic meaning. "." is kind of a null sentence. If I randomly say "a" people will wonder wtf am I talking about. 01:55
01:56 pierre_ left
sena_kun Yeah, that's another reason I thought of(seems like I postfactum try to act smart, but still). And dot visually takes a very little space so it's easier to flow through the log. 01:57
ZoffixLappy That's a curious point, because the stuff that takes no "space" at all is a space, yet no one is using it: 01:59
Because it's not a "null sentence" :D
sena_kun Ow.
Cool.
To be honest, I didn't knew it, lol.
ZoffixLappy :)
sena_kun Ah.
01:59 stmuk_ left
sena_kun My grammar becomes worse when morning come. It's time to sleep then. 02:00
02:01 sena_kun left
gfldex 02:01
02:02 TimToady left 02:03 pierre_ joined 02:04 TimToady joined 02:07 stmuk_ joined 02:08 pierre_ left 02:18 noganex joined 02:21 noganex_ left 02:22 pierre_ joined 02:26 ZoffixLappy left, pierre_ left 02:30 pierre_ joined 02:35 wamba joined 02:47 bob777 joined 02:48 zacts left 02:50 kid51 left 02:57 stmuk joined 02:59 stmuk_ left, canopus left 03:02 Actualeyes left 03:06 canopus joined
MasterDuke .tell moritz i commented on an open issue for each of SVG ( github.com/moritz/svg/issues/1 ) and SVG::Plot ( github.com/moritz/svg-plot/issues/8 ) that seemed to be about the same problems i am having 03:10
yoleaux 14 Aug 2016 20:05Z <moritz> MasterDuke: please open an issue for your SVG::Plot problems; otherwise I'M afraid I'll forget
MasterDuke: I'll pass your message to moritz.
03:27 khw left 03:32 wamba left 03:54 pduh left 03:58 skids left 04:03 mempko joined 04:20 Actualeyes joined 04:23 Cabanossi left 04:25 Cabanossi joined
zostay m: say 3 %% 2; say 3 !%% 2; say 4 %% 2; say 4 !%% 2; 04:26
camelia rakudo-moar ee8a25: OUTPUT«False␤True␤True␤False␤»
zostay mind blown 04:27
04:29 silug left
zostay m: class T { has $.foo where *.elems !%% 2 }; T.new(:foo(^3)); T.new(:foo(^4)); 04:32
camelia rakudo-moar ee8a25: OUTPUT«Type check failed in assignment to $!foo; expected <anon> but got Range (^4)␤ in block <unit> at <tmp> line 1␤␤»
04:42 rkazak left 04:44 silug joined 04:52 labster left 04:55 mempko left 04:59 pierre_ left 05:04 leego left, pierre_ joined 05:08 pierre_ left 05:21 zengargoyle joined 05:22 nightfrog left 05:25 CIAvash joined 05:26 mempko joined 05:29 harovali1 left 05:30 harovali joined 05:37 BenGoldberg left 06:08 pierre_ joined 06:12 pierre_ left 06:25 avuserow_ joined 06:26 firstdayonthejob joined, pierre_ joined 06:28 pierre_ left, pierre_ joined
avuserow_ hello #perl6-ians. I think I have found myself some utf-16 data of the wrong endianness (big endian I think). Any way I can efficiently transform it? `$data.decode("utf-16le")` doesn't seem to exist 06:29
06:29 holyghost left, holyghost joined
gfldex avuserow_: please file a bug report 06:30
06:30 holyghost left 06:31 redhands joined 06:39 Actualeyes left 06:41 rkazak joined 06:42 andrzejku joined
moritz MasterDuke: ok, thanks 06:44
yoleaux 03:10Z <MasterDuke> moritz: i commented on an open issue for each of SVG ( github.com/moritz/svg/issues/1 ) and SVG::Plot ( github.com/moritz/svg-plot/issues/8 ) that seemed to be about the same problems i am having
06:50 firstdayonthejob left 06:58 nightfrog joined 06:59 darutoko joined 07:03 rburkholder joined
zengargoyle avuserow_: does your data hava a BOM? 07:04
07:11 gnull joined 07:12 zakharyas joined 07:15 wbill left
zengargoyle guess the problem is not having 'utf-16be' / 'utf-16le' / etc. in decode() right? 07:17
decode('UTF-16') handles both BE and LE as long as there is a BOM. 07:18
07:20 zakharyas left 07:22 zakharyas joined 07:25 redhands left 07:33 pdcawley joined 07:34 setty1 left, pierre_ left 07:37 bjz joined 07:39 pierre_ joined, pdcawley left 07:40 holyghost joined, pdcawley joined
holyghost gm, just configured a system 07:41
next, booze time
zengargoyle clink! 07:42
holyghost lol
zengargoyle i just put in my '2 week notice' and am way ahead of you. :P
holyghost lol 07:43
07:44 nadim joined, nightfrog left
holyghost roflmao 07:45
zengargoyle guess i'll have time to hack on perl6 real soon now. 07:47
in a few days depending ...
on whether they want their two weeks or do the OMG nuke from orbit. 07:49
07:53 bjz left 07:54 pierre_ left 07:55 pierre_ joined 07:57 movlex joined
zengargoyle i'm aiming for a 6m-1y sabbatical doing perl5/perl6 stuff. i've been trapped in a not so friendly to outside things place for the past 15 years. 07:57
holyghost ok 07:58
08:01 rkazak left
zengargoyle clink! 08:04
08:06 nadim left 08:07 nadim joined 08:18 bjz joined, domidumont joined 08:22 domidumont left 08:23 domidumont joined
holyghost clinks 08:38
zengargoyle nqp/MoarVM/src/strings/ops.c MVM_string_find_encoding() has a selection of hard coded encodingings that are supported. (vs say checking for any sort of known by underlying libraries encoding). utf8,ascii,latin1,windows1252,utf16,utf8_c8 09:01
avuserow_: ATM you'll need to add appropriate BOM to your data and 'UTF-16' should work. 09:03
09:05 Lemy joined
zengargoyle some google leaves me with the impression that Unicode Consortium may not like utf16le vs utf16be sort of distinction without a BOM. 09:06
09:06 pierre_ left 09:07 rburkholder left
zengargoyle i.e. 'utf-16' encoding works with approptiate BOM (with LE as default) and doing utf-16 otherwise (via 'utf-16-be' without BOM) is not a desired thing. 09:09
but i may be wrong there... :)
like it's not really UTF-16 unless it's LE or has a BOM and should be handled otherwise. 09:11
09:12 Actualeyes joined 09:13 andrzejku left, pierre_ joined 09:18 pierre_ left, pierre_ joined, rburkholder joined 09:22 labster joined 09:24 mempko left
zengargoyle my guess, the portability layer libuv only supports a few bog standard encodings and anything stranger needs to use a module (iconv or similar) that supportes everything under the sun. 09:26
zengargoyle torn between decode() supporing only 6-ish encodings vs supporting everything imaginable. 09:32
gfldex what would a problem solver want to have? 09:33
zengargoyle a problem... :) 09:34
what sort of problem solver? 09:35
gfldex a wise answer but I doubt it will help you with making up your mind if 6-ish or problem solvend
09:35 AlexDaniel joined
gfldex a programming language can be an exercise in programming languages or a tool for solving problems. A perfect program language is both. 09:36
zengargoyle i'm mostly happy with DIY. too many encounters with odd/bad data that most corrections need more umph than decode('X') 09:38
gfldex 6-ish encoding doesn't sound like a practical consideration to me
zengargoyle unless X is simple
your input data is proper or not.
working with the non-propper should require heavy (maybe non-portable) modules á la Encode that use like libiconv or something. 09:40
is adding libiconv vs libuv sort of thing to core worth it?
to also support SHIFT-JIS? 09:41
or WINDOWS-936
09:41 pierre_ left
gfldex likely not and libiconv can be found on any platform, so a module makes sense 09:41
zengargoyle yeah, iconv is my frienemy 09:42
slap a BOM on BOM-less UTF-16-BE and UTF-16 will handle it.
otherwise, maybe not really just a matter of weird encoding (re original question) 09:43
hell, pipe through iconv if you need (but even iconv won't put a BOM on UTF-16BE, seemingly per Unicode specs about specifying encodings). 09:44
zengargoyle but maybe being convienient and handling le/be swapping for users isn't that bad). 09:46
still no utf32, ... etc.
09:47 pierre_ joined
zengargoyle and at least doing the Linux/Mac/Windows whatever versions of whatever UTF idea they have is a decent place to be. 09:47
09:51 pierre_ left, pierre_ joined 09:52 rburkholder left
zengargoyle would probably stop with decode() supporting what it does plus any UTF-XXX encodings that can be massaged into into UTF8 and let the rest be module land. 09:55
zengargoyle assuming most UTF things are just bit fiddling 09:56
10:00 nadim_ joined 10:04 nadim left 10:13 grondilu joined 10:14 labster left 10:17 pmurias joined 10:35 xinming joined 10:41 domidumont left 10:45 pierre_ left 10:50 mvorg joined 10:51 bjz left, bjz joined
grondilu Hello. 10:52
hahainternet howdy
grondilu I can define a variable as a role: my $role = role {...}
but then can I use $role to type parameters?
I guess I could use a where clause, but what else? 10:53
sub ($arg where $arg ~~ $role) {...}
since I suppose sub ($role $arg) {...} is just wrong, isn't it? 10:54
m: my $r = role {}; say (pi but $r) ~~ $r;
camelia rakudo-moar ee8a25: OUTPUT«True␤»
grondilu m: my $r = role {}; say (pi but role {}) ~~ $r;
camelia rakudo-moar ee8a25: OUTPUT«False␤»
gfldex $role will contain a type object and there is no way to convert a type object into a type capture
those 2 anonymous roles are not the same thing 10:55
grondilu is there a performance loss in using a where clause as opposed to a typed parameter?
gfldex yes
grondilu that's regrettable.
gfldex at least for now.
it is hard to prove equivalence of two where clauses, so the compiler can cheat less 10:56
grondilu thing is, I'm thinking about a way to generate roles in user-space code. And then create polymorph subs using these roles.
I'd like to avoid using EVAL 10:57
gfldex you either want macros or you may get away with type captures. Depends on what you want to do.
grondilu not sure what type captures are. 10:59
gfldex my role R[::T, I] { my T $i = I}; my class C does R[Int, 42] {}; dd C.new; 11:00
m: my role R[::T, I] { my T $i = I}; my class C does R[Int, 42] {}; dd C.new;
camelia rakudo-moar ee8a25: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Invalid typename 'I' in parameter declaration.␤at <tmp>:1␤------> 3my role R[::T, I7⏏5] { my T $i = I}; my class C does R[Int,␤»
gfldex m: my role R[::T, $I] { my T $i = $I}; my class C does R[Int, 42] {}; dd C.new; 11:01
camelia rakudo-moar ee8a25: OUTPUT«C.new␤»
gfldex m: my role R[::T, $I] { my T $i = $I}; my class C does R[Int, 42] {}; dd C.new.i;
camelia rakudo-moar ee8a25: OUTPUT«Method 'i' not found for invocant of class 'C'␤ in block <unit> at <tmp> line 1␤␤»
gfldex m: my role R[::T, $I] { has T $i = $I}; my class C does R[Int, 42] {}; dd C.new
camelia rakudo-moar ee8a25: OUTPUT«C.new␤»
gfldex m: my role R[::T, $I] { has T $i = $I}; my class C does R[Int, 42] {}; dd C.new.i
camelia rakudo-moar ee8a25: OUTPUT«Method 'i' not found for invocant of class 'C'␤ in block <unit> at <tmp> line 1␤␤»
gfldex m: role R[::T, $I] { has T $.i = $I }; class C does R[Int, 42] {}; dd C.new.i 11:02
camelia rakudo-moar ee8a25: OUTPUT«42␤»
hahainternet ^ that's very cool 11:03
grondilu oh yeah, parametric types. 11:04
that shoud do.
And I bet I can use them as parameter contraints.
m: role R[$i] { has $.i = $i }; sub (R[rand] $) {} 11:05
camelia ( no output )
grondilu nice
gfldex there only limitations on type captures are the boundery between modules. And that's a bug.
llfourn ^ hmmm 11:06
m: sub wtf { say "ran"; rand }; role R[$i] { }; sub foo(R[wtf] $) { }; try foo(R); try foo(R) 11:08
camelia rakudo-moar ee8a25: OUTPUT«ran␤»
llfourn I guess it runs at compile time
m: sub wtf { say "ran"; rand }; role R[$i] { }; sub foo(R[wtf] $) { }; BEGIN say "compile"; try foo(R); try foo(R) # yes 11:09
camelia rakudo-moar ee8a25: OUTPUT«ran␤compile␤»
gfldex it should and I should doc that :)
llfourn gfldex++ # doc-ing
11:10 Actualeyes left
llfourn m: sub wtf { say "ran"; rand }; role R[$i] { }; say R[wtf] ~~ R[wtf]; BEGIN say "compiling" # this is runtime though 11:12
camelia rakudo-moar ee8a25: OUTPUT«compiling␤ran␤ran␤False␤»
11:15 torbjorn left 11:20 rindolf joined
grondilu for those curious, it was about translating github.com/weshoke/versor.js. My Clifford module does most of it, but not nearly as optimized. 11:22
11:22 pierre_ joined 11:23 kid51 joined, Actualeyes joined 11:26 pierre_ left 11:28 sftp left 11:30 RabidGravy joined 11:36 pierre_ joined
AlexDaniel gfldex: by the way, regarding comment editing. I just realized that some time ago I edited your issue (#838) to make it a todo list. Should I refrain from doing so next time? 12:16
gfldex that's no problem 12:23
AlexDaniel ok 12:25
12:27 Sgeo_ left 12:32 n1lp7r joined 12:34 wamba joined 12:47 dLeCamarae joined 12:51 prammer joined 12:52 prammer left 12:55 cdg joined
lizmat starts working on the Perl 6 Weekly while she's awake 12:56
markk sends hugs to the -hopefully speedily recovering- lizmat 12:59
lizmat thanks! :-)
AlexDaniel shit. Weeks fly by so fast 13:00
gfldex lizmat: docs had mostly housekeeping, noteable are docs.perl6.org/language/functions#sub_USAGE_, corrections in docs.perl6.org/syntax/gather%20take and addition of docs.perl6.org/language/typesystem..._Arguments 13:01
timotimo lizmat: scanning for literal strings in an :i regex is now not catastrophically slow and memory-hungry! :) 13:02
well, for big haystack strings anyway 13:03
lizmat timotimo: and that is news ?
timotimo in short haystack strings you wouldn't notice anything, i'm sure
i *think* that went in last week
let me confirm that
lizmat ah, *not* memory hungry
:-)
guess I'm not awake enough yet...
timotimo yup, tuesday of last week i made that commit
13:03 smls joined
lizmat
.oO( it only hurst when I breathe :-)
13:04
*hurts
*sigh*
13:04 perlpilot joined
timotimo haha, i just looked over my commit and it said "haystacklc" and i thought "wow, that's a really, really bad typo" 13:04
turns out that's just how i called the "haystack converted to lower case" variable %)
13:05 mcmillhj joined 13:11 andrzejku joined
gfldex should .wrap do something reasonable on a sub that returns gather ? 13:14
timotimo i don't see a problem with that 13:15
jnthn Why would .wrap care?
13:15 holyghost left
jnthn (I'd expect it to be orthogonal to the type of the return value of the wrapped thing) 13:16
13:18 cdg left
gfldex m: sub f(){ gather for ^20 { take .Str } }; &f.wrap(-> |c { say 'oi!'; my $r = callsame; note &c.name ~ " called with " ~ c.perl ~ " returned " ~ $r }); say f()[^10] 13:20
camelia rakudo-moar ee8a25: OUTPUT«oi!␤Use of Nil in string context in block at <tmp> line 1␤ called with \() returned 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19␤Index out of range. Is: 1, should be in 0..0␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in b…»
gfldex m: sub f(){ lazy gather for ^20 { take .Str } }; &f.wrap(-> |c { say 'oi!'; my $r = callsame; note &c.name ~ " called with " ~ c.perl ~ " returned " ~ $r }); say f()[^10]
camelia rakudo-moar ee8a25: OUTPUT«oi!␤Use of Nil in string context in block at <tmp> line 1␤ called with \() returned ...␤Index out of range. Is: 1, should be in 0..0␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in block <unit> at <tmp> line 1␤␤»
gfldex the Seq is eaten up (no surprise) and the .name is gone. 13:23
13:23 cdg joined
gfldex but I cant reproduce what I wanted to. In my example I get a Seq of Nil. All values are Nil. I will try again later. 13:24
jnthn Hm, eaten up is a bit odd in that a second attempt to iterate a Seq is an explicit exception...
(Not just an empty thing)
13:25 cyphase left
jnthn I wonder if callsame is guilty of doing something bad 13:25
timotimo um, hold on
no,you're just returning the result of nome
note
gfldex m: sub f(){ lazy gather for ^20 { take .Str } }; &f.wrap(-> |c { say 'oi!'; my $r = callsame; note &c.name ~ " called with " ~ c.perl ~ " returned " ~ $r; $r }); say f()[^10]
camelia rakudo-moar ee8a25: OUTPUT«oi!␤Use of Nil in string context in block at <tmp> line 1␤ called with \() returned ...␤(0 1 2 3 4 5 6 7 8 9)␤»
timotimo m: sub f(){ lazy gather for ^20 { take .Str } }; &f.wrap(-> |c { say 'oi!'; my $r = callsame; }; say f()[^10]
camelia rakudo-moar ee8a25: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Unable to parse expression in argument list; couldn't find final ')' ␤at <tmp>:1␤------> 3'oi!'; my $r = callsame; }; say f()[^10]7⏏5<EOL>␤ expecting any of:␤ postfix␤»
gfldex indeed
timotimo m: sub f(){ lazy gather for ^20 { take .Str } }; &f.wrap(-> |c { say 'oi!'; my $r = callsame; }); say f()[^10]
camelia rakudo-moar ee8a25: OUTPUT«oi!␤(0 1 2 3 4 5 6 7 8 9)␤»
13:26 skids joined, rindolf left
timotimo i'm pretty proud that i immediately spotted that :) 13:27
jnthn oh, duh, I missed it :P
gfldex i made the same mistake in my example but with an if-statement at the end. That was the Nil source.
it's all good :)
13:28 cdg left
smls On the topic of gather/take subs, is there an easier way to use recursion with them than to split it into two subs? 13:28
See the second snioppet here, for an example: rosettacode.org/wiki/Walk_a_directo...ely#Perl_6 13:29
13:29 cdg joined
gfldex but i don't really want to wrap the sub, I want to watch the take. Output debug message for every 20 values. 13:29
13:30 cyphase joined
gfldex smls: see github.com/perl6/doc/blob/master/u...ods.p6#L54 13:30
jnthn smls: That's not a great example in that it calls dir() twice :)
(for the same directory)
So hits the filesytem twice
gfldex it's the &?BLOCK trick
jnthn Also c is clsoed over so doesn't need taking by the inner sub :) 13:31
smls good points :) 13:32
13:32 ChristopherBotto joined
gfldex we need to show of harder on rosettacode :) 13:32
13:32 andrzejku left
ChristopherBotto gfldex: o/ 13:33
13:34 rindolf joined, dLeCamarae left
ChristopherBotto gfldex: I'm so sorry about editing your posts. I never thought about it being rude, but I can totally see where you're coming from now. 13:36
gfldex don't worry, it's all good
ChristopherBotto gfldex: Thanks! I really appreciate your work in the community. I have a lot of respect for you. 13:37
13:40 wamba left 13:42 prammer joined 13:46 Sgeo_ joined 13:48 ChristopherBotto left 13:49 nightfrog joined 13:54 heatsink left
ugexe m: my $a := gather for 1..5 -> $i { take $i; &?BLOCK(100); }; say $a # smls 13:54
camelia rakudo-moar ee8a25: OUTPUT«(1 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 1…»
smls ugexe: Yeah, that was gfldex's solution too 13:55
13:55 holyghost joined
smls But it may require you to go to contortions to avoid having nested blocks inside the gather 13:56
ugexe ah i didn't even notice that was in a gather block heh
gfldex m: class C { method iterator { IterationEnd } }; for C.new { .say } 14:00
camelia rakudo-moar ee8a25: OUTPUT«X::TypeCheck::Binding exception produced no message␤ in block <unit> at <tmp> line 1␤␤»
timotimo good golf
unmatched} m: .say for class { method iterator {IterationEnd} } 14:02
camelia rakudo-moar ee8a25: OUTPUT«X::TypeCheck::Binding exception produced no message␤ in block <unit> at <tmp> line 1␤␤»
timotimo m: .say for IterationEnd
camelia rakudo-moar ee8a25: OUTPUT«Method 'map' not found for invocant of class 'Mu'␤ in block <unit> at <tmp> line 1␤␤»
timotimo enh, fair enough
unmatched} :D
holyghost *lol* again, I'll stop with it :-) 14:04
14:08 pmurias left
smls gfldex: For some reason I can't get it to work for the find-files examples... 14:11
gist.github.com/smls/1637615d59f87...c9723d864b
14:11 Possum joined
smls It hangs on the .&?BLOCK call 14:12
gfldex my @files = .dir; on every iteration? 14:13
smls every iteration has a different directory for $_, doesn't it?
ugexe smls: have you seen the last example of docs.perl6.org/routine/dir? it uses a stack instead of recursion, but maybe that doesnt matter for you? 14:14
14:15 leedo is now known as leedo_ 14:16 leedo_ is now known as leedo
smls too imperative :P 14:17
ugexe i agree :), i've been down this same road before and couldn't find a cleaner way though :( 14:18
gfldex ugexe: gist.github.com/gfldex/79f54dda830...5553ae6770
ugexe i end up going with map/grep instead :/ github.com/ugexe/Perl6-PathTools/b...ols.pm6#L3 14:19
smls I think Python has "yield from" for recursive generators
ugexe i stopped using &?BLOCK because it didnt work correctly in this case on jvm (but this was before 6.c) 14:20
timotimo yup, yield from was much needed, but sadly came too late since i had already moved on to perl6 when it got put in :P 14:21
gfldex i can't wait for autothreading to see all those ». blow up in our faces :) 14:22
smls gfldex: Recursing for every file (rather than just for each directory) irks me a little, for some reason.
gfldex it only recurses for dirs
14:23 robinsmidsrod left
smls Too bad `take |find-files ...` doesn't work like "yield from" 14:23
gfldex would be nice to sort by .f, so it shows all files and then descends deeper 14:24
14:24 avenj joined 14:25 robinsmidsrod joined
gfldex maybe a strategic wrap could yield on every recursion step 14:25
ugexe to add on what gfldex said its also nice because you can reverse that order to get the order needed to delete all files and directories (which need to be empty)
jnthn smls: does .take for find-files ...; not do it? 14:26
14:26 zacts joined
smls Looks like it does... 14:28
gist.github.com/smls/c1c0b390fda76...5f5f4dd038 # seems to work 14:29
gfldex .IO.dir(test => $test).sort({.d})».&?BLOCK when .IO.d 14:30
that should sort dirs up
m: say True <=> False;
camelia rakudo-moar ee8a25: OUTPUT«More␤»
gfldex m: say True cmp False; 14:31
camelia rakudo-moar 8f43bb: OUTPUT«More␤»
gfldex no wrong, since True is more then False and sort is ascending
timotimo we did have a version of the hyperoperator that mixes up execution order 14:32
i think it was removed because it was pretty expensive performance-wise?
it might be enough to just mix the first and second execution, perhaps
and do the rest in sequence
smls jnthn: Is there much overhead for constructing a new "gather" Seq for each directory?
gfldex updated: gist.github.com/gfldex/79f54dda830...5553ae6770 14:33
jnthn smls: Compared to the cost of the I/O, not really :) 14:35
smls ok
14:35 khw joined 14:42 bob777 left
smls Hm. Was indexing a Seq with .[^50] always eager? 14:43
gfldex doesn't matter in that case because say is calling .join 14:45
smls `.say for find-files(...)` prints results as they come, but `.say for find-files(...)[^50]` blocks until 50 results are available and the prints them in one go 14:46
I thought the postcircumfix used to return a lazy list, but I may be misremembering.
jnthn Indexing isn't lazy
[Coke] smls: I would expect it to be eager up to the 50. how else can it satisfy your request?
smls ok
jnthn I think .head(50) would be
smls That works, thanks 14:48
14:50 pmurias joined
smls jnthn: To avoid calling dir() twice, I have to re-implement its :test handing though: gist.github.com/smls/e4adead89c3aa...725d2cd803 14:50
unmatched} So use fatal makes warnings fatal. Are there any other pragmas similar to it? 14:51
smls Do you think this is better ok to put on rosettacode to replace the old code?
jnthn unmatched}: makes *failures* fatal, not warnings 14:52
unmatched} jnthn: oh... seems warnings too then:
m: "foo" ~~ S/^//;
camelia rakudo-moar 8f43bb: OUTPUT«Potential difficulties:␤ Smartmatch with S/// is not useful. You can use given instead: S/// given $foo␤ at <tmp>:1␤ ------> 3"foo" ~~ 7⏏5S/^//;␤»
unmatched} m: use fatal; "foo" ~~ S/^//;
camelia rakudo-moar 8f43bb: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Smartmatch with S/// is not useful. You can use given instead: S/// given $foo␤at <tmp>:1␤------> 3use fatal; "foo" ~~ 7⏏5S/^//;␤»
14:53 mohae_ joined
timotimo unmatched}: IIRC, a try around code will also cause "use fatal" to be in effect 14:53
jnthn unmatched}: o.O
That looks odd 14:54
unmatched} heh...
14:54 pierre_ left
unmatched} m: no worries; "foo" ~~ S/^//; say "Blah blah"; 14:55
camelia rakudo-moar 8f43bb: OUTPUT«Potential difficulties:␤ Smartmatch with S/// is not useful. You can use given instead: S/// given $foo␤ at <tmp>:1␤ ------> 3no worries; "foo" ~~ 7⏏5S/^//; say "Blah blah";␤Blah blah␤»
14:55 mohae left
unmatched} m: quietly { "foo" ~~ S/^// }; say "Blah blah"; 14:56
camelia rakudo-moar 8f43bb: OUTPUT«Potential difficulties:␤ Smartmatch with S/// is not useful. You can use given instead: S/// given $foo␤ at <tmp>:1␤ ------> 3quietly { "foo" ~~ 7⏏5S/^// }; say "Blah blah";␤Blah blah␤»
timotimo come-quietly-no-screaming { ... }
unmatched} It's a $/.PRECURSOR.worry(...)
timotimo dont-alert-the-police { ... }
15:01 canopus left 15:02 mempko joined 15:04 zacts left 15:10 canopus joined 15:16 wamba joined
smls ugexe: I'm reasonably happy with the updated example I just sumbitted to rosettacode.org/wiki/Walk_a_directo...ely#Perl_6 15:17
Do you think this should also replace the kinda messy @stack munging example in docs.perl6.org/routine/dir ?
perlpilot smls: or ... make dir() have a :recurse option :) 15:20
smls heh
15:20 zakharyas left, kurahaupo joined
perlpilot I started on an implementation once, but got sidetracked on something else and never made it "right" 15:21
smls perlpilot: I think in practice, you'd want such a function to have more control options though, and that might be too much for the built-in dir
unmatched} The "Actually thrown at" bits seem a bit LTA. There was a case where it was printing it even when the actually thrown at was empty (now fixed), but now I see it's basically repeating the previous content, like here:
m: gist.github.com/zoffixznet/54462d1...a305db04be
camelia rakudo-moar 8f43bb: OUTPUT«Calculating distance traveled by airplane␤Calculating distance traveled by spaceship␤Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5oops' (indicated by ⏏)␤ in sub distance at <tmp> line 1␤ in blo…»
unmatched} Well, here's easier to see: gist.github.com/zoffixznet/94de331...9f3a69c436 15:22
smls perlpilot: e.g. you'd want it to be able to do depth-first if needed, or do a test against the whole path rather than basename, etc.
unmatched} I'm really loving that subscript/superscript work on that code :D I just wish we could use subscript numerals too
smls perlpilot: and all the other countless options that GNU find has... :) 15:23
perlpilot smls: I think if you can reduce all the possible options to just a few, dir() is the right place for them. (for efficiency's sake if nothing else)
But ... I dream a little :) 15:24
one day, when I have some free time, I'll probably try to implement it again.
ugexe PathTools (and File::Tree?) do that as well 15:25
avuserow_ hey zengargoyle, thanks for the suggestion. I'll give it a try. This data definitely does not have a BOM in each string that I am decoding, but rather one per file. (It's an absurd format.) 15:40
unmatched} I'm having trouble finding something core that returns a failure... any idea? 15:44
m: try { say (42 div 0) ~~ Failure; CATCH { default {.^name.say } } } 15:45
camelia rakudo-moar 8f43bb: OUTPUT«X::Numeric::DivideByZero␤»
avuserow_ manually copying in a BOM works. I'm just doing: `Buf.new(@BOM, $data.list).decode("utf-16")` 15:47
and wow, zengargoyle++, this is faster than even my wrong and cheating solution of decoding as latin-1 and removing 0-value bytes!
unmatched} m: sub x { (2+4i).Num }; say x.^name
camelia rakudo-moar 8f43bb: OUTPUT«Can not convert 2+4i to Num: imaginary part not zero␤ in sub x at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in sub x at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤»
ugexe m: say ::("XXX").perl 15:48
camelia rakudo-moar 8f43bb: OUTPUT«Failure.new(exception => X::NoSuchSymbol.new(symbol => "XXX"), backtrace => Backtrace.new)␤»
unmatched} m: sub x { (1...Inf).elems }; say x.^name
camelia rakudo-moar 8f43bb: OUTPUT«Failure␤»
unmatched} m: sub x { EVAL "+'foo'" }; say x.^name 15:49
camelia rakudo-moar 8f43bb: OUTPUT«Failure␤»
unmatched} m: sub x { +'foo' }; say x.^name 15:50
camelia rakudo-moar 8f43bb: OUTPUT«Failure␤»
unmatched} :S
Oh, ok I think I see what my problem was
m: sub infix:<Δ> { abs $^a − $^b }; say ("foo" Δ 42).^name 15:51
camelia rakudo-moar 8f43bb: OUTPUT«Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5foo' (indicated by ⏏)␤ in sub infix:<Δ> at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in sub infix:<Δ> at <tmp> line 1…»
15:58 zakharyas joined
avuserow_ are there any tools to make p6 scripts into .exe files? thinking something like PAR or pp for Perl 5, or along the lines of py2exe for Python 15:58
15:58 jeek left
timotimo we don't have something for that yet, but it'll be possible at some point for sure 15:58
there's been multiple attempts in the past 15:59
we call it "fakexecutable" or "fakecutable"
harmil_wk avuserow_: For the JVM background there's a JAR creation process that I've never touched, but I think it has large pieces of what you are asking for...
timotimo having a jar still requires you to launch it as if you were using a module 16:00
i.e. ./perl6-j -mMyFancyJar -e ''
same with our stuff for moar so far. we might get a single file, but you'll still have to -Mblahblah -e '' 16:01
harmil_wk timotimo: correct. That's what I was saying.
timotimo oh, you were? OK!
harmil_wk Yeah, "large pieces of what you want"
timotimo hehehe.
ugexe does that work for --target=moar modules? 16:02
harmil_wk Once you have a JAR, you just need the runtime and some linkage glue for a main that invokes the runtime, right? 16:03
timotimo yeah, because rakudo will look for .moarvm files in the -I
16:18 Hor|zon joined 16:19 dwarring left
avuserow_ yeah, I'm just doing preliminary investigation of distribution methods for a program I'm writing 16:21
I'm thinking that requiring java and having the users run `java -jar perl6.jar -jar myprogram.jar` would be okay 16:22
if we have good MSIs for p6 on windows, that might work too... 16:23
timotimo java programs always have a shell script type of launcher thing with them anyway
mst and they're always terrible
avuserow_ yeah, I mean in the sense of what they need preinstalled. I think people would be more likely to have a JVM installed than P6, sadly :P
timotimo yes, always terrible. no doubt about it 16:24
16:24 andrzejku joined
mst right, ideally, we'd do statically compiled binary packages as well or something 16:25
but I've got a different argument to have with the build system first ;)
timotimo :)
16:32 zacts joined 16:37 zakharyas left 16:38 zakharyas joined 16:43 domidumont joined 16:49 zakharyas left 16:57 araujo left 17:05 kyclark joined
kyclark How do I printf to $*ERR? 17:06
smls $*ERR.print: sprintf ...
timotimo or "note sprintf ..." 17:09
note will give you a \n at the end for free 17:10
17:14 brrt joined
unmatched} New blog post: "The Awesome Errors of Perl 6": perl6.party/post/The-Awesome-Errors-of-Perl-6 17:17
17:18 mvorg left 17:21 zacts left 17:23 TEttinger left
brrt reads 17:24
17:24 firstdayonthejob joined 17:25 TEttinger joined
brrt well, loads 17:25
17:30 prammer left, Ven joined 17:31 labster joined 17:32 harovali1 joined 17:34 harovali left 17:35 labster left
kyclark Thanks. 17:37
17:37 kyclark left 17:41 prammer joined 17:43 sena_kun joined 17:48 brrt2 joined, brrt left 17:49 Ven left 17:50 Ven joined 17:52 vendethiel joined, Ven left 17:53 Ven joined 17:54 Ven left 17:55 Ven joined 17:56 Ven left
unmatched} m: sub term:<-1> { *-1 }; my @a = ^10; say @a[-1] 17:58
camelia rakudo-moar 8f43bb: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Unsupported use of a negative -1 subscript to index from the end; in Perl 6 please use a function such as *-1␤at <tmp>:1␤------> 3rm:<-1> { *-1 }; my @a = ^10; say @a[-1]7⏏5<EOL>␤»
unmatched} gah. Well, so much for that :(
m: sub term:<① > { *-1 }; my @a = ^10; say @a[① ] 17:59
camelia rakudo-moar 8f43bb: OUTPUT«9␤»
unmatched} \o/
18:01 heatsink joined 18:03 mcmillhj left 18:07 Ven joined
jnthn smls: Sorry, got dug into some $dayjob stuff and didn't get to comment on the files-files thing. It's not entirely clear whether the test handling in that code is correct also. What if the test matches *and* it's a directory? 18:09
smls: Oh wait, that's the case you handled...
Oh, or is it... :)
I htink something is a bit odd though in that if you have a directory that matches the test it'll be included and traversed, and if you have a dir that doesn't match the test it'll be traversed, etc. :) 18:10
smls Isn't that what `find -iname ...` does? 18:11
jnthn No idea :) 18:12
18:13 n1lp7r left, ptolemarch joined
smls Basically, traverse the whole tree and return all paths where the basename matches the test 18:14
18:15 mcmillhj joined 18:16 labster joined 18:17 Ven left 18:24 smls left 18:26 domidumont left 18:30 TEttinger left 18:34 TEttinger joined 18:36 kyclark joined
kyclark Is there a framework or suggested path to test the output from Perl 6 scripts? E.g., do I need to use ‘proc’ to get the output and then the various methods from Test? 18:37
18:37 cdg left
lizmat kyclark: you can assign $*OUT to some class that has a .print in it 18:37
avuserow_ kyclark: Test::Output in the ecosystem looks potentially useful. haven't tried it personally but worth a look 18:40
lizmat m: my @log; { my $*OUT = class { method print(*@a) { @log.push(@a) } }.new; say "foo" }; dd @log
camelia rakudo-moar 8f43bb: OUTPUT«Array @log = [["foo\n"],]␤»
unmatched} kyclark: there's modules.perl6.org/repo/Test::Output and depending on your needs, take a look at roast's is_run/get_out subs. Maybe you can steal them: github.com/perl6/roast/blob/master...st/Util.pm 18:42
kyclark Test::Output looks pretty good! I’ll try that. Thanks!
18:43 brrt2 left 18:47 rindolf left 18:51 zacts joined, TEttinger left 18:54 Ven joined, TEttinger joined 18:57 Ven left, domidumont joined 18:59 heatsink left 19:01 djbkd_ left 19:03 labster left 19:08 zacts left
AlexDaniel unmatched}: since you explain *-42 anyway, perhaps you can also add an example with “@a[-42]”? It has an awesome error message too. 19:08
19:08 Girafferson joined
perlpilot AlexDaniel, unmatched} : For that same example, I was thinking it would be nice to introduce shaped arrays too: my @a[42]; @a[50] = 7; 19:10
unmatched}: and +1 to what AlexDaniel said :) 19:11
19:13 rindolf joined
AlexDaniel is going to submit some LTA tickets after reading a post about awesome error messages… 19:15
19:16 andrzejku left 19:21 domidumont left 19:22 Lemy left
dalek osystem: e48a097 | Altai-man++ | META.list:
Add Texas::To::Uni package
19:23
harmil_wk We should have more modules in that namespace. Texas::To::California would be interesting. 19:25
19:26 ridthyself joined
sena_kun harmil_wk, I'm super-bad with naming. :-( I'll rename it if you can give me a better name. 19:26
Perhaps, it should be something like "Text::Operators-Converting" or such. Dunno. 19:27
19:27 darutoko left
harmil_wk I wasn't complaining. It's very clear what it's for... 19:27
ridthyself greetings everyone -- sorry to interrupt -- but are Roles in PERL6 how interfaces are done?
AlexDaniel sena_kun: wait… what 19:28
sena_kun AlexDaniel, what "what"?
ridthyself if you were to create a class to use as an interface, would you use a role?
ugexe yes 19:29
AlexDaniel sena_kun: so it replaces =~= with ≅, pi with π, but at the same time it replaces “” with "" and 「」 with Q//. What does it all mean?
19:29 Lemy joined
sena_kun AlexDaniel, afk for 25 minutes, sorry. 19:29
ugexe m: role Foo { method bar { ... }; }; class Bar1 does Foo { }; class Bar2 { }; sub check-me(Foo $x) { say "OK" }; check-me(Bar1.new); check-me(Bar2.new) 19:30
camelia rakudo-moar 8f43bb: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Method 'bar' must be implemented by Bar1 because it is required by a role␤at <tmp>:1␤»
sena_kun AlexDaniel, it's a bug, obviously.
AlexDaniel ah ok
ugexe m: role Foo { method bar { ... }; }; class Bar1 does Foo { method bar { 1 }; }; class Bar2 { }; sub check-me(Foo $x) { say "OK" }; check-me(Bar1.new); check-me(Bar2.new) 19:31
camelia rakudo-moar 8f43bb: OUTPUT«OK␤Type check failed in binding to $x; expected Foo but got Bar2 (Bar2.new)␤ in sub check-me at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤»
AlexDaniel sorry for this reaction, but I was like “WTF??? WTF???” ;)
hmm, there's no unicode character for triple question mark⁇ 19:32
ridthyself okay I understand, thanks ugexe
zengargoyle avuserow_: glad it worked out into an easy hackaround. 19:33
19:36 cpage_ joined
ridthyself How would I have one class own another class? A Player Class owning a Player-Character class, for example... 19:36
it does not seem appropriate to say a Character is-a Player 19:37
19:40 zengargoyle left 19:41 zengargoyle joined
ugexe what do you mean by own 19:43
Inherit? Compose? Lexically scoped to an outer class? 19:44
19:45 kobain joined, kobain is now known as Guest17874 19:46 Guest17874 is now known as jverce
ridthyself if i were writing procedurally, i would make a Player struct which has a Character struct 19:46
ugexe I'm not sure what you mean by "has a". class Foo { my class Bar { }; } ? 19:47
19:47 jverce left
mst ridthyself: not sure that's wrong with a character attribute 19:47
well, actually, I'd have an array of
since some players control multiple PCs 19:48
unmatched} m: class Player { my class Character { has $!strength; }; has $.character = Character.new }.new.character.^name.say
camelia rakudo-moar 4d85cd: OUTPUT«Player::Character␤»
ridthyself oh! that could work
can I declare the Character class seperately, or do i need to declare it within the Player Class declaration? 19:49
mst depends if you're planning to re-use it outside 19:51
ridthyself Although I don't suppose I'll ever need Characters that aren't owned by a player, even NPC would be owned by the "world".
yeah 19:52
thanks everyone! PERL 6 is awesome, I'm having so much fun. Peace! 19:55
19:55 ridthyself left
timotimo but it's just spelled "Perl" ... 19:57
sena_kun AlexDaniel, this module is still 0.1, so we(or I, rather) need good parsing, good replacing mechanism, good tests, good everything... You get the tendencies. (: I converted the table from docs to Hash using emacs macro, so things happen. 20:00
20:01 labster joined, cdg joined 20:02 TEttinger left
kyclark How can I get around this error: 20:03
m: my %count = A => 1, G => 5; put join ' ', %count<A C T G>
camelia rakudo-moar 4d85cd: OUTPUT«Use of uninitialized value <element> of type Any in string context.␤Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in block <unit> at <tmp> line 1␤Use of uninitialized value <element> of type Any in string c…»
CIAvash m: my %count = A => 1, G => 5; put join ' ', %count<A C T G>:v 20:04
camelia rakudo-moar 4d85cd: OUTPUT«1 5␤»
20:04 TEttinger joined
kyclark What does :v do? 20:05
Also, I would actually like to print 0 when nothing exists.
Ah, found it (docs.perl6.org/syntax/$COLONv) 20:06
avuserow_ m: my %count = A => 1, G => 5; put join ' ', %count<A C T G>:exists 20:07
camelia rakudo-moar 4d85cd: OUTPUT«True False False True␤»
ugexe m: my %count = A => 1, G => 5; put join " ", map {.defined ?? $_ !! 0 }, %count<A C T G>
camelia rakudo-moar 4d85cd: OUTPUT«1 0 0 5␤»
avuserow_ m: my %count = A => 1, G => 5; put join ' ', %count<A C T G>:exists>>.Int
camelia rakudo-moar 4d85cd: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Missing << or >>␤at <tmp>:1␤------> 3 put join ' ', %count<A C T G>:exists>>.7⏏5Int␤»
20:07 prammer left
ugexe m: my %count = A => 1, G => 5; put join " ", map {$_ // 0}, %count<A C T G> 20:08
camelia rakudo-moar 4d85cd: OUTPUT«1 0 0 5␤»
CIAvash m: my %count is default(0) = A => 1, G => 5; put join ' ', %count<A C T G>
camelia rakudo-moar 4d85cd: OUTPUT«1 0 0 5␤»
avuserow_ m: my %count = A => 1, G => 5; put join ' ', (%count<A C T G>:exists)>>.Num; # appears to work if you want 0/1 rather than True and False 20:09
camelia rakudo-moar 4d85cd: OUTPUT«1 0 0 1␤»
kyclark Thanks! 20:10
unmatched} Just use a Bag 20:12
m: my $dna = BagHash.new: <A A G G G>; say $dna<A T C G>' 20:15
camelia rakudo-moar 4d85cd: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Two terms in a row␤at <tmp>:1␤------> 3Hash.new: <A A G G G>; say $dna<A T C G>7⏏5'␤ expecting any of:␤ infix␤ infix stopper␤ postfix␤ statement end␤ …»
unmatched} (2 0 0 3)
stupid phone :(
20:15 prammer joined
ugexe you typed that on your phone? ouch 20:15
unmatched} :) 20:16
20:17 vendethiel left
harmil_wk m: say ^3 >>*>> 2; say ^3 S[>>*>>] 2 20:19
camelia rakudo-moar 4d85cd: OUTPUT«(0 2 4)␤Too few positionals passed; expected 2 arguments but got 0␤ in block <unit> at <tmp> line 1␤␤»
harmil_wk Is that second form supposed to work?
20:23 Wiertek joined
tailgate m: my @a = (1,2,3); @a[1]:delete; say @a; 20:33
camelia rakudo-moar 4d85cd: OUTPUT«[1 (Any) 3]␤»
tailgate how do I delete without the (
how do I delete without the (Any)?
avuserow_ m: my @a = <1 2 3>; splice @a, 1; say @a
camelia rakudo-moar 4d85cd: OUTPUT«[1]␤»
timotimo right, splice it 20:34
avuserow_ m: my @a = <1 2 3>; splice @a, 1, 1; say @a
camelia rakudo-moar 4d85cd: OUTPUT«[1 3]␤»
20:34 mvorg joined
tailgate thanks 20:34
20:37 trnh joined, trnh left, trnh joined 20:39 sftp joined 20:45 wamba left
tailgate m: (1,2,3,1,1,2,3) ==> grep { 1 === $_}; 20:50
camelia ( no output )
tailgate m: say (1,2,3,1,1,2,3) ==> grep { 1 === $_};
camelia rakudo-moar 4d85cd: OUTPUT«(1 2 3 1 1 2 3)␤»
tailgate m: say (1,2,3,1,1,2,3) ==> grep { 1 == $_};
camelia rakudo-moar 4d85cd: OUTPUT«(1 2 3 1 1 2 3)␤»
unmatched} is amused by the "devs are immature" critique of Perl 6 :) 20:52
m: sub foo {}; for foo {}
camelia rakudo-moar 4d85cd: OUTPUT«5===SORRY!5===␤Function 'foo' needs parens to avoid gobbling block␤at <tmp>:1␤------> 3sub foo {}; for foo {}7⏏5<EOL>␤Missing block (apparently claimed by 'foo')␤at <tmp>:1␤------> 3sub foo {}; for foo {}7⏏5<EOL>␤␤»
avuserow_ tailgate: try an extra set of parens between `say` and `;`. or use grep as a method or sub call.
unmatched} Look! Look! It says "gobbling"! How terrible :)
tailgate avuserow_: thanks, I actually couldn't duplicate the problem I was having 20:53
unmatched} Programming must be boring. How dare the compiler make me chuckle :p
tailgate It's a breath of fresh air after spending 8 hours as a java dev
CIAvash m: 1,2,3,1,1,2,3 ==> grep(1 == *) ==> say(); 20:58
camelia rakudo-moar 4d85cd: OUTPUT«(1 1 1)␤»
20:58 zacts joined
unmatched} m: m: (1,2,3,1,1,2,3).Bag{1} 20:58
camelia ( no output )
unmatched} m: m: (1,2,3,1,1,2,3).Bag{1}.say 20:59
camelia rakudo-moar 4d85cd: OUTPUT«3␤»
20:59 tx0h joined 21:00 tx0h left
tailgate So, I have this code: gist.github.com/ahalbert/5cd22fafc...dc0a50d614 It's giving me a single element per item found, when I want all the items. What is wrong with my code? 21:01
21:03 Actualeyes left 21:04 skids left
ugexe (@rest ==> grep { $head eq $key($_)}, $head) # what is this meant to do? 21:04
tailgate take all items in the array eq $key($_) and add head to the end 21:05
it should be a push
21:07 zacts left
tailgate I fixed it. Thanks! 21:08
CIAvash tailgate: you can use `classify` to do that 21:13
21:14 mempko left 21:18 mcmillhj left, Actualeyes joined 21:19 kyclark left 21:20 kyclark joined
lizmat and another Perl 6 Weekly hits the Net: p6weekly.wordpress.com/2016/08/15/...-go-wrong/ 21:21
21:22 prammer left
hoelzro lizmat++ 21:23
21:23 jeek joined 21:28 mcmillhj joined 21:29 trnh left
CIAvash lizmat++ 21:31
21:32 nadim_ left 21:33 trnh joined 21:35 Wiertek left 21:37 kjs_ joined, zacts joined 21:41 kalkin-_ joined
kalkin-_ hi 21:41
21:41 kalkin-_ is now known as kalkin-
lizmat kalkin- o/ 21:42
21:42 kjs_ left 21:43 pmurias left, rindolf left, n1lp7r joined 21:54 rkazak joined
zacts hi perl6 nerds 21:56
21:56 mscha joined
ugexe takes zacts lunch money 21:56
21:56 mcmillhj left
zacts ugexe: nice 21:57
21:58 telex left
mscha m: my @sq = (^10).map: *²; say @sq; 21:59
camelia rakudo-moar 4d85cd: OUTPUT«Cannot resolve caller Numeric(Whatever: ); none of these signatures match:␤ (Mu:U \v: *%_)␤ in block <unit> at <tmp> line 1␤␤»
mscha m: my @sq = (^10).map: * ** 2; say @sq;
camelia rakudo-moar 4d85cd: OUTPUT«[0 1 4 9 16 25 36 49 64 81]␤»
21:59 mcmillhj joined 22:00 telex joined 22:07 CIAvash left 22:09 bjz left
TEttinger hm. what hashing algorithm does perl6 use? does it differ on JVM and Moar? I seem to recall something about random hashing 22:10
there's some interesting properties of the JVM's builtin hashCode functions for arrays, particularly long arrays. as in, new long[]{-1} and new long[]{0} both hash to 31 22:11
22:11 mcmillhj left
TEttinger ... so I kinda hope perl6 doesn't use that 22:12
(that uses Arrays.hashCode because the .hashCode method on arrays is just some variant on the memory address)
22:15 zacts left
timotimo moar has ut_hash in it 22:15
but also, arrays are mutable, so you can't sensibly use it in a hash as an object key 22:16
not without supplying the exact same object every time you want to access; which basically means you'll have to keep a list of keys around, or grab the keys off the hash, or something like that
22:20 mcmillhj joined 22:23 rkazak left 22:24 bjz joined, mcmillhj left 22:25 bjz left 22:31 skids joined 22:33 rkazak joined 22:34 mcmillhj joined 22:37 harovali1 left, kyclark left 22:39 mcmillhj left 22:40 kyclark joined
TEttinger I think I only use hashing of arrays by value (preferably with a 64-bit hash) when I want to have a relatively certain statement that two caches are identical 22:40
timotimo don't forget arrays can have anything they want in them 22:41
TEttinger or when I know that an array isn't going to be modified by me and is internally-used only
timotimo in that case you need to use something else :) 22:42
like a list
TEttinger mm, yeah, I mostly wanted to mention that because Java's arrays seem like they have some issues with hashing and I didn't want JVM Perl 6 to hit the same issue
I'll look up ut_hash 22:43
timotimo www.reddit.com/r/perl/comments/4xg...ms/d6i57le - would you call this an idiom? :(
lizmat timotimo: the reason I mentioned it, is that it refers to Perl 6
timotimo i wonder why nobody answered with the subst method/sub in perl6
because that code is just ... no. 22:44
lizmat timotimo: there's still time, no ?
timotimo of course
22:45 mcmillhj joined 22:46 RabidGravy left 22:48 bjz joined
TEttinger huh, searching for ut_hash finds some interesting unrelated stuff duckduckgo.com/?q=ut_hash&ia=web 22:48
22:49 bjz left
timotimo oh, it's called uthash actually 22:49
..... wat. 22:50
22:50 bjz joined, mcmillhj left 22:51 firstdayonthejob left
grondilu this page about perl idioms pointed to an example that made me realize something. In Perl often we do something like "do this\nl or die "could not do that";". That is putting a newline before ending the statement with a semi-colon, and add a or die $error-message; below, usually with ident. We can't always do that in Perl 6. 22:55
22:55 bjz left
grondilu e.g. do { do-stuff }\n or die "could not do stuff"; # would fail 22:55
timotimo yeah, curlies.
grondilu it's very slightly LTA 22:56
timotimo do we already give a good error when we find an infix op like "or" at the beginning of aline when the previous line has a } at its end?
grondilu nope
most likely you'll get an "undeclared routine 'or'"
22:58 mcmillhj joined
El_Che starting to get syntax error support for vim with syntastic, but vimscript is painful 23:00
timotimo gist.github.com/timo/9036c265cebe2...a6624eceb3 - what do people think? 23:02
El_Che I saw that azawawi added a perl6 lint support to atom using "perl6 -c". It that the only way for now? (One of the perl5 linters on systastic uses perl -c but it's disabled out of the box because of security issues (running external code)
timotimo yeah, perl6 also has that exact security issue 23:03
El_Che yeah, that's what I thought
23:04 mcmillhj left
El_Che I am copying what they did for perl5: add a config option to enable if wanted 23:04
dalek pan style="color: #395be5">perl6-examples: 639577e | (David Warring)++ | categories/parsers/CSSGrammar.pm:
Credit wayland76++ for CSSGGrammar example
23:07
23:14 mscha left 23:15 mcmillhj joined 23:18 cdg left, pi__ joined 23:19 mcmillhj left 23:27 _28_ria left 23:28 _28_ria joined
dataangel p6: my @f = <3 4>; say @f; my @g = [3, 4]; say @g; # what is the difference? 23:40
camelia rakudo-moar 6cd6ef: OUTPUT«[3 4]␤[3 4]␤»
23:41 rkazak left
timotimo no difference; the assignment will take whatever values you put in and throw them into an array; that's because of the one-argument-rule, which ensures that the thing on the RHS of the = will get iterated over 23:44
m: my @f = <3, 4>, <9, 9>; say @f.perl; my @g = [3, 4], [9, 9]; say @g.perl 23:45
camelia rakudo-moar 6cd6ef: OUTPUT«[("3,", IntStr.new(4, "4")), ("9,", IntStr.new(9, "9"))]␤[[3, 4], [9, 9]]␤»
timotimo ^- now here's a difference
oh, haha
man, i need to go to bed :)
the difference between your two pieces of code is that the @g one won't remember how you spelled the numbers, as they'll be "only" Int objects, whereas what's in < blah > will get the IntStr (and friends) treatment 23:46
m: my @f = <0x3 4>; say @f.perl
camelia rakudo-moar 6cd6ef: OUTPUT«[IntStr.new(3, "0x3"), IntStr.new(4, "4")]␤»
timotimo see how it remembers whether you wrote it in hexadecimal or in decimal?
dataangel Interesting... Not sure what I would do with it yet but interesting 23:47
timotimo m: say <foo bar baz>.perl; say [1, 2, 3].perl
camelia rakudo-moar 6cd6ef: OUTPUT«("foo", "bar", "baz")␤[1, 2, 3]␤»
timotimo ^- see also round parens vs brackets
m: say <foo bar baz>.WHAT; say [1, 2, 3].WHAT 23:48
camelia rakudo-moar 6cd6ef: OUTPUT«(List)␤(Array)␤»
timotimo that's only before you put it into the @f and @g, though
dataangel Didn't realize there is an array/list distinction... What's the point when you have auto extending arrays?
timotimo lists are immutable 23:51
arrays also have every element in a scalar container
dataangel So is there a syntax for list doesn't remember how things are spelled? I'm assuming the spelling distinction is the main feature of < stuff here > 23:52
* that doesn't
23:53 wbill joined, mcmillhj joined 23:55 kurahaupo left
timotimo yes, < and > does the spelling thing 23:57
you want round parens to get a regular old list
23:57 mcmillhj left
timotimo and you can write [<foo bar baz>] to get an array of the things in that inner list 23:57
(same "one argument rule" applies here. just one "thing" inside the [], so we iterate over it) 23:58