»ö« 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.
ugexe zef install . --deps-only --to=inst#local --/test --debug --contained # install *all* depends into local/ 02:10
zef list --installed inst#local # list exact versions of all depends for current app
perl6 -I inst#local -e '...' # use self contained local lib to run app
so i was thinking about how to do e.g. cpanfile.snapshot type functionality in zef. its mostly there 02:11
just need to add a way to read the output of the file generated from `zef list --installed inst#local`
maybe add an option for an argument of `-` that means read stdin line-by-line (reading a list of modules) 02:12
lucs How can I do something like: use Inline::Perl5; use lib 「path to Perl5 Foo module」; use Foo:from<Perl5> # That 'use lib …' doesn't reach Perl5, eh. 02:20
( use lib:from<Perl5>… something? )
ugexe yes use lib:from<Perl5> 'something'
lucs Oh, that simple eh :) Trying...
I think it's working (but getting some other kind of error, my mistakes probably). 02:22
GaborSzabo H 02:23
lucs H to you too ;)
discord6 <Rogue> I agree. H. 02:24
GaborSzabo Im f
And a
U guys pro? 02:25
lucs GaborSzabo: Um, you're a bit hard to follow... 02:25
xinming m: class T is Hash { has $.abc is required; submethod (:$!abc) { } }; my %x is T = (:a<b>, :c<d>); %x.perl.say; %x.abc.perl.say; 06:23
camelia {:a("b"), :c("d")}
Any
xinming In this case, the abc is *required*, But doesn't fail, Is this correct behaivor?
And also, How do we init the $!abc in this case?
m: role T { has $.xxx is required; }; my %x = (:a<b>, :c<d>) does T(123); %x.xxx.perl.say; 06:25
camelia No such method 'xxx' for invocant of type 'Hash'
in block <unit> at <tmp> line 1
xinming And for the later one, Where I did wrong? 06:26
m: role T { has $.xxx is required; }; my %x = (:a<b>, :c<d>); %x does T(123) ; %x.xxx.perl.say; 06:27
camelia 123
xinming m: role T { has $.xxx is required; }; (my %x = (:a<b>, :c<d>)) does T(123) ; %x.xxx.perl.say;
camelia 123
xinming So, later one get fixed. :-)
Geth doc: ab74b86a9f | (JJ Merelo)++ | doc/Type/Code.pod6
Corrections and prefixed method, refs #2683
06:44
doc: 62c7f85638 | (JJ Merelo)++ | doc/Type/Slip.pod6
Revised Slip

Adds definitions, reflows. Actually, no need to prefix anything with sub, so this closes #2683
Geth doc: 33dafa9600 | (JJ Merelo)++ | doc/Language/traps.pod6
Reflows while revising for #1265
07:02
jmerelo xinming: above, submethod should have a name, right? 07:03
xinming: you're probably past that, but anyway. Surprised it didn't complain.
xinming m: sub test () { return %(:a, :b) }; sub wrap-test { my $res = test; $res; }; my %t = test; %t.perl.say; my %x = wrap-test; %x.perl.say; 07:41
camelia {:a, :b}
{:a, :b}
xinming Anyone here would clarify why will $res auto unbox to %hash successfully? What is the reasoning behind it?
lookatme_q m: my %x = ${:A, :C}; say %x 07:44
camelia {A => True, C => True}
lookatme_q m: my %x = ${:A, :C}; dd %x
camelia Hash %x = {:A, :C}
moritz xinming: docs.perl6.org/syntax/Single%20Argument%20Rule
xinming moritz: Thanks
lizmat hmmm looks like docs.perl6.org is stuck at 88383891 ? 08:58
masak that's a suspiciously decimal hex prefix. 09:03
masak m: my $prob = (10/16) ** 8; say "Things like that happen with a probability of {($prob * 100).fmt("%.1f")}%" 09:05
camelia Things like that happen with a probability of 2.3%
masak m: my $prob = (10/16) ** 8; say "There's a one in {ceiling 1 / $prob} chance of it happening" 09:06
camelia There's a one in 43 chance of it happening 09:07
lizmat masak: with the number of commits we're doing on doc, that will happen like once every few weeks ? 09:08
masak if you know the approximate rate of commits, a Poisson distribution will tell you how often 09:13
m: my $prob = (10/16) ** 8; my $n = 100; say "Among {$n} commits, there's a {((1 - (1 - $prob) ** $n) * 100).fmt("%.2f")}% chance of at least one decimal prefix" 09:15
camelia Among 100 commits, there's a 90.52% chance of at least one decimal prefix
masak so, yeah. not rare :) 09:16
masak I'm trying to come to grips with what the spec means by 'listop' exactly 09:17
pmurias ugexe: re nqp::cpucores pull request is nqp::cpucores supposed to return the number of CPUs in the machine or the ones that the process can make use of? 09:18
lizmat pmurias: that the process can make use of, I'd say... it's intended to be used as a way to determine how many workers to allow 09:19
masak is this a correct understanding, you think? "an operator from the 'List prefix' category, which, because it's looser than commas, tends to consume the rest of the expression up until the next surrounding terminator"
lizmat and that wouldn't make any sense if thee CPU's are there and not usable :-)
pmurias hmm, v8 has worker threads (which don't share memory) 09:22
but is single threaded in terms of Perl 6 threads 09:23
lizmat hmmm... not sure how to handle that then 09:24
SmokeMachine m: sub infix:<< £ >>(Int $a; Int $b; Int $c) is assoc<list> { "$b is between $a, $c" }; say 1 £ 2 £ 3 09:57
camelia 2 is between 1, 3
SmokeMachine m: sub infix:<< < >>(Int $a; Int $b; Int $c) is assoc<list> { "$b is between $a, $c" }; say 1 < 2 < 3
camelia Too few positionals passed; expected 3 arguments but got 2
in sub infix:«<» at <tmp> line 1
in block <unit> at <tmp> line 1
SmokeMachine why it doesn't work with <? 09:58
moritz SmokeMachine: I don't think you can change the associativity of an existing operator 10:05
SmokeMachine moritz: shouldn't it be possible? 10:06
jnthn Well, the other thing is that all the chaining operators receive special compilation anyway 10:07
yoleaux 20 Mar 2019 20:22Z <DrForr> jnthn: No worries at all, it's by no means crucial and I might even be able to provide you a patch when I've got some spare tuits myself.
jnthn They're not compiled into simple sub calls, because they need to ensure they only compile each operand once 10:07
SmokeMachine jnthn: same problem as && and || right? 10:08
jnthn SmokeMachine: Well, "problem", but yeah, those also cannot be straight sub calls and receive special compilation as a result
(Becuase we shouldn't evaluate the RHS always) 10:09
SmokeMachine I'd love if it would be possible to override &&, ||, >, <, >=, <= to use it on Red...
github.com/FCO/Red/issues?q=is%3Ai...t+looks%22 10:10
jnthn: isn't it an issue? I mean, should this be "fixed"? 10:15
jnthn SmokeMachine: Which one? 10:21
SmokeMachine jnthn: &&, ||, >, >=, < and <= 10:22
jnthn: all of them
jnthn Well, question is how would be fix it? 10:23
*we 10:24
SmokeMachine jnthn: is it possible to change the behaviour only if the operator was overwritten? 10:25
jnthn: maybe set a $*AND_WAS_OVERWITTEN = True 10:26
jnthn SmokeMachine: But even then, what would be be compiling it in to?
&& and || don't compile into a sub call 10:27
SmokeMachine couldn't it be compiled to a subcall receiving 2 blocks?
jnthn In theory, yes 10:28
Though perhaps this is more of a job for macros
SmokeMachine m: use experimental :macros; macro infix:<&&>($a, $b) { quasi { say "OK" } }; say 1 && 2 10:31
camelia WARNINGS for <tmp>:
OK
True
Useless use of constant integer 2 in sink context (line 1)
Useless use of constant integer 1 in sink context (line 1)
SmokeMachine jnthn: maybe something like this could work?
SmokeMachine jnthn: but how could I test if any of its arguments is a Red::AST? 10:33
$a and $b are AST... (not Red::AST...)
jnthn It's compile time so you don't know?
SmokeMachine jnthn: back to the same problem? 10:34
SmokeMachine jnthn: AST has an annotation field, hasn't it? 10:35
jnthn SmokeMachine: Well, hash, which putting arbitrary annotations on it, yes 10:39
SmokeMachine jnthn: would it be possible to annotate my AST... never mind... 10:40
jnthn SmokeMachine: Dunno...maybe if you can always tell at compile time that's what it is, though you're certainly in slang territory (and using non-specified API that could change) by this point. 10:43
SmokeMachine jnthn: maybe I should run the left part and see he type of what it returns... and decided based on that...
but my && would only work if starting with a Red::AST... 10:44
jnthn Yeah, that's why I was curious what you were going to do with it :) 10:45
SmokeMachine jnthn: if the first part isn't a Red::AST, but is true, I run the second one if it returns a Red::AST I create my return, else I just return it... 10:49
Im luck cause if the first part is false, my version of && should return False anyway... :) 10:50
masak nit pick: `&&` et al are not "chaining", they're "list-associative" 10:56
I only recently learned of this distinction 10:57
"chaining" is for the comparison ops, that tend to result in a truthiness value
"list associative" is for infix ops that conceptually take N operands, not 2
SmokeMachine masak: like <, >, <=, >=, == right?
masak N ~~ 0..*
those are the chaining ones, yes 10:58
SmokeMachine yes...
masak SmokeMachine: if your question is "how to override", I think you'll have to wait until we have macros for that
in current Rakudo, they're just "special-cased"
from the point of 007, they're macros
SmokeMachine masak: but when we can overwride (or in 007), how do we know if we should use the override on or the core one? 11:00
masak that is all resolved with normal lexical lookup 11:01
the override is used whenever its definition is still visible
SmokeMachine masak: I mean: if its operands are Red::AST I'd like to use my &&, and the core's one other wise... 11:02
masak m: use experimental :macros; macro infix:<und>($l, $r) { quasi { if my $t = {{{$l}}} { $t = {{{$r}}} }; $t } }; say(5 und 7) 11:03
camelia WARNINGS for <tmp>:
Useless use of constant integer 7 in sink context (line 1)
Useless use of constant integer 5 in sink context (line 1)
Cannot assign to an immutable value
in any at <tmp> line 1
in block <unit> at <tmp> line 1
masak (not really sure why I get those warnings)
(or that error)
SmokeMachine: I think you'd like a thing that I wrote recently-ish
hold on, gonna dig it up
masak SmokeMachine: github.com/masak/007/issues/294#is...-392330477 11:04
masak speaking of "list associative" ops, it's quite funny, I realized. infix:<&&> and infix:<||> don't actually _need_ to be list-associative, because they'd work the same (as macros) even if they were left-associative 11:06
but the operator that really, _really_ needs to be list-associative is infix:<^^> :D
see github.com/masak/007/issues/464 for details
antoniogamiz o/ 11:14
masak \o 11:29
kawaii I have a module I'm working on which asks an API for some values, and then I'd like to be able to pull those values out and display them nicely for clarity. `say $result<attributeScores><{@models}>.map: *<summaryScore><value>;` I was hoping this would iterate over anything in my @models array but I just get an `((Any))` back in return, ideas? 11:32
`my MODEL @models = TOXICITY, SPAM;`, this is what my array looks like
jnthn I bet <{@models}> should just be {@models} 11:33
Otherwise you're looking up a literal string key '<{@modules}>'
*models
kawaii jnthn: `(0.017453287 0.4579174)` you're right! 11:34
is there a way I can prefix each value with the name of the model in the array?
jnthn say @models Z~ ... 11:35
Though you maybe want it formatted nicely too :) 11:36
I guess you can :p after {@models} and you'll get Pairs out where .key is the thing for @models and the .value is what you are getting now 11:37
masak SmokeMachine: anyway, with current Rakudo, I'm afraid infix:<&&> are too special-cased to override. :( from my macro-infused perspective, that's because we haven't defined them in core as (overridable) macros. 11:38
SmokeMachine masak: what about it? 11:39
m: use experimental :macros; macro infix:<&&>($a, $b) { quasi { say "OK" } }; say 1 && 2
camelia WARNINGS for <tmp>:
OK
True
Useless use of constant integer 1 in sink context (line 1)
Useless use of constant integer 2 in sink context (line 1)
SmokeMachine it was overrides, no?
masak hm, so it seems
kawaii jnthn: worked nicely, thanks :)
masak then that's slightly better news than I thought :)
pmurias in regards to using Perl 6 to generate queries from isn't that something that should be done more with code inspection rather then overriding operators 11:40
?
SmokeMachine masak: I was thinking to use something like that...
antoniogamiz what module would you use for scraping with perl6? 11:42
kawaii antoniogamiz: scraping HTML or? 11:43
pmurias as it seems like we really want to just compile a subset of Perl 6 to a SQL/some query structure
antoniogamiz kawaii: yep html 11:44
kawaii I'd probably use Cro::HTTP::Client for something like that 11:45
SmokeMachine masak: now Im trying something like this (but its not working...)
m: use experimental :macros; macro infix:<&&>($a, $b) { quasi { $a ~~ Int ?? "MyOwnObject" !! (so $a ?? ($b ~~ Int ?? "MyOwnObject" !! $b) !! False) } }; say 1 && 2
camelia WARNINGS for <tmp>:
True
Useless use of constant integer 2 in sink context (line 1)
Useless use of constant integer 1 in sink context (line 1)
antoniogamiz I've been looking Gumbo and LWP::Simple
I'll take a look at Cro::HTTP 11:46
::Client*
SmokeMachine masak: something that would be converted to something like this: 11:47
m: my $a = 1; my $b = 2; say $a ~~ Int ?? "MyOwnObject" !! (so $a ?? ($b ~~ Int ?? "MyOwnObject" !! $b) !! False)
camelia MyOwnObject
sena_kun antoniogamiz, you _may_ look at `deredere` module which uses Gumbo for parsing and HTTP::UserAgent. Though keep in mind that it is super-basic and for any non-trivial case you have to either extend it or rewrite things, maybe stealing some approach.
antoniogamiz sena_kun: I will use for something a bit complex so I'm going to choose cro instead, but thanks for the info :) 11:49
sena_kun antoniogamiz, we always can upgrade this module to use Cro. ;) But sure, use whatever is more suitable for the job. 11:51
antoniogamiz tbrowder: I've reading the discussion about #2529 11:58
kawaii jnthn: Z=> turned out to be a better operator for clarity by the way :)
antoniogamiz tbrowder: and I've though that maybe the minidocs should be "dockerized" (I dont know if that work exists)
tbrowder: what do you think? 11:59
sena_kun antoniogamiz, there is a minimal Docker container with Perl 6 installation, manual repo clone && some building may be needed though. 12:01
tbrowder antoniogamiz: i don't know much about docker, but let me look at that issue... 12:04
antoniogamiz sena_kun: yeah I know, but that dockerfile is used for the entire doc
sena_kun: the issue I've sent (#2529) says that a minidoc repository would be helpful 12:06
in order to test of the tooling with a self-contained subset of the current doc
tbrowder antoniogamiz: that looks like a good one to me. i see my comment there. i would start filling out more details to address that after checking with jj 12:09
antoniogamiz tbrowder: ok :) I'm telling you this because I've had a meeting this morning with him and we have been discussing the new proposal
tbrowder ok, he's more on top of that, and you're in good hands with him 12:11
antoniogamiz tbrowder: thanks :) 12:12
tbrowder any progress on doc tooling is a giant plus
antoniogamiz well, are you going to participate in the perl weekly challenge? :D
sena_kun is there any explanation on rules and stuff like that? 12:18
masak SmokeMachine: I'm sorry, I don't follow :/ 12:19
xinming In class declaration, Is it possible to apply role after the after class definition? 13:15
sena_kun only using MOP 13:17
FooClass.^add_role(FooRole); FooClass.^compose;
xinming m: role R { method test () { "before".say; callsame; "after".say; }; }; class T does R { method test () { "class method".say; } }; T.new.test;
camelia class method
xinming sena_kun: Ok, Thanks, that's what I want.
sena_kun: I'd wish we can have something like, later-does R 13:18
role R { method test () { "before".say; callsame; "after".say; }; }; class T last-does R { method test () { "class method".say; } }; T.new.test;
maybe last-does or later-does 13:19
sena_kun xinming, you can create a custom trait.
xinming or deferred-does
sena_kun but traits are applied at compile time anyway.
xinming Will learn that, Just thought though
sena_kun: Can we use ::?ClASS.^add_role(FooRole); within class definition to achieve the same thing? 13:20
sena_kun both does and a possible custom `does-later` will be executed at compile time, so not so much difference.
maybe if we knew your initial intention, something better could be proposed. 13:21
xinming m: role R { method test () { "before".say; callsame; "after".say; }; }; class T { method test () { "class method".say; } }; T.^add_role(R); T.^compose; T.new.test;
camelia class method
sena_kun m: role A { method test {1.say} }; class C { method a { ::?CLASS.^add_role(A); ::?CLASS.^compose; } } 13:22
camelia ( no output )
sena_kun m: role A { method test {1.say} }; class C { method a { ::?CLASS.^add_role(A); ::?CLASS.^compose; } }; C.test;
camelia No such method 'test' for invocant of type 'C'. Did you mean any of these?
List
Set
gist
list

in block <unit> at <tmp> line 1
sena_kun m: role A { method test {1.say} }; class C { method a { ::?CLASS.^add_role(A); ::?CLASS.^compose; } }; C.a; C.test;
camelia 1
xinming sena_kun: I had a role, Which will wrap some methods for a class, that class will provide the method to for role to wrap;
sena_kun xinming, ^ 13:23
xinming m: role R { method test () { "before".say; callsame; "after".say; }; }; class T { method test () { "class method".say; } }; T.^add_role(R); T.^compose; T.new.test; 13:24
camelia class method
xinming sena_kun: Why won't my example work?
I called T.^add_role(R); and T.^compose; 13:25
sena_kun well, your class method overrides one from role.
so it is getting called. 13:26
m: role R { method test () { "before".say; callsame; "after".say; }; }; class T { }; T.^add_role(R); T.^compose; T.new.test
camelia before
after
xinming sena_kun: Actually, In my example, what I want to do is that method test in R will wrap the method test in T class.
is it possible to do?
jnthn Composition is flattening, so only one method wins, and that'll be the one in the class 13:27
It looks more like you want to do a runtime mixin of the role, though that'd not affect the original class, but that's probably a good thing anyway :)
xinming jnthn: I want to affect the original class.
jnthn (Doing runtime role addition to an existing class like that will probably win you precomp conflicts)
xinming Ok, so, Seems, I need to consider other approach. 13:28
jnthn xinming: Yes, that sounds wise
xinming m: role R { method test () { "before".say; callsame; "after".say; }; }; class T { method test () { "class method".say; } }; my $x = T.new; $x does R; $x.test; 13:30
camelia before
class method
after
xinming jnthn: how to mix the role to the T class at compile time in this case? 13:31
sena_kun m: role R { method test () { "before".say; callsame; "after".say; }; }; class T { method test () { "class method".say; } }; my $x = T.new; infix:<does>($x, R); $x.test; 13:32
camelia before
class method
after
sena_kun probably
m: role R { method test () { "before".say; callsame; "after".say; }; }; class T { method test () { "class method".say; } }; sub ap($x, $role) { infix:<does>($x, R); }; my $x = T.new; $x.test; 13:33
camelia class method
sena_kun m: role R { method test () { "before".say; callsame; "after".say; }; }; class T { method test () { "class method".say; } }; sub ap($x, $role) { infix:<does>($x, R); }; my $x = T.new; ap($x, R); $x.test
camelia before
class method
after
jnthn xinming: Maybe something like my constant T = anon class T { ... } does role R { ... }; 13:34
uh, *but role R
xinming let me try.
jnthn I don't actually know what you're overall trying to achieve though, so there may be a much cleaner solution to the original problem :)
xinming jnthn: I have classes only do computation, and I have a role will save to keep the results of the computation when condition meets. 13:37
sena_kun maybe a dynamic variable will help? if it is a logger-like kind of thing 13:38
xinming in this case, the class T will be the class do computation, And R will save the results somewhere. So if I want the computation class to keep history, I can give it "does R" to keep the history.
sena_kun: Not logger-like, It's per-class, Not per object.
m: role R { method test () { "before".say; callsame; "after".say; }; }; my constant T = anon class T { method test () { "class method".say; } } does R; my $x = T.new; $x.test; 13:39
camelia 5===SORRY!5=== Error while compiling <tmp>
An exception occurred while evaluating a constant
at <tmp>:1
Exception details:
Cannot use 'does' operator on a type object T.
in block at <tmp> line 1
xinming m: role R { method test () { "before".say; callsame; "after".say; }; }; my constant T = class T { method test () { "class method".say; } } does R; my $x = T.new; $x.test;
camelia 5===SORRY!5=== Error while compiling <tmp>
An exception occurred while evaluating a constant
at <tmp>:1
Exception details:
Cannot use 'does' operator on a type object T.
in block at <tmp> line 1
xinming jnthn: Will this be a bug? :-) 13:40
vrurg xinming: why inheritance doesn't work for you?
sena_kun m: my $*SAVE = class anon { method save { say 'saved' }; method is-good { True } }; class A { method test { $*SAVE.save if $*SAVE.is-good } }; A.test
camelia saved
xinming vrurg: Because the class T will provide the calcuation method
jnthn xinming: I corrected it to `but` 13:41
sena_kun (but the dynamic variable thing is a rough emulation for inheritance that is full of design flaws though)
vrurg xinming: And? If your other code relies on class T – can't that code get particular class through some kind of a function/method which would return the right class for them? 13:42
xinming m: role R { method test () { "before".say; callsame; "after".say; }; }; my constant T = anon class T { method test () { "method".say; } } but R; my $x = T.new; $x.test;
camelia before
method
after
xinming This worked. :-)
vrurg: The T class is not base class, they are the class provide calculation implementation. 13:43
vrurg: It can be done via per-object bias to determine which object to keep history, and which object doesn't. I just try to make it for class instead of per object. 13:45
sena_kun xinming, I think the idea is to have "Saver" class/role with a defined interface, so `class Calc does Saver { method calc { call-saver-method; } }`
masak m: say 1 || 2 // 3 13:45
camelia 1
vrurg xinming: It doesn't make sense for me. Any class can be a base class. But as I don't have the full picture I can't judge.
masak according to S03, this should parsefail ^^
(because different list-associative operators on the same precedence level need to be disambiguated with parentheses) 13:46
jnthn: thoughts?
TimToady: if you're there, thoughts? :)
S03:79, fwiw
I can easily believe that S03 shouldn't be implemented as it stands -- but in that case, we need to put down a new rule _somewhere_ 13:47
xinming sena_kun: This is what I thought first. But later, i realized that subclass don't need to call the call-saver-method at all.
sena_kun xinming, why it doesn't? because you want to make it work using role/callsame magic? 13:48
masak something like "sequences of list-associative operators of the same precedence implicitly group by exact operator, and the groups associate to the left"
xinming sena_kun: My first implementation does something like, self.keep-history(%result); in each method in subclasses. But later, I try to make this process "transpernt"
masak that is, `1 || 2 // 3` means `(1 || 2) // 3`
jnthn masak: Those are left associative, not list associative 13:49
kawaii So I've seen some people use inline pod on their modules, and others put all the pod at the end of the module, is there some consensus on what users prefer for documentation?
masak jnthn: again, not according to S03
xinming m: role Saver { method calc () { my $res = callsame; "save-result-here".say; }; }; my constant T = anon class T { method calc () { "do-calculation".say; } } but R; my $x = T.new; $x.test;
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared name:
R used at line 1
xinming m: role Saver { method calc () { my $res = callsame; "save-result-here".say; }; }; my constant T = anon class T { method calc () { "do-calculation".say; } } but Saver; my $x = T.new; $x.test; 13:50
camelia No such method 'test' for invocant of type 'T+{Saver}'. Did you mean any of these?
List
Set
gist
list

in block <unit> at <tmp> line 1
sena_kun xinming, not sure if applicable, but I would not hide the call at all.
jnthn masak: S* are more of historical interest now; it's the spectest suite that defines how things should be
masak jnthn: I had a feeling you would say that; I find that answer... somewhat unsatisfactory. was there a decision in-between S03 and the spectest suite to make those operators left-associative?
xinming m: role Saver { method calc () { my $res = callsame; "save-result-here".say; }; }; my constant T = anon class T { method calc () { "do-calculation".say; } } but Saver; my $x = T.new; $x.calc;
camelia do-calculation
save-result-here
masak if not, why were they made left-associative? 13:51
xinming sena_kun: This what I mean :-)
I know I can do run time mix-in for single objects.
jnthn masak: Quite possibly, but I don't have time to do the digging.
masak: It's also, of course, possible that it was just implemented that way because it would have been a pain to do different from a code-gen point of view, and nobody noticed 13:53
(until now)
masak jnthn: in the Perl 6 grammar, `|| ^^ //` all have prec %tight_or, which is list-associative 13:54
so I don't think they are left-associative
(notice, again, that for `|| //`, there's no noticeable difference in semantics)
jnthn Which Perl 6 grammar are you looking at? 13:55
Rakudo's has:
token infix:sym<||> { <sym> <O(|%tight_or, :iffy(1), :assoc<left>, :pasttype<unless>)> }
token infix:sym<^^> { <sym> <O(|%tight_or, :iffy(1), :pasttype<xor>, :thunky<..t>)> }
token infix:sym<//> { <sym> <O(|%tight_or, :assoc<left>, :pasttype<defor>)> }
See the :assoc<left>
masak I was looking at those lines, yes. but apparently reading them wrong :) 13:56
jnthn ah :)
masak oh, so the operators pick first a precedence, and then _override_ the associativity. fun.
this... messes with my mental model of precedence and associativity a bit
ok, but that answers my question. thank you, jnthn. 13:57
jnthn Not really, O just receives a set of named args 13:57
And so the "override" is just arg passing semantics
And the O that handles precedence never knows the difference 13:58
masak yes yes
xinming sena_kun: What will you do to solve my problem? The Saver thing.
masak it's just that... to me, associativity is something that a _precedence level_ has. that's in fact quite clear from the (S03) precedence table
masak and so if operators devidate from their level's precedence, then that's... an interesting form of anarchy, model-wise 13:59
deviate*
sena_kun xinming, what is the problem? a boilerplate method call in every calculation method?
I wouldn't consider it as an issue in the first place, I think, unless it is some disaster type of thing. 14:00
masak jnthn: I come at this as someone who has spent a *lot* of the past 4-5 years thinking really hard about custom operators. doesn't mean I'm right, of course, but... getting an associativity that's separate from the one from your precedence level is a thing that Worries Me.
jnthn masak: Hm, but the concept of predence level doesn't really exist so far as the Perl 6 OPP goes 14:01
It's a model concept of the language user, perhaps, but it ain't really one of the parser
masak it's about how the optable parser is meant to build the tree. first it tiebreaks by precedence, and then it tiebreaks by (that precedence level's) associativity 14:02
but if the two ops in question each have an associativity, the second tiebreak may be inconclusive
xinming sena_kun: I don't like boilerplate method call for each of the subclass. But just now, I thought through about what you said, each class should be considered inheritable. Then my sollution makes these class not suitable for inheritance. 14:04
masak what if you do `a X b Y c`, and X says to associate to the right but Y says to be non-associative?
masak (X and Y being of equal precedence) 14:05
SmokeMachine m: class R { method test () { "before".say; callsame; "after".say; }; }; class T last-does R { method test () { "class method".say; } }; T.^add_parent: R; T.new.test;
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse class definition
at <tmp>:1
------> 3y; callsame; "after".say; }; }; class T7⏏5 last-does R { method test () { "class m
expecting any of:
generic role
SmokeMachine m: class R { method test () { "before".say; callsame; "after".say; }; }; class T { method test () { "class method".say; } }; T.^add_parent: R; T.new.test; 14:05
camelia Parents cannot be added to class 'T'after it has been composed
in block <unit> at <tmp> line 1
SmokeMachine m: class R { method test () { "before".say; callsame; "after".say; }; }; class T is R { method test () { "class method".say; } }; T.new.test; 14:06
camelia class method
xinming SmokeMachine: Because the method in T wins.
the my constant T = anon class T { .. } but xx version works
masak in a way, associativity is _meant_ to be "when precedence is not enough, we at least build the tree in this unambiguous way". if associativity comes back with conflicting results, we're in trouble. 14:07
sena_kun xinming, what's the issue with inheritance here? you want different savers for different children classes?
xinming Nothing wrong with inheritance, just want to make the Saver transparent. :-) 14:08
ignore me though, I'll go with inheritance, But good to know how to achieve something I want in perl6. :-) 14:09
sena_kun xinming, well, I am at no use here then, sorry. I'd consider it a bad design solution, to be honest. I mean, you are intentionally hiding execution parts from the user. It becomes harder to understand, debug and change.
SmokeMachine xinming: why don't you transform the computation class into roles and the saves into classes? 14:10
sena_kun a method call approach is surely more boilerplate (which is not bad considering the code piece is sensible), but instead it can be easily disabled for a particular case, overloaded and so on. while "One Rule Them All" solution is less customize-able. 14:12
but that's just me. :)
xinming SmokeMachine: I thought calculation is the important part, and keep results is a "feature". But now, I think in each calc method, explictly keep-result may not be that bad. 14:14
SmokeMachine xinming: if you are saving it on the database, you could do it with a Red model... :) 14:15
masak m: sub infix:<po>(*@v) is assoc<list> { @v.join(" po ") }; sub infix:<fi>(*@v) is equiv(&infix:<po>) is assoc("list") { @v.join(" fi ") }; say 1 po 2 po 3 fi 4 fi 5 14:33
camelia 5===SORRY!5=== Error while compiling <tmp>
Only identical operators may be list associative; since 'po' and 'fi' differ, they are non-associative and you need to clarify with parentheses
at <tmp>:1
------> 3t") { @v.join(" fi ") }; say 1 po…
masak good news: we do have a warning in place \o/
s/warning/error/ 14:34
xinming SmokeMachine: No need to advertise, My next project will try Red. I've used Xoo, It works, But Still lacks many features I want. At least not to the level DBIC can offer 14:35
masak my first foray into the spectest suite indicates that it's non-committal over the associativity of infix:<||> and infix:<&&>. I will mess around with building Rakudo in various ways to try to confirm this 14:41
for the record, I skimmed through S03-operators/precedence.t and S03-operators/short-circuit.t, both of which looked promising 14:42
ugexe pmurias: i looked at node ( github.com/nodejs/node/blob/f2064d...os.cc#L114 ) and moarvm source (github.com/MoarVM/MoarVM/blob/d159...m/sys.c#L9 ) for uv_cpu_info -- so that pr will give the same result as moarvm. what exactly that result represents is not immediately clear to me from the documentation ( 15:06
docs.libuv.org/en/v1.x/misc.html#c.uv_cpu_info_t )
patrickb Is there an easy way to look at the installed sources of a module? 15:47
tobs patrickb: `zef look` will take you there 15:53
sena_kun patrickb, just keep in mind that they are not meant to be edited by hands. 15:54
patrickb tobs: does `zef look` display installed modules or the ones from the repo? 15:55
timotimo i think it checks out the repo for you
patrickb :-(
ugexe zef locate ... 16:02
editing those sources won’t do what you want though. But that’s how you locate installed sources to view 16:03
xinming m: role T { method t () { "method".say; } }; sub x (%t is copy) { %t.WHAT.say; }; my @a; my %h= (:a, :b); %h does T; @a.push: %h; x(%h); 16:05
camelia (Hash)
xinming In this case, How can I also copy the "role"?
with is-copy, role info are dropped. 16:06
ugexe m: my $test-dist = $*REPO.repo-chain.grep(CompUnit::Repository::Installable).map(*.candidates("NativeCall")).first.head; say $test-dist.content("lib/Test.pm6").slurp 16:07
camelia use MONKEY-GUTS; # Allow NQP ops.

unit module Test;
# Copyright (C) 2007 - 2018 The Perl Foundation.

# settable from outside
my int $perl6_test_times = ?%*ENV<PERL6_TEST_TIMES>;
my int $die_on_fail = ?%*ENV<PERL6_TEST_DIE…
ugexe you can query for a dist that contains some short-name, then ask for the content of a file in that distribution as shown above 16:08
patrickb ugexe: Great! I don't want to edit them. It's helpful to look at installed stuff during error hunting. 16:10
tyil rakudo.org is down 16:56
or not
my internet is dodgy
xinming Another suggestion, Can we have a warning in if $x => 1 == ablabla { } ?? 16:57
Today, I got typo with if $x => 1 takes a while to find the problem.
moritz what were you trying to write? 17:20
timotimo like "numerical equivalence of pairs is useless, did you mean >= instead of =>?" 17:21
moritz m: say (a => 1) == (b => 1) 17:30
camelia Cannot resolve caller Numeric(Pair:D: ); none of these signatures match:
(Mu:U \v: *%_)
in block <unit> at <tmp> line 1
moritz seems like an error message that doesn't trigger a minute-long search 17:31
though "Cannot coerce Pair to Numeric" would be a better message
xinming timotimo: Yes, something like that. 17:32
Just now, I have something like if $idx => @history-reversed.elems - 1; 17:33
Which I actually should write if $idx >= @history-reversed.elems -1
So, if there is warning here, can save a lot of time for people 17:34
timotimo decentraleyes.org/ - awesome!! 17:52
tadzik "download an install to learn more" rubs me the wrong way 17:55
but there's a readme in the gitlab link :)
it is very cool though :) 17:56
timotimo it's so obvious 17:58
tadzik at the same time, I think that's something that caching is supposed to solve 18:00
timotimo it should, but there's still the original request
tadzik true. But with this extension, you don't know if the content you get is authentic, do you? 18:01
websites use this checksum mechanism for validating external resources, except when they don't 18:02
timotimo ha 18:03
timotimo for that you'd have to trust the extension does the right thing 18:03
these checksums are in use on many sites, and of course should be used on every one of them
then again, who says that you're getting the authentic thing from whatever cdn the site is using
ab6tract .tell japhb sent a followup email :) 18:22
yoleaux 14 Mar 2019 21:59Z <japhb> ab6tract: No, I hadn't noticed that, though it's been a while since I checked all my mail accounts and folders. I'll see if I can find it.
ab6tract: I'll pass your message to japhb.
Skarsnik Hello there. I rerun my gumbo benchmark, and I admit I am kinda disapointed to be only 4x faster since rakudo 2016.01 x) gist.github.com/Skarsnik/2161a360c...8c8fc6d9d8 21:07
timotimo could you perhaps do a "perf record" and "perf report --stdio" of that benchmark? and perhaps another with the jit turned off?
ufobat mhm 2019.03.1 segfaulted on the first attempt of compiling it 21:08
timotimo core dump please? :3
Skarsnik what does that do? x)
timotimo perhaps "coredumpctl"?
Skarsnik: it's a profiler that'll sample what function it hits (actually which exact instruction) a few thousand times per second (adjustable frequency) 21:09
Skarsnik Hoo you mean as rakudo option
timotimo just "perf record perl6 blah"
it'll also tell us what parts of gumbo take how much time 21:10
Skarsnik the call to the lib C (gumbo parse html function) take like 0.01 x)
ufobat tries to make a coredump
timotimo ufobat: maybe coredumpctl has one for you already? 21:11
Skarsnik: damn :D
ufobat coredumpctl is not installed
timotimo OK
Skarsnik hm 0.02 sec 21:12
timotimo i mean, that's still like 10% :) :) 21:13
Skarsnik so basicly it take 10 time to time to parse the html5 to just transform the C struct to Perl 6 object 21:13
timotimo mhm
Skarsnik does 2019.03.1 is up2date for your profiler? x) 21:14
timotimo yeah, i believe so
Skarsnik still no dock image or stuff to easily install it? x) 21:16
timotimo nope, but now... now we have relocateable perl6 launchers! 21:17
it can become an appimage!!
Skarsnik I guess I just have to send the profile file xD 21:18
ufobat it doesnt segfault anymore, i tried it 5 times
Skarsnik this is weird, I had no issue compiling 2019.03.1
timotimo i feel like i already started on a Dockerfile, but i can't find it any more :| 21:19
Skarsnik I saved a lot of time patching XML and removing some NCast call between the 2 runs of my benchmark. rakudo-2018.09, gumboxml.p6, 0.52847010577 vs rakudo-2018.09, gumboxml.p6, 0.3243064942 21:21
timotimo impressive
Skarsnik I run the test 50 times for each release and do an average, it's not a single run 21:22
Skarsnik ./rakudo-2016.01.1/install/bin/perl6 --profile --profile-filename testgumbo.json to get a profile? 21:23
ufobat is there a rakudo brew clean command? 21:24
it just dont segfault anymore
Skarsnik you could cd rakudo and make distclean I guess? 21:25
timotimo nah, you'll have to use .sql for the filename 21:33
ufobat: "nuke" is the one, it hink
ufobat jup.. 21:34
last try
Skarsnik the sql file is html lol 21:35
timotimo in that case the filename didn't take? somehow? 21:37
oh
you're in 2016.01
Skarsnik I ran the wrong rakudo yes lol
gist.github.com/Skarsnik/47cbaa402...082ffac864 21:38
timotimo crap, my hard drive is *super* filled up to the brim 21:39
need to do some emergency cleaning
Skarsnik I have too many hard drive xD 21:40
Skarsnik C: 233G 138G 95G 60% /mnt/c 21:48
F: 1.9T 1.3T 619G 67% /mnt/f
G: 1.9T 344M 1.9T 1% /mnt/g
K: 448G 70G 378G 16% /mnt/k
El_Che /mnt and disk as drive letters 21:50
a little schizzo :)
Skarsnik it's WPL 21:51
El_Che WSL?
Skarsnik yes? the win 10 stuff to have a linux env ^^ 21:52
very handy
Xliff m: class A { method a { say ::?CLASS.name }; }; class B is A { }; A.new.a.say; B.new.a.say 22:14
yoleaux 20 Mar 2019 09:16Z <SmokeMachine> Xliff: github.com/FCO/Red/issues/15#issue...-474745855
camelia No such method 'name' for invocant of type 'A'. Did you mean any of these?
none
note
take

in method a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff m: class A { method a { say ::?CLASS.^name }; }; class B is A { }; A.new.a.say; B.new.a.say
camelia A
True
A
True
Xliff Is there any way to get the second "A" to say "B"? 22:18
Skarsnik self::?CLASS.^name?
jnthn Xliff: self.^name 22:19
guifa Are there any rough style guideliness for when to pass named args in or out of the parenthetical main args? 22:22
guifa By that I mean, foo(5, :$bar) is the same as foo(5) :$bar … or is it? 22:23
Xliff m: class A { method a { say self.^name }; }; class B is A { }; A.new.a.say; B.new.a.say 22:24
camelia A
True
B
True
Skarsnik hm 22:26
m: class A { method a { say self.^name }; }; class B does A { }; A.new.a.say; B.new.a.say
camelia 5===SORRY!5=== Error while compiling <tmp>
A is not composable, so B cannot compose it
at <tmp>:1
ugexe why are you "does"ing a class? 22:28
Skarsnik dunno
timotimo that code has too high a doesage
Xliff jnthn++ 22:32
Skarsnik I think Perl 6 class and heritance is always super confusing x)
moritz Skarsnik: why? it works exactly like in any other language 22:34
Skarsnik m: class A { method foo(){say "foo"} }; class B is A { method foo(Int $a) { say "foo Int"}}; B.new.foo(42); 22:36
camelia foo Int
Skarsnik Hoo this work now
m: role A { method foo(){say "foo"} }; class B does A { method foo(Int $a) { say "foo Int"}}; B.new.foo(42); 22:38
camelia foo Int
lizmat weekly: brrt-to-the-future.blogspot.com/20...on-is.html 22:57
notable6 lizmat, Noted!
guifa is there any syntactical sugar for converting a scalar into an array in a method signature, or should I just keep going with multi’s for that? (where I assume a list will be passed but want to accept a scalar rather than make someone create a single item list) 23:05
discord6 <Vendethiel> *@ or **@ or +@? 23:07
lizmat m: sub a(*@a) { dd @a }; a 42
camelia Array element = [42]
guifa That’ll work great in this case, actually. (although if it were the first of several positionals, I guess it wouldn’t) 23:09
Vandethiel++ lizmat++
lizmat sleep&
discord6 <Vendethiel> Perl 6 alas doesn’t treat end of lists as much like first citizens as beginning of lists (because of fear of the laziness abyss)
guifa Interesting. The docs say that %?RESOURCES<foo> returns an IO::Path object, but it’s actually a Distribution::Resource one that holds an IO::Path inside, so it fails type checks 23:34
timotimo i think IO::Path used to be what it did and then it was changed but not updated in the docs? perhaps? 23:42
guifa That sounds likely. There’s zero documentation for Distribution::Resource 23:43
discord6 <Vale> Hey I have a general question 23:44
discord6 <Vale> How can I compare 2 strings char by char with a loop? 23:44
discord6 <Vale> my ($first, $second) = @_; foreach my $charA, $charB ($first, $second){ #compare $charA with $charB } 23:45
<Vale> Let $first and $second be strings
<Vale> is this even possible like this?
timotimo you can get a list of characters with .comb and you can get a matching one from each with the Z metaop
m: my ($first, $second) = ("hello", "goodbye")>>.comb; for $first Z $second -> $a, $b { say "$a-$b" } 23:46
camelia Too few positionals passed; expected 2 arguments but got 1
in block <unit> at <tmp> line 1
timotimo m: my ($first, $second) = ("hello", "goodbye")>>.comb; for $first Z $second -> ($a, $b) { say "$a-$b" }
camelia h e l l o-g o o d b y e
timotimo nope
m: my ($first, $second) = ("hello", "goodbye")>>.comb; for @$first Z @$second -> ($a, $b) { say "$a-$b" }
camelia h-g
e-o
l-o
l-d
o-b
timotimo see how it ends when the shorter string ends
that's a thing that Z does that you have to be aware of
m: my ($first, $second) = ("hello", "goodbye")>>.comb; for @$first »,« @$second -> ($a, $b) { say "$a-$b" } # if you want it to throw an exception when the lists aren't the same length use »,« 23:48
camelia Lists on either side of non-dwimmy hyperop of infix:<,> are not of the same length while recursing
left: 5 elements, right: 7 elements
in block <unit> at <tmp> line 1
timotimo m: my ($first, $second) = ("hello", "goodbye")>>.comb; for @$first «,» @$second -> ($a, $b) { say "$a-$b" } # if you want it to repeat the shorter one until the longer one is exhausted, use «,» 23:49
camelia h-g
e-o
l-o
l-d
o-b
h-y
e-e
discord6 <Vale> hmm
timotimo `Z` is equivalent to `Z,` but you can also use other operators there 23:50
discord6 <Vale> Alright thanks
<Vale> This is helpful 23:51
timotimo m: .perl.say for (<a b c d e> Z=> <1 2 3 4 5>)
discord6 <Vale> 😃
camelia :a(IntStr.new(1, "1"))
:b(IntStr.new(2, "2"))
:c(IntStr.new(3, "3"))
:d(IntStr.new(4, "4"))
:e(IntStr.new(5, "5"))
timotimo ha, that's not such helpful output actually
m: .perl.say for ("a b c d e".words Z=> "1 2 3 4 5".words)
camelia :a("1")
:b("2")
:c("3")
:d("4")
:e("5")