»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_log/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 July 2018.
Herby_ My googling is failing me a bit. 00:24
Is there a simple way of getting P6 on the Raspberry Pi 3? 00:25
Herby_ disregard, looks like I can use nxadm's Debian 8 package 00:36
Zoffix Herby_: FWIW, you can also build from scratch: github.com/zoffixznet/perl6.party/...udo-perl-6 01:28
Herby_ Zoffix: awesome, i was looking for a guide like that. Thanks! 01:30
vrurg I wonder: if an attribute from a parent class needs to be set at object initialization stage how could it be done? Neither $.parent-attr nor $!parent-attr are not available in TWEAK... 01:35
Zoffix how come $.parent-attr not available? 01:36
vrurg m: class Foo { has $.attr; }; class Bar is Foo { submethod TWEAK { $.attr = "YES" } }; Bar.new; 01:37
camelia 5===SORRY!5=== Error while compiling <tmp>
Virtual method call $.attr may not be used on partially constructed object (maybe you mean $!attr for direct attribute access here?)
at <tmp>:1
------> 3ss Bar is Foo { submethod TWEAK { $.attr7…
Zoffix try self.attr instead 01:37
vrurg No method error
geekosaur that's telling you the truth. the attribute exists, the iplicit etter and seter don't yet so $.x doesn't work
vrurg m: class Foo { has $.attr; }; class Bar is Foo { submethod TWEAK { self.attr = "YES" } }; Bar.new; 01:38
camelia Cannot modify an immutable Any ((Any))
in submethod TWEAK at <tmp> line 1
in block <unit> at <tmp> line 1
vrurg m: class Foo { has $.attr is rw; }; class Bar is Foo { submethod TWEAK { $.attr = "YES" } }; Bar.new;
camelia 5===SORRY!5=== Error while compiling <tmp>
Virtual method call $.attr may not be used on partially constructed object (maybe you mean $!attr for direct attribute access here?)
at <tmp>:1
------> 3ss Bar is Foo { submethod TWEAK { $.attr7…
vrurg m: class Foo { has $.attr is rw; }; class Bar is Foo { submethod TWEAK { self.attr = "YES" } }; Bar.new;
camelia ( no output )
vrurg Ok, self works... I need more investigation on what's going on in my code. Thanks! 01:39
Zoffix R#2152
synopsebot R#2152 [open]: github.com/rakudo/rakudo/issues/2152 Using `%.foo` in places throws, but changing it to `self.foo` works
vrurg m: class Foo { has $.attr is rw; }; class Bar is Foo { submethod TWEAK { self.attr = "YES" } }; say Bar.new.attr; 01:40
camelia YES
vrurg Zoffix: Doe it mean I shall expect that at some point (sigil).attr notation will work eventually? 01:43
Zoffix vrurg: I'm not an expert in that area and don't know for sure, but just logically thinking about it: if we can make `self.foo` work, surely we can make `$.foo` work as well 02:04
Zoffix &
Herby__ Found this repo on Algorithms, figured I'd try my hand with some Perl 6 solutions 02:39
github.com/TheAlgorithms
Here is my first pass at Bubble Sort: tio.run/##VY5NCoMwFITXySke1IWlTzGm...FUT24jCu/f
It appears to yield correct results but it is squawking a bunch of warnings at me
where am I going wrong?
MasterDuke Herby__: you're going to far. your range goes to @array.elems - 1, but then you add 1 when indexing 02:46
geekosaur you're comparing the last element against the next position which is empty
that 02:47
MasterDuke likewise
Herby__ hmm 02:48
Herby__ Fixed it: tio.run/##VY5NCoMwFITXySke1IWlTzGm...ntxGFN6/AQ 03:10
Here's the P6 version on Rosetta code: rosettacode.org/wiki/Sorting_algor...ort#Perl_6
araraloren o/ 05:13
buggable New CPAN upload: Getopt-Advance-1.0.7.tar.gz by ALOREN modules.perl6.org/dist/Getopt::Adva...pan:ALOREN 05:17
Geth doc: e178989095 | (JJ Merelo)++ | doc/Language/glossary.pod6
Moves anchors above and fixes hash links refs #1303
08:11
synopsebot Link: doc.perl6.org/language/glossary
CIAvash[m] .tell kephra_lk look at the last two examples on docs.perl6.org/routine/cross 08:34
yoleaux CIAvash[m]: I'll pass your message to kephra_lk.
buggable New CPAN upload: AccountableBagHash-0.0.1.tar.gz by ELIZABETH cpan.metacpan.org/authors/id/E/EL/...0.1.tar.gz 10:37
Zoffix m: say '123' ~~ / :my $a=2; <{ '$a' }> / 11:36
camelia 「2」
Zoffix Is this meant to work like that? I'm surprised the variable gets interpreted like that. I would've thought it'd match just as plain string '$a'
sena_kun well, isn't it `<{}>` which gives you interpolation? 11:41
it's described at docs.perl6.org/language/regexes.ht...erpolation
sena_kun >Note that the first two syntax interpolate the string lexically, while <$pattern> and <{$pattern.method}> causes implicit EVAL, which is a known trap. 11:41
Zoffix ok. thanks. 11:42
Geth doc: threadless-screw++ created pull request #2336:
Rewrite of Syntax-Identifier section
11:42
sena_kun well, the question may be "aren't `''` quotes should imply "return a plain string here"", but `EVAL '$a'` gives you '5'. 11:43
and I guess in case of `<{ $a }>` those quotes are implied, but in `<{ '$a' }>` those are explicit. 11:44
just my guess though. :)
tobs m: say '123' ~~ / :my $a=2; <{ 「'$a'」 }> / 11:50
camelia Nil
sena_kun m: say '123' ~~ / :my $a=2; <{ 「$a」 }> / 11:52
camelia 「2」
pmurias do we have documentation how list flattening works? 12:11
docs.perl6.org/language/list - isn't good at all 12:12
it contains bits of info and examples but it doesn't contain an actuall description how things work 12:17
Geth doc: f41418bf0f | (Zoffix Znet)++ (committed using GitHub Web editor) | doc/Type/Lock/Async.pod6
Make right/wrong examples more similar

To ensure the reader doesn't assume the wrongness comes from lack of variable use.
12:21
synopsebot Link: doc.perl6.org/type/Lock::Async
Geth doc: 89bc20da78 | (Paweł Murias)++ | doc/Type/Str.pod6
Fix description of Str.comb($integer)
12:38
synopsebot Link: doc.perl6.org/type/Str
buggable New CPAN upload: Getopt-Advance-1.0.8.tar.gz by ALOREN modules.perl6.org/dist/Getopt::Adva...pan:ALOREN 12:47
Fritz Hi 13:42
This works: DBIish.connect('Pg', :host<localhost>, :database<agrammon_dev>, :user<postgres>); 13:43
This doesn't: my $db-info = (:host<localhost>, :database<agrammon_dev>, :user<postgres>); DBIish.connect('Pg', $db-info);
What am I doing wrong?
sena_kun connect('Pg', |%$db-info); 13:45
and better:
Fritz This is the error message: Too many positionals passed; expected 2 arguments but got 3
sena_kun my %db-info = host => 'localhost', database => 'foo', user => 'foo';
give me a second...
m: sub f($a, :$b, :$c) { say $a + $b + $b }; my %params = b => 1, c => 2; say f(1, |%params); 13:47
camelia 3
True
sena_kun of course, way to create a hash isn't important here.
m: sub f($a, :$b, :$c) { say $a + $b + $b }; my %params = :1b, :2c; say f(1, |%params);
camelia 3
True
Fritz Ok. So I guess flattening the hash makes it the same list of parameters. 13:48
sena_kun m: sub f($a, :$b, :$c) { say $a + $b + $b }; my %params = :b(1), :c(2); say f(1, |%params);
camelia 3
True
sena_kun Fritz, yes, about that. :)
m: sub f($a, :$b, :$c) { say $a + $b + $b }; my $params = :b(1), :c(2); say f(1, |%$params);
camelia WARNINGS for <tmp>:
3
True
Useless use of ":c(2)" in sink context (lines 1, 1)
Fritz Thanks very much!
sena_kun you are welcome! 13:49
Fritz May I ask another one?
sena_kun sure
Fritz This fails: require DBIish; DBIish.connect(); with No such method 'connect' for invocant of type 'DBIish' 13:50
It works (obviously) with use DBIish; 13:51
moritz_ empty connect() works?
Fritz No. Undeclared routine: connect used at line 181 13:52
And DBIish::connect gives Could not find symbol '&connect' 13:53
I looked at docs.perl6.org/language/modules#require but don't get it. 13:54
I am trying to use either DB::Pg (if on Linux) or DBIish (if on MacOSX). I works if I just use DB::Pg; use DBIish; but that seems both silly and dangerous ... 13:55
sena_kun well, I think that when you do `require DBIish`, you have a package under this name in scope(opposite to having a class under this name in scope). and now I need to remember how to get what you want... 13:57
m: use DBIIsh; 13:59
camelia ===SORRY!===
Could not find DBIIsh at line 1 in:
/home/camelia/.perl6
/home/camelia/rakudo-m-inst-2/share/perl6/site
/home/camelia/rakudo-m-inst-2/share/perl6/vendor
/home/camelia/rakudo-m-inst-2/share/perl6
CompUnit::R
sena_kun m: use DBIish;
camelia ===SORRY!===
Could not find DBIish at line 1 in:
/home/camelia/.perl6
/home/camelia/rakudo-m-inst-2/share/perl6/site
/home/camelia/rakudo-m-inst-2/share/perl6/vendor
/home/camelia/rakudo-m-inst-2/share/perl6
CompUnit::R
sena_kun star: use DBIish;
Fritz Ah ... as I am doing this inside a if then else, I guess I could get away with just doing a use XY; inside the if and else blocks?
camelia ( no output ) 14:00
sena_kun star: use DBIish; say DBIish.HOW;
camelia Perl6::Metamodel::ClassHOW.new
sena_kun star: require DBIish; say DBIish.HOW;
camelia Perl6::Metamodel::PackageHOW.new
sena_kun Fritz, not sure about that, to be honest. 14:01
Fritz According to docs.perl6.org/language/modules#Le...le_loading this should do what I want: my $db; if true { use DBIish; $db = DBIish.connect() } else { use DB::Pg; $db = DB::Pg.... } 14:03
Ok, thanks. I will try that. Seems to be working for the moment. 14:04
timotimo the "use" is at compile time in this code 14:05
so even though one is in the "then" and one in the "else" branch, both will be run 14:06
and if either is missing, compilation will fail
Fritz Ah, stupid me, you are right.
timotimo rakudo.org/post/lexical-require-upgrade-info - this should help
Fritz Thats why I wanted to require in the first place ...
timotimo correct
araraloren_ what about the `use :if` 14:17
Fritz Timo, the link you provides is basically the same info as in docs.perl6.org/language/modules#require ... I just cant' figure out what instead of DBIish.connect() I have to use.
timotimo oh
probably ::('DBIish').connect() 14:18
actually
timotimo it depends on how your code looks, but if you have like: my $connection; unless (try require DBIish) === Nil { $connection = (require DBIish).connect(...) }; without $connection { my $driver = (try require DB::Pg); unless $driver === Nil { $connection = $driver.connect(...) } }; without $connection { exit note "please install either DBIish or DB::Pg" } 14:21
that ought to work
Fritz This require DBIish; my $db = ::('DBIish').connect('Pg', :user<postgres>, :host<localhost>, :database<agrammon_dev>); gives No such method 'connect' for invocant of type 'DBIish' 14:23
I know I should add the try stuff, but that would be next. 14:24
sena_kun star: 'require DBIish; ::("DBIish").connect
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in single quotes; couldn't find final "'"
at <tmp>:1
------> 3'require DBIish; ::("DBIish").connect7⏏5<EOL>
expecting any of:
single quotes
term
sena_kun star: 'require DBIish; try ::("DBIish").connect
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in single quotes; couldn't find final "'"
at <tmp>:1
------> 3require DBIish; try ::("DBIish").connect7⏏5<EOL>
expecting any of:
single quotes
te…
sena_kun star: 'require DBIish; say ::("DBIish").connect 14:25
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in single quotes; couldn't find final "'"
at <tmp>:1
------> 3require DBIish; say ::("DBIish").connect7⏏5<EOL>
expecting any of:
single quotes
te…
sena_kun star: require DBIish; ::("DBIish").connect
camelia Too few positionals passed; expected 2 arguments but got 1
in method connect at /home/camelia/star-2017.07/share/perl6/site/sources/F18EA8A0FD337C840672427703CC68FA0720FEDF (DBIish) line 29
in block <unit> at <tmp> line 1
sena_kun oops
my bad
Fritz SORRY ... looking at the wrong line (I had a second connect() attempt not commented out. 14:26
timotimo aah, that makes sense
araraloren_ star: say try require DBIish;
camelia (DBIish)
timotimo yeah, that kind of thing happens to me all the time, too :)
araraloren_ m: say try require DBIish;
camelia Nil
araraloren_ star: say require DBIish;
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared name:
DBIish used at line 1
Undeclared routine:
require used at line 1
Fritz So: require DBIish; my $db = ::('DBIish').connect('Pg', :user<postgres>, :host<localhost>, :database<agrammon_dev>); works fine. 14:27
Thanks everyone!
timotimo \o/
araraloren_ o////////
oh
timotimo that looks painful 14:28
Geth doc: sarna++ created pull request #2338:
Fix a link
14:35
doc: 21cc40d03b | sarna++ | doc/Type/IO.pod6
Fix a link
14:36
doc: 5a1c928b0a | (Bartosz Janus)++ (committed using GitHub Web editor) | doc/Type/IO.pod6
Merge pull request #2338 from sarna/master

Fix a link
synopsebot Link: doc.perl6.org/type/IO
pmurias is there a tool to show me where a method on something is defined? 15:23
timotimo yup 15:27
s: Str, "comb", \()
SourceBaby timotimo, Sauce is at github.com/rakudo/rakudo/blob/5f35...l.pm6#L197
pmurias s: help 15:32
SourceBaby pmurias, Something's wrong: ␤ERR: ===SORRY!=== Error while compiling -e␤Undeclared routine:␤ help used at line 6␤␤
pmurias s: Seq, 'unique' 15:33
SourceBaby pmurias, Something's wrong: ␤ERR: Type check failed in binding to parameter '&code'; expected Callable but got Method+{is-nodal} (Method+{is-nodal}.new)␤ in sub do-sourcery at /home/zoffix/services/lib/CoreHackers-Sourcery/lib/CoreHackers/Sourcery.pm6 (CoreHackers::Sourcery) line 45␤ in sub sourcery at /home/zoffix/services/lib/CoreHackers-Sourcery/lib/CoreHackers/Sourcery.pm6 (CoreHackers::Sourcery) line 36␤ in block <unit> at -e li
pmurias s: Seq, 'unique', \() 15:34
SourceBaby pmurias, Sauce is at github.com/rakudo/rakudo/blob/5f35....pm6#L1571
xinming_ m: my %a = (:a(1..5), :b[1..5]); %a<a>.perl.say; %a<b>.perl.say; 15:41
camelia 1..5
$[1, 2, 3, 4, 5]
xinming_ m: my %a = (:a(1..5) :b[1..5]); %a<a>.perl.say; %a<b>.perl.say;
camelia 1..5
1..5
xinming_ Anyone here would clarify this for me? why there are the differences between them?
the (:a(1..5), :b[1..5]) vs (:a(1..5) :b[1..5]);
xinming_ m: %a = (:a<a b c> :c<a b c>); 15:48
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '%a' is not declared
at <tmp>:1
------> 3<BOL>7⏏5%a = (:a<a b c> :c<a b c>);
xinming_ m: my %a = (:a<a b c> :c<a b c>);
camelia ===SORRY!===
cannot stringify this
xinming_ m: my %a = :a<a b c> :c<a b c>;
camelia ( no output )
xinming_ m: my %a = :a<a b c> :c<a b c>; %a.perl.say;
camelia {:a($("a", "b", "c"))}
xinming_ m: my %a = (:a<a b c> :c<a b c>); %a.perl.say;
camelia ===SORRY!===
cannot stringify this
xinming_ Is this a bug? (:a<a b c> :c<a b c>).perl.say;
m: (:a<a b c> :c<a b c>).perl.say;
camelia ===SORRY!===
cannot stringify this
geekosaur known bug and it has nothing to do with .perl 15:49
geekosaur mm, I know we've seen this one but not spotting it. it may be in rt instead of github. basically two consecutive colonpairs gets misparsed 15:57
the "SORRY!" means it's blowing up in the compile phase, not runtime 15:58
xinming_ Got it, thanks. 16:01
pmurias github.com/perl6/doc/issues/2339 - new docs issue, is it clear enough? 16:10
pmurias in general the docs seem to be confused if something is reference documentation or an introduction 16:18
I'm not sure how fix that
example: in docs.perl6.org/language/functions we alude that routines have several forms but we mention only the two most notable forms 16:20
xinming_ pmurias: thanks, I'll check them. 16:21
ccc m: my @a=[^4];-> (Int :@lst) {say @lst}(@a) 16:23
camelia Type check failed in binding to parameter '@lst'; expected Positional[Int] but got Array ($[])
in block <unit> at <tmp> line 1
jmerelo m: my @a=[^4];-> (Int :@lst) {say @lst}(|@a) 16:24
camelia Cannot unpack or Capture `0`.
To create a Capture, add parentheses: \(...)
If unpacking in a signature, perhaps you needlessly used parentheses? -> ($x) {} vs. -> $x {}
or missed `:` in signature unpacking? -> &c:(Int) {}
in block <unit> at …
jmerelo my @a=[^4];-> (Int :@lst) {say @lst}( lst => @a) 16:25
ccc Why does the array get itemized?
jmerelo m: my @a=[^4];-> (Int :@lst) {say @lst}( lst => @a)
camelia Too few positionals passed to '<anon>'; expected 1 argument but got 0
in block <unit> at <tmp> line 1
timotimo m: my @a = [^4]; say @a.perl
camelia [0, 1, 2, 3]
ccc timotimo: Doesn't have the needed Positional[Int] constraint 16:26
timotimo i think the problem is that you're not passing the array
and its default value is just Array
jmerelo m: my @a=[^4];-> (Int @lst) {say @lst}( @a)
camelia Type check failed in binding to parameter '@lst'; expected Positional[Int] but got Int (0)
in block <unit> at <tmp> line 1
timotimo oh, oyu're trying to unpack it
m: my Int @a = [^4]; -> Int @lst { say @lst.perl }(@a)
camelia Array[Int].new(0, 1, 2, 3)
jmerelo m: my @a:=[^4];-> (Int @lst) {say @lst}( @a)
camelia Type check failed in binding to parameter '@lst'; expected Positional[Int] but got Int (0)
in block <unit> at <tmp> line 1
timotimo the reason why you get 0 instead of Positional[Int] there is that you're telling the signature to unpack the first argument and find an array in its first slot 16:27
like this:
jmerelo timotimo: thanks!
timotimo m: my &foo = -> ($a, $b) { say "a is $a and b is $b" }; foo([1,2])
camelia a is 1 and b is 2
ccc I'm sending ONE argument the array INTO one argument and array. Why isn't it doing the expected thing? 16:28
edit -- I'm sending ONE argument the array INTO one argument, an array. 16:29
jmerelo ccc: to be precise, you're sending a Positional into another Positional.
ccc yes 16:30
Array is shorter to say than Positional
timotimo which exact code are we talking about now, ccc?
ccc m: my @a=[^4];-> (Int :@lst) {say @lst}(@a)
camelia Type check failed in binding to parameter '@lst'; expected Positional[Int] but got Array ($[])
in block <unit> at <tmp> line 1
jmerelo ccc: not exactly the same, though. In this case the problem is the type. 16:31
timotimo why do you have the colon there, and why do you have parenthesis around it?
jmerelo m: my Int @a=[^4];-> (Int :@lst) {say @lst}(@a)
camelia Type check failed in binding to parameter '@lst'; expected Positional[Int] but got Array ($[])
in block <unit> at <tmp> line 1
jmerelo m: my Int @a=[^4];-> (Int @lst) {say @lst}(@a)
camelia Type check failed in binding to parameter '@lst'; expected Positional[Int] but got Int (0)
in block <unit> at <tmp> line 1
timotimo m: sub test(Int :@a) {}()
camelia ( no output )
jmerelo m: my Int @a=[^4];-> Int @lst {say @lst}(@a)
camelia [0 1 2 3]
ccc Ah - I have a named parameter! Confusing error message.
jmerelo The parenthesis is doing the itemization... 16:32
ccc m: my @a=[^4];-> (Int :@lst) {say @lst}(:lst(@a))
camelia Too few positionals passed to '<anon>'; expected 1 argument but got 0
in block <unit> at <tmp> line 1
jmerelo m: my @a=[^4];-> @lst {say @lst}(@a)
camelia [0 1 2 3]
ccc jmerelo: I NEED it to be type constrained
timotimo m: -> Int @test { say "@test is good" }([^4]) 16:33
camelia Type check failed in binding to parameter '@test'; expected Positional[Int] but got Array ($[0, 1, 2, 3])
in block <unit> at <tmp> line 1
timotimo m: -> Int @test { say "@test is good" }(my Int @ = [^4])
camelia @test is good
jmerelo ccc: just take the first form. The thing is eliminating the parentheses.
timotimo m: -> Int @test { say "@test is good" }(Array[Int].new(^4))
camelia @test is good
timotimo m: -> Int @test { say "@test[] is good" }(Array[Int].new(^4))
camelia 0 1 2 3 is good
timotimo m: -> Int @test { say [email@hidden.address] is good" }(Array[Int].new(^4))
camelia Array[Int].new(0, 1, 2, 3) is good
jmerelo Hi, pmurias . You've probably seen my answer to your issue in perl6/doc, right? 16:34
ccc In the code I'm working on the type constraint is on a method. 16:35
timotimo: Can you make that work with sub (Int :@a) ... 16:36
timotimo m: sub do-it(Int @test) { say [email@hidden.address] is good" }; do-it(Array[Int].new(^4)) 16:37
camelia Array[Int].new(0, 1, 2, 3) is good
ccc m: my @a=[^4];-> (Int @lst) {say @lst}(@a)) 16:38
camelia 5===SORRY!5=== Error while compiling <tmp>
Unexpected closing bracket
at <tmp>:1
------> 3my @a=[^4];-> (Int @lst) {say @lst}(@a)7⏏5)
timotimo you're missing a very important point here 16:38
the parenthesis you're using there have a meaning that you do not want
ccc m: mya @a=[^4];sub (Int @a) {say @a}(@a) 16:39
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '@a' is not declared
at <tmp>:1
------> 3mya 7⏏5@a=[^4];sub (Int @a) {say @a}(@a)
ccc m: my @a=[^4];sub (Int @a) {say @a}(@a)
camelia Type check failed in binding to parameter '@a'; expected Positional[Int] but got Array ($[0, 1, 2, 3])
in sub at <tmp> line 1
in block <unit> at <tmp> line 1
timotimo well, you need to pass an Array-Of-Int, not just an array that happens to have ints in it at that moment
ccc I still don't understand what's wrong with the above. 16:40
timotimo the last one?
ccc yes
timotimo m: my Int @a=[^4];sub (Int @a) {say @a}(@a)
camelia [0 1 2 3]
timotimo this is how you make it work
ccc So user's of my class have to use put the darn thing in a variable? 16:41
timotimo no 16:42
m: sub (Int @a) {say @a}(Array[Int].new(1, 2, 3, 4))
camelia [1 2 3 4]
ccc I'm passing an array of int
timotimo no variable needed
alternatively, you perhaps want this instead:
m: sub do-it(@a where .all ~~ Int) {say @a} do-it([1, 2, 3, 4]); do-it([1, 2, "foo"]) 16:43
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3sub do-it(@a where .all ~~ Int) {say @a}7⏏5 do-it([1, 2, 3, 4]); do-it([1, 2, "foo"
expecting any of:
timotimo m: sub do-it(@a where .all ~~ Int) {say @a}; do-it([1, 2, 3, 4]); do-it([1, 2, "foo"])
camelia [1 2 3 4]
Constraint type check failed in binding to parameter '@a'; expected anonymous constraint to be met but got Array ($[1, 2, "foo"])
in sub do-it at <tmp> line 1
in block <unit> at <tmp> line 1
ccc m: my @a=[^4];sub (@a where .all ~~ Int) {say @a}(@a) 16:44
camelia [0 1 2 3]
ccc Ok, so the lesson is that the parameter unpacking doesn't descend into the container to check Positional[Foo], the sub or method has to do it itself? 16:46
timotimo types in perl6 are nominal, which means the name of the type is what counts
except it's not a name as in "string", but as in parameterized roles and such 16:47
ccc Well that makes Array[Foo] much less useful as part of an API. If used, it's a traps for users. 16:48
timotimo m: sub do-the-slow-thing(@a where .all ~~ Int) { my $i = 0; while $i < @a.end { say @a[$i]; sleep 0.1 } }; my @haha = 1, 2, 3, 4, 5, 6, 7, 8; start { do-the-slow-thing(@haha); }; sleep 0.2; @haha[7] = "LOL";
camelia 1
1
timotimo m: sub do-the-slow-thing(@a where .all ~~ Int) { my $i = 0; while $i < @a.end { say @a[$i]; sleep 0.1 } }; my @haha = 1, 2, 3, 4, 5, 6, 7, 8; my $are-you-finished = start { do-the-slow-thing(@haha); }; sleep 0.2; @haha[7] = "LOL"; await $are-you-finished 16:49
i forgot to $i++
camelia (timeout)1
timotimo m: sub do-the-slow-thing(@a where .all ~~ Int) { my $i = 0; while $i < @a.end { say @a[$i++]; sleep 0.1 } }; my @haha = 1, 2, 3, 4, 5, 6, 7, 8; my $are-you-finished = start { do-the-slow-thing(@haha); }; sleep 0.2; @haha[7] = "LOL"; await $are-you-finished
camelia 1
2
3
4
5
6
7
timotimo oh?
m: sub do-the-slow-thing(@a where .all ~~ Int) { my $i = 0; while $i < @a.end { say @a[$i++]; sleep 0.1 } }; my @haha = 1, 2, 3, 4, 5, 6, 7, 8; my $are-you-finished = start { do-the-slow-thing(@haha); }; sleep 0.1; @haha[5] = "LOL"; await $are-you-finished
camelia 1
2
3
4
5
LOL
7
timotimo nice array of ints you have there
would be a shame if someone put a LOL in it 16:50
pmurias jmerelo: I'm looking at the answer...
timotimo how would you like sub test(Int @foo) to behave? 16:51
ccc Look if you're expecting a container to contain nothing but type Foo, SOMETHING has to check it. We're just sweeping the difficulty to the caller if he has to do Array[Foo].new. 16:53
timotimo either that or you use the "where" or a named subset that has the check within it
github.com/zoffixznet/perl6-Subset-Helper - perhaps this is also interesting to you 16:54
ccc Yes I've played around with subset already. 16:55
timotimo if you want to, you can invert the responsibilities and have your library call a user-provided function and pass the container they want the user to fill 16:56
ccc If I'm designing an API for a module, I believe it's my duty to take care of the tedious little gotchas. It shouldn't be dumped on the user of the module.
timotimo right, which it won't be if you use subsets, right?
that was worded kind of poorly
the "tell don't ask" principle, or something 16:57
which is also good for multithreaded stuff, because it's easier to not mess up data accesses
i wish i remembered what talk it was from, jnthn had mentioned that in one place; probably the "8 ways to do concurrent programming" one? in the section about actors and monitors? 16:59
jnthn Thanks for multi-dispatch, it's entirely possible to have an API that both efficiently handles Array[Int] (e.g. O(1) check) *and* has a candidate that delegates to that doing the O(n) check.
yoleaux 12:15Z <Zoffix> jnthn: RE github.com/perl6/roast/commit/8b5e39093 Do you think there's some similarity between Lock::Async.lock/.unlock and IO::Handle.lock/.unlock? Because in that commit we spec Lock::Async.unlock to throw if not locked, but IO::Handle.unlock silently does nothing. Was wondering if this asymetry is acceptable.
jnthn oops, *thanks *to* multi dispatch
timotimo wow, that was a *fast* response to me mentioning you
jnthn hah, was just glancing the converstaion :) 17:00
timotimo convertion station?
jnthn *conversation :P
Yes, there's a mention of tell don't ask in that talk; also there's probably at least as much on it in my Objects ∩ Concurrency talk :) 17:01
pmurias jmerelo: I didn't even notice that flattening was described in more detail in the List class documentation
timotimo then that's potentially the better one
i should ingest more talks about design in that kind of space, surely 17:02
jmerelo pmurias: there's almost always the two parts: a detailed method-by-method documentation, and then a tutorial. Anyway, if you find something missing, please reformulate. Or if it's not clear enough that flattening was described there with more detail.
pmurias "except when they are not itemized or they are the single argument to an operation such as append:" seems unclear what operations flatten 17:03
jmerelo pmurias: please clarify that in the issue, if you don't mind. 17:05
jnthn .tell Zoffix Both Lock and Lock::Async will complain about unlock while not held (difference being that Lock::Async isn't recursive). Both of those are in-process locks. File locks are just calling some OS-provided API; I'm guessing it doesn't error out, or we ignore the error. So we'd have to try to track it ourselves, though I don't know if we can without making a new gotcha. Needs exploring some more.
yoleaux jnthn: I'll pass your message to Zoffix.
pmurias jmerelo: how should I reference particular unclear sentences? 17:06
quote them?
jmerelo pmurias: yep, that would help.
pmurias jmerelo: doing the split between tutorial and reference documention purely in the way that method references are reference material and other pages are tutorial does seem to have problems 17:08
pmurias the per type pages seem to be gathering cookbook style hints and the tutorial pages are sometimes growing long lists of exhaustive variants of things 17:09
jmerelo pmurias: it certainly does. Sometimes methods include several examples, and, well, "tutorialize" as long as there's not a lot of other concepts in there. 17:09
jmerelo pmurias: that's the style of some of the doccers, yes. I mean, style is not uniform. 17:10
pmurias: that means that reference is sometimes too much tutorialish and tutorials too much referenceish.
jmerelo pmurias: but changing to another kind of structure would be huge, and given current resources, simply will not be done. So we have to make do improving what we can, given current organization. 17:11
pmurias jmerelo: splitting up some pages into reference documentation and tutorial could be done on invidual basis 17:19
it's not something that requires some kind of huge one time investment 17:20
jmerelo pmurias: as long as we know which ones we should split, that's correct. 17:25
mst glot.io/snippets/f59gs0jd0d 18:46
does rakudo not try and spot things like that given the type info available?
masak mst: not yet, no 18:51
mst ah
masak there's plenty of low-hanging fruit there that doesn't happen at compile time 18:52
not sure your case is the lowest-hanging, since it seems to rely on propagation of type information along the execution flow... but still, static typechecking has a long way to go in Rakudo 18:53
I'm not aware that the spec says much about static typechecking one way or another
jnthn masak: I think successive versions of the spec (that is, test suite) will gradually add more things as being detected at compile time; the introduction of such things needs to happen at langauge version boundaries, though. 19:45
masak: It's fair to say that hasn't been a particular focus so far, though. 19:46
pmurias masak: re static type checking, a big problem with that is that you can either disallow programs or allowed type errors at runtime 19:58
* disallow valid programs
masak jnthn: apologies, my use of "the spec" is archaic. I meant the synopses.
pmurias: would it be so bad to disallow mst's example program at compile time instead of failing at run time? 19:59
pmurias: I don't think I see your point about a big problem
jnthn pmurias: We may indeed make some programs fail by detecting problems they never concretely run into at runtime, yes, thus my comment about why extra checks want to come in at language version bumps. 20:00
masak oh right, true 20:01
pmurias masak: I mean you can either add a static type system *or* catch some type errors in an adhoc manner
masak agree it makes sense to turn on such strictures either behind a pragma, or at version boundaries
jnthn I don't really understand the statement "add a static type system". Perl 6 *has* a type system. We don't currently perform many possible analyses that it makes possible. 20:02
(Compile time analyses, to be clear) 20:03
jnthn But rather defer all enforcement until runtime. Bringing forward the point that we detect problems isn't adding a static type system, it's just better exploiting the one we have. 20:03
masak it is a good point though that an improved static type system might start flagging up things that never actually caused problems in a working program 20:05
jnthn Indeed. 20:06
hahainternet would ♥ to see improved static typing 20:07
jnthn Ah well, something to take some steps on for 6.e :)
pmurias jnthn: by adding a static type system I mean in the sense we could have a TypeScript like TypedPerl6 slang that would enforce type safety at compile time 20:13
jnthn: as opposed to the compiler catching obvious runtime errors at compile time
jnthn pmurias: That could happen *too*, but there's already bags of scope for doing more in core. 20:14
pmurias: With the type system we already have in the langauge.
Of course, I've no objections to somebody working on a slang like you describe also. :)
diakopter jnthn: typo "thanks to these change." 20:15
jnthn Where?
oh, I found it 20:16
pmurias is changing the type hierarchy at runtime disallowed in Perl 6?
jnthn In the default MOP, we don't really allow for that. Nobody has terribly missed it. :) 20:17
jnthn afk for a bit 20:18
diakopter: Fixed, thanks
pmurias has think if that would allow any crazy optimizations for the js backend :) 20:21
Xliff_ What's the latest release of rakudo? 20:28
El_Che 09 20:29
Xliff_ Does anyone know why this error would come up in stage parse? 20:51
Cannot look up attributes in a GTK::RadioToolButton type objec
timotimo Xliff_: does it point to anywhere specific if you use --ll-exception? 20:54
Xliff_ Will check
Yes, but even with that location, the error makes no sense. 20:58
Found it. The problem was using ::?CLASS.name in the DEPRECATED trait message. 21:11
timotimo ah, instead of .^name? 21:26
and for some reason the class also had a "name" method? 21:27
Xliff_ Yeah. Belonging to the top-level superclass. 21:28
So does ::?CLASS just replace the current class type object? 21:29
I thought it was a meta object.
timotimo you mean represent? 21:31
i do believe you get the type object from it
geekosaur m: dd ::?CLASS 21:56
camelia 5===SORRY!5=== Error while compiling <tmp>
No such symbol '::?CLASS'
at <tmp>:1
------> 3dd ::?CLASS7⏏5<EOL>
geekosaur guess that follows