»ö« 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.
grondilu m: say Set().total 00:50
camelia No such method 'total' for invocant of type 'Set(Any)'
in block <unit> at <tmp> line 1
grondilu was expecting 0
wander4096 need some help >_< 01:18
what's the difference between method and subroutine in perl 6 docs
geekosaur methods are called on objects; subs are just called 01:20
m: class A { method a { say 'in A::a' } }; sub b { say 'in b' }; my A $x .= new; $x.a; b(); 01:21
camelia in A::a
in b
wander4096 I think so, but see it docs `routine isa` which can be only(?) used as sth.isa(...) 01:22
geekosaur but the proto says 'multi method isa' 01:25
geekosaur "routine" is a superclass for both subs and methods (and, quietly, it's possible to call a method as a sub by marking the invocant explicitly) 01:27
m: my Int $a = 5; say isa($a: 'Int')
camelia True
geekosaur the colon there is an invocant marker 01:28
wander4096 ok, so `Str(42:)` can't work but `isa(42: Int)` works, `method Str` and `routine isa` 01:40
BenGoldberg m: sub foo { dd callframe(1).code.name }; (sub { foo() }).(); 02:06
camelia ""
wander4096 m: say "test" 02:17
camelia test
ipatrol if I interpolate one regex into another with <$regex>, how are the groups in the substituted regex addressed? 02:21
ipatrol m: my $reg = /(.)(.)(.)/; my $mat = "abcdefg" ~~ /<$reg>(.)/; say $mat.gist; 02:23
camelia 「abcd」
0 => 「d」
ipatrol m: my $reg = /(.)(.)(.)/; my $mat = "abcdefg" ~~ /<$reg>(.)/; say $0;
camelia 「d」
ipatrol m: my $reg = /(.)(.)(.)/; my $mat = "abcdefg" ~~ /(<$reg>)(.)/; say $/; 02:24
camelia 「abcd」
0 => 「abc」
1 => 「d」
02:25
ipatrol m: my $reg = /(.)(.)(.)/; my $mat = "abcdefg" ~~ /(<$reg>)(.)/; say $/[0];
camelia 「abc」
ipatrol m: my $reg = /(.)(.)(.)/; my $mat = "abcdefg" ~~ /(<reg>)(.)/; say $/[0];
camelia No such method 'reg' for invocant of type 'Match'
in block <unit> at <tmp> line 1
ipatrol doesn't preserve it
ipatrol m: my regex reg {(.)(.)(.)}; my $mat = "abcdefg" ~~ /(<reg>)(.)/; say $/.gist; 02:27
camelia 「abcd」
0 => 「abc」
reg => 「abc」
0 => 「a」
1 => 「b」
2 => 「c」
1 => 「d」
Todd Hi All. "Once Upon A time", I found a reference in the documentation as to what the variables were is you wanted to force the issue: Int64, StrD, etc.. I thought I had written it down, but can't find it if I did. I found docs.perl6.org/language/variables but it does not go into the the types of forced variables 02:52
ipatrol m: my $reg = /(.)(.)(.)/; my $mat = "abcdefg" ~~ /$reg(.)/; say $mat.gist; 02:53
camelia 「abcd」
0 => 「d」
b2gills m: my $reg = /(.)(.)(.)/; my $mat = "abcdefg" ~~ /$<reg> = $reg(.)/; say $mat.gist; 02:54
camelia 「abcd」
reg => 「abc」
0 => 「a」
1 => 「b」
2 => 「c」
0 => 「d」
ipatrol b2gills: thanks, though I actually found another way of doing what I wanted 02:59
Todd In `method getc(IO::Handle:D: --> Str:D)` what does the "D" stand for in "Handle"? Never undefined? 03:07
got to go 03:20
ipatrol m: say 'cat'.end; 03:51
camelia 0
ipatrol m: say 'cat'.first; 03:52
camelia cat
ipatrol m: 'cat'split('').last; 03:53
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3'cat'7⏏5split('').last;
expecting any of:
infix
infix stopper
statement end
statement modifier
state…
ipatrol m: 'cat'split('').tail; 03:54
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3'cat'7⏏5split('').tail;
expecting any of:
infix
infix stopper
statement end
statement modifier
state…
ipatrol m: 'cat'.split('').tail; 03:54
camelia ( no output )
ipatrol m: 'cat'.split('').last;
camelia No such method 'last' for invocant of type 'Seq'. Did you mean any of these?
Hash
List
Rat
flat

in block <unit> at <tmp> line 1
ipatrol m: 'cat'.split('').List.tail; 03:55
camelia ( no output )
ipatrol m: 'cat'.split('')[*-1];
camelia ( no output )
ipatrol m: 'cat'.split('').eager[*-1]; 03:56
camelia ( no output )
ipatrol m: say 'cat'.split('').eager[*-1];
camelia
ipatrol m: say 'cat'.split('', :no-empty).eager[*-1]; 03:57
camelia
ipatrol m: say 'cat'.split('', :skip-empty).eager[*-1];
camelia t
ipatrol m: say 'cat'.split('', :skip-empty).tail;
camelia t
ipatrol m: say 'cat'.tail; 03:57
camelia cat
wander4096 what is the word "invocant" means? i'm from china and difficult to understand it 05:33
the word is here and there, every time puzzle me 05:34
TEttinger "One who calls upon or invokes." I don't know the specific meaning in perl 6, but it would normally be something that is calling something else (probably a method) 05:36
piojo ‎wander4096‎: do you know C and C++ (or C++ and function objects or boost)? 05:37
perl methods are like class functions in these environments: the invisible first function argument (usually ignored) is the caller--usually the class object 05:38
this is the invocant
But I don't think the invocant is always an object of that class, but almost always 05:39
and within the method, you can use "self" to refer to the invocant.
wander4096 emmmm... 05:40
piojo (call its other methods, mostly)
wander4096 sounds more like in Python
piojo I don't know that much Python, but I think it's like this in most object oriented languages
wander4096 thx, maybe i got it :) 05:43
piojo wander4096: you're welcome. BTW, the invocant can be a class instance or the class itself, corresponding to Foo.new.Func versus Foo.Func 05:46
piojo and it's not called "caller" because "caller" means the caller *scope* in perl 05:48
wander4096 so it is. the latter i know it for the first time. 05:50
masak wander4096: when you do `$something.method()`, the object that's in $something gets bound as the invocant of the method call (and can be accessed as `self` inside that call) 05:58
wander4096: you're right in that Perl culture is quite unique in using that word :) 05:59
wander4096 this question occurs when distinguish `method does` from `method isa` 06:04
and i wonder if a role does `Mu`
m: Callable.does(Mu)
camelia ( no output )
wander4096 m: say Callable.does(Mu)
camelia True
wander4096 but in the type graph, i can't find something like the root of roles 06:05
so how can Callable does Mu?
even 06:06
m: say Callable.isa(Mu)
camelia True
piojo The docs for .does() and .isa() don't mention each other 06:31
but in each case, the docs say it's equivalent to `~~`
funny.
piojo files a doc bug/suggestion 06:34
wander4096 em, how to "files a doc bug/suggestion"? 06:52
piojo wander4096: start the message with "/me " 06:56
wander4096 is there a manual about chatroom robot? 07:03
piojo I just found this: github.com/perl6/whateverable/wiki 07:12
piojo and this mentions a few more that aren't listed there (aren't part of the "whateverable" project): github.com/perl6/doc/issues/711 07:12
sena_kun [Coke], ping. 10:06
HoboWithAShotgun m: $_ = chr(12); .say; s/{chr(12)}/x/; .say; 11:20
camelia
x
yoleaux 15 Sep 2017 17:55Z <Zoffix> HoboWithAShotgun: managed to make it work without parens (and slurpy slurps the things): multi postfix:<°> { $^a }; multi prefix:<△> (*@things) is looser(&[,]) { class Triangle { has $.things; method beta { $!things.perl.uc } }.new: :@things }; .beta.say with △ α => 75°, c => 3, b => 3
HoboWithAShotgun m: $_ = chr(65); .say; s/{chr(65)}/x/; .say; 11:21
camelia A
xA
HoboWithAShotgun i thought i can have code blocks anywhere 11:21
HoboWithAShotgun m: $_ = chr(65); .say; s/ {return chr(65)} /x/; .say; 11:30
camelia A
Attempt to return outside of any Routine
in regex at <tmp> line 1
in block <unit> at <tmp> line 1
HoboWithAShotgun m: my @a = 3, (if 0 { 2 }), 1; say @a.elems 11:45
camelia 2
HoboWithAShotgun interesting. i would have expected 3
timo the result of a non-executed if is () aka Empty
that flattens away in list assignment 11:46
HoboWithAShotgun so there is a value produced, it just happens to be of type Empty. So, 0 ?? 2 !! Empty should be the equivalent 11:49
m: my @a = 3, 0 ?? 2 !! Empty, 1; say @a.elems 11:50
camelia 2
HoboWithAShotgun heh
HoboWithAShotgun but i have skimmed the control flow and regex docs now, i still don't know what s/{something}/does/; and why it seems to match the beginning of a string 11:52
HoboWithAShotgun i figured it'd execute "something" and replace its return value, but it doesn't 11:54
piojo timo: it seems that Empty is |(), not () 11:54
piojo and I'm also interested to know how (if 0 {}) becomes Empty 11:55
obviously () is empty, but not Empty (not a slip)
so how does putting some x inside -- (x) -- cause perl6 to turn it into a slip? 11:56
MasterDuke_ HoboWithAShotgun: {something} just executes, <{something}> interpolates the result of executing it into the regex
timo oh, right, it must be a slip
good catch
piojo perl really isn't like other languages... the way it parses things makes me smile but stretches my brain. 11:57
piojo Actually, I think I know how that case works: grouping paretheses are ignored, after they serve their purpose, so `(code...)` is not the same as`()`, because the latter is not for grouping, and it can't be just dropped by the compiler. 12:00
so `(code)` can be turned into a slip because it's actually equivalent to `code`, not list(`code`)
("turned into a slip" == evaluated and returns something that is a slip) 12:01
timo m: say ()
camelia ()
timo m: say ().perl
camelia ()
timo gee thanks %)
m: say ().^name
camelia List
piojo m: say (42).perl
camelia 42
piojo m: say ().perl
camelia ()
timo yeah, the comma is normally what causes a list to be created, except if the parens are completely empty (and not in a place where they would be an argument list) 12:02
piojo so () is only kept when it doesn't serve a semantic purpose
MasterDuke_ m: say (42,).perl
camelia (42,)
piojo but you know what gets me? this:
m: say <hi>.perl
camelia "hi"
moritz m: say <hi>.^name
camelia Str
piojo m: dd <hello world>, 12:04
camelia ("hello", "world")
piojo so with a comma, it doesn't matter whether there's just one word, or more
except it's awkward to do that in an argument list
piojo m: say <hello>,, ('world',) 12:05
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix , instead
at <tmp>:1
------> 3say <hello>,,7⏏5 ('world',)
piojo m: say (<hello>,), ('world',)
camelia (hello)(world)
piojo awkward ways to make lists :P
timo corner cases everywhere! 12:07
jnthn m: say @('hello'), @('world') # arguably prettier than trailing , 12:08
camelia (hello)(world)
piojo jnthn: I like that, thanks. I'll try to remember that 12:08
m: dd @<hello>
camelia (Nil,)
timo haha
piojo shrugs
timo that's a postcircumfix there
kind of like %foo<bar baz> 12:09
jnthn Is it?
I thought it was the match object access sytnax
timo right, it should complain about @ not having hash access
jnthn Usually used as $<named-arg>
timo oh, right!
it is
i thought of an anonymous state var
jnthn m: dd @'hello'
camelia 5===SORRY!5=== Error while compiling <tmp>
Name must begin with alphabetic character
at <tmp>:1
------> 3dd @7⏏5'hello'
expecting any of:
infix
infix stopper
postfix
statement end
st…
piojo oh, I've seen % and @ used with no variable name before, and I wondered what that was
jnthn m: dd @"hello"
camelia 5===SORRY!5=== Error while compiling <tmp>
Name must begin with alphabetic character
at <tmp>:1
------> 3dd @7⏏5"hello"
expecting any of:
infix
infix stopper
postfix
statement end
st…
jnthn Yeah, figured one'd not get away with that :) 12:10
moritz m: /a b+/ 12:11
camelia Potential difficulties:
Space is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)
at <tmp>:1
------> 3/a7⏏5 b+/
piojo so is @<hello> really the match object? Is this a way to access / <hello>* / ?
moritz I'm kinda annoyed by this warning; the quantifier after the second atom makes the whitespace very sensible
HoboWithAShotgun MasterDuke_: thanks, yet what does <{}> do? where is that documented? 12:12
piojo m: 'a b c' ~~ m/<match>=(.*)/; say @<match>.perl 12:13
camelia 5===SORRY!5===
Unrecognized regex metacharacter = (must be quoted to match literally)
at <tmp>:1
------> 3'a b c' ~~ m/<match>7⏏5=(.*)/; say @<match>.perl
Couldn't find terminator / (corresponding / was at line 1)
at <tmp>:1
------>…
piojo m: 'a b c' ~~ m/ <match>=(.*) /; say @<match>.perl
camelia 5===SORRY!5===
Unrecognized regex metacharacter = (must be quoted to match literally)
at <tmp>:1
------> 3'a b c' ~~ m/ <match>7⏏5=(.*) /; say @<match>.perl
Couldn't find terminator / (corresponding / was at line 1)
at <tmp>:1
-----…
moritz piojo: should be $<match>=
piojo moritz: thanks! 12:13
m: 'a b c' ~~ m/ $<match>=(.*) /; say @<match>.perl 12:14
camelia ()
piojo m: 'a b c' ~~ m/ $<match>=(.*) /; say $<match>.perl
camelia Match.new(list => (), made => Any, pos => 5, hash => Map.new(()), orig => "a b c", from => 0)
piojo jnthn: so @<foo> isn't the match object, it seems
MasterDuke_ HoboWithAShotgun: don't know where it's documented
m: say "a1b2c3" ~~ /a <{"hobo".chars - "hob".chars}> b/ 12:16
camelia 「a1b」
MasterDuke_ m: say "a1b2c3" ~~ /a <{"hobowithashotgun".chars - "hob".chars}> b/
camelia Nil
jnthn piojo: heh, wow, I thought t was... 12:17
piojo jnthn: the test wasn't rigorous, though. a better test would have a named match group with a quantifier 12:18
teatime just wanna say: the fact that even you guys can't always remember the special vars / funny symbols, gives me hope
jnthn huh, the AST seems to agree with me 12:19
- QAST::Op(callmethod list) <sunk> :statement_id<?>
- QAST::Op(call &postcircumfix:<{ }>) <foo>
- QAST::Var(lexical $/)
- QAST::WVal(Str) foo
@<foo> desugars to $/{'foo'}.list 12:20
piojo jnthn: you were right
m: grammar G { token TOP { <match>* }; token match { . } }; G.parse('foo'); dd @<match>
camelia [Match.new(list => (), made => Any, pos => 1, hash => Map.new(()), orig => "foo", from => 0), Match.new(list => (), made => Any, pos => 2, hash => Map.new(()), orig => "foo", from => 1), Match.new(list => (), made => Any, pos => 3, hash => Map.new(()), o…
piojo my other example must have failed because of details about when the array part of the match is assigned to. 12:21
timo one day we'll totally build that desuger module/function 12:21
jnthn m: "aaa" ~~ /[$<foo>=a]+/; say @<foo> 12:22
camelia [「a」 「a」 「a」]
piojo If you have a certain $/ in local scope, does @<...> come along for the ride just as $<...> ? 12:23
timo they are literally just syntax shortcuts to calling postcircumfix:<{ }> on $/ 12:24
(and in the case of @< > and %< > also calling .list or .hash on them)
piojo timo: oh, thanks. 12:25
though I have to assume that's merely _almost_ true
timo ah?
piojo because that doesn't explain why @<match> is not populated, when in the same code has $<match> containing a value
m: 'a b c' ~~ m/ $<match>=(.*) /; say $<match>.perl; say @<match>.perl 12:26
camelia Match.new(list => (), made => Any, pos => 5, hash => Map.new(()), orig => "a b c", from => 0)
()
timo oh
of course you get the .list of the thing
piojo haha 12:26
timo and the list => () part from the Match is what you get here
piojo oh
oh, so .list isn't like list()
sorry, should have realized
I've been confusing myself about that, recently. this goes a long way toward clearing up some things I've been puzzling about, like when hash(...) gives a different result than (...).hash 12:27
timo it gets more interesting when the $<foo>=... is actually captured multiple times
timo like jnthn showed above with the "aaa" match 12:28
piojo yeah
I know that's gonna be useful
I've wondered in the past about how to address when a match should be an array that might have 0 or 1 value(s). This is probably applicable
piojo though I think @($<match>) would also solve that problem 12:30
timo for "0 or 1 matches" you can decide between using "?" where you'll get a Nil or a single value, or using ** 0..1, where you'll always get a list
m: "" ~~ / "a"* /; say $/.perl
camelia Match.new(list => (), made => Any, pos => 0, hash => Map.new(()), orig => "", from => 0)
timo m: "a" ~~ / "a"* /; say $/.perl
camelia Match.new(list => (), made => Any, pos => 1, hash => Map.new(()), orig => "a", from => 0)
piojo timo: that's good to know
I actually meant *, though
I wasn't sure the engine would give me a list if there's 1 match
timo oh, that wasn't interesting at all
m: "a" ~~ / ("a")* /; say $/.perl 12:31
camelia Match.new(list => ([Match.new(list => (), made => Any, pos => 1, hash => Map.new(()), orig => "a", from => 0)],), made => Any, pos => 1, hash => Map.new(()), orig => "a", from => 0)
piojo I suppose it will. my code was buggy enough that I'm not sure I got to that point
timo there it is
piojo m: 'a' ~~ / [ $<a>='a']* /; say $<a>.elems 12:32
camelia 1
piojo sorry, that's the newbie version :) 12:33
uh-oh, I'm remembering more details 12:34
teatime timo: are you also timotimo ?
piojo m: 'aa' ~~ / $<match>=a | [ $<match>=a ]* /; say $<match>.elems 12:36
camelia 2
piojo m: 'aa' ~~ / $<match>=a || [ $<match>=a ]* /; say $<match>.elems
camelia 1
piojo m: 'aa' ~~ / $<match>=a /; say $<match>.elems
camelia 0
piojo haha
It's definitely smarter than I expected 12:37
timo teatime: i am 12:39
timotimo sorry for the confusion 12:39
piojo teatime: who will you be in an hour?
timotimo who will you be when the irc drops?
piojo I mean, if you're teatime now.
teatime so, tea is lovely nearly any time. and, it's all kinds of different times around the globe. I assert that any time is teatime :) 12:40
piojo excellent answer :) 12:41
teatime timotimo: no worries, just curious / trying to keep up w/ "faces".
teatime I do not at all understand why 'aa' ~~ / $<match>=a /; say $<match>.elems --> 0 12:41
hrm, it is a Match though, not a Str like I was thinking. 12:42
timotimo because the .elems goes at the .list part i'd expect
piojo so the more interesting question is how the .list part gets populated 12:42
teatime "Returns the number of positional elements in the Capture." aha, gotcha. 12:43
piojo I think it's populated permissively, if there could *possibly* be anything in the list, then that thing is put in
m: 'aa' ~~ / $<match>=a || $<match>=a /; say $<match>.elems 12:44
camelia 0 12:44
piojo yep, that's how it looks. if it sees any value being populated by the *, +, or {x}, or {x..x} quantifiers, it will be treated as belonging to a list, even if that match-codepath is not true (doesn't match) 12:44
teatime finally gets it. 12:50
pmurias or backends where there are really only 32bit integers do we want to emulate 8,16bit behavior for int16, int8 etc.? 12:59
moritz I think so, yes 13:02
there are some algorithms (like hash sums / message digests) where the wrapping is mandatory
but maybe wait for somebody elses opinion 13:03
pmurias dislikes doing language design choices 13:05
too much questions where there are arguments for both choices ;) 13:06
teatime <stdint.h> -> uint16_t is *exactly* 16 bits wide. it would surprise me if I used a type called "int16" and it was actually ≥16 rather ==16 bits wide. 13:09
hahainternet teatime: hope you don't put things in structs ;) 13:13
piojo ‎hahainternet‎: it would be nice if we could put things in structs 13:14
hahainternet piojo: i thought nativecall padded correctly
piojo I reimplemented a clever file duplicate finding algorithm in perl, and it kept running out of memory and choking
I mean, not structs for native calls, but structs for perl 13:15
hahainternet i don't see why that's a problem, p6 has native types
piojo objects with a known memory layout and size
I haven't explored that yet--actually, I wasn't planning to port it to perl6 until it's faster 13:16
perl6 seems quite slow for filesystem operations
teatime I need to deep-dive into the nativecall stuff at some point... it's a mystery to me how it (that is, the ecosystem libs that wrap shared libs) can work reliably.
hahainternet it's quite slow in general, but that's not really a criticism given how much work has gone into it so far
piojo: i would say though, treating memory as an on-demand, virtually allocatable, balloonable pool is a naive approach and you should implement a fixed size pool in your code 13:17
but that's arguably also pre-optimisation
and i know many people who prefer the Lambda approach
teatime like, it's way easier to successfully make one of those wrappers than should be possible, or something. 13:17
hahainternet teatime: C calling conventions are pretty straightforward 13:18
piojo ‎hahainternet‎: I'm not sure what you mean. But my (perl5) code is all perl objects and code. The memory I'm running out of is because for example a perl int is a lot bigger than 32 bytes.
hahainternet piojo: imagine trying to write this same algorithm on a system that was severely memory constrained 13:19
say a megabyte or two
instead of creating arbitrary objects and adding to a list or similar
piojo but even if all the memory usage were equivalent to native bytes, it would still be a tight squeeze, so I converted it to use sqlite, which is probably the right path, given that the size increases with the count of files examined
hahainternet: yeah, that agrees with what I eventually decided
hahainternet you would statically allocate an area of memory and reuse it consistently 13:20
sqlite is a decent approach depending on your index requirements
piojo hahainternet: the algorithm requires remembering some data for every file examined
hahainternet i would usually hesitate to mention this, but you could consider memcached
piojo: right, but how much it can remember depends on your system
and if you simply blindly allocate objects and store them, you'll never know if your script can work on a system or not without trying it
anyway i'm not saying you should go away and go statically allocating 13:21
piojo hahainternet: it has to remember all of it. and yes, you're right, that can't possibly work, but there's not a better way, other than ridiculous hacks that would require lots of extra I/O because information was purged from memory
so a database is necessary if the script is going to run on all systems. 13:22
hahainternet piojo: so make the extra IO more efficient, learn about r/b trees etc (depending on your balancing requirements)
anyway i'm not trying to suggest you've done anythign wrong or bad
just saying that strategy is not going to be a winner even if you have 10x more RAM, because its memory requirement is set by the size of the challenge
you should aim to design your software so that its memory requirement is as static as possible no matter the input set size
memcached/sqlite are excellent options there 13:23
piojo some algorithms are O(n) in memory usage--I believe file duplicate checking falls into that category 13:23
at a minimum, you need to memorize the size of each file 13:24
*duplicate file finding, not just checking
hahainternet i can think of smaller algorithms
hash the file, store the first nibble
there's always going to be options
it's more of a question for your use case what's appropriate
piojo that's stil O(n), just a smaller n
hahainternet i just wanted to point out that if you're OOMing on perl5, no language will fix that explosion
piojo: big-o is a complexity class 13:25
a multi-stage algorithm is not the same
piojo It's still O(n), even if there are 3-4 passes over the input data
hahainternet i suppose technically if you're using big enough ints that the file size certainly fits inside 13:26
hahainternet but the size of your result is actually known, vs 'a big number' 13:26
moritz
.oO( O(4n) )
hahainternet piojo: you can easily think of this in a different way 13:28
piojo hahainternet: basically, I agree with you, it might be acceptable to write programs that will run fine "unless you try to run it on more than 30 million files", as long as that limitation is documented
hahainternet take the length of your files, int divide it
(by 2)
piojo but it would hurt my pride to write one that chokes with a much smaller limit
hahainternet now you need only store which of the two categories the file is in
two whole bits :p
and yeah piojo that is quite common with an awful lot of tools 13:29
but it's also a very common mistake i see, especially in my own code :)
piojo hahainternet: that's clever, but in the case I tried, it wouldn't have helped because almost every file had at least one duplicate, so pre-passes saved IO (by comparing inodes) but didn't really reduce the amount of stuff that had to be remembered so much 13:32
hahainternet piojo: it's just a hash :p 13:33
but yeah there are plenty of techniques
it's up to you to choose what works best for your use case
piojo hahainternet: actually, I'm not sure I understand. are you talking about dividing divide and conquor, based on categorizing the size?
hahainternet yeah if you have 30 million files, and you store if the length is odd or even, you need 30 million bits total
and that bisects your set to approximately 15 million files
so next pass you now have 2 bits per file to play with
piojo plus the size of the filenames, which is the real killer
hahainternet then 4 bits
then 8 bits
piojo: sort them, use bit # in memory to be file # 13:34
there are lots and lots of techniques for this, i don't want to imply you've done anything wrong though
piojo I thought about that, but decided it wouldn't help enough :)
I'm sure you have a lot of great ideas I haven't thought of
but I divided the acceptable memory usage by the number of files and found even perfect optimizations wouldn't be enough, except one-- 13:35
it ended up not working out, but in c++ (not perl) I would have been able to store the filenames in a trie, with each node representing a directory (or the basename)
I tried it in perl but it used even more memory than just storing each fname as a full string. Because of overhead for variables, I think 13:36
hahainternet well you can do that in perl, but yeah memory usage
pmurias hmm, is there a way to determine which multi variant is called?
hahainternet piojo: just out of interest, can you give me some actual numbers 13:38
like you have 4 billion files
and 200mb memory
piojo hahainternet: if I recall, it was 5 billion files. 8 GB ram, with half taken up by other programs that were running
hahainternet yeah that's quite difficult, no matter how efficient
piojo some long filenames. lots of hard links because it was a backup disk. Slow frustrating I/O, so that had to be as efficient as possible 13:39
hahainternet oh, this smells like a mailserver backup usign rsync
how far am i off the mark?
piojo just a personal backup with rsync :)
hahainternet 5 billion files, crikey
piojo I don't know where they all came from 13:40
hahainternet anyhow i'd do some sort of component analysis there, because short of using the technique of a 2 bit hash and repeated passes
piojo oh, I think there probably was a mail directory in there somewhere
hahainternet the next stage after that is to make your hash function more perfect
that is, you identify the type of test that is most likely to split your set up into a small 'potential match' set
piojo I borrowed the algorithm from fslint, but modified it to be smart about repeated inodes
hahainternet microsoft have an interesting paper on perfect hash functions
i think what you'd want is kinda the opposite 13:41
piojo the hash doesn't need to be that fast, because it's not run very often--first pass gets sizes, then sorts. next pass makes sure the inode hasn't been seen yet (this is my change) and gets a checksum of the first kilobyte. next pass does a full checksum 13:42
hahainternet i see the thought, and doing a size pass is a good idea if it fits in memory 13:43
piojo I should really get around to publishing that on cpan. I need to clean it up and find out what the coding standards for publication are...
hahainternet but the 'hash' is just a consistent reduction of your data into a smaller space
a perfect hash embodies the minimum set required to identify a member uniquely
hahainternet you kinda want the opposite, the shortest hash required to identify a minimum set 13:44
right i'm gonna go deal with some irl things, i'm sorry i can't be of any direct help piojo
but fun chat :)
piojo hahainternet: yeah, good talking to you!
hahainternet plus there's always people here willing to help out with perl, and you should play with 6 regardless
because it's absurdly fun, -Ofun don't you know
piojo yeah, I like it a lot
but I'm not gonna wait for rakudo to scan 5 billion files 3 times 13:45
hahainternet why not? do it and profile it
timotimo maybe only with 5 thousand files
hahainternet then you're providing useful data on what's really slow as heck
teatime warning: perl6 is known to the state of california to be addictive.
piojo If that's useful, we could start smaller
hahainternet you kids and your » symbols
piojo a directory walk is significantly slower in perl6 than perl5
piojo though threading speeds it up to be just 50% slower 13:46
(err, that's for a type of full-text search, not just a directory walk)
I'm also comparing apples to oranges, since my perl5 version is using the cygwin perl5, which is far faster than the windows perl5 13:47
raschipi 💩💩💩 13:51
HoboWithAShotgun allright. how can it be an operator behaves differntly depending on wether i import it from a module or wether it is in the program itself 13:54
raschipi HoboWithAShotgun: How so? 13:55
HoboWithAShotgun apparently a precedence issue 13:58
consider, hastebin.com/ixomivepoh.pl 14:00
raschipi considers 14:01
Are you sure the other code declares itself looser than the comma? 14:03
HoboWithAShotgun i am sure the code is identical
raschipi Does anyone know a way to introspect the precedence of an operator? 14:04
timotimo m: say &infix:<,>.pred 14:09
camelia No such method 'pred' for invocant of type 'Sub+{<anon|63427424>}+{Precedence}'. Did you mean any of these?
grep
prec
tree

in block <unit> at <tmp> line 1
timotimo m: say &infix:<,>.precedence
camelia No such method 'precedence' for invocant of type 'Sub+{<anon|63427424>}+{Precedence}'
in block <unit> at <tmp> line 1
timotimo m: say &infix:<,>.prec
camelia {assoc => list, prec => g=}
timotimo there we go
raschipi Thanks, timotimo. 14:11
HoboWithAShotgun: Can you run that method in your code?
HoboWithAShotgun it says {} for the op in the script file and {prec => v=} for the imported one 14:15
so, yes. the precedence is different 14:16
raschipi Are you sure it's calling the correct multi? 14:17
HoboWithAShotgun yes, as seen in the output. there is no third one 14:18
HoboWithAShotgun i put together a minimal case and see if that persists. if so i gonna file a bug 14:19
raschipi HoboWithAShotgun: I think you hit RT #128042 14:20
synopsebot6 Link: rt.perl.org/rt3/Public/Bug/Display...?id=128042
HoboWithAShotgun uh, nice and the fix right there 14:24
raschipi Tidal bots. 15:09
HoboWithAShotgun how do i introspect the parameters to a sub within the sub via introspection. I know I must get ahold of the routine object of the mehod but how 15:14
HoboWithAShotgun that's all i can find in the docs: "Introspection on subroutines is provided via Routine." 15:19
yes, tyvm. that doesn't tell me how to get an instance of it 15:20
jnthn &?ROUTINE 15:22
HoboWithAShotgun doesn't work within the routine. maybe that's xy. i have a sub with various named arguments and i want to access those via a hash 15:24
moritz HoboWithAShotgun: just declare the signature with *%named or so 15:25
m: sub foo(*%named) { say %named.keys.sort.list.perl }; foo a => 2, :b, :c(34); 15:26
camelia ("a", "b", "c")
HoboWithAShotgun i know. but i want to keep the explicitly named arguments
ugexe is passing an action class + supply to a JSON grammar a kind of streaming json parser if the action class emits its first level objects from the action class? 15:29
moritz HoboWithAShotgun: you can have both with a subsignature 15:30
moritz m: sub foo(*%named (:$a, Int :$b) ) { say $b; say %named.keys }; foo b => 42; 15:30
camelia 42
(b)
weabot What's the best way to use a long-lived thread that I basically want to use as a different process sharing the same address space? 15:31
is the Thread class more reliable for this than promises?
moritz weabot: what reliability issues are you having with promises? 15:37
weabot they hang after a bit, I'll make an example real quick 15:37
jnthn How many are you creating? If lots of them, it's possible you're running into the thread pool size limit (which you can increase) 15:42
weabot I'm creating them with Promise.start, appending the return value to an array that's cleaned when another function sees that the promise is kept, I make sure that the amount of promises I have stays under 10 15:43
well, I call .Bool on each promise and delete the entry if it shows True
weabot alright here it is p.teknik.io/L88yU 15:47
on my end this prints 1 and 2, and eventually stops
there is no 0
I'm sure I'm doing something wrong, but this is generally what happens in my program
it starts, and after a few instructions it hangs 15:48
sena_kun weabot, it prints 2 infinitely for me. 15:49
weabot what OS are you on?
and version
sena_kun linux, 2017.08-108-g760530a52 built on MoarVM version 2017.08.1-150-g0b81969db
weabot interesting, I'll try it on linux 15:50
weabot yup, only prints 2 on linux 15:50
on 2017.07 15:51
but it eventually stops
weabot now here's something 15:53
weabot if I call them all individually without a loop, they all print before stopping 15:54
piojo weabot: for me on linux it prints 1 and 2 15:59
but my version is 16:00
sub t($i) {
while (True) {
print($i);
}
}
sub MAIN() {
loop (my $i = 0; $i < 2; $i++) {
Promise.start({t($i)});
}
t($i);
# Not reached
return 0;
}
err, sorry about that
two clipboards!
my version is 2017.08-96-ge5a600997 built on MoarVM version 2017.08.1-135-ge86428d4
whoa, I ran it again and it only printed 2. 16:01
piojo is $i is being copied in the closure rather than aliased? because my guess is the variable is being copied only when the function call happens 16:03
piojo and if the function call occurs after the loop has already gotten to i=1 or i=2, then the function's value of $i will be frozen at that point 16:04
so the "22222222" behavior happens if all the iterations of the loop happen before the thread pool actually lets the threads long enough that they can get to the t() function call.
*before the thread pool lets the threads run long enough to get to the t() function call 16:05
(which means this is unexpected but not a bug. c# had the same issue, but they decided to change the language behavior because it was so damn counter-intuitive) 16:06
weabot hmm
the bug is that the threads just stop printing anything after not too long for me
piojo I bet if you make a copy of $i within the loop body, you get 0, 1, and 2
weabot but let's see
piojo weabot: isn't that just the program finishing? 16:07
weabot nope, the command line doesn't return, I have to SIGINT
and I tried to do this
my $done = Promise.allof(@promises);
await $done;
no returns
piojo weabot: oh, sorry, of course you're right. it also hangs for me. I had a dumb (actually an "it's my bedtime") moment
piojo but I tested and was right about the "2222222" issue 16:08
weabot hmm
weabot but when I use .ACCEPTS on t instead of putting it in a block, it only prints 0 16:08
piojo weabot: sorry, I'm not familiar with what that is 16:09
weabot docs.perl6.org/type/Code#method_ACCEPTS 16:10
it lets you pass arguments
piojo changing it to &t.ACCEPTS($i) ? when I run that, I just get "22222222" 16:12
weabot I only had 000 16:13
weabot anyway, here's what strange 16:13
piojo I think on my computer, it causes the code to take longer to run
weabot putting $i into another variable made it run forever
let me try again
piojo oh, that is strange! It didn't do that fo rme
weabot yep, it looks like it's gone for good 16:14
I have no clue why
piojo oh, and when it hangs, it's using 100% cpu. I wonder if it's deadlocked? 16:16
weabot that's what I was thinking
piojo I've gotta go to bed. sorry I didn't have an answer for the more buggy part of this test case.
weabot but on 2017.07 both on linux and macOS, setting $i in another variable lets it go on forever 16:17
I'm clueless
anyhow, good nigth piojo
night*
piojo night. It's too bad I'm not patient enough to stick around to hear the answer, if there is one. :D
weabot yeah, I'm not sure we'll have them 16:18
weabot if anything this way we'll figure out workarounds and write bug reports 16:18
Skarsnik ping jnthn x) 16:19
ipatrol Can a module declared inline access variables from outside itself? 17:32
ipatrol m: my $foo = 'cat'; module Bar {sub foobar {say $foo;}} import Bar 'foobar'; foobar(); 17:37
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3at'; module Bar {sub foobar {say $foo;}}7⏏5 import Bar 'foobar'; foobar();
expecting any of:
infix
ipatrol m: my $foo = 'cat'; module Bar {sub foobar() {say $foo;}} import Bar 'foobar'; foobar(); 17:37
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3'; module Bar {sub foobar() {say $foo;}}7⏏5 import Bar 'foobar'; foobar();
expecting any of:
infix
ipatrol m: my $foo = 'cat'; my module Bar {sub foobar() {say $foo;};}; import Bar 'foobar'; foobar(); 17:38
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
foobar used at line 1
ipatrol m: my $foo = 'cat'; my module Bar {sub foobar() {say $foo;};}; import Bar 'foobar'; Bar::foobar(); 17:38
camelia Could not find symbol '&foobar'
in block <unit> at <tmp> line 1
ipatrol m: my $foo = 'cat'; my module Bar {our sub foobar() {say $foo;};}; import Bar 'foobar'; Bar::foobar();
camelia cat
ipatrol m: my $foo = 'cat'; my module Bar {our sub foobar() {say $foo;};}; Bar::foobar(); 17:39
camelia cat
ipatrol m: my $foo = 'cat'; module Bar {our sub foobar() {say $foo;};}; Bar::foobar();
camelia cat
ipatrol m: my $foo = 'cat'; module Bar {my $baz = 'nap'; our sub foobar() {say "$foo$baz";};}; Bar::foobar(); 17:40
camelia catnap
HoboWithAShotgun m:class Bar { method bar { die "a b c"; } }; throws-like { Bar.new().bar }, Exception, "test3", message => /a \s b/; # ok 18:57
evalable6 (exit code 1) 04===SORRY!04=== Error while compiling /tmp/OvmH1EDAz3
Undeclared routine:
throws-like used at line 1
HoboWithAShotgun m:use Test; class Bar { method bar { die "a b c"; } }; throws-like { Bar.new().bar }, Exception, "test3", message => /a \s b/; # ok
evalable6 1..3
ok 1 - code dies
ok 2 - right exception type (Exception)
ok 3 - .message matches /a \s b/
ok 1 - test3
HoboWithAShotgun m:use Test; class Bar { method bar { die "a b c"; } }; throws-like { Bar.new().bar }, Exception, "test3", message => m:s/a b/; 18:58
evalable6 (exit code 1) Use of uninitialized value of type Any in string context.
Methods .^name, .p…
HoboWithAShotgun, Full output: gist.github.com/00b35084df73b2cc62...1abf326612
HoboWithAShotgun m: use Test; class Bar { method bar { die "a b c"; } }; throws-like { Bar.new().bar }, Exception, "test4", message => m:s/a b/; 18:59
camelia Use of uninitialized value of type Any in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
1..3
ok 1 - code dies
ok 2 - right exception type (Exception)
not ok 3 - .messa…
HoboWithAShotgun strange. on my perl6 this does something different. also wrong, but different 19:00
HoboWithAShotgun scratch that, i misread 19:02
HoboWithAShotgun so, why does the second test fail? message => /a \s b/ and message => m:s/a b/ should be equivalent 19:03
shouldn't they
geekosaur HoboWithAShotgun, the m// executes immediately 19:07
it is not a value, it is performed and its result is made the value associated with the key 'message'
HoboWithAShotgun i see. 19:08
ipatrol use rx instead of m
geekosaur ^ 19:08
ipatrol I have managed to condense virtually the entire system of verb conjugations in Japanese, into 150 lines of code, whitespace included. 19:13
moritz ipatrol: you scare me 19:16
HoboWithAShotgun pff. i am not scared. i am panicking :) 19:19
can i express this a bit shorter? $_ ~~ %_ && %_{$_}.defined
moritz why not just %_{$_}.defined ? 19:20
HoboWithAShotgun good question. i figured that would throw an error 19:21
since i cannot know if $_ is an existing key 19:22
Skarsnik %_{$_}:exists?
ugexe that includes undefined values 19:23
ipatrol moritz: why do I scare you? 19:24
ipatrol I think I can knock out all the polite forms in another 50 lines or so 19:40
gfldex lolibloggedalittle: gfldex.wordpress.com/2017/09/16/th...-continue/ 20:15
timotimo hehe 20:17
ipatrol can't see the whole line in my browser for some reason 20:18
AlexDaniel gfldex: hehe :D 20:46
ipatrol Actually, I was able to code the polite conjugations in only 22 lines, plus a couple of functions defined earlier 20:52
ipatrol gist.github.com/anonymous/d8123631...d6f2208e72 21:02
unclechu hey guys, could someone explain me how i've got `-2.44929359829471e-16` by `sin(pi * 2)` instead of zero? 21:20
timotimo we use floating point numbers for trigonometry functions 21:22
you'll get the same result from, for example, python
geekosaur floating point is inherently inaccurate
or at least a similar but still nonzero one, unless something is specifically checking or you limit output precision 21:23
TEttinger also, no way to store the exact value of pi 21:25
you could store it symbolically, but then it's just the symbol pi and needs special treatment 21:26
e-16 means it's very small though
ipatrol you could store a routine that computes pi to arbitrary precision
TEttinger can you pass an arbitrary precision number to sin()? 21:27
ipatrol TEttinger: depends on how it's implemented
ipatrol unclechu: the thing is, Perl 6 is not a CAS. 21:27
TEttinger in perl 6, thatis
unclechu thanks 21:28
geekosaur floating-point-gui.de/ 21:29
TEttinger I'm guessing there's a convenient way to compare within some epsilon
ipatrol TEttinger: I think =~= does that 21:30
sjn m: say sin(π * 2) =~= 0
camelia True
TEttinger nice
ipatrol the epsilon it uses is $*TOLERANCE 21:31
TEttinger say sin(π / 2.0) =~= 1
evalable6 True
ipatrol m: say $*TOLERANCE;
camelia 1e-15
TEttinger huh, evalable6 took over there, thanks evalable6 21:32
gfldex m: say sin(π / 2.0) ≅ 1
camelia True
ipatrol I'm not sure what semantics assign which bot to which statement
TEttinger I think m: goes to camelia always, not sure how evalable6 figured out I pasted code 21:33
ipatrol TEttinger: probably using the `say` 21:33
TEttinger say say
ipatrol say 'Happy';
evalable6 Happy
TEttinger say say 0;
evalable6 0
True
gfldex another ENODOC 21:34
ipatrol It might try to evaluate everything of that form, and just remain silent if it gets a syntax error 21:34
say <STDIN>; 21:35
evalable6 (exit code 1) 04===SORRY!04=== Error while compiling /tmp/sQEiG4Wrx7
Unsuppo…
ipatrol, Full output: gist.github.com/c45dab4405f075bc74...52e4da1365
ipatrol nopu
say <STDIN> 21:36
evalable6 (exit code 1) 04===SORRY!04=== Error while compiling /tmp/jufkdMXG5H
Unsuppo…
ipatrol, Full output: gist.github.com/1857f7551593864e64...3f78166eaa
ipatrol no idea then
geekosaur evalable6 takes lines that it thinks "look like" perl 6 code. but it ignores anything specifically directed to another bot with a prefix 21:37
AlexDaniel say you start your message with “say”, it shouldn't eval, right? 21:43
;)
because magic
ipatrol say "I just wanna run" 21:44
evalable6 I just wanna run
AlexDaniel actually, evalable calculates the ratio of non-\w characters in a message, and if there are too many, then it's probably code
ipatrol say I saw a man say "desu"
AlexDaniel ^ here we have more regular letters, so maybe it's not code 21:45
say I saw a man say "d““e”s”u"
ipatrol say <I> saw <a> man? !say "desu"
evalable6 (exit code 1) 04===SORRY!04=== Error while compiling /tmp/GSzSnIPyV2
Two ter…
ipatrol, Full output: gist.github.com/dec2122d6d5583a29b...ef5c2297c7
AlexDaniel well, you get the idea :) fun stuff
github.com/perl6/whateverable/blob...p6#L42-L54 21:46
^ code that does it
and here's what does the trick: $0.chars / $0.comb(/<-alpha -space>/) ≤ 10 21:47
ipatrol so it only works on "say", intentionally omits "say I", omits anything that ends in a period, question mark, or exclamation point, automatically operates on `say I "..."`, and otherwise requires a word/nonword ratio of 10 or less 21:50
* automatically operates on `say "..."`
Geth whateverable: a9d9697df2 | (Aleks-Daniel Jakimenko-Aleksejev)++ | bin/Evalable.p6
Add ELI5 description for code detection

  ipatrol++
22:54
AlexDaniel ipatrol: thanks :) ↑
Geth whateverable: 1e5270241c | (Aleks-Daniel Jakimenko-Aleksejev)++ | bin/Evalable.p6
Explain how we got there
22:57
timotimo i think i found a tiny buglet in the permutations iterator 23:01
it uses $b, which is a lexical in the outer scope, inside the iterator class
since classes aren't closures, that'll give bogus values after the first use
MasterDuke can you show an example where it breaks? 23:03
timotimo doesn't look like i can 23:07
grondilu in S14 I read I should be able to do '$fido does Wag($tail)' but I can't get it to work. 23:19
m: role Dog { has $.tail }; my $dog does Dog($) 23:20
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in typename; couldn't find final ')'
at <tmp>:1
------> 3le Dog { has $.tail }; my $dog does Dog(7⏏5$)
grondilu m: role Wag { has $.tail }; say class Dog does Wag($) {}.new
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in typename; couldn't find final ')'
at <tmp>:1
------> 3 { has $.tail }; say class Dog does Wag(7⏏5$) {}.new
grondilu m: role Wag { has $.tail }; say class Dog does Wag(my $tail) {}.new 23:21
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in typename; couldn't find final ')'
at <tmp>:1
------> 3 { has $.tail }; say class Dog does Wag(7⏏5my $tail) {}.new
grondilu what am I missing?
timotimo grondilu: don't think that's a thing we have 23:21
there's only parametric roles 23:22
jnthn grondilu: Confusing does trait with does infix, and iirc it's only `but` that does that magic anyway 23:23
timotimo oooooh, *that* 23:24
grondilu A role applied with "does" may be parameterized with an initializer in
parentheses, but only if the role supplies exactly one attribute to the
mixin class
meh, * 23:25
jnthn Maybe the synopses is unclear. I wrote chunks of it, sorry if so. But I at least know what it's meant to mean, and that certainly only is talking about the infix. 23:26
grondilu I tried the infix too though 23:27
m: role Dog { has $.tail }; my $dog; $dog does Dog($) 23:28
camelia Unexpected named argument 'value' passed
in block <unit> at <tmp> line 1
jnthn Yeah, I'm a bit confused in that I was sure that only applied to `but`
grondilu m: role Dog { has $.tail }; my $dog; $dog but Dog($)
camelia Unexpected named argument 'value' passed
in block <unit> at <tmp> line 1
jnthn m: role Dog { has $.tail }; my $dog; $dog but Dog('foo')
camelia Unexpected named argument 'value' passed
in block <unit> at <tmp> line 1
jnthn oh!
Of course
A mixin has to be into an object 23:29
m: role Dog { has $.tail }; my $dog = Any.new; $dog but Dog('foo')
camelia ( no output )
jnthn m: role Dog { has $.tail }; my $dog = Any.new; $dog does Dog('foo')
camelia ( no output )
grondilu ok
jnthn Error reporting should be better there.
grondilu it actually makes sense
jnthn And yeah, it's right about it working on does, it seems
Guess it can :) 23:30