»ö« 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 Zoffix on 25 May 2018. |
|||
Xliff | I have two new methods: multi method new (GtkOrientation $orientation, gint $spacing), and multi method new (:$box). When I try and use the first one I get the following error: Default constructor for 'GTK::Box' only takes named arguments. | 00:08 | |
I thought positionals superseded named arguments. | 00:09 | ||
timotimo | i recommend overriding the default "new" method by putting a proto method in there | 00:10 | |
m: class Test { }; say Test.^find_method("new").^candidates | 00:12 | ||
camelia | No such method 'candidates' for invocant of type 'Perl6::Metamodel::ClassHOW' in block <unit> at <tmp> line 1 |
||
timotimo | m: class Test { }; say Test.^find_method("new")[0].^candidates | ||
camelia | No such method 'candidates' for invocant of type 'Perl6::Metamodel::ClassHOW' in block <unit> at <tmp> line 1 |
||
timotimo | mhh | ||
m: class Test { }; say Test.^find_method("new") | |||
camelia | new | ||
timotimo | m: class Test { }; say Test.^find_method("new").^name | 00:13 | |
camelia | Method | ||
timotimo | m: class Test { }; say Test.^find_method("new").^methods | ||
camelia | (gist <anon> leave <anon> <anon> wrap <anon> <anon> <anon> onlystar <anon> <anon> candidates <anon> package unwrap yada <anon> multi <anon> soft <anon> <anon> <anon> <anon> cando <anon> perl BUILDALL <anon> has-phaser set_why fire_if_phasers of phaser… | ||
timotimo | m: class Test { }; say Test.^find_method("new").perl | ||
camelia | proto method new (Mu: |) {*} | ||
timotimo | m: class Test { }; say Test.^find_method("new").candidates | ||
camelia | (new new) | ||
timotimo | m: class Test { }; say Test.^find_method("new").candidates>>.perl | ||
camelia | (multi method new (Mu: *%attrinit) { #`(Method|45274992) ... } multi method new (Mu: $, *@, *%_) { #`(Method|45275144) ... }) | ||
Xliff | Hrm. | 00:14 | |
timotimo | it's got a slurpy positional there | ||
Xliff | Can I define two protos? | ||
Yeah. I see that. | |||
timotimo | not for the same name | ||
but you can just make its signature maximum free, like proto method new (|) {*} | 00:15 | ||
Xliff | That kinda sucks though. | 00:16 | |
timotimo | how so? | ||
Xliff | Because I can't do positionals OR named parameters. I have to do both. | 00:17 | |
timotimo | the proto has to accept anything you want to have a candidate for | ||
the union, so to speak | |||
Xliff | So new(Int, Int) cannot coexist with new(:$nv) unless proto method new(Int?, Int? |) | 00:18 | |
timotimo | or new(|) | ||
Xliff | new(|) won't accept two positionals. | ||
Just named arguments. | |||
lookatme | maybe new(:$nv!) | ||
timotimo | really? | 00:19 | |
Xliff | Don't want :$nv in case 1 | ||
Yeah. Tried new(|) and it gave me an error | |||
timotimo | m: proto sub blerp(|) {*}; multi blerp($a, $b) { say "two ints" }; multi blerp(:$nv) { say "nv" }; blerp(1, 2); blerp(nv => 99) | ||
camelia | two ints nv |
||
Xliff | Try method | ||
timotimo | m: class Floop { proto method blerp(|) {*}; multi method blerp($a, $b) { say "two ints" }; multi method blerp(:$nv) { say "nv" }; }; Floop.blerp(1, 2); Floop.blerp(nv => 99) | 00:20 | |
camelia | two ints nv |
||
Xliff | m: class Floop { proto new blerp(|) {*}; multi method new($a, $b) { say "two ints" }; multi method new(:$nv) { say "nv" }; }; Floop.new(1, 2); Floop.new(nv => 99 | 00:21 | |
lookatme | m: class F { multi method new(:$nv!) { say "nv"; }; multi method new(Int $a?, Int $b?) { say "two"; }; }; say F.new(1, 2); | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Missing block at <tmp>:1 ------> 3class Floop { proto new7⏏5 blerp(|) {*}; multi method new($a, $b) expecting any of: new name to be defined |
||
two True |
|||
timotimo | you have "proto new" instead of "proto method" | ||
Xliff | m: class Floop { proto new blerp(|) {*}; multi method new($a, $b) { say "two ints" }; multi method new(:$nv) { say "nv" }; }; Floop.new(1, 2); Floop.new(nv => 99); | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Missing block at <tmp>:1 ------> 3class Floop { proto new7⏏5 blerp(|) {*}; multi method new($a, $b) expecting any of: new name to be defined |
||
Xliff | OK. I will try mandatory named. | ||
timotimo | do you see the problem with "proto new"? | 00:22 | |
lookatme | m: class F { multi method new(:$nv!) { say "nv"; }; multi method new(Int $a?, Int $b?) { say "two"; }; }; F.new(1, 2); F.new(nv => 22); | ||
camelia | two nv |
||
lookatme | m: class F { multi method new(:$nv) { say "nv"; }; multi method new(Int $a?, Int $b?) { say "two"; }; }; F.new(1, 2); F.new(nv => 22); | ||
camelia | two nv |
||
lookatme | m: class F { multi method new(:$nv) { say "nv"; }; multi method new(Int $a?, Int $b?) { say "two"; }; }; F.new(); | ||
camelia | nv | ||
lookatme | :D | 00:23 | |
timotimo | yeah, the nv one is more specific, because it has exactly 0 positionals, whereas the Int? Int? one is for either 0, 1, or 2 ints | ||
lookatme | what is 0 ints ? | 00:24 | |
:( | |||
timotimo | "0 parameters, all of them ints" | ||
lookatme | I prefer they raise an compile error, or warning | 00:26 | |
timotimo | not possible with regular methods, as they are completely late-bound | ||
lookatme | they are all can accept zero parameters obviously | ||
00:27
mst left
|
|||
lookatme | oh | 00:27 | |
timotimo | do note that named parameters are only ever used to break ties, and every method has an implicit *% argument | 00:28 | |
lookatme | yeah, I know this recently | 00:29 | |
00:34
mst joined,
mst left,
mst joined
|
|||
Xliff | Now: class A { multi method new ($a, $b) { say "ab"; }; multi method new (:$box) { say "Box!" }: }; A.new(1, 2); A.new(:box(3); | 00:38 | |
m: class A { multi method new ($a, $b) { say "ab"; }; multi method new (:$box) { say "Box!" }: }; A.new(1, 2); A.new(:box(3); | 00:39 | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Unexpected closing bracket at <tmp>:1 ------> 3multi method new (:$box) { say "Box!" }:7⏏5 }; A.new(1, 2); A.new(:box(3); |
||
Xliff | m: class A { multi method new ($a, $b) { say "ab"; }; multi method new (:$box) { say "Box!" }; }; A.new(1, 2); A.new(:box(3); | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1) at <tmp>:1 ------> 3"Box!" }; }; A.new(1, 2); A.new(:box(3);7⏏5<EOL> expecting … |
||
Xliff | m: class A { multi method new ($a, $b) { say "ab"; }; multi method new (:$box) { say "Box!" }; }; A.new(1, 2); A.new(:box(3)); | ||
camelia | ab Box! |
||
00:39
Ven` joined
|
|||
Xliff | When I try that in my code, it says "Too few positionals passed; expected at least 2 arguments but got only 1" | 00:40 | |
timotimo | any more classes you derive from, roles you include, anything like that? | 00:42 | |
version difference perhaps?! | |||
committable: releases class A { multi method new ($a, $b) { say "ab"; }; multi method new (:$box) { say "Box!" }; }; A.new(1, 2); A.new(:box(3)); | |||
committable6 | timotimo, ¦releases (31 commits): «abBox!» | ||
timotimo | that's probably not it, hmm. | ||
00:43
Ven` left
00:44
jeromelanteri joined
|
|||
timotimo | anyway, i have to go get sleep | 00:44 | |
00:49
jeromelanteri left
|
|||
Xliff | nn "timo"x2 | 00:55 | |
m: ("timo" x 2).say | |||
camelia | timotimo | ||
Xliff | m: ("timo" xx 2).join.say | 00:56 | |
camelia | timotimo | ||
lookatme | timotimo, good night :) | ||
00:57
Xliff left
01:01
jameslenz joined
01:02
jeromelanteri joined
01:04
Kaypie left
01:05
lizmat left,
jameslenz left
01:06
subr left,
subroot joined
01:10
spycrab0 left
01:46
atweiden-air joined
|
|||
atweiden-air | Hey you guys; i read in the newsletter something that will break a bunch of my code:the `is required` trait does not make sense on private attributes in a class because private attributes will never be assigned by the default object building logic (aka .new). To avoid confusion, adding is required to a private attribute is now a compilation error. | 01:48 | |
i take issue with this change: `has $!thing is required` is perfectly reasonable assuming the class has a custom submethod BUILD. | |||
e.g. github.com/atweiden/mktxn/blob/8e6...XN.pm6#L56 | 01:49 | ||
01:51
fake_space_whale joined
|
|||
atweiden-air | for me it's a visual aid: i can know with certainty private attributes of a class marked `is required` had to have been derived during a custom instantiation process. it's perfectly self-documenting | 01:54 | |
02:02
molaf left,
Zoffix joined
|
|||
Zoffix | atweiden-air: but that's misleading code, because the check is not enforced. | 02:03 | |
You may as well just make those basic comments. | |||
atweiden-air | i suppose this won't affect my code if I provide `has $.thing is required; method thing() {*}` ..? | ||
commit: github.com/rakudo/rakudo/commit/1a...d070f1R104 | 02:04 | ||
committable6 | atweiden-air, I cannot recognize this command. See wiki for some examples: github.com/perl6/whateverable/wiki/Committable | ||
Zoffix | atweiden-air: then it's not a private attribute | ||
atweiden-air | i mean `has $!thing is required` | ||
maybe that would pass the conditional check `$attr.has_accessor` | |||
Zoffix | atweiden-air: it doesn't know it's an accessor | 02:05 | |
atweiden-air | m: class ABC { has $!thing is required; }; ABC.new.perl.say; | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> 'is required' only works on a public attribute $.thing, not a private $!thing at <tmp>:1 |
||
atweiden-air | dunno how to show the error from the current stable release | 02:06 | |
but it's `The attribute '$!thing' is required, but you did not provide a value for it.` | |||
Zoffix | That is the error | ||
atweiden-air | Zoffix: so i think this is currently enforced | ||
Zoffix | ? | 02:07 | |
atweiden-air | Zoffix: you said earlier "because the check is not enforced." | ||
Zoffix | c: 2018.06 class Foo { has $!foo is required; } | ||
committable6 | Zoffix, ¦2018.06: «» | ||
Zoffix | I meant before the change showing you have a bug in your code, the `is required` check was not enforced | ||
atweiden-air: in either case. Such discussions are better had on the Issue tracker ( github.com/rakudo/rakudo/issues/new ), but I doubt you'll have much luck convincing the core devs they should leave in dead, misleading code because you've used it instead of a comment ( xkcd.com/1172/ ). You may choose an alternate strategy, such as suggesting making the attribute enforce that the private | 02:09 | ||
attribute, but that runs into an issue of what "some value" really is, since the default default of the container is "some value" | |||
atweiden-air | not sure what you mean. 2018.06 throws an error on this: `class ABC { has $!thing is required; }; ABC.new.perl.say;` | ||
the error message is: The attribute '$!thing' is required, but you did not provide a value for it. | |||
Zoffix | Ah, I forgot a .new | ||
c: 2018.06 class ABC { has $!thing is required; }; ABC.new.perl.say; | |||
committable6 | Zoffix, ¦2018.06: «The attribute '$!thing' is required, but you did not provide a value for it. in submethod BUILDALL at /tmp/f1vpWNHMc8 line 1 in block <unit> at /tmp/f1vpWNHMc8 line 1 «exit code = 1»» | ||
Zoffix | c: 2018.06 class ABC { has $!thing is required; submethod BUILD(:$!thing = 42) {} }; ABC.new.perl.say; | ||
committable6 | Zoffix, ¦2018.06: «ABC.new» | ||
Zoffix | c: 2018.06 class ABC { has $!thing is required; submethod BUILD(:$!thing = Any) {} }; ABC.new.perl.say; | ||
committable6 | Zoffix, ¦2018.06: «ABC.new» | ||
atweiden-air | Zoffix: i suppose i could open an issue on GH. i like venting on IRC tho :) | 02:12 | |
Zoffix | atweiden-air: filed an Issue for this: R#2083 | ||
synopsebot | R#2083 [open]: github.com/rakudo/rakudo/issues/2083 [LTA][regression] `is required` change removed useful feature | ||
Zoffix | atweiden-air: well, then you may choose to vent on #perl6-dev that has higher chance of being noticed by coredevs :) | 02:13 | |
atweiden-air | attn coredevs | 02:16 | |
atweiden-air squints, shakes fist | |||
Zoffix | :) | ||
Actually, breakage of that module would've shown up on toaster run, and I'd guess the release manager would revert the change. But it's nice to also have an argument for why it was a useful feature to go along with it :) | 02:17 | ||
greppable6: \$\!.+is required | 02:18 | ||
greppable6 | Zoffix, 13 lines, 9 modules: gist.github.com/c0349a59a74bf44068...aa3d89ae04 | ||
Zoffix | hm, wonder why your module doesn't show up in the list (was the issue of missing modules in all-modules repo fixed?) | ||
Hhahaha | 02:19 | ||
Even my own module is broken by the change: github.com/zoffixznet/perl6-WWW-vl...ote.pm6#L6 | |||
02:26
Zoffix left
02:48
giraffe joined
02:51
atweiden-air left
03:00
Kaypie joined
03:01
jameslenz joined
03:04
El_Che left
03:05
El_Che joined,
jameslenz left
03:27
kjk joined
|
|||
kjk | is there an existing method for updating a Hash with another such that if a key exists its value is replaced otherwise the new key value are added? | 03:29 | |
MasterDuke | m: my %orig = :1a, :2b; my %new = :5b, :6c; %orig ,= %new; dd %orig | 03:32 | |
camelia | Hash %orig = {:a(1), :b(5), :c(6)} | ||
03:33
aindilis left
|
|||
MasterDuke | kjk: ^^^ | 03:34 | |
kjk | MasterDuke: thanks for the solution. Is it optimized behind the scene so that it's not actually creating a new hash from both old and new and then overwrite %orig? | ||
MasterDuke | i believe so, but not 100% sure | 03:36 | |
kjk | is that the idiomatic why to do it in perl6? sorry, new to perl6. In python, I'd just use the dict.update method | 03:37 | |
MasterDuke | pretty idomatic. it may or may not be what you want if there are multi-level hashes, depends on your use-case | 03:38 | |
sleeping & | 03:44 | ||
kjk | p6: my %orig = :1a, :2b; my %new = :5b, :6c; for %new.kv { %orig{$^k} = $^v } | ||
camelia | ( no output ) | ||
kjk | p6: my %orig = :1a, :2b; my %new = :5b, :6c; for %new.kv { %orig{$^k} = $^v }; dd %orig | ||
camelia | Hash %orig = {:a(1), :b(5), :c(6)} | ||
03:50
subroot left
03:53
MasterDuke left
03:55
eliasr left
|
|||
fake_space_whale | Is using $?FILE the proper way to construct a path relative to the executing file for loading resources? for example something like my $config = $?FILE.IO.sibling("config.txt").slurp; | 03:55 | |
Juerd | kjk: Why the loop? :) | 03:56 | |
p6: my %orig = :1a, :2b; my %new = :5b, :6c; %orig{ %new.keys } = %new.values; dd %orig | |||
camelia | Hash %orig = {:a(1), :b(5), :c(6)} | ||
03:57
sauvin joined
|
|||
Juerd | fake_space_whale: $*PROGRAM.resolve.sibling(...) | 03:57 | |
kjk | Juerd: cool another way to do it | ||
Juerd | fake_space_whale: $?FILE is compile-time and could be a module. | ||
kjk | Juerd: so, is .keys guarrentee to return the keys in the same order as the their values? | 03:58 | |
Summertime | should do as long as the hash doesn't get mutated inbetween? assuming its like python's old dicts | 03:59 | |
Juerd | kjk: That's missing from the documentation. Would you care to create a github issue for that? I'm about to go to bed (6am here) | 04:00 | |
github.com/perl6/doc/issues | |||
Summertime | ? > Note that the order in which keys, values and pairs are retrieved is generally arbitrary, but the keys, values and pairs methods return them always in the same order when called on the same object. | ||
Juerd | Good night! | ||
Summertime | I'd say that implies it enough | ||
kjk | I like MasterDuke's version better: %orig ,= %new but I'm not sure if that's doing it the smart way behind the scene or creating a new hash from %orig and %new | ||
Summertime | I'd assume it'd be making a new hash, you'd expect that it wouldn't mutate the original value, much like most other thing= uses | 04:02 | |
kjk | I kinda hope it would mutate the %orig in this case since it's going to reassign it anyway creating a copy, mutate it, and then assign it to %orig would be a waste. | 04:05 | |
fake_space_whale | Juerd: Thank you | ||
kjk | Juerd: I'm not sure if you mean no doc on how to update a Hash with another or no doc about the order of .keys and .values | 04:06 | |
lookatme | no docs about the order | ||
kjk | ok | 04:07 | |
Summertime | probably just needs some clarification in the third paragraph of the Map class documentation | 04:08 | |
04:11
Ven` joined
04:15
Ven` left
04:50
curan joined
05:01
jameslenz joined
05:06
jameslenz left
05:08
HaraldJoerg joined
05:15
xtreak joined
05:26
sno left
05:32
troys left
05:44
aindilis joined,
fake_space_whale left
05:46
sarna joined
|
|||
sarna | hey, how do I define a custom destructor? | 05:48 | |
geekosaur | submethod DESTROY() { ... } | 05:54 | |
sarna | thanks :) | 05:55 | |
05:56
rindolf joined
05:58
fake_space_whale joined
06:12
fake_space_whale left
06:25
robertle joined,
nebuchadnezzar joined
06:32
sno joined
06:35
wamba joined
06:39
konsolebox left
06:41
konsolebox joined
07:02
jameslenz joined
07:06
jameslenz left
07:10
domidumont joined
07:11
psychoslave joined
07:14
pecastro joined
07:16
wamba left
07:17
domidumont left
|
|||
perlawhirl | I'm unable to build NQP :( | 07:17 | |
MoarVM panic: Memory allocation failed; could not allocate 4294967296 bytes | |||
07:18
domidumont joined
|
|||
moritz | it tries to allocate 4GB RAM at once? | 07:20 | |
perlawhirl | seems that way. | 07:21 | |
i might try a reboot first, and failing that, rollback commits on Moar and NQP and retry building | 07:22 | ||
07:26
woolfy left
07:27
woolfy joined
07:37
dakkar joined
07:44
lizmat joined
07:45
araujo left
07:48
wamba joined
|
|||
lizmat clickbaits p6weekly.wordpress.com/2018/07/16/...llination/ | 07:48 | ||
07:52
wamba left
07:53
wamba joined
07:57
ilogger2 joined,
ChanServ sets mode: +v ilogger2
08:04
scimon joined
08:15
Ven` joined
08:17
pmurias joined
|
|||
El_Che | lizmat: you found an antagonist on perlmonks it seems | 08:20 | |
08:21
faraco joined,
faraco left,
faraco joined,
subroot joined
|
|||
ecocode | some software devs are reluctant to change ;) | 08:22 | |
El_Che | this one was rather vexed from somethong of 15y ago | ||
faraco o/ | 08:23 | ||
lookatme | :) | ||
08:29
pmurias left,
pmurias joined
08:36
faraco left
08:48
wamba joined
08:53
Woodi joined,
sarna joined
08:55
subroot left
|
|||
lizmat | El_Che: oddly enough, I didn't recall him being vexed 15 years ago | 08:55 | |
sarna | o/ | 08:58 | |
lizmat | I only see a reaction from said person in 2008 | 09:00 | |
09:02
jameslenz joined
|
|||
sarna | tyil: the link to GTK::Simple on your application programming tutorial 404s :) | 09:03 | |
09:06
jameslenz left
|
|||
El_Che | lizmat: I understand someone not agreeing with you, ar finding your argument false, but there is no discussion there. He's just venting/trolling | 09:11 | |
xq | thanks for that link | 09:12 | |
lizmat | El_Che: yeah, unfortunately :-( | 09:14 | |
09:17
mscha joined
|
|||
mscha | p6: my $t = time; (1..25).race.map({ sleep 0.1 }); say time - $t; | 09:18 | |
camelia | 3 | ||
mscha | p6: my $t = now; (1..25).race.map({ sleep 0.1 }); say now - $t; | ||
camelia | 2.55431795 | ||
mscha | Do race/hyper actually do something yet? It seems not... | ||
09:19
pmurias left
09:20
pmurias joined
|
|||
moritz | m: my $t = time; (1..25).map({ sleep 0.1 }); say time - $t; | 09:20 | |
camelia | 2 | ||
moritz | m: my $t = time; (1..25).race(jobs => 8).map({ sleep 0.1 }); say time - $t; | ||
camelia | 2 | ||
jnthn | p6: my $t = now; (1..25).race(:batch(1)).map({ sleep 0.1 }); say now - $t; | 09:21 | |
camelia | 0.73301941 | ||
jnthn | The default batch size is 64 items | ||
mscha | Ah, that explains it, thanks jnthn. :-) | ||
moritz | and you can't win chosing a smaller default, because then fast-ish maps become really slow due to the overhead | ||
mscha | m: my $t = now; (^128).hyper.map({ sleep 0.01 }); say now - $t; | 09:23 | |
camelia | 0.73068783 | ||
mscha | m: my $t = now; (^128).map({ sleep 0.01 }); say now - $t; | ||
camelia | 1.32154434 | ||
mscha | yup. :-) | ||
09:23
sena_kun joined
|
|||
tyil | sarna: I'll update it right away, thanks for notifying | 09:23 | |
sarna | tyil: no prob :) just letting you know | 09:24 | |
tyil: I've tried sending your tutorial to a friend and your website was offline yesterday :D | |||
I'm glad it's back online, it's my cheatscheet for new projects | |||
tyil | hmm, I didn't do much yesterday, other than the rss/atom feed | ||
how's the more lightweight design? :. | 09:25 | ||
:p | |||
sarna | yesterday evening, I was getting nginx errors | ||
I like it :) | |||
tyil | if you have any ideas for tutorials, let me know | 09:26 | |
or hope that TPF approves my grant, then you'll get a whole book | |||
sarna | woo! | ||
please do norvig.com/lispy.html but better | |||
tyil | heh | 09:27 | |
that could be interesting | |||
I'll read through that and see if I can redo it in a timely manner in Perl 6 :> | |||
sarna | I've tried :) it's pretty straightforward, but I ran out of steam | 09:28 | |
I think it'd be fun to implement some additional features | 09:29 | ||
"look how easy it is in perl6!" | |||
tyil | everything is easy to Perl 6 from my (limited) experience | 09:30 | |
and if it's not easy, I complain here | |||
09:31
xtreak joined
|
|||
sarna | "make the easy things easy and the hard things possible" :D | 09:32 | |
mscha | m: my $t = now; say +(^10_000).grep(&is-prime); say now - $t; | 09:33 | |
camelia | 1229 1.5468864 |
||
mscha | m: my $t = now; say +(^10_000).race.grep(&is-prime); say now - $t; | ||
camelia | 1229 0.6871809 |
||
moritz | m: my $t = now; say +(^10_000).race(:batch(500)).grep(&is-prime); say now - $t | 09:37 | |
camelia | 1229 0.64363365 |
||
moritz | m: my $t = now; say +(^10_000).race(:batch(500), :jobs(8)).grep(&is-prime); say now - $t | 09:38 | |
camelia | 1229 0.55715299 |
||
sarna | does perl6 have a preference about bracing style? | 09:43 | |
lizmat | TIMTOWTDI :-) | 09:47 | |
Different Perl 6 books use different styles | |||
so I'd so, no, perl6 does not have a preference | |||
except for syntactical correctness | 09:48 | ||
which means in general, you *must* have whitespace before the opening { | |||
sarna | ha! great :D | ||
tbrowder_ | hi, #perl6 | 09:51 | |
09:52
zakharyas joined
|
|||
tyil | hi | 09:53 | |
sarna: even me and my gf have vastly different ways of writing our perl 6 programs | |||
just write it in a way that makes you work best with it | 09:54 | ||
when you're in a team, you might want to have some guidelines, to make it look consistent across the project, though | |||
sarna | tyil: yeah, consistency is important | ||
tbrowder_ | my doc PR #2177 needs a look (and votes welcome) before a possible merge. it implements the Phase 2 doc Language listing reorg discussed in the doc wiki. AlexDaniel is not excited about it but i am. please review if you can and ask questions if something doesn’t make sense. | 09:55 | |
tyil: hi | |||
tyil | hi :> | 09:56 | |
tbrowder_ | i am making progress on the proper handling of the =defn block | ||
tyil | nice :> | 09:57 | |
do you think it will be able to get into this month's rakudo star? | |||
tbrowder_ | the grammar around it is somewhat ugly | ||
when is the star release cutoff? | 09:58 | ||
tyil | AlexDaniel: would you know when the exact date is ^ | 09:59 | |
AlexDaniel | most likely won't make it into the release | 10:00 | |
thing is that jnthn++ did a lot of nice work for perf improvements | |||
but we saw some bugs appear because of that | 10:01 | ||
see this ticket: github.com/rakudo/rakudo/issues/2047 | |||
now, we haven't fully decided *yet*, but it looks like the upcoming release will not include these changes | |||
so that we can test them a bit more in the upcoming month | 10:02 | ||
and that means that the release will be cut from a commit few weeks ago | |||
tyil | ah | ||
tbrowder_: in that case, no hurry :p | |||
AlexDaniel | + some manually cherry-picked changes, if we find anything really important | ||
Geth | doc: 320b82aeaf | (Elizabeth Mattijsen)++ | doc/Language/list.pod6 Rwerite the "Testing for Elements" section It assumed that you have to convert something to a Set before being able to use a set operator on it. This is not true: set operators will take care of conversion when needed. In the shown example, it was actually detrimental to first convert to a Set, because the (elem) operator can short-circuit whenever it finds a match, so it won't have to examine all ... (6 more lines) |
10:03 | |
synopsebot | Link: doc.perl6.org/language/list | ||
sarna | I'd just like to say I'm thankful for all the work on Rakudo and stuff o/ | 10:04 | |
AlexDaniel | samcv: btw we'll have to discuss this tomorrow-ish ↑ | 10:05 | |
samcv | ok, now (maybe) works for me if it works for you | 10:07 | |
Geth | doc: ea2a05b8d8 | (Elizabeth Mattijsen)++ | doc/Language/list.pod6 Duh, it's using the infix === , not infix =:= |
10:08 | |
synopsebot | Link: doc.perl6.org/language/list | ||
10:13
robertle joined
|
|||
AlexDaniel | samcv: well, I think jnthn also wanted to look at current blockers and stuff | 10:13 | |
samcv | ah ok | ||
AlexDaniel | previous discussion: colabti.org/irclogger/irclogger_log...07-16#l328 | 10:14 | |
10:14
mscha left
10:21
wamba1 joined
10:23
wamba left
|
|||
Ulti | < lizmat> Different Perl 6 books use different styles <--- sure and at least one of those was universally disliked by anyone who was vociferous about something that pointless, Allman or K&R style pick one is not the worst advice... | 10:24 | |
tyil | sarna: are you going to the Perl Conference or Perl workshops? | ||
Ulti: which style was universally disliked? :o | 10:25 | ||
lizmat | Ulti: I'm well aware of those feelings | 10:26 | |
Ulti | the easiest is to just look at what people are using in the ecosystem if you genuinely care about picking one | ||
sarna | tyil: I'm currently in Denmark, haven't heard about any | ||
tyil | ah | ||
there's a conference in Glasgow next month, if that's doable for you | 10:27 | ||
I don't know about other Perl 6 events that would be closer to you, sadly | |||
Ulti | tyil: I believe it was a variant of Ratliff | 10:28 | |
en.wikipedia.org/wiki/Indentation_...liff_style | |||
tyil | oh | ||
sarna | tyil: unfortunately no, I'm a poor uni student :D | ||
Ulti | this sort of stuff is kind of weird it feels like psychology could probably measure which is actually "the best" | ||
tyil | I've seen people use it, but I can admit I'm not too fond of that style either, Ulti :p | ||
sarna | maybe I'll try to convince my colleagues to use perl6 and we'll organise something, who knows | ||
tyil | sarna: I recently lost my job, so it's struggling for me as well to find the means to attend, but I do want to go there | 10:29 | |
Ulti | I think it only matters if you are used to a given style to the point you rapidly parse it visually | ||
in many ways Ratliff would make switching from P6 to Python simpler if you got used to it | |||
which is a definite bonus I can see and fits the concept of the braces exist to demark the end of a block, I can see the logic of it... I just cant quickly look at it is the only problem which is personal to me | 10:30 | ||
Geth | doc: 5e73790ee6 | (Elizabeth Mattijsen)++ | doc/Language/operators.pod6 Elaborate a bit about === - show that it disregards containers - put in link to ValueObjAt to create custom .WHICH methods |
10:31 | |
synopsebot | Link: doc.perl6.org/language/operators | ||
tyil | Ulti: I'd guess using a K&R-like style would work best, since that's what seems to be the standard used by many other books | 10:32 | |
but in the end, it all depends on what an individual likes best | |||
it's impossible to make a book (or other article) that caters to everyone | |||
Ulti | tyil: sure but even then the real zealots start to get into if you cuddle an } else { | 10:33 | |
this is the sort of stuff thats seriously down in the weeds of importance | |||
I think I probably have an inconsistent use of cuddling too, if its a single if and else I will cuddle, if its a chain of elsif I will keep them all uncuddled for clarity and easy cut and paste movement | 10:36 | ||
which if you think about it is a good argument for never having cuddles | 10:37 | ||
tyil | I tend to not use an elsif when possible | ||
given/when looks cleaner imo when you have many cases | |||
lizmat | tyil: but you can cuddle when's just as much | 10:38 | |
tyil | w-why | ||
Ulti | whens you cuddle | ||
lizmat | not saying that you should | ||
tyil | I cuddle my } else {, if I have one | ||
but generally I try to avoid those altogether | |||
lizmat | } when { :-) | 10:39 | |
tyil | no! | ||
lizmat | :) | 10:40 | |
Ulti | the worst would be cuddling your phasers | ||
lizmat | .oO( don't cross the streams! ) |
10:41 | |
Ulti | this is really why I think programming at the developer level should be much more symbolic rather than about crafting text files | ||
there's no reason you couldn't render Perl 6 exactly like Python style white space and negotiate that with saving to file | 10:42 | ||
then all these really stupid arguments go away | |||
tyil | wouldn't it be possible to use a slang to basically apply python style to a perl 6 program | 10:44 | |
Ulti | you would probably have to still allow braces for blocks otherwise you will lose a lot of expressivity | ||
10:45
psychoslave joined
|
|||
Ulti | but yeah Tux has his own Slang to just allow a single white space difference >:D | 10:45 | |
github.com/FROGGS/p6-Slang-Tuxic | 10:46 | ||
lizmat | Tux is very specific: he actually proxies HTML pages to filter out fonts he doesn't like :-) | ||
Ulti | you can probably reuse the code in the Rakudo grammar for indent of here docs too | 10:47 | |
sarna | is there a syntax for multiple traits? like 'is (required, rw)' instead of 'is required is rw' | 10:48 | |
Ulti | then implement all of the Python standard library.... and you have Python 4.0 | ||
10:48
cognominal joined
|
|||
jnthn | sarna: No | 10:49 | |
lizmat | sarna: no there isn't, afaik | ||
sarna | :( | ||
jnthn | "is" is a very short word :) | ||
m: say 'is (required, rw)'.chars | |||
camelia | 17 | ||
sarna | "repetition is bad" got burned into my brain, sorry | ||
jnthn | m: say 'is required is rw'.chars | ||
camelia | 17 | ||
jnthn | It's not even shorter! :P | ||
lizmat | sarna: also, if they get long, I tend to make it a multi-line, with " is" at the start of each line | 10:50 | |
tyil | jnthn: but what if you could do is <required rw> | ||
that will save you a character | |||
jnthn | But traits aren't strings | ||
tyil | not yet | ||
sarna | lizmat: yep, that's what I do as well | ||
tyil | that could be changed | ||
jnthn | lol | ||
no | |||
Eww :) | |||
Ulti | ^ needs more o's | ||
jnthn | In the early says of Perl 6 implementation, on Parrot, various things - including types - we represented as strings. That was "fun" | 10:51 | |
*early days | |||
tyil | if everything is a string | 10:52 | |
you'll have no conversion issues | |||
jnthn | hah :) | ||
Ulti | "fun" <--- punned air quotes as a string? | 10:53 | |
Geth | modules.perl6.org: 71d4c79656 | (Zoffix Znet)++ (committed using GitHub Web editor) | lib/ModulesPerl6/DbBuilder/Dist/PostProcessor/p30METAChecker.pm Harden metachecker against undefs Avoids immediate error causing github.com/perl6/modules.perl6.org/issues/108 |
10:59 | |
10:59
stmuk joined
11:02
jameslenz joined
11:04
dakkar joined
11:06
jameslenz left
|
|||
sarna | how to say an array has to have, for example, seven ints? arr[7] and arr[Int], but how to connect those | 11:09 | |
timotimo | i think you want "my Int @arr[7]" | 11:11 | |
sarna | got it! my Int @arr[7] or my @arr[7] of int | ||
yeah :D | |||
11:11
Ven` left
|
|||
timotimo | shaped arrays are a little bit wonky in some respects, but really only if they have more than one dimension i think | 11:11 | |
sarna | `@arr[6;6] of Int` works just as well as his one-dimensional brother | 11:13 | |
lizmat | timotimo: I think I covered dimensions 1..3 pretty well, above that, it gets a bit wonky indeed :-) | 11:17 | |
timotimo | unless you hit "partially dimensioned views NYI" | 11:18 | |
lizmat | ah, yes | ||
Geth | doc: 208213bdb1 | (Elizabeth Mattijsen)++ | 2 files Document ValueObjAt |
11:20 | |
doc: a5899670b4 | (Elizabeth Mattijsen)++ | doc/Type/List.pod6 Document my int @a; @a.sum(:wrap) |
11:27 | ||
synopsebot | Link: doc.perl6.org/type/List | ||
Geth | doc: e57e45852c | (Elizabeth Mattijsen)++ | doc/Type/ValueObjAt.pod6 Adhere to the way we document actual output |
11:30 | |
synopsebot | Link: doc.perl6.org/type/ValueObjAt | ||
pmurias | Ulti: re developement being more symbolic, making people switch editors is a gigantic barrier to programming language adoption | 11:52 | |
sarna | hey, how to access a private array from a class? self.arr doesn't work, even from inside the class | 11:55 | |
oh well, it's just `@!arr`, weird | 11:56 | ||
lizmat | sarna: yeah, attributes inside a class can always be accessed with sigil ~ ! ~ name | 11:57 | |
the @ sigil just means it needs to get something Positional: | 11:58 | ||
m: my @a := "foo" but Positional; dd @a; dd @a.WHAT | |||
camelia | "foo" Str+{Positional} |
||
lizmat | m: my @a := "foo" | 11:59 | |
camelia | Type check failed in binding; expected Positional but got Str ("foo") in block <unit> at <tmp> line 1 |
||
12:00
Ven` joined
|
|||
kanbas | hey, is there any way to see if coercion to an enum failed? Currently I have enum Stuff( foo => 25, bar => 30 ), and I want to return True for e.g. Stuff(25) and false for e.g. Stuff(40) | 12:06 | |
Stuff(40) is still of type Stuff and Mu, so I can't check with ~~ Stuff or ~~ Mu, and .HOW is also EnumHOW | 12:07 | ||
lizmat | kanbas: enums are compile time, and I assume "40" is just an example of a runtime value, right ? | 12:08 | |
12:08
markoong joined
|
|||
kanbas | lizmat: yeah - I need to take some values and check if they would be valid as enums, but wondered if there was a better way than keeping a map of the Enum collection and looking the value up in it | 12:09 | |
lizmat | so you want to map numeric values to True/False ? | ||
kanbas | Nah, I need to map keywords to numeric values and detect if an incoming Int would be a valid keyword | ||
i'm trying to write a telnet state machine atm, and using enums for the control codes | 12:10 | ||
lizmat | so in fact you're mapping Ints to strings ? | 12:13 | |
(or enums as that may be) | |||
kanbas | yeah, though the current implementation is mapping strings to ints | 12:14 | |
ideally i just want to be able to either lookup the string via the int, or the int via the string | 12:15 | ||
12:15
eliasr joined
|
|||
kanbas | (well, it could do with doing both rather than one or the other) | 12:15 | |
lizmat | perhaps just 2 Maps would be best: | 12:17 | |
m: my %f is Map = foo => 25, bar => 42; my %g is Map = %f.invert; dd %f, %g | |||
camelia | Map.new((:bar(42),:foo(25))) Map.new(("25" => "foo","42" => "bar")) |
||
lizmat | first one is by name, second one by integer value ? | 12:18 | |
kanbas | TIL Map.invert. Yeah that looks like it'd be perfect tbf. Thanks | ||
12:20
sarna left
|
|||
Geth | whateverable: 465332e8e8 | (Aleks-Daniel Jakimenko-Aleksejev)++ | bin/Releasable.p6 Link to rakudo wiki |
12:25 | |
whateverable: aeed5c233e | (Aleks-Daniel Jakimenko-Aleksejev)++ | config-default.json Spam every 20 hours by default So that it shifts a bit every day to cover all timezones. |
|||
tobs | m: enum Stuff(foo => 25, bar => 30); say so Stuff(25):exists; say so Stuff(50):exists | ||
camelia | True False |
||
12:27
releasable6 joined,
ChanServ sets mode: +v releasable6
|
|||
lizmat | tobs: TIL that works :-) | 12:34 | |
m: enum Stuff(foo => 25, bar => 30); say Stuff(25):exists; say Stuff(50):exists | 12:35 | ||
camelia | foo (Stuff) |
||
lizmat | hmmm... that feels wrong | ||
m: enum Stuff(foo => 25, bar => 30); say Stuff(25); say Stuff(50) | |||
camelia | foo (Stuff) |
||
12:35
sena_kun left
|
|||
lizmat | the :exists isn't necessary at all | 12:35 | |
12:35
sena_kun joined
|
|||
timotimo | m: enum Stuff(foo => 25); say Stuff(50):lolwhat | 12:35 | |
camelia | (Stuff) | ||
lizmat | TIL that doesn't work, at least not for the reason you think | ||
timotimo | it just ignores it | 12:36 | |
lizmat | yup | ||
however, you could use that with "with" | |||
timotimo | yeah | ||
lizmat | m: enum Stuff(foo => 25, bar => 30); with Stuff(25) { .say }; with Stuff(50 { die } # doesn't die | 12:37 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1) at <tmp>:1 ------> 3; with Stuff(25) { .say }; with Stuff(507⏏5 { die } # doesn't die… |
||
kanbas | tobs: oh neat, ty also | ||
lizmat | m: enum Stuff(foo => 25, bar => 30); with Stuff(25) { .say }; with Stuff(50) { die } # doesn't die | ||
camelia | foo | ||
lizmat | m: enum Stuff(foo => 25, bar => 30); with Stuff(25) { .say }; without Stuff(50) { say "doesn't exist" } | 12:38 | |
camelia | foo doesn't exist |
||
tobs | m: enum Stuff(foo => 25, bar => 30); say so Stuff(25); say so Stuff(50) | 12:39 | |
camelia | True False |
||
tobs | I see, lizmat++ | ||
AlexDaniel | FWIW we're currently at 50 tickets with testneeded tag | 12:40 | |
some of them are easy, others maybe not | |||
but if anyone is looking for a way to help, perhaps that's a good start :) | |||
github.com/rakudo/rakudo/issues?q=...testneeded | 12:41 | ||
and fail.rakudo.party/t/TESTNEEDED | |||
see also `easy to resolve` tickets: github.com/rakudo/rakudo/issues?q=...resolve%22 | |||
12:43
xtreak left
|
|||
Geth | doc: 4aaa191664 | (Zoffix Znet)++ (committed using GitHub Web editor) | doc/Type/IO/Handle.pod6 Fix incorrect plurification |
12:43 | |
synopsebot | Link: doc.perl6.org/type/IO::Handle | ||
Geth | marketing: 59df463292 | (Zoffix Znet)++ | 14 files Add "Simple Handle" 6.d Teaser Flyer / ID 1531801752 |
12:55 | |
12:56
buggable joined,
ChanServ sets mode: +v buggable
|
|||
Geth | doc: d6b162b2ff | (Elizabeth Mattijsen)++ | doc/Type/Attribute.pod6 Document that "is required($reason)" is also possible |
12:59 | |
synopsebot | Link: doc.perl6.org/type/Attribute | ||
13:02
jameslenz joined
13:03
Ven` left
13:04
eythian joined,
eythian left,
eythian joined
13:07
jameslenz left
13:09
Ven` joined
13:16
brrt joined
13:25
skids joined
13:41
molaf joined
13:46
tbrowder_ joined
13:47
HaraldJoerg1 joined
13:55
uzl joined
14:05
fake_space_whale joined
|
|||
uzl | Hello to everybody! | 14:06 | |
timotimo | greetings uzl | 14:07 | |
jkramer | Is there something in P6 that allows me to assign some value to nothing, like this: | 14:10 | |
m: my @foo = <foo bar baz>; my ($a, _, $c) = @foo | |||
camelia | 5===SORRY!5=== Error while compiling <tmp> Invalid typename '_' in parameter declaration. at <tmp>:1 ------> 3my @foo = <foo bar baz>; my ($a, _7⏏5, $c) = @foo |
||
AlexDaniel | m: my @foo = <foo bar baz>; my ($a, $, $c) = @foo | ||
camelia | ( no output ) | ||
jkramer | Oh true. But that's an actual assignment, isn't that costly? | 14:11 | |
AlexDaniel | if it is costly, then file a ticket. Can be optimized away I'm pretty sure | ||
14:11
zakharyas left
|
|||
jkramer | I mean $ is an actual variable, even though it's value is lost afterwards | 14:11 | |
14:11
zakharyas joined
|
|||
uzl | greetings timotimo! | 14:12 | |
timotimo | could be optimized out, jkramer. maybe it isn't yet, though | ||
uzl | To anyone interested: I've translated Think Perl 6 to Spanish. As of now, I'm going over the translation and fixing typos (at least the one I can spot) and doing minor corrections. | 14:14 | |
Nonetheless, I think it'd benefit from some proofreading. | |||
timotimo | RT #124822 | ||
synopsebot | RT#124822 [new]: rt.perl.org/Ticket/Display.html?id=124822 [CONC] S17-supply/stable.t line:14 reason: doesn't work or can't test | ||
AlexDaniel | .tell jmerelo colabti.org/irclogger/irclogger_log...07-17#l631 | ||
yoleaux | AlexDaniel: I'll pass your message to jmerelo. | ||
timotimo | huh. | ||
AlexDaniel | weekly: colabti.org/irclogger/irclogger_log...07-17#l631 | 14:15 | |
notable6 | AlexDaniel, Noted! | ||
uzl | Gitlab repo: gitlab.com/uzluisf/piensaperl6 | ||
Book (simple) page: uzluisf.gitlab.io/piensaperl6/ | |||
El_Che | Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License | ||
14:15
zakharyas left
|
|||
El_Che | nice | 14:15 | |
AlexDaniel | is it? Kinda non-free if you can't sell | 14:16 | |
I mean in terms of available resources for perl6 that's indeed not bad :) | |||
El_Che | it's not software, o'reilly will not get beter version when somene adapt it and sells it | 14:17 | |
AlexDaniel | timotimo, jkramer: I think it's not optimized currently | ||
uzl | El_Che: It has the same license as Think Perl 6. | 14:18 | |
El_Che | uzl: yes, that's the license I was referring to | ||
uzl | But I think any derived work from it must have the same license? | 14:19 | |
El_Che: Oh, got it! | |||
El_Che | uzl: creativecommons.org/licenses/by-nc-sa/3.0/ | ||
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. | |||
14:19
brrt left
|
|||
uzl | My intended purpose ;) | 14:22 | |
El_Che | uzl++ | ||
uzl | AlexDaniel: No commercial plan behind it! | 14:29 | |
El_Che | uzl: as long as oreilly does not public the book in Spanish, you have a captive market :) | 14:30 | |
uzl | El_Che: just a community effort for Perl 6 to reach far and beyond... | 14:33 | |
14:34
MilkmanDan joined
|
|||
El_Che | good, very useful | 14:34 | |
uzl | Now I'm wondering if using one of those printing services (lulu, etc) fall under commercial. I guess it's not since all the money goes into printing it. | 14:37 | |
jkramer | Hmpf, in some regards P6 is really painfully slow, to a point where it just can't be used for real-life applications. :( | 14:39 | |
bpaste.net/raw/a14abeaf6bcc - this is running for 8 minutes already for a ~130M text file. | |||
timotimo | jkramer: i believe .tail(*-2) is a whole lot faster than .[2..*] | 14:40 | |
14:40
nemo joined
|
|||
jkramer | And using 2G of RAM :D | 14:41 | |
Thanks, I'll try | |||
nemo | been a looong time since I've been here. how do I ask the bot a question again? | ||
I mean. a snippet | |||
camelia that is | |||
timotimo | just m: the code | ||
jkramer | Is .head also faster than .[0] maybe? | ||
nemo | m: 729**⅓ | ||
camelia | WARNINGS for <tmp>: Useless use of "**" in expression "729**⅓" in sink context (line 1) |
||
nemo | O_o | ||
m: print 729**⅓ | 14:42 | ||
camelia | 8.999999999999998 | ||
timotimo | oh, you have to explicitly "say" things | ||
or print, yes | |||
nemo | hm | ||
timotimo | jkramer: should be | ||
nemo | ok. so. if I ask our haskell bot pow(729,1/3) | ||
it returns 9 😝 | |||
so does calculator | |||
what is nqp/camelia/rakudo doing? | |||
gnome-calculator etc | |||
timotimo | floating point calculations | ||
nemo | well obv 😉 | 14:43 | |
timotimo | rakudo just outputs it precisely | ||
14:43
Zoffix joined
|
|||
nemo | hm | 14:43 | |
timotimo | can you check if the result == 9 or not? | ||
nemo | timotimo: so you think the others are just rounding their fp eh | ||
Zoffix | jkramer: what's some sample data you're feeding it with? | ||
lizmat | m: my @a = ^10; @a[0] for ^10000; say now - INIT now | ||
camelia | 0.00898764 | ||
Zoffix | m: say 729 ** ⅓ | ||
camelia | 8.999999999999998 | ||
jkramer | Hmm if I use .head and .tail it complains about the Seq already being used up. No I don't know what's faster/slowing, using .[0] instead of .head or .cache on the Seq :) | 14:44 | |
nemo | our haskell bot says that 729**⅓ ==9 | ||
timotimo | that's good | ||
nemo | well. pow(729,1/3)==9 | ||
lizmat | m: my @a = ^10; @a.head for ^10000; say now - INIT now | ||
camelia | 0.03005977 | ||
lizmat | that is weird | ||
Zoffix | nemo: what about (-125)**⅓ ? | ||
timotimo | oh, it's muhc slower? | ||
jkramer | Zoffix: Just plain text, about 1-10 words per line, plus a line number in the beginning and a separator (the element that's skipped) | ||
nemo | Zoffix: -5 | 14:45 | |
m: say -125**⅓ | |||
camelia | -4.999999999999999 | ||
nemo | m: say -125**⅓==-5 | ||
camelia | False | ||
lizmat | m: my @a = ^10; for ^1000000 { my $a = @a[0]; say now - INIT now | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Missing block at <tmp>:1 ------> 030000 { my $a = @a[0]; say now - INIT now7⏏5<EOL> expecting any of: postfix statement end statement modifier sta… |
||
lizmat | m: my @a = ^10; for ^1000000 { my $a = @a[0] }; say now - INIT now | ||
camelia | 0.3849081 | ||
lizmat | m: my @a = ^10; for ^1000000 { my $a = @a.head }; say now - INIT now | 14:46 | |
camelia | 1.4415858 | ||
lizmat | jkramer: when done on an array, [0] is definitely faster | ||
Zoffix | nemo: -125**⅓ is no the same as (-125)**⅓ | ||
m: say (-125)**⅓ | |||
e: say (-125)**⅓ | |||
lag :( | |||
camelia | NaN | ||
timotimo | but .words is a Seq | ||
evalable6 | NaN | ||
Zoffix | jkramer: well, what's the actual data? | 14:47 | |
jkramer | lizmat: But is it still worth it with the overhead of turning Seq into an Array? :) | ||
lizmat | no, probably not :-) | ||
jkramer | Zoffix: filebin.net/za13pgx296tpfpo3 | ||
timotimo | cool | ||
lizmat | m: my $a = "foo " x 1000; $a.words[0] for ^100000; say now - INIT now | 14:48 | |
camelia | 0.5005249 | ||
lizmat | m: my $a = "foo " x 1000; $a.words.head for ^100000; say now - INIT now | ||
camelia | 0.26912142 | ||
nemo | Zoffix: heh. true. guess I need to wait to see what camelia's response is though | ||
Zoffix | nemo: the response is a NaN | 14:49 | |
You need to force explicit complex to do powers with negative numbers, even if the power is an odd power | |||
e: say (-125+0i)**⅓ | |||
evalable6 | 2.500000000000001+4.330127018922194i | ||
Zoffix | huh | 14:50 | |
nemo | why would it be NAN? | ||
Zoffix: -5*-5*-5 = -125 | |||
oh | |||
weird | |||
required even for odd eh | |||
Zoffix | e: say (<125+1i>)**⅓ | 14:51 | |
evalable6 | 5.000035554712788+0.013333175313586194i | ||
Zoffix | weird | ||
timotimo | jkramer: it doesn't seem like it can even get past the first line :) | ||
ah, the first thing it does is assign to spot number 2087584 | 14:52 | ||
Zoffix | jkramer: are you sure your logic is correct? Starting with the first 6 lines of the file I already get an array with 2087584 elements in it | ||
jkramer: what's this program meant to do? | 14:53 | ||
timotimo | it's supposed to put the words after the # in the nth spot, where n is the first field | ||
i forgot to put input.txt into stdin m) | 14:54 | ||
that's why i didn't get any progress, it was waiting for me to type something in | |||
i'm smart | |||
Zoffix | That just describes what it's doing… | 14:55 | |
14:55
HaraldJoerg1 is now known as HaraldJoerg
|
|||
timotimo | by outputting the +@line at the end, you could also just put all the numbers into a set | 14:56 | |
jkramer | Zoffix: It's a coding challenge. :) The number is the line number (the file is supposed to be a "shuffled" book), so I'm trying to assign the lines to the correct spot in the array instead of reading it all and then sorting by line number to save some time. | ||
timotimo | but i don't think that's the goal, just a benchmark | ||
14:57
ruoso joined
|
|||
jkramer | The code I posted above is just the beginning, there's some more stuff to do with the input, once I manage to read it :) | 14:57 | |
timotimo | we spend a whole lot of time GC-marking the huge array | ||
Zoffix | jkramer: if it's a coding challenge, perhaps it's part of the challenge that you need to come up with a fast algo and has nothing to do with "P6 is really painfully slow, to a point where it just can't be used for real-life applications" | 14:58 | |
nemo | Zoffix: BTW your NaN thing applies to javascript at least | ||
Zoffix: no idea how to even include a negative component in javascript ☺ | 14:59 | ||
er imaginary component | |||
Zoffix | nemo: it's posible the NaN thing comes from IEEE standard | ||
jkramer | Zoffix: Sorry if that came across as a complaint or bashing, but reading a big file is not a very difficult task and the way I'm doing it is already the fastest way (alternative would be to read all lines, then sort it). | ||
timotimo | honestly, it'd be faster to store byte offsets into the file in a native integer array ;) | 15:00 | |
fake_space_whale | have you considered using a hash instead of an array? (I don't know if it would be faster or not) | ||
since that way you wouldn't need to claim as big chunks of memory | |||
at first at least | 15:01 | ||
15:02
jameslenz joined
|
|||
Zoffix | jkramer: except the reading of the file takes just 11 seconds | 15:03 | |
"can't be used for real-life applications" is a pretty bold claim | |||
7 seconds if you .lines a .slurp | |||
timotimo | fake_space_whale: it would actually be faster since it won't have to parse the numbers into an integer | 15:04 | |
but i'm not actually sure how much time it spends parsing, i just saw that it does | |||
jkramer | Zoffix: But that's not what I said or meant. I can't use it for this specific task which I consider a "real-life" scenario. | 15:05 | |
15:06
pmurias left
|
|||
scovit | jkramer: this is much faster for me, gist.github.com/scovit/f162349b4ac...7bd693afac | 15:06 | |
buggable | New CPAN upload: Image-Libexif-0.0.2.tar.gz by FRITH modules.perl6.org/dist/Image::Libexif:cpan:FRITH | ||
15:06
pmurias joined
15:07
jameslenz left
|
|||
jkramer | scovit: Thanks, I'll try that | 15:07 | |
scovit | dunno if it helps.. I often resort to perl5 for these kind of works | ||
nemo | Zoffix: I bet Haskell is doing exact cube root while perl6 and javascript are doing floating point approximations | 15:08 | |
Zoffix | nemo: what about (-1953125)**(1/9) does that give -5 in Haskel? | 15:09 | |
jkramer | scovit: I already implemented it in perl5, I justed wanted to do in Perl6 as well :) | ||
nemo | Zoffix: it does yes | 15:10 | |
Zoffix: and ofc 0.33333333333333333333333333333333333333333333333333!=(1/3) ☺ | |||
scovit | jkramer point is that perl6 is encoding all the strings in unicode | ||
nemo | Zoffix: which is true in javascript | ||
scovit | even if it is not, it still carries all the logic | ||
nemo | m: say 0.333333333333333333333333333333333333333333333333333==⅓ | 15:11 | |
camelia | False | ||
nemo | interesting! | ||
well score one for camelia | |||
Zoffix | m: say 0.33333333333333333333333333333333333333333333333333 ≠ ⅓ | ||
camelia | True | ||
Zoffix | nemo: yeah, because in P6 that's a Rational number, but in JS it's a float, innit? | ||
double | |||
15:11
pmurias left
|
|||
Zoffix | not-rational | 15:11 | |
nemo | Zoffix: oh. ok. well that would explain why Math.pow(-125,1/3) fails in javascript but not perl6 then | 15:12 | |
Zoffix | Well, it does "fail". It gives you NaN | ||
jkramer | scovit: Yours took about 2.5min on my machine, much better :) | ||
nemo | Zoffix: but... odd that it does = -5 in perl6... if it is doing rationals | ||
*doesn't* | |||
m: say (-125)**⅓ | |||
camelia | NaN | ||
Zoffix | nemo: the power op is just C's pow call | ||
[Coke] | Folks - perlfoundation.org updated their website; please feel free to hit me up with any issues you find before it gets publicized more. Already known: YAPC not TPC, confusing YAPC::NA and YAPC north america links, donate button. hit me up with anything else. | ||
nemo | oh oups. I thought that worked | ||
doh | |||
Zoffix | I think | 15:13 | |
nemo | m: say ⅓==1/3 | ||
camelia | True | ||
nemo | oh good | ||
Zoffix | s: &infix:<**>, \(-125, ⅓) | ||
SourceBaby | Zoffix, Sauce is at github.com/rakudo/rakudo/blob/7a7e...l.pm6#L147 | ||
scovit | jkramer happy it helps! | ||
Zoffix | hmm | 15:14 | |
m: say (-125.0)**⅓ | |||
camelia | NaN | ||
Zoffix | s: &infix:<**>, \(-125.0, ⅓) | ||
SourceBaby | Zoffix, Sauce is at github.com/rakudo/rakudo/blob/7a7e...l.pm6#L147 | ||
Zoffix | oh well | 15:15 | |
15:16
uzl left
|
|||
buggable | New CPAN upload: Desktop-Notify-0.3.4.tar.gz by FRITH modules.perl6.org/dist/Desktop::Not...cpan:FRITH | 15:16 | |
15:17
zakharyas joined
|
|||
Zoffix | having trouble profiling jkramer's program | 15:18 | |
Got down to 400 entries and yet the profile is so huge, it kills my browser :/ | |||
15:19
benjikun2 joined
|
|||
Zoffix | At 285 entries it's empty :| | 15:19 | |
And at 145 entries, it's mostly red :/ | 15:20 | ||
15:22
pmurias joined
15:24
psychoslave left
|
|||
timotimo | i wonder if the call graph gets bloated somehow | 15:24 | |
Zoffix | timotimo: looks like it. I managed to sit long enough to load a profile of doing a run over 365-line file. The call graph looks like a cardiogram lol: temp.perl6.party/out.html | 15:25 | |
15:26
psychoslave joined
|
|||
Zoffix | temp.perl6.party/z.png | 15:26 | |
15:26
troys joined
|
|||
timotimo | haha | 15:27 | |
that is funny | |||
in my run it's got 2_704_613 nodes in the call graph | |||
Zoffix | "There was no global deoptimization triggered by the profiled code. There was one global deoptimization triggered by the profiled code. There were 0 global deoptimization triggered by the profiled code." | ||
lol wat? 0 and 1 and "no"? | 15:28 | ||
timotimo | it's the bug that happens in some circumstances due to inlining | ||
15:28
zakharyas1 joined
|
|||
timotimo | turn inlining off and the profile file should become tiny | 15:28 | |
15:28
zakharyas left
|
|||
Zoffix | timotimo: is there something wrong with the code that it made the callgraph look like that or is that just a deficiency in the profiler itself? | 15:29 | |
timotimo | it's a deficiency in the profiler part that lives in moarvm | ||
Zoffix | ok | ||
heh, it tells me <unit> took 2398076729582145.5ms to run :P | |||
I'm older than I thought to have waited so long | |||
timotimo | that's ... also a bug that annoys me | 15:30 | |
Geth | doc: coke assigned to lizmat Issue attribute example dies github.com/perl6/doc/issues/2184 f8d9b441c8 | (Will "Coke" Coleda)++ | doc/Language/list.pod6 |
15:31 | |
synopsebot | Link: doc.perl6.org/language/list | ||
15:32
raschipi joined,
psychoslave left
|
|||
timotimo | postcircumfix:<[ ]> spends like a third(?) of its time in POSITIONS in that code | 15:34 | |
15:34
pmurias left
|
|||
timotimo | i imagine that's the 2..* part | 15:34 | |
Geth | ¦ doc: coke self-assigned attribute example dies github.com/perl6/doc/issues/2184 | 15:35 | |
15:35
pmurias joined
|
|||
tbrowder_ | [Coke]: site needs p6 logo and PERL6.ORG near PERL.ORG link | 15:36 | |
timotimo | push-exactly from Iterator.pm6 is on the top spot with 5.3%, and it's only jitted in small part | 15:37 | |
Zoffix | m: say 0.1150374/0.0808938 | ||
camelia | 1.4220793 | ||
Zoffix | This version is about 42% faster than scovit's gist.github.com/zoffixznet/73f1cb0...4b8ae753f3 | 15:38 | |
timotimo | oh i didn't see scovit suggest a change, let me scroll | 15:39 | |
15:39
pmurias left
|
|||
timotimo | ah, hypered the .words, eh? | 15:39 | |
Zoffix | Yeah | ||
timotimo | i imagine that's a bit slower than the .words inside the for loop's body | 15:40 | |
Zoffix | yeah, like | ||
oh, yeah, I think that's where my speedup comes from | |||
tbrowder_ | [Coke]: would be nice to see EVENTS on the main top bar menu. | ||
timotimo | i imagine it'd be most performant to only split the line in "before the separator" and "after the separator" and only lazily split the words off in the next step | 15:41 | |
that way you have so many fewer long-lived objects on the heap | |||
Zoffix | jkramer: how long does perl5's version take to run? | 15:42 | |
scovit | Zoffix I think that your version is faster because of Seq instead of List | 15:44 | |
timotimo | m: say 1000000 / 26 | ||
camelia | 38461.538462 | ||
timotimo | 38.5k lines per second | ||
15:44
psychoslave joined
|
|||
scovit | but it is surprising to me that the assignment in the for loop body leads to a .cache | 15:44 | |
Zoffix | scovit: @a = .words consumes the Seq and creates an Array | 15:45 | |
no cache | |||
scovit | right | 15:46 | |
timotimo | my assumption it'd be faster with a hash was wrooooong | ||
Zoffix | :) | ||
timotimo | GC for arrays that are mostly null slots is extremely expensive | 15:51 | |
15:52
wamba1 left
15:55
pmurias joined
|
|||
timotimo | if we knew that up front, we could switch to an implementation that tries to skip multiple slots at a time | 15:55 | |
15:56
psychoslave left
|
|||
Zoffix | What is it GCing tho? There's just one mostly-null-slot array in there, isn't there? | 15:56 | |
timotimo | yeah | ||
but it has to go through all 2 million or what slots | |||
mienaikage | What's happening in the following? Switching to a block or using '==' works as expected. Does LHS not become the topic here?: | ||
subset Tuesday of Date where *.day-of-week ~~ 2; | |||
15:56
brrt joined
|
|||
Zoffix | timotimo: But why is it GCing it? It's one object that's living through the whole program? | 15:57 | |
timotimo | mienaikage: ~~ will make the RHS the topic of the LHS | ||
Zoffix | mienaikage: the closure ends before the ~~ | ||
timotimo | Zoffix: check the difference between full and minor collections | ||
i have a profile here that looks like this: The profiled code did 5986 garbage collections. There were 9 full collections involving the entire heap. | 15:58 | ||
The average nursery collection time was 12.24ms. The average full collection time was 326.39ms. | |||
15:58
zakharyas1 left
|
|||
timotimo | the trick is that the last gc run, number 5201, took 978ms | 15:58 | |
mienaikage | 👍 | ||
timotimo | number 3680 is 687.6ms | 15:59 | |
Zoffix | There's a doc issue for making info on whatevercodes clearer D#2017 | 16:00 | |
synopsebot | D#2017 [open]: github.com/perl6/doc/issues/2017 [docs] Docs on Whatever curry could be clearer / don't cover everything | ||
timotimo | but also the minor collections start at about 3ms, but end at about 19ms | ||
Zoffix | You can also dump the QAST with --target=optimize and see the subset's matcher thunked your thing and it's basically a `{ *.day-of-week ~~ 2 }.ACCEPTS: $param's-value`: gist.github.com/zoffixznet/94af7dc...5b556cde21 | 16:01 | |
.oO( maybe this should warn... ) |
|||
m: { *.so } # like we do here | 16:02 | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Malformed double closure; WhateverCode is already a closure without curlies, so either remove the curlies or use valid parameter syntax instead of * at <tmp>:1 ------> 3{ *.so } # like we do here7… |
||
16:03
brrt left
|
|||
Zoffix | mienaikage: filed R#2086 for that | 16:04 | |
synopsebot | R#2086 [open]: github.com/rakudo/rakudo/issues/2086 [LTA][RFC] Maybe warn when thunking `*.foo ~~ $bar` constructs? | ||
16:05
Khisanth joined
16:06
robertle left
|
|||
jkramer | Zoffix: In total ~12sec, but that includes solving the actual challenge as well, not just reading and sorting lines into the array | 16:08 | |
Zoffix | Interesting. A mostly-nqp version of the code is a bit SLOWER than my last version above | 16:09 | |
for ~16K rows, the HLL version takes 0.5290986 and NQP one … oh, nm, they're the same… I think it was just noise, NQP is 0.52661446 | 16:10 | ||
This one: gist.github.com/zoffixznet/1670ac2...f252eb94de | |||
jkramer | I also have an implementation in rust (~5.5sec) and C (~1.1sec) :) | 16:11 | |
Zoffix | Which is awesome news, no? Means it's one of the cases where we *are* converting HLL version to basic bits that's NQP version | ||
jkramer: is that 12 sec with full UTF8 encoding? | |||
lizmat smells a blog post | 16:13 | ||
jkramer | Zoffix: No, just bpaste.net/show/0e705b0135cf | ||
Zoffix | mhm | ||
jkramer | Oh actually that's a bit unfair because it doesn't split _all_ words | ||
No wait. It does, later in the code :) | |||
Zoffix | That's one of the things that makes p6 version slower. You pay automatically for encoding and graphemes and all taht stuff | 16:14 | |
timotimo | it also doesn't - 1 on the $n | ||
jkramer | timotimo: Yes but later when iterating over the sorted array it does a defined check on all rows. Actually I think removing that and doing the -1 instead would be faster | 16:15 | |
I'm gonna try that | |||
timotimo | i'll be afk for a bit | ||
16:17
Zoffix left
|
|||
jkramer | No, didn't really change anything | 16:17 | |
16:21
guest__ joined
16:30
isacl joined
16:31
scimon left
16:34
wamba joined
|
|||
tbrowder_ | AlexDaniel: any objection to a doc merge if i use a different bar style row separator (thinner, but double-line)? | 16:39 | |
16:39
dakkar left,
guest__ left
|
|||
AlexDaniel | tbrowder_: uh… well… let's merge it and then modify to our liking… | 16:48 | |
16:48
perlpilot joined
|
|||
tbrowder_ | ok, will do | 16:56 | |
Geth | doc/master: 7 commits pushed by (Tom Browder)++ | 16:57 | |
17:01
donpdonp joined
|
|||
donpdonp | whats the right way to give grep a block, this is my best non-funcitonal try: [1,2].grep {element == 2} | 17:01 | |
timotimo | you need either a : after grep, or parenthesis around the block | 17:02 | |
donpdonp hmms | |||
timotimo | because it's a method call | ||
sub calls take everything after themselves as arguments, method calls don't | |||
donpdonp | what do I use for 'element' | 17:03 | |
17:03
jameslenz joined
|
|||
timotimo | oh | 17:03 | |
$_ would be your candidate | |||
i mean, i'd probably have written it as a whatevercode, or with just the 2 instead of a block | |||
m: say "2" ~~ 2 | 17:04 | ||
camelia | True | ||
timotimo | mhm mhm | ||
donpdonp | interesting thx. | ||
timotimo | because grep uses smartmatch | ||
donpdonp | whats the significance of grep: {expr} over grep(expr) | ||
timotimo | foo.grep: ... will take everything after it as arguments as well | ||
raschipi | donpdonp: It's the same thing. | ||
perlpilot | raschipi, not quite | 17:05 | |
timotimo | and you can't use : with grep if you use it as a sub | ||
grep: {expr} will be a label followed by a bare block | |||
greppable6 | timotimo, Found nothing! | ||
timotimo | thank you greppable6 | ||
m: thissubdoesntevenexist: 1 | |||
camelia | WARNINGS for <tmp>: Useless use of constant integer 1 in sink context (line 1) |
||
donpdonp | timotimo: great. thx. | ||
raschipi | right, only works for methods. | ||
17:05
domidumont joined
|
|||
raschipi | It's possible to call methods like they are subs using 'method Object: arg1, arg2' too. | 17:06 | |
17:07
jameslenz left
|
|||
timotimo | yup, think of it like "new Foobar: 1, 2, 3" | 17:10 | |
[Coke] | timotimo: that's a label, no? | 17:11 | |
jkramer | Interestingly, reading the whole file first and then sorting the lines is faster than putting the lines into their slot directly :) my @input = lines.sort: { +.substr(0, .index(' ')) }; | 17:13 | |
raschipi | It's indirect method call. | ||
timotimo | [Coke]: no, only single identifiers in front of the : are labels | ||
jkramer | This is about ~30s fast than scovit's approach from earlier today on my machine | ||
*er | |||
timotimo | jkramer: that'll probably significantly cut down on GC time for all the empty slots that would otherwise be in the array early on | 17:14 | |
[Coke] | timotimo: thissubdoesntevenexist is a single identifier... | 17:17 | |
donpdonp | is there a way to say "use Cro::HTTP::Client as Client" so I can say "Client.get($url)" instead of "Cro::HTTP::Client.get($url)" | 17:18 | |
timotimo | const Client = Cro::HTTP::Client; should work | ||
El_Che | make an object? | ||
timotimo | [Coke]: oh, you meant that line. yes, that was an example of a label | 17:19 | |
[Coke] | perl6 --target==barf ... be nice if this told you what valid targets were. | ||
raschipi | [Coke]: does it at least barfs though? | ||
Geth | doc: 826c3b9e6f | (Aleks-Daniel Jakimenko-Aleksejev)++ | manage-page-order.p6 Just say `Category` instead of annoying unicode art |
17:25 | |
[Coke] | yes, you get: Unknown compilation target '=barf' | ||
17:25
zakharyas joined
|
|||
AlexDaniel | tbrowder_: so… let's talk about it a bit more… | 17:25 | |
[Coke] | but then a bunch of nqp stacktrace | ||
AlexDaniel | tbrowder_: why can't we have a separate table for every category? | ||
raschipi | So it's doing exactly what you asked for? | ||
donpdonp | timotimo: where would be a good place to put that const in the .pm6? this is how not to do it: module { const Client = Cro::HTTP::client; sub go($url) { Client.get($url) }; | 17:27 | |
17:27
sarna joined
|
|||
timotimo | you'll also need a "use", but other than that the position should be fine, as long as it's not an "our constant" | 17:27 | |
constants are "my" scoped by default, right? | |||
Geth | doc: 8cc0fde924 | (Aleks-Daniel Jakimenko-Aleksejev)++ | manage-page-order.p6 Empty subtitle for categories After thinking about it a bit more, no subtitle will make it more appealing visually. That's a temporary solution anyway. |
||
El_Che | my $client = Cro::HTTP::client.new; $client.get($url) | ||
sarna | hey, so I have an object with a list of objects in it. how do I populate this list? I put a loop in BUILD() that creates objects, but it doesn't seem to work | 17:28 | |
donpdonp | El_Che: many sub's in the module will need Client, so im trying to put it at the module-level if thats possible | ||
El_Che | donpdonp: I see | ||
is it OO? it could be an attribute | 17:29 | ||
Geth | doc: 0d7b7c93a9 | (Rafael Schipiura)++ (committed using GitHub Web editor) | doc/Language/contexts.pod6 Numeric context converts to numeric. |
||
synopsebot | Link: doc.perl6.org/language/contexts | ||
tbrowder_ | AlexDaniel: good idea for the next step. | ||
donpdonp | timotimo: use Cro::HTTP::Client; module Commands { const Client = Cro::HTTP::Client; => Preceding context expects a term, but found infix = instead. | ||
timotimo | oh? | 17:30 | |
perlpilot | donpdonp, except you'll want to spell "const" as "constant" :) | ||
timotimo | d'oh, yes, constant not const | ||
we can put a better error message for that in the parser! | |||
donpdonp | ha thx perlpilot ! | ||
too much typescript i think. | |||
raschipi | AlexDaniel tbrowder_ : Also, remove the bit about "mostly alphabetical order" at the top while you're at it. | 17:34 | |
17:36
Xliff joined,
Xliff left
17:40
Xliff joined
|
|||
AlexDaniel | raschipi++ | 17:40 | |
Geth | doc: 46a7470c01 | (Aleks-Daniel Jakimenko-Aleksejev)++ | htmlify.p6 The list is no longer in alphabetical order |
||
Xliff | \o | 17:43 | |
<- New supporter of comma. | |||
moritz | Xliff++ | ||
sena_kun | Xliff++ | 17:44 | |
perlpilot | I like commas too They go well between items ;) | 17:46 | |
Geth | doc: a2336a5fe2 | (Zoffix Znet)++ (committed using GitHub Web editor) | doc/Type/Any.pod6 Reword implementation-specific versioning of 6.d feature |
17:47 | |
synopsebot | Link: doc.perl6.org/type/Any | ||
raschipi | But not periods. | 17:48 | |
17:49
Zoffix joined
|
|||
Zoffix | What's a really awesome example of .toggle's use? docs.perl6.org/routine/toggle | 17:49 | |
Xliff | Yeah. Does Comma come with any docs? I am trying to use it to debug p6 code. | ||
17:50
fbynite joined
|
|||
timotimo | the debug support isn't quite fantastic yet | 17:50 | |
commaide.com/docs - this is the odcs | |||
tbrowder_ | AlexDaniel: putting doc/Language categories alone on the language page with links to a separate page is good. Or we could have collapsible lists under the categories. | ||
Zoffix | *crickets* | 17:52 | |
Xliff | m: ( (^10).toggle: * %% 2).say | ||
camelia | (0) | ||
tbrowder_ | At any rate, for now I’m going to go back to working on pod =defn. Anyone is weclome to continue to move the docs toward your vision if they wish. | 17:53 | |
Xliff | m: ( (^10).toggle: * %% 2, :off, * > 8).say | ||
camelia | (0) | ||
perlpilot | Zoffix, maybe something with identifying a square wave out of some random data? (I clearly don't have any awesome examples) | ||
Xliff | m: ( (^10).toggle: * %% 2, * > 8).say | ||
camelia | (0 9) | ||
Xliff | m: ( (^10).toggle: * %% 2, :on, 7, * > 8).say | ||
camelia | No such method 'CALL-ME' for invocant of type 'Int' in block <unit> at <tmp> line 1 |
||
Zoffix | Xliff: so what does that do? | ||
Xliff | m: ( (^10).toggle: * %% 2, :on, * == 7, * > 8).say | ||
camelia | (0 7) | ||
Xliff | Zoffix: I'm moving to camelia. Trying to figure it out. | 17:54 | |
Zoffix | heh | ||
c'mon, it's a new feature in 6.d! It's meant to be awesome for something | |||
perlpilot | Seems like an example that would be good for ff would also be good for .toggle (but with extra behavior because of the callables) | 17:55 | |
17:56
imcsk8_ joined
|
|||
Zoffix | m: say ^10 .toggle: :off, * > 3, * < 8 | 17:57 | |
camelia | (4 5 6 7) | ||
Zoffix | m: say ^10 .grep: 3 < * < 8 | ||
camelia | (4 5 6 7) | ||
17:58
sarna left
|
|||
Xliff | Yeah. The syntax of toggle is weird. | 17:58 | |
Would be better if there was a clear indication of what is on and what is off | |||
tyil | I reposted one of the reddit threads mentioned in the p6weekly to other subreddits, for those interested in a discussion: old.reddit.com/r/programming/comme...at_should/ and old.reddit.com/r/ProgrammingLangua...at_should/ | ||
Geth | atom-language-perl6: threadless-screw++ created pull request #86: Variable identifiers with embedded dashes/apostrophes highlight properly |
17:59 | |
Zoffix | heh | ||
visiting that URL killed my browser | |||
Xliff | m: ( (^10).toggle: :on, * < 3, *.is-prime ).say | ||
camelia | (0 1 2 5 6 7 8 9) | ||
tyil | :( | ||
Xliff | ^^ Not clear here as to what is going to show. | ||
tyil | it shouldn't do that | 18:00 | |
Zoffix | Didn't get a chance to read the answer that started with "find relevance in modern programming language" | ||
Xliff | 0, 1, 2 are there by the first condition. 4 is skipped by the *is-prime | ||
So why the 6, 7, 8, and 9? | |||
Zoffix | Xliff: did you read the documentation for the method? | ||
Xliff | Yeees. | ||
perlpilot | you're missing an arg | 18:01 | |
Xliff | m: ( (^10).toggle: :on, * < 3, *.is-prime, :off ).say | ||
camelia | (0) | ||
perlpilot | I mean if you wanted is-prime to modulate the "on" values | ||
Xliff | m: ( (^10).toggle: :on, * < 3, :on,*.is-prime, ).say | ||
camelia | (0 1 2 5 6 7 8 9) | ||
Xliff | Again. Docs aren't clear and neither is the syntax. | 18:02 | |
Zoffix | Xliff: :on is the default. It keeps producing els while first callable is true, that happens for 0, 1, 2, then it toggles and switches to the next callable in the list, which is *.is-prime, 5 makes that true, so it toggles again, and there are no other callables, so it remains on until the rest of the sequence, giving you 6, 7, 8, and 9 | ||
Xliff | I figured that out. | 18:03 | |
Zoffix | Xliff: there's no special syntax involved, so you using `:on` and `:off` named args in certain places has no effect on anything. They're unordered | ||
Xliff | m: ( (^10).toggle: :on, * < 3, *.is-prime, *.is-prime ).say | ||
camelia | (0 1 2 5) | ||
Xliff | So why no 7? | ||
Zoffix | Xliff: it toggles off on 6, and there are no more callables, in the list so it never switches back on | 18:04 | |
m: say ^10 .toggle: *.is-prime xx * | |||
camelia | (2 3 5 7) | ||
Zoffix | m: say ^100 .toggle: *.is-prime xx * | ||
camelia | (2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97) | ||
Zoffix | m: say ^100 .grep: *.is-prime | ||
camelia | (2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97) | ||
Xliff | m: ( (^10).toggle: :on, * < 3, *.is-prime xx 4 ).say | ||
camelia | (0 1 2 5 7) | ||
Xliff | m: ( (^100).toggle: :on, * < 3, *.is-prime xx 4 ).say | ||
camelia | (0 1 2 5 7) | ||
Zoffix | .ask lizmat do you remember what was the usecase for .toggle? I need something nice and awesome for a 6.d teaser poster | 18:05 | |
yoleaux | Zoffix: I'll pass your message to lizmat. | ||
Xliff | ^^ That says to me that I should get the next 4 prime numbers. | ||
18:05
domidumont left
|
|||
Xliff | m: ( (^100).toggle: :on, * < 3, *.is-prime xx 6 ).say | 18:05 | |
camelia | (0 1 2 5 7 11) | ||
Xliff | ^^ You'd have to know where the next prime number is to get to 11 | 18:06 | |
18:06
domidumont joined
|
|||
Zoffix | You'd just use .grep for that | 18:06 | |
Xliff | Well.... you asked for a cool use. I'm trying, here! | ||
Numbers less than 3, the next 4 prime numbers and numbers within a range. | 18:07 | ||
That would be a cool use of toggle. | |||
m: ( (^100).toggle: * ~~ 10..30).say | |||
camelia | () | ||
Xliff | m: ( (^100).toggle: * < 10, * ~~ 10..30).say | 18:08 | |
camelia | (0 1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87… | ||
Xliff | m: ( (^100).toggle: * < 9, * ~~ 10..30).say | ||
camelia | (0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 8… | ||
tyil | also, for what it's worth, the Den Bosch Linux User Group is now making use of Perl 6 on their mail server :> | 18:09 | |
Xliff | m: ( (^100).toggle: * < 9, * ~~ 10..30, &is-prime).say | ||
camelia | (0 1 2 3 4 5 6 7 8 10 11) | ||
Zoffix | Xliff: yeah, but that describes a grep condition. | ||
Xliff throws hands up in the air. | |||
I guess I just don't grok the coolness, yet. | |||
raschipi | You don't toggle the coolnesss. Yet. | 18:10 | |
18:10
domidumont left
18:11
donpdonp left
|
|||
Xliff | A grep filter will do me just fine until I do. | 18:11 | |
perlpilot | Maybe in data processing where your conditions are something like "header lines match this pattern" and "data lines match this pattern" where you're given a sequence of lines where there's junk lines before/after the header/data lines | 18:13 | |
I dunno. I can't imagine any neat examples for .toggle | 18:14 | ||
Xliff | That sounds on the right track though, perlpilot | ||
AlexDaniel | yeah maybe something similar to stuff you'd use ff operator for: docs.perl6.org/routine/ff | ||
Xliff | .toggle: *.is-header, ( (*.is-junk, *.is-data) xx 5 ).flat # Cover a header and 5 groupings of junk and data. | 18:16 | |
Zoffix | But again, that's a grep, not a toggle | 18:17 | |
m: say <a 42 b c d e 100 d> .toggle: :off, +* | |||
perlpilot | yeah | ||
camelia | (42 b c d e 100 d) | ||
Zoffix | m: say gather for <a 42 b c d e 100 d> .lines { .take if 42 ff 100 } | 18:18 | |
camelia | () | ||
Zoffix | .oO( does that docs example even work ) |
18:19 | |
nope | |||
yup (forgot to CTRL+S, I think) | 18:20 | ||
18:20
pmurias left
|
|||
Zoffix | m: say gather for <a 42 b c d e 100 d> { .take if 42 ff 100 } | 18:21 | |
camelia | (42 b c d e 100) | ||
Zoffix | m: say gather for <a 42 b c d e 100 d 100> { .take if 42 ff 100 } | ||
camelia | (42 b c d e 100) | ||
18:22
zakharyas left
|
|||
Zoffix | m: say <a 42 b c d e 100 d> .toggle: :off, * == 42, * == 100 | 18:22 | |
camelia | Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5a' (indicated by ⏏) in block <unit> at <tmp> line 1 |
||
Zoffix | m: say <a 42 b c d e 100 d> .toggle: :off, {+$_ andthen $_ == 42}, {+$_ andthen $_ == 100} | ||
camelia | (42) | ||
Zoffix | m: say <a 42 b c d e 100 d> .toggle: {+$_ andthen $_ == 42}, {+$_ andthen $_ == 100} | ||
camelia | (100 d) | ||
perlpilot | .toggle still makes me think of square waves and leading/trailing edges. | 18:23 | |
Zoffix | This kind of problems don't occur when devs document the stuff they implement, because they know why they're implementing | ||
Instead of having some one else describe the behaviour of the implementation in the docs, rather than the purpose of the routine | 18:24 | ||
SmokeMachine | Zoffix: is it cool? `ifconfig | perl6 -e 'say join "\n", lines.toggle: :off, * ~~ /^lo/, * ~~ /^\s+/'` | 18:25 | |
perlpilot | Zoffix, just look at the IRC logs from Nov 2017 and see what lizmat was thinking! ;-> | 18:26 | |
Zoffix | perlpilot: way ahead of you :) | ||
The original names were skip-until and skip-while | |||
TimToady | m: my %orig = :1a, :2b; my %new = :5b, :6c; %orig «=« %new; dd %orig | 18:28 | |
camelia | Hash %orig = {:a(1), :b(5), :c(6)} | ||
TimToady | kjk: ^^^ | ||
Zoffix | SmokeMachine: I guess | ||
I was expecting {/^eth1/}, {/^\s+/} to also work, | |||
m: my $c := {/^eth1/}; if $c("eth") {say 42 } | 18:29 | ||
camelia | ( no output ) | ||
Zoffix | Oh, I ran it with `perl` | 18:30 | |
$ perl -e 'my $c := {/^eth1/}; if $c("eth") {say 42 }' | |||
Use of := for an empty attribute list is not allowed at -e line 1. | |||
was gonna yell at it :} | |||
18:31
Xliff left
|
|||
Zoffix | m: my $c := {?/^eth1/}; dd $c("eth") | 18:31 | |
camelia | Bool::False | ||
Zoffix | m: my $c := {?/^eth1/}; dd $c("eth1") | ||
camelia | Bool::True | ||
Zoffix | oh | ||
OK, now I get why {/^eth1/} doesn't work | |||
SmokeMachine: the uncool part is * ~~ /^lo/ looks really gross :) | |||
SmokeMachine | Zoffix: `*.starts-with("lo")` ? | 18:32 | |
Zoffix | I was thinking more of smartmatching | 18:33 | |
Like taking a bunch of matchers instead of just a bunch of callables | |||
TimToady | kjk: Unless something has changed since I last looked at it, I suspect «=« is implemented key-by-key, but ,= is gonna do the stupid thing; one should try timing it both ways, of course | ||
Zoffix | You could write it as .toggle: :off, /^lo/, /^\s/ | ||
SmokeMachine | Zoffix: why only `/^lo/` doesnt work? that have to be a Callable... why? | 18:34 | |
Geth | doc: d2a28d2c03 | (Clifton Wood)++ | doc/Language/nativecall.pod6 - Fixes bad link in route page for nativecast. |
||
doc: 43cbe0e463 | Altai-man++ (committed using GitHub Web editor) | doc/Language/nativecall.pod6 Merge pull request #2180 from Xliff/master - Fixes bad link in route page for nativecast. |
|||
synopsebot | Link: doc.perl6.org/language/nativecall | ||
SmokeMachine | Zoffix: that was my first try... | ||
Zoffix | SmokeMachine: ifconfig | perl6 -e '/^eth1/ fff^ !/^\s+/ and .say for lines' | ||
:) | |||
SmokeMachine: why it has to be a Callable? Dunno, it was designed that way, I guess | 18:35 | ||
But it's not too late to change it | |||
SmokeMachine | www.irccloud.com/pastebin/lI8nQoWQ/ | ||
Zoffix | SmokeMachine: yeah, that's cause Regex is a Callable | 18:36 | |
but you can't just call it with a string | |||
AlexDaniel | gah did I break the doc build | ||
SmokeMachine | Zoffix: couldnt it be just like grep? | 18:37 | |
m: say grep ^100: /^2/ | |||
camelia | (2 20 21 22 23 24 25 26 27 28 29) | ||
SmokeMachine | Zoffix: talking about grep... why this doesnt work? | 18:39 | |
m: say map ^100: :is-prime | |||
camelia | Cannot resolve caller map(Range: :is-prime); none of these signatures match: ($: Hash \h, *%_) (\SELF: █; :$label, :$item, *%_) in block <unit> at <tmp> line 1 |
||
SmokeMachine | m: say map ^100: * ~~ :is-prime # if it works... | 18:40 | |
camelia | (False False True True False True False True False False False True False True False False False True False True False False False True False False False False False True False True False False False False False True False False False True False True … | ||
SmokeMachine | i mean with grep... | ||
m: say grep ^100: :is-prime | |||
camelia | Cannot resolve caller grep(Range: :is-prime); none of these signatures match: ($: Bool:D $t, *%_) ($: Mu $t, *%_) in block <unit> at <tmp> line 1 |
||
SmokeMachine | m: say grep ^100: * ~~ :is-prime | ||
camelia | (2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97) | ||
Zoffix | m: say map ^100: (:is-prime) | 18:41 | |
camelia | Cannot resolve caller map(Range: Pair); none of these signatures match: ($: Hash \h, *%_) (\SELF: █; :$label, :$item, *%_) in block <unit> at <tmp> line 1 |
||
Geth | doc: 78fd2efec4 | (Aleks-Daniel Jakimenko-Aleksejev)++ | manage-page-order.p6 No subtitle instead of empty subtitle Otherwise Pod::To::BigPage seems to be unhappy. |
||
Zoffix | m: say ^100 .grep: (:is-prime) | ||
camelia | (2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97) | ||
Zoffix | SmokeMachine: 'cause .map takes a mapper, not a matcher | 18:42 | |
SmokeMachine | isnt it mapping to Bool? | ||
TimToady | it's smartmapping to Bool :P | 18:43 | |
Zoffix | SmokeMachine: it's not doing anything. There isn't any candidate that accepts Pair as a mapper | ||
SmokeMachine | Zoffix: sure! its not using `~~`, sorry I was thinking of grep... | 18:44 | |
but shouldnt `.toggle` behave as grep? | |||
TimToady: :P | 18:45 | ||
Zoffix | R#2088 | ||
synopsebot | R#2088 [open]: github.com/rakudo/rakudo/issues/2088 [RFC] Make .toggle take matchers, not just Callables | ||
SmokeMachine | :) | ||
you are faster than I thought | |||
TimToady suspects Zoffix downloaded his brain into a supercomputer a year or two ago | 18:47 | ||
18:47
Ven` left
|
|||
Zoffix suspects there is more than one Zoffix and they all pretend to be the same person to appear to do stuff super fast | 18:48 | ||
TimToady | you can say that again | ||
Geth | doc: 6639ef1811 | (Will "Coke" Coleda)++ | xt/examples-compilation.t add note |
18:49 | |
doc: 896c9bd363 | (Will "Coke" Coleda)++ | doc/Type/List.pod6 fix example compilation |
|||
synopsebot | Link: doc.perl6.org/type/List | ||
[Coke] wonders why we have new top level .p6 files in doc | 18:50 | ||
SmokeMachine | Do all Zoffix have a lock? how does they syncronize the job? whitch one do the boring tasks? :P | ||
[Coke] | wasn't tbrowder_ one of the people that was just concerned about that? | ||
Zoffix | SmokeMachine: here's another cool one. Get all the changes for last Rakudo release: ./perl6 -e 'for lines.toggle: :off, {?/^\S/}, {?/\s+/} { .say }' docs/ChangeLog | 18:51 | |
:) | 18:52 | ||
SmokeMachine | :) | ||
perlpilot | If .toggle had some way to distinguish between toggling from on to off and off to on and/or when to actually switch the callable, then it would have a way to do something with leading/trailing edges of square waves. And it could also have the same distinction as ff and fff. (I dunno how useful that is though given I don't entirely grok .toggle :-) | ||
I mean, I understand what we've got, I just don't quite understand why we've got it | 18:53 | ||
Zoffix | ./perl6 -e 'for lines.toggle: :off, ({?/^\S/}, {?/\s+/}) xx 3 { .say }' docs/ChangeLog | ||
Change log for last 3 releases | |||
wooo, I think I finalle grok it :P | 18:54 | ||
perlpilot | I think anyone who uses .toggle is going to have to do mental exercises each time to understand the results. That's somewhat counter productive. (Or maybe there just hasn't been an awesome enough example yet that makes it clear to everyone :-) | 18:57 | |
Zoffix | Or maybe the docs suckl | 18:58 | |
perlpilot | m: say ^20 .toggle: * < 4, * < 7, * < 12 | 18:59 | |
camelia | (0 1 2 3 5 6 7 8 9 10 11) | ||
perlpilot | I still have to *really* think about it to understand what's happening there. | 19:00 | |
Zoffix | The originally suggested .while/.until is kinda a better name **to understand the workings**: `.toggle: :off, {?/^\S/}, {?/\s/}` => (starting with off position) .until {?/^\S/} is true, don't take stuff; then, .while {?/\s+/} is true take stuff; then, ooops.. ran out of toggles and we're toggled off, so we won't take any more stuff | ||
perlpilot | I don't know that I'd go "oh! of course!" if I ran across it in the wild | ||
AlexDaniel | perlpilot: sure, but what's the alternative? | 19:01 | |
I mean, toggle was introduced because there was no better way, sort of | |||
Zoffix | perlpilot: what you wrote is not the common case, I think. A common case is to toggle once (based on discussions in 2017 logs). So understanding `.toggle: * < 4, * < 7, * < 12` is equivalent to understanding a multi-line grep or something | ||
perlpilot | Zoffix, "common case"? Have you seen what sort of crazy stuff people write? ;) | ||
Zoffix | perlpilot: the common case designed for | 19:02 | |
@pressure-readings.toggle: * > .005 { FIRST say "our spacecraft entered the atmosphere!"; say "Current atmospheric presure: $_" } | 19:03 | ||
perlpilot | AlexDaniel, the alternative is more code that is perhaps clearer in intent. | ||
19:03
jameslenz joined
|
|||
Zoffix | That's a good example actually | 19:03 | |
AlexDaniel | perlpilot: well, that code should work nicely with Seqs :) | ||
19:04
fbynite left
|
|||
Zoffix | Well, missing `:off`, but whatever | 19:05 | |
perlpilot | Show me an example that uses 3 or more conditions. That would be the best for the docs IMHO. | 19:06 | |
Zoffix | In .toggle? | ||
perlpilot | aye | ||
Zoffix | "<Zoffix> perlpilot: what you wrote is not the common case," | ||
SmokeMachine | I would like `list.while(/^lo/).until(/^$/)` | ||
Zoffix | That's like saying, show me a grep with a dozen conditions. That would be the best for the docs | 19:07 | |
19:07
jameslenz left
|
|||
perlpilot | eh, I don't think so. Toggling once or twice is easy-ish *without* .toggle | 19:08 | |
Zoffix | perlpilot: ok, let's see it | ||
in code | |||
perlpilot | heh, I knew you were going to say that :) | ||
Zoffix | :) | ||
raschipi | 'say ^20 .toggle: * < 4, * < 7, * < 12' from the explanation above, I would expect this to be (0, 1, 2, 3, 7, 8, 9, 10, 11) | ||
Zoffix | m: say ^20 .toggle: * < 4, * < 7, * < 12 | 19:09 | |
camelia | (0 1 2 3 5 6 7 8 9 10 11) | ||
perlpilot | raschipi, the * < 7 condition is used once and throw away (because of the toggling) | 19:10 | |
s/throw/thrown/ | |||
Zoffix, I don't have any code in my head right now, so I'll retract my statement until I can come up with some actual code for it. But it still *feels* easyish given that I've written such code many times before (though not in P6 nor with a Seq) | 19:11 | ||
Zoffix | 'say ^20 .toggle: * < 4, * < 7, * < 12' => we're starting in on position, so the first is `.while` => .while * < 4 is true, take stuff (we take 0, 1, 2, 3); we switch to .until => until * < 7 we don't take stuff, it's immediatelly true, so we toggle to .while => .while * < 12 is true, take stuff, so we take 5, 6, 7, 8, 9, 10, 11, now we toggle, there's no more callables, so we remain off | 19:12 | |
raschipi | I see, so it's not a toggle? | 19:13 | |
Zoffix | raschipi: what do you mean? It does toggle from on and off | ||
SmokeMachine: yeah, the .while + .until pair is better than a single .toggle | |||
raschipi | m: say ^20 .toggle: * > 4, * > 7, * > 12 | ||
camelia | (8) | ||
19:14
jmaslak joined
|
|||
Zoffix | `m: say ^20 .toggle: * > 4, * > 7, * > 12` => `m: say ^20 .toggle: [take all that stuff that's * > 4], [ignore all the stuff that's * > 7], [take all the stuff that's * > 12]` | 19:19 | |
`m: say ^20 .toggle: * > 4, * > 7, * > 12` => `m: say ^20 .toggle: [take until * > 4], [ignore until * > 7], [take until * > 12]` | 19:20 | ||
yeaaaah | |||
m: say join ' ', ('^50 .toggle: * > 3, * > 7, * > 10, * < 15, * > 20'.split(/':'|','/) Z, ^10 .map: {<take ignore>[$++ %% 2] ~ " until"}) | 19:22 | ||
camelia | ^50 .toggle ignore until * > 3 take until * > 7 ignore until * > 10 take until * < 15 ignore until * > 20 take until | ||
19:22
pmurias joined
|
|||
Zoffix | m: say join ' ', ('^50 .toggle: * > 3, * > 7, * > 10, * < 15, * > 20'.split(/':'|','/) Z, ^10 .map: {<ignore ignore>[$++ %% 2] ~ " until"}) | 19:22 | |
camelia | ^50 .toggle ignore until * > 3 ignore until * > 7 ignore until * > 10 ignore until * < 15 ignore until * > 20 ignore until | ||
Zoffix | bah | ||
.oO( why are they all ignores... ) |
19:23 | ||
a bug? | 19:24 | ||
m: say join ', ', ('^50 .toggle: * > 3, * > 7, * > 10, * < 15, * > 20'.split(/':'|','/) Z, ^10 .map: {my $v = $++; dd $v; <ignore take>[$v %% 2] ~ " until"}) | |||
camelia | Int $v = 0 ^50 .toggle, take until, * > 3, ignore until, * > 7, take until, * > 10, ignore until, * < 15, take until, * > 20, ignore until Int $v = 1 Int $v = 2 Int $v = 3 Int $v = 4 Int $v = 5 Int $v = 6 |
||
perlpilot | because you used <ignore ignore> | ||
Zoffix | oh | ||
haha | |||
so that gives us: 0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 | 19:25 | ||
m: ^50 .toggle: * > 3, * > 7, * > 10, * < 15, * > 20 | |||
camelia | ( no output ) | ||
Zoffix | m: say ^50 .toggle: * > 3, * > 7, * > 10, * < 15, * > 20 | ||
camelia | (8 10) | ||
Zoffix | -_- | ||
perlpilot | initial condition is "on" and is toggled by the first condition | 19:26 | |
See? that's kind of my only objection here: .toggle is too inscrutable. | 19:28 | ||
19:30
japhb__ joined,
hythm_ joined,
japhb__ left
|
|||
[Coke] | it's slightly more scrutable than "ff" | 19:31 | |
SmokeMachine | sorry, what means "inscrutable"? | 19:32 | |
Zoffix | inescrutável | ||
inescrutable | |||
hard to understand | |||
Filed R#2089 | 19:33 | ||
synopsebot | R#2089 [open]: github.com/rakudo/rakudo/issues/2089 [6.d review][LTA][RFC] .toggle is hard to understand | ||
perlpilot | [Coke]: I don't think so. With 'ff' you only have to worry about a single "toggle"; a single bit of hidden information changing state | ||
(changing state one time) | |||
hythm_ | Hi, is there a way to evaluate WhateverCode { ... } to actual code text? | 19:34 | |
p6: my $c = * > *; say $c.perl; | |||
camelia | { ... } | ||
Zoffix | hythm_: noi | ||
*no | 19:35 | ||
hythm_: or at least not at the moment | |||
hythm_ | Ok, thank you | ||
perlpilot | hythm_: in your mind perhaps :-) * > * is the same as { $^a < $^b } in any case | ||
er, * > * is the same as { $^a > $^b } even | 19:37 | ||
hythm_ | Hmm, i needed to serialize WhatEver code, which can be , * > * or | ||
perlpilot | (why do those keys have to be so close to each other? ;) | ||
Zoffix | [Coke]: not really, you can understand `ff` without knowing what the data is. `2 ff 5` will give you the all the items between the first 2 and the first 5. With .toggle you can't say that. You must know the positions of 2 and 5 in the list. you might get all the data after the first 5, you might get the 2, and then all the data after the first 5, or you might *just* get the data after the first 5 | 19:38 | |
[Coke] | perlpilot: I thought you were referring just to the routine name. | 19:39 | |
19:39
pmurias left
|
|||
perlpilot | no, the name is fine and makes good sense to me. It's the implementation that seems surprising at times. | 19:40 | |
(even though it works as advertised) | 19:41 | ||
19:41
benji__ joined
|
|||
perlpilot | btw, ff and fff both start in the "off" position. I wonder if .toggle should too? | 19:41 | |
Zoffix | s/With/With .toggle: * == 2, * == 5/ | ||
perlpilot: I think it should be split off into two separate routines | 19:42 | ||
perlpilot: but you should leave your comments on the ticket: github.com/rakudo/rakudo/issues/2089 | |||
Zoffix & | |||
19:42
Zoffix left
19:44
benjikun2 left
19:51
pmurias joined
|
|||
hythm_ | my $var can be assigned one of these values: ">" or "<", how can i create WhateverCode like: * $var * | 19:51 | |
raschipi | EVAL | 19:52 | |
timotimo | hythm_: if it's okay you can just store &infix:«>» and &infix:«<» instead of building a whatevercode | ||
hythm_ | EVAL did not work | 19:53 | |
SmokeMachine | Zoffix: yes, I dont know whats 'inescrutável' in portuguese either... :( | ||
hythm_ | timotimo: will try that | 19:54 | |
raschipi | It means incomprehensible | ||
But in an inescrutável way | 19:55 | ||
SmokeMachine | raschipi: thanks! | 19:56 | |
geekosaur | 'inscrutable' | 20:00 | |
(== 'can't be scrutinized' / studied) | |||
20:01
ChoHag joined
20:07
hythm_ left
|
|||
hobbs | scruting the inscrutable since 1963 | 20:13 | |
20:15
perlpilot left
20:17
zakharyas joined
20:20
zakharyas1 joined
|
|||
sena_kun | see the invisible, hear the unhearable, do the impossible... | 20:20 | |
geekosaur | I think "unscrewing the inscrutable" is the best take I've seen on that one | ||
20:21
zakharyas left,
sno joined
|
|||
pmurias | in the browser should printing to stdout/stderr be mapped to console.log/console.error? | 20:23 | |
20:24
raschipi left
|
|||
sena_kun | I'd say, that's natural enough approach. | 20:24 | |
20:29
zakharyas1 left
|
|||
masak .oO( redirect it to the printer! ) | 20:50 | ||
20:56
skids left
21:03
jameslenz joined
|
|||
SmokeMachine | what about `.take-while`, `.ignore-while`, `.take-until` and `ignore-until`? | 21:05 | |
jmaslak | I've got a user question here. I'm looking for something like IO::Socket::Async where I can basically ask for a socket that listens on a system-assigned, available epithermal port (I.E. a high numbered port), and get the port number chosen back once it's listening. Basically "I don't care what port you listen on, just let the system pick a port and then tell me what it picked." | 21:08 | |
21:08
jameslenz left
|
|||
jmaslak | Does anyone have any ideas on that? | 21:08 | |
21:09
HaraldJoerg left
|
|||
moritz | jmaslak: I'd approach this by using a random list of high ports and checking each one if it can be bound to | 21:09 | |
jmaslak: something like (1024..32255).roll(*).map(&try-connect).first | 21:10 | ||
21:10
p6fan joined
|
|||
moritz | where sub try-connect($port) { ... } tries to bind to the port, and returns an undefined value if it fails | 21:10 | |
.first(&so) instead of .first | 21:11 | ||
AlexDaniel | jmaslak: I had the same question some time ago | ||
moritz | (I'm not aware of any system call that automatically allocates a free port in an atomic manner) | ||
AlexDaniel | just using port 0 should work on linux | 21:12 | |
jmaslak | That's kind of where I was landing, but it seems not-terribly-elegant to code for something. Plus it ignores the system configuration of epithermal ports, so it's possible I could randomly grab something something else doesn't expect me to grab. | ||
AlexDaniel | but there was a problem of doing that from perl 6, IIRC | ||
timotimo | we do get the ports for you, iirc | ||
geekosaur | epithermal? too hot to touch? | 21:13 | |
p6fan | Popular youtuber Derek Banas has listed perl6.org as a supporter in his recent videos and has said that he is working on creating a Perl6 tutorial video! www.youtube.com/watch?v=I96uPDifZ1w | 21:14 | |
timotimo | that's bananas! | ||
AlexDaniel | p6fan: what second in the video? | 21:15 | |
[Coke] | epithermal? ephemeral? | ||
AlexDaniel | oh, I see something in the description of the video. Interesting | 21:16 | |
timotimo | oh, damn it | ||
p6fan | The video link just shows perl6.org in the description. I messaged him about a perl6 tutorial and he said that it is one of the videos he is currently working on. | ||
timotimo | we get the host and port (both remote and local) only when a connection comes in | ||
AlexDaniel | p6fan: plz don't forget to let us know when it's out :) sounds very cool | 21:17 | |
b2gills | m: say (^100).toggle: :off, *==5, * <=10, *==23, * <= 30, *==50, * <=52; # (^100).toggle: :off, 5, 10, 23, 30, 50, 52 | ||
camelia | (5 6 7 8 9 10 23 24 25 26 27 28 29 30 50 51 52) | ||
AlexDaniel | jmaslak: can you file a ticket for that? | ||
huggable: rakudobug | |||
huggable | AlexDaniel, Report bugs on github.com/rakudo/rakudo/issues/new If you don't have access to GitHub, you can email your report to [email@hidden.address] . See also: github.com/rakudo/rakudo/wiki/rt-introduction | ||
p6fan | I followed the channel and will let you all know when it is out. I am really looking forward to it. I have actually watched a lot of his other tutorials. | 21:18 | |
AlexDaniel | timotimo: so I guess you can listen on port 0 but you wouldn't know what port that is? | ||
timotimo | that's right. only once a connection has come in will you get the port | ||
lizmat | doesn't 'cro stub' have some code to generate a port to listen on ? | ||
timotimo | lizmat: i believe 'cro run' is the one you mean | 21:19 | |
lizmat | ah, could be :-) | ||
timotimo | since what port to use is more or less dynamic, based on what's in use | ||
21:23
raschipi joined
|
|||
jmaslak | Yes, I can definitely put in a ticket. It would help a lot of types of network code to have something along those lines. | 21:24 | |
21:25
p6fan left
|
|||
timotimo | does it make any sense to also feed back the host used from the VM to the perl6 code? | 21:25 | |
i know it makes sense for the port if it's 0, but will the "actually used" host ever differ from what you passed in? | |||
[Coke] | I like the idea of splitting toggle up into separate chunks of *until and *while | 21:27 | |
(and then you can more easily put a .race in front of it) | |||
timotimo | On Windows if the addr is initialized to point to an unspecified address (0.0.0.0 or ::) it will be changed to point to localhost. This is done to match the behavior of Linux systems. | 21:30 | |
sayeth the uv docs | |||
Geth | doc/coke/build: 27 commits pushed by (Will "Coke" Coleda)++, Coke++ review: github.com/perl6/doc/compare/93709...d0c9f66fd5 |
21:33 | |
jmaslak | Hmmpf, looks like github is having problems, I got a 500 error from them when I submitted the ticket. I'll try again in a bit. | 21:35 | |
AlexDaniel | jmaslak++ # persistence | 21:37 | |
21:38
MasterDuke joined
|
|||
xi- | does the <<terminator in string initialization work differently in perl6? it can't seem to find it p.nuxi.ca/pnmjoyqbx/sbv60s | 21:40 | |
[Coke] | docs.perl6.org/syntax/heredocs%20:to | ||
(yes) | |||
xi- | right, thank you | ||
timotimo | jmaslak: i've got the right functions together, and the places it has to go. just need to decide on an API to use between moarvm/jvm and rakudo ... | 21:44 | |
jmaslak | github.com/rakudo/rakudo/issues/2091 - I apologize if anything is unclear in the ticket. | 21:46 | |
22:00
sena_kun left
22:10
wamba left,
Xliff joined
|
|||
Xliff | m: grammar Test { token TOP { <A> || <B> }; token A { 'A' }; token B { 'B' }; }; Test.^methods.name.say; | 22:12 | |
camelia | No such method 'name' for invocant of type 'List'. Did you mean any of these? none note race take in block <unit> at <tmp> line 1 |
||
Xliff | m: grammar Test { token TOP { <A> || <B> }; token A { 'A' }; token B { 'B' }; }; Test.^methods.gist.say; | ||
camelia | (token TOP { <A> || <B> } token A { 'A' } token B { 'B' } parse parsefile subparse chunks orig CURSOR set_how space punct !cursor_start_subcapture same INDRULE !LITERAL perl pos prematch !cursor_push_cstack ident switch_to_slang !DYNQUANT_LIMITS blank… | ||
Xliff | Is there a way to get the name assigned to a regex object? | 22:15 | |
m: my regex A { 'A' }; A.^name.say | |||
camelia | Too few positionals passed; expected 1 argument but got 0 in regex A at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
Xliff | m: my token A { 'A' }; A.^name.say | 22:16 | |
camelia | Too few positionals passed; expected 1 argument but got 0 in regex A at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
Xliff | m: my token A { 'A' }; my $a = /<A>/; $a.^name.say | ||
camelia | Regex | ||
Xliff | m: my token A { 'A' }; my $a = /<A>/; $a.VAR.name | 22:19 | |
camelia | ( no output ) | ||
Xliff | m: my token A { 'A' }; my $a = /<A>/; $a.VAR.name.say | ||
camelia | $a | ||
Xliff | Maahahahaaha! | ||
xinming | is 'has $a' the same as 'has $!a' ? | ||
Xliff | m: my token A { 'A' }; A.VAR.name.say | 22:20 | |
camelia | Too few positionals passed; expected 1 argument but got 0 in regex A at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
jnthn | m: my token A { }; say A.name | 22:21 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Null regex not allowed at <tmp>:1 ------> 3my token A { 7⏏5}; say A.name » | ||
jnthn | m: my token A { xxx }; say A.name | ||
camelia | Too few positionals passed; expected 1 argument but got 0 in regex A at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
Xliff | m: grammar Agrammar{ token A { 'A' }; }; for A.^methods { when Regex { $_.VAR.name.say }; }; | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Undeclared name: A used at line 1 |
||
jnthn | m: my token A { xxx }; say &A.name | ||
camelia | A | ||
jnthn | duh :) | ||
Xliff | Yeah. I figured it out. Thanks, jnthn++ | ||
jnthn | You just need .name.say there, not .VAR.name.say :) | ||
xinming | is 'has $a' the same as 'has $!a' ? <--- ANyone here? :-) | ||
Xliff | xinming: Yes. | ||
Not the answer to your question. One sec. | |||
No. "has $a" is not the correct syntax. | 22:22 | ||
jnthn | xinming: Yes, in that it declares $!a. It also adds a compile-time alias so you can write $a and it is rewritten to $!a | ||
Xliff | Oops! Listen to jnthn. | ||
I didn't know that. :p | |||
xinming | jnthn: Thanks. That answer makes more sense. :-) | ||
I actually wish to understand the internal idea of the differences. | 22:23 | ||
jnthn | It was a sop to people who don't like twigils, but the only folks I've ever seen objecting to them would just have found something else about Perl 6 to object to anyway. :P | ||
xinming: Every attribute is actually stored with with the ! twigil. Always. | |||
xinming | jnthn: Yea, understand that, the $. only addess accessor method | 22:24 | |
jnthn | Yeah, it's similar for has $a :) | ||
xinming | is rw makes the accessor writble. | ||
writable* | |||
22:24
jmaslak left
|
|||
jnthn | Except that by runtime there's actually no "evidence" left behind of the fact it was declared has $a | 22:24 | |
The compiler just rewrites them as it sees it | 22:25 | ||
xinming | Ok, Thanks. | ||
jnthn | m: class C { has $a = 42; method m() { say $a } }; C.new.m | ||
camelia | 42 | ||
jnthn | m: class C { has $a = 42; method m() { EVAL 'say $a' } }; C.new.m | ||
camelia | 5===SORRY!5=== Error while compiling /home/camelia/EVAL_0 Variable '$a' is not declared. Did you mean '$!a'? at /home/camelia/EVAL_0:1 ------> 3say 7⏏5$a |
||
jnthn | Rumbled :) | ||
xinming | I have several small projects, and they'll be in perl6. :-) | ||
jnthn | :) | 22:26 | |
xinming | I've been here over 12 years, and sees the huge changes in perl6 for each development stage. :-) | 22:27 | |
jnthn | Wow, I think that's longer than me :D | 22:29 | |
[Coke] | if I have a #| pod section before a sub invocation, how can I refer to it from inside the sub? #| some stuff \n add-it(3,4); sub add-it($a, $b) { ... what is the .WHY ? } | 22:32 | |
jnthn | &?ROUTINE.WHY? | ||
oh, the invocation | 22:33 | ||
duh | |||
Umm...I'm not sure that that pod declarator comment attaches to anything | |||
Though there's others who know the Pod6 stuff better than I | |||
Xliff | jnthn: It looks like for grammars, you need the .VAR | 22:35 | |
m: grammar Test { token TOP { <A> || <B> }; token A { 'A' }; token B { 'B' }; }; for Test.^methods { .VAR.name.say }; | |||
camelia | TOP A B parse subparse parsefile prematch xdigit same !DELEGATE_ACCEPTS at switch_to_slang FAILGOAL postmatch Str !reduce clone_braid_from to !cursor_start_subcapture snapshot_braid !cursor_init INDRUL… |
||
Xliff | The only problem comes when I want to filter by Regex | 22:36 | |
m: grammar Test { token TOP { <A> || <B> }; token A { 'A' }; token B { 'B' }; }; for Test.^methods { when Regex { .VAR.name.say }; }; | |||
camelia | TOP Died with X::Multi::NoMatch in block <unit> at <tmp> line 1 A B |
||
Xliff | m: grammar Test { token TOP { <A> || <B> }; token A { 'A' }; token B { 'B' }; }; for Test.^methods { when Regex { .VAR.name.say }; default { .name.say }; }; | 22:37 | |
camelia | TOP Died with X::Multi::NoMatch in block <unit> at <tmp> line 1 A B parse parsefile subparse |
||
jnthn | Ah, it's probably tripping over the various internal methods | 22:38 | |
.^methods(:local) might help | |||
Xliff | \o/ | ||
Yep. That works. Thanks much! | |||
[Coke] | jnthn: I feel like I might be able to abuse it with CALLER somehow. :P | 22:43 | |
Altreus | does 'is copy' apply deeply to a data structure? | ||
separately: is there a shortcut to the current class, so I can say a constructor will return one? | 22:45 | ||
22:46
benji__ is now known as benjikun
|
|||
jnthn | Altreus: No, shallow | 22:48 | |
And ::?CLASS for the second | |||
Altreus | nice | 22:49 | |
thanks :) | |||
turns out I actually want the input parameter to be ro | |||
so that one was ok | |||
23:03
jameslenz joined
23:08
jameslenz left
23:09
DarthGandalf joined
23:15
testABC joined
23:16
pmurias left
|
|||
xinming | Is there a good web framework for perl6? | 23:17 | |
timotimo | xinming: Cro is a thing. it's more focused on "microservices", but it can do web apps, too | 23:18 | |
xinming | timotimo: THanks. | 23:19 | |
timotimo | xinming: cro.services is the web address | ||
23:21
testABC left
|
|||
xinming | Thanks | 23:25 | |
23:30
kerframil joined
23:33
raschipi left
23:34
Xliff left
|
|||
SmokeMachine | is there any way to "mix" a class into IterationEnd to "return some data" to the class is iterating the iterator? but make it continue to finish the loops | 23:34 | |
jnthn | No | 23:37 | |
SmokeMachine | :( | ||
jnthn | IterationEnd is a constant, if you did find a way to mix in to it you'd affect it globally | 23:38 | |
SmokeMachine | jnthn: I meant something using `but` but: | 23:39 | |
timotimo | all code that i've seen compares against the constant "behind" IterationEnd | ||
m: say IterationEnd.^name | 23:40 | ||
camelia | Mu | ||
SmokeMachine | m: say IterationEnd =:= IterationEnd but role :: {} | ||
camelia | False | ||
jnthn | You can do that, but then it won't be the end of the iteration | 23:41 | |
Just some object | |||
SmokeMachine | jnthn: Yes... I tried that... :( | 23:42 | |
jnthn | I susggest finding some other way to do whatever you're trying to do | ||
timotimo | throw a control exception :P | 23:43 | |
like, a warn | |||
b2gills | Maybe an empty Slip just before IterationEnd? | ||
Actually, I don't think that would work | 23:44 | ||
SmokeMachine | I was trying to implement `.take-while` and `.ignore-until`... | ||
I was trying something like this: www.irccloud.com/pastebin/XbfFizxy/ | 23:45 | ||
b2gills | I tried that once gist.github.com/b2gills/b877658f38...dc0990f581 except I went for .accept-while | 23:46 | |
MasterDuke | benchable6: HEAD compare my %orig = :1a, :2b; my %new = :5b, :6c; %orig «=« %new for ^10_000; dd %orig ||| my %orig = :1a, :2b; my %new = :5b, :6c; %orig ,= %new for ^10_000; dd %orig | 23:48 | |
benchable6 | MasterDuke, starting to benchmark the 1 given commit | ||
MasterDuke, No new data found | |||
MasterDuke | benchable6: compare HEAD my %orig = :1a, :2b; my %new = :5b, :6c; %orig «=« %new for ^10_000; dd %orig ||| my %orig = :1a, :2b; my %new = :5b, :6c; %orig ,= %new for ^10_000; dd %orig | ||
benchable6 | MasterDuke, starting to benchmark the 1 given commit | ||
MasterDuke, ¦HEAD: «Benchmark: Hash %orig = {:a(1), :b(5), :c(6)}«timed out after 10 seconds»» | |||
MasterDuke | benchable6: compare HEAD my %orig = :1a, :2b; my %new = :5b, :6c; %orig «=« %new for ^5_000; dd %orig ||| my %orig = :1a, :2b; my %new = :5b, :6c; %orig ,= %new for ^5_000; dd %orig | 23:49 | |
benchable6 | MasterDuke, starting to benchmark the 1 given commit | ||
MasterDuke, gist.github.com/c74a3252c670db25a3...70022e64ca | |||
jnthn | m: sub take-while($matcher, Iterable \things) { gather { for things { if $matcher.ACCEPTS($_) { .take } else { last } } } }; say take-while(* < 3, 1..10) | ||
camelia | (1 2) | ||
MasterDuke | TimToady, kjk: ^^^ (the benchable results) | ||
SmokeMachine | jnthn: I was trying to make possible something like: `^10 .take-while(* < 3).ignore-until(5).take-while(* < 9)` and that would return `(0, 2, 5, 6, 7, 8)` | 23:52 | |
sorry: `(0, 1, 2, 5, 6, 7, 8)` | 23:54 | ||
TimToady | MasterDuke: you mean the one that says "too few iterations" :) | ||
jnthn | Ah, that'd be done by having an implementation of Iterable like TakeIgnoreIterable or some such | 23:55 | |
And then add .ignore-until and .take-until methods on to that and stack them up | |||
And then apply them all at the point we really iterate | 23:56 | ||
SmokeMachine | jnthn: yes, that makes sense... | ||
jnthn: both, take-while and ignore-until, would make some changes on self and return self, right? (being self a Seq) | 23:58 | ||
jnthn | No | 23:59 | |
Always do immutable things | |||
SmokeMachine | or a new instance of Seq? | ||
ok | |||
jnthn | But you might actually want a TakeIgnoreSeq or something (name to be bikeshed later :)) |