»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_log/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 July 2018.
jmerelo Just a reminder that we *need* articles for the Perl 6 advent Calendar: github.com/perl6/mu/blob/master/mi...8/schedule 06:15
The schedule is virtually empty. So really, really, please, think about some topic and request one day github.com/perl6/mu/blob/master/mi...8/schedule 06:16
holyghost .tell Xliff I would like to have public_html in my home dir working (e.g. /etc/httpd.rc) 06:29
yoleaux holyghost: I'll pass your message to Xliff.
holyghost .tell Xliff Then you should point to the $HOME local directories in and html file (index.html) with "serverip/~holyghost" in /var/www/index.tml instead of the default apache page 06:34
yoleaux holyghost: I'll pass your message to Xliff.
holyghost .tell Xliff If you like, I'll give you a nice index.html file with CSS and everything, so we have a nice main website 06:37
yoleaux holyghost: I'll pass your message to Xliff.
holyghost .tell Xliff they should find me on the main website with e.g. in html <a href="/~holyghost/">The Holy Ghost software</a> IIRC 07:01
yoleaux holyghost: I'll pass your message to Xliff.
Geth mu: b745ffb483 | (Naoum Hankache)++ (committed using GitHub Web editor) | misc/perl6advent-2018/schedule
Update schedule
07:50
El_Che That +r freenode thingie is crap. Oh well, my irssi config is 2 channels less 08:42
masak El_Che: is the +r thingie what keeps the spam bots at bay. why is it crap? 09:04
s/\./?/
El_Che because I can't log in 09:26
coffee time
Altreus Is there a perl6y way of removing one array of items from another in some magically efficient manner? 09:27
moritz splice 09:31
Altreus this appears to remove a range rather than a subset 09:44
@array.remove(@subset) 09:45
something like this but that actually exists
moritz if you want to remove several indexes, it's usually more efficient to keep the others 09:46
@array = @array[@indexes_to_keep]
my \indexes_to_remove = set(@indexes_to_remove); my @indexes_to_keep = @array.keys.grep(none(indexes_to_remove)) 09:47
Altreus OK so basically, figure out which indices they are and invert that set 09:53
cool :)
Geth mu: 9a5485e3bf | (Ramiro Encinas)++ (committed using GitHub Web editor) | misc/perl6advent-2018/schedule
Update schedule
09:56
nwellnhof p6: say (1,2,3; 4,5,6; 7,8,9)[{0,1}] 10:03
camelia ((1 2 3) (4 5 6))
nwellnhof p6: say (1,2,3; 4,5,6; 7,8,9)[*;0,1]
camelia (1 2 4 5 7 8)
nwellnhof p6: say (1,2,3; 4,5,6; 7,8,9)[*;{0,1}]
camelia (3 6 9)
nwellnhof The last result seems like a bug. 10:04
jnthn m: say {0,1}.elems # This will be numified, I think? So it's like [*;2] 10:13
camelia 1
jnthn Oh...it won't 'cus it's a code object 10:14
It will be passed the target, and then return a list, which will probably then be numified
Though I see in the first case we re-dispatch on what the thing returns. Hmm. 10:15
Yeah, it should be consistent one way or the other.
jnthn I'd suggest to file an issue. 10:17
Or patch :)
Xliff Anyone awake? 10:27
yoleaux 06:29Z <holyghost> Xliff: I would like to have public_html in my home dir working (e.g. /etc/httpd.rc)
06:34Z <holyghost> Xliff: Then you should point to the $HOME local directories in and html file (index.html) with "serverip/~holyghost" in /var/www/index.tml instead of the default apache page
06:37Z <holyghost> Xliff: If you like, I'll give you a nice index.html file with CSS and everything, so we have a nice main website
07:01Z <holyghost> Xliff: they should find me on the main website with e.g. in html <a href="/~holyghost/">The Holy Ghost software</a> IIRC
Geth mu: 3c0b3cb9c0 | Altai-man++ (committed using GitHub Web editor) | misc/perl6advent-2018/schedule
Update schedule
Xliff .tell holyghost Sorry. This is a git server. I am using it to serve HTTP. If you want that, please get a webhost 10:28
yoleaux Xliff: I'll pass your message to holyghost.
holyghost Xliff: ok 10:29
yoleaux 10:28Z <Xliff> holyghost: Sorry. This is a git server. I am using it to serve HTTP. If you want that, please get a webhost
holyghost Xliff: I'll publish in priv git then 10:30
Xliff Yes. Please do.
holyghost I have to make a script to update my files 10:31
Anyone, can git be used locally with an ip just as cvs ? 10:32
Xliff Yes. It can. I am out, now. Just priv me if you have questions. 10:33
Please... not too many though. It's been a day.
holyghost ok, take care
Geth mu: c1607089d0 | (Nigel Hamilton)++ (committed using GitHub Web editor) | misc/perl6advent-2018/schedule
Provide another topic
10:51
nige could someone please point me to the github ticket that we are waiting on Larry to weigh in on - regarding raku? 10:57
lizmat I assume you mean github.com/perl6/user-experience/issues/31 ? 11:02
nige thanks lizmat - yes I think that's the one 11:10
Xliff \o lizmat and nige 11:13
buggable New CPAN upload: Object-Delayed-0.0.4.tar.gz by ELIZABETH modules.perl6.org/dist/Object::Dela...:ELIZABETH 12:07
lizmat hmmm.... so *where* do we document "start { }" ? 12:38
somewhere hidden in the Promise.start docs: This is considered to be such a commonly required pattern that it is also provided as a keyword: 12:39
masak we don't have a list of statement prefixes somewhere? 12:41
I saw we have a list of phasers, but this is slightly different
`once` is documented under "Control flow" -- this feels similar 12:42
lizmat ok, I'll add it there
Geth doc: a7845c0085 | (Elizabeth Mattijsen)++ | doc/Language/concurrency.pod6
Add mention that only one whenever block runs at a time
12:43
synopsebot Link: doc.perl6.org/language/concurrency
ufobat_ !seen sena-kun 12:48
timotimo .seen sena_kun 12:58
yoleaux I saw sena_kun 14 Nov 2018 19:31Z in #perl6: <sena_kun> pmurias, I hope so. Numbers of FF users are decreasing every year, which is sad to see. But, well, disregard that, if you ask me, I'd +1 on polyfill usage.
koto timotimo, I'm here. 12:59
sena_kun ufobat_, cro bugs, yes? 12:59
ufobat_ openapi::model issues :D 13:00
sena_kun there are ones I know to exist, yes... let's move to #cro if you don't mind and I'm ready to look into things. 13:01
ufobat_ aye 13:03
timotimo m: say term:<now>() 13:11
camelia Instant:1542373945.973841
timotimo m: say term:<now>(:test)
camelia Unexpected named argument 'test' passed
in block <unit> at <tmp> line 1
timotimo &term:<now>.wrap(-> |, :$set-mock-time { state $mock-time; $mock-time = $_ with $set-mock-time; $mock-time // callsame }); say now; term:<now>(set-mock-time => 12345); 13:12
m: &term:<now>.wrap(-> |, :$set-mock-time { state $mock-time; $mock-time = $_ with $set-mock-time; $mock-time // callsame }); say now; term:<now>(set-mock-time => 12345);
camelia Potential difficulties:
Useless use of 'now' in sink context
at <tmp>:1
------> 3 now; term:<now>(set-mock-time => 12345)7⏏5;
Instant:1542373978.510927
timotimo ^- hum?
ufobat_ can someone point me out what i need to read in order to understand this: github.com/croservices/openapi-mod...1148-L1160 13:17
the `does Role[ ...quite a lot of code... ]` thingy
it looks like a different kind of inheritance?
timotimo it puts a value into the role's argument 13:18
jnthn Roles can take parameters
m: role R[$v] { method m { $v } }; class C does R[42] { }; C.m
camelia ( no output )
jnthn m: role R[$v] { method m { $v } }; class C does R[42] { }; say C.m
camelia 42
ufobat_ thats basically the same as javas Collection<Type> thingy? 13:20
but in more flexible
timotimo it's similar, but the arguments to roles don't just disappear 13:21
SmokeMachine m: my %a := :{}; my %b; %b<bla> = 1; %a{%b.clone} = 1; say %a; %b<bla> = 2; %a{%b.clone} = 2; say %a # why is this happening if im cloning b? 13:23
camelia {(bla => 1) => 1}
{(bla => 2) => 2, (bla => 2) => 1}
ufobat_ maybe it is a stupid question, but when do you use that? I've never needed or used that in my perl5 code
timotimo SmokeMachine: it's not the same object any more, so it's a different key 13:25
SmokeMachine I was thinking to use `.Map` instead of `.clone` but it stringifies the key...
timotimo "the" key?
jnthn ufobat_: When you want to factor something out into a role, but make it configurable in some way.
SmokeMachine timotimo: yes, that's what I want, but the problem is: `{(bla => 2) => 2, (bla => 2) => 1}` its changing... 13:26
timotimo my %a := :{}; my %b; %b<bla> = 1; %a{%b.Map} = 1; say %a; %b<bla> = 2; %a{%b.Map} = 2; say %a.perl
evalable6 {(bla => 1) => 1}
:{(:bla(1)) => 1, (:bla(2)) => 2}
timotimo my %a := :{}; my %b; %b<bla> = 1; %a{%b.Map} = 1; say %a.perl; %b<bla> = 2; %a{%b.Map} = 2; say %a.perl
evalable6 :{(:bla(1)) => 1}
:{(:bla(1)) => 1, (:bla(2)) => 2}
SmokeMachine m: my %bla = :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.keys.head.^name
camelia Potential difficulties:
Useless use of hash composer on right side of hash assignment; did you mean := instead?
at <tmp>:1
------> 3my %bla = :{42 => 1}7⏏5; say %bla.keys.head.^name; say %bla.Map
Str
Str
timotimo i don't see it stringify keys
SmokeMachine m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.keys.head.^name 13:27
camelia Int
Str
SmokeMachine timotimo: ^^ 13:28
timotimo oh
m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.^roles
camelia Int
((Associative) (Iterable))
timotimo m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.^roles[0].^parameters
camelia Int
No such method 'parameters' for invocant of type 'Perl6::Metamodel::ParametricRoleGroupHOW'. Did you mean 'parameterize'?
in block <unit> at <tmp> line 1
tobs "A Map is an immutable mapping from string keys to values of arbitrary types."
timotimo m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.^roles[0].^params
camelia Int
No such method 'params' for invocant of type 'Perl6::Metamodel::ParametricRoleGroupHOW'
in block <unit> at <tmp> line 1
timotimo m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.^roles[0].^arguments 13:29
camelia Int
No such method 'arguments' for invocant of type 'Perl6::Metamodel::ParametricRoleGroupHOW'
in block <unit> at <tmp> line 1
timotimo ...
m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.^roles[0].arguments
camelia Int
No such method 'arguments' for invocant of type 'Associative'
in block <unit> at <tmp> line 1
timotimo m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.^roles[0].parameters
camelia Int
No such method 'parameters' for invocant of type 'Associative'
in block <unit> at <tmp> line 1
timotimo m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Map.^roles[0].^role_arguments 13:31
camelia Int
No such method 'role_arguments' for invocant of type 'Perl6::Metamodel::ParametricRoleGroupHOW'
in block <unit> at <tmp> line 1
timotimo huh.
SmokeMachine this works, but is there a better solution? 13:33
m: my %a := :{}; my %b; %b<bla> = 1; %a{%b.kv.map(-> $k, $v { $k.clone => $v })} = 1; say %a; %b<bla> = 2; %a{%b.kv.map(-> $k, $v { $k.clone => $v })} = 2; say %a
camelia {(bla => 1) => 1}
{(bla => 1) => 1, (bla => 2) => 2}
SmokeMachine timotimo: ^^ 13:34
timotimo it probably shouldn't stringify those keys. 13:34
SmokeMachine tobs: ^^
timotimo oh
Map is supposed to be strings to objects, then?
SmokeMachine timotimo: but Hash also does...
m: my %bla := :{42 => 1}; say %bla.keys.head.^name; say %bla.Hash.keys.head.^name
camelia Int
Int
timotimo well, hash's default role parameters are Str(Any) iirc
tobs SmokeMachine: I can only imagine that the clone issue has something to do with it making shallow copies...
SmokeMachine sorry... not Hash on a Hash... 13:35
timotimo s: :{42 => 1}, 'Hash', \() 13:36
SourceBaby timotimo, Ehhh... I'm too scared to run that code.
SmokeMachine tobs: yes, that's what I was wandering... that probable would be "fixed" if `.Map` didn't stringily...
timotimo s: Hash, 'Hash', \()
SourceBaby timotimo, Sauce is at github.com/rakudo/rakudo/blob/21f1...ash.pm6#L8
timotimo that would explain why .Hash on a Hash doesn't do anything :) 13:37
tobs m: my %a := :{}; my %b; %b<bla> = 1; %a{(my Any %{Any} = %b)} = 1; say %a; %b<bla> = 2; %a{(my Any %{Any} = %b.clone)} = 2; say %a
camelia {(bla => 1) => 1}
{(bla => 1) => 1, (bla => 2) => 2}
SmokeMachine yes, that just returns self...
tobs %)
tobs this is what you expected right? (forgot to remove the last .clone) 13:38
SmokeMachine m: my %a := :{}; my %b; %b<bla> = 1; %a{my %{Any} = %b.clone} = 1; say %a; %b<bla> = 2; %a{my %{Any} = %b.clone} = 2; say %a 13:40
camelia {(bla => 1) => 1}
{(bla => 1) => 1, (bla => 2) => 2}
SmokeMachine m: my %a := :{}; my %b; %b<bla> = 1; %a{my %{Any} = %b} = 1; say %a; %b<bla> = 2; %a{my %{Any} = %b} = 2; say %a
camelia {(bla => 1) => 1}
{(bla => 1) => 1, (bla => 2) => 2}
SmokeMachine tobs: that's it! thanks!
tobs SmokeMachine: it could look nicer though. (I learned that last week while doing something similar and looking at .perl outputs.) 13:41
SmokeMachine tobs: thanks! 13:43
SmokeMachine timotimo: Now I have to find a way to transfer this into a Red::AST... :P www.irccloud.com/pastebin/Cz0Aeet5/ 13:44
SmokeMachine timotimo: www.irccloud.com/pastebin/jk9eqzHy/ 13:58
timotimo i like it 14:00
would you tunr that right into a piece of the SQL so that stuff that would immediately .next won't appear in the first place, or would that screw with code that actually does something useful before calling .next? 14:01
SmokeMachine timotimo: the idea is to translate that to sql... 14:11
do `.map: { next unless .b; .a }` will write the same sql as `.grep({so .b}).map: {.a}` 14:12
select a from table_name where b is not null and b != 0 14:14
timotimo: for example... 14:15
Altreus is it kosher to use a promise to sort of signal that something else is happening? I will explain my example
SmokeMachine timotimo: but it's not on Red master yet... its on a branch... 14:16
Altreus I have a "bulk delete messages" operation on a Channel object. This first sends an API request and, on success, finds those messages in the object's @.messages and removes them. This whole thing happens in a Promise so someone could read @.messages after the method was called but before they are removed from the list
SmokeMachine timotimo: if some one like to help... (would you?)
Altreus Would it make sense to hide @.messages behind a Promise, so that I can keep that promise when people are allowed to see the message array? 14:17
as a sort of lock
or can I just straight up lock something and force a blocking operation?
I was thinking something like method messages { $!message-lock.then({ @!messages }) } 14:18
moritz there are locks, yes
docs.perl6.org/type/Lock
Altreus cor
moritz use them with care :-) 14:19
Altreus ah this recommends higher-level constructs
I suspect the promise-lock might be less dangerous
Geth doc: 6165d4362a | (Elizabeth Mattijsen)++ | doc/Language/control.pod6
Add start { } to control flow
14:33
synopsebot Link: doc.perl6.org/language/control
buggable New CPAN upload: ModelDB-0.0.3.tar.gz by HANENKAMP cpan.metacpan.org/authors/id/H/HA/...0.3.tar.gz 14:37
jnthn Altreus: Yes, using the Promise there sounds better. 14:38
El_Che robe pike's diss about Perl: youtu.be/RIvL2ONhFBI?t=150 14:50
SmokeMachine timotimo: my "Red::AST optimizer" is not optimising anything yet... but it looks that the `next if` is working... www.irccloud.com/pastebin/7oqzHGSQ/ 14:53
lizmat
.oO( go Rob, go! :-)
SmokeMachine timotimo: I mean the optimizer will transform `not not X` into `X` 14:54
Altreus jnthn: thanks, this means I'm getting the hang of stuff 14:57
:D
SmokeMachine timotimo: github.com/FCO/Red/wiki/Better-map-grep 15:14
lizmat SmokeMachine: { next unless .b; .a } perhaps better written as { .a if .b } ? 15:32
SmokeMachine lizmat: but it won’t next, right? It will return Nil... 15:53
lizmat m: dd (^10).map: $_ if $_ == 5 15:54
camelia Use of uninitialized value of type Any in numeric context
in block <unit> at <tmp> line 1
lizmat m: dd (^10).map: { $_ if $_ == 5 }
camelia (5,).Seq
lizmat map is smarter than that :-)
timotimo it returns Empty, doesn't it? 15:55
SmokeMachine lizmat: thanks!
PavelB Does perl6 have repl?
SmokeMachine lizmat: I’ll add that to my code! Thanks!
timotimo PavelB: yes, just run "perl6" and the repl should greet you 15:56
PavelB :O
timotimo other than that we have a kernel that can be used with the jupyter notebook, or ipython console
SmokeMachine m: say ^10 .map: { $_ if %% 2 }
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3say ^10 .map: { $_ if %%7⏏5 2 }
expecting any of:
infix
infix stopper
PavelB *and* it has line editing
woah
SmokeMachine m: say ^10 .map: { $_ if $_ %% 2 } 15:57
camelia (0 2 4 6 8)
timotimo it has some very strange behaviours sometimes, though
the repl, i mean
operators defined on one line aren't available outside that same line, for example
and using native lexicals, like "my int $foo" instead of "my Int $foo" can cause strange issues, too
SmokeMachine m: say { $_ if $_ %% 2 }.(3) 15:58
camelia ()
PavelB So, I'm coming from Perl 5 and I noticed that `say (1, 2, 3)`, `say 1, 2, 3`, and `say [1, 2, 3]` are causing different outputs. What's the difference? 15:59
timotimo the first one you pass a list to say, the second one you pass three arguments, the third one you pass an array
SmokeMachine m: say { if False {}}.()
camelia ()
SmokeMachine m: say { do if False {}}.()
camelia ()
PavelB So perl6 doesn't have the auto-list-splatting thing? 16:00
lizmat PavelB: could you express that in Perl 5 code ?
SmokeMachine m: say |(1, 2, 3)
camelia 123
timotimo yeah, arguments are only expanded ("slipped") if you use the | operator 16:01
PavelB Perl 5 has `(1, (2, (3), 4, (5)), 6), 7` as the same thing to `(1, 2, 3, 4, 5, 6, 7)`
timotimo you can slip an array to pass positional arguments or a hash to pass named arguments
SmokeMachine PavelB: in perl6 it isn’t... 16:02
lizmat m: dd ((1, (2, (3), 4, (5)), 6), 7).flat # PavelB
camelia (1, 2, 3, 4, 5, 6, 7).Seq
lizmat m: say ((1, (2, (3), 4, (5)), 6), 7).flat
camelia (1 2 3 4 5 6 7)
PavelB I'm starting to doubt this language is actually similar to Perl 5 16:03
lizmat PavelB: everything in Perl 6 is an object
and so are arrays and lists
PavelB Like, reasonable representations of lists? Wuuuuut? 16:04
lizmat PavelB: perhaps this could be of interest to you: opensource.com/article/18/8/containers-perl-6 16:05
</plug>
PavelB lizmat: So I'm reading that and I'm not sure I'm seeing the purpose of having an @ sigil if you can just stick lists in $scalars and it works fine 16:06
lizmat the @ indicates how you want to look at it 16:08
m: my $l := 1,2,3,4; for $l { say $_ }
camelia 1
2
3
4
ufobat_ m: my $a = (foo => 1, bar => 2); say $a<foo> 16:10
camelia Type List does not support associative indexing.
in block <unit> at <tmp> line 1
ufobat_ m: my $a = (foo => 1, bar => 2).Hash; say $a<foo> 16:11
camelia 1
lizmat afk&
ufobat_ ha :D 16:14
scimon Zoffix: Jsut to say. Looking at the Color module. Importing the Color::Operators only added .5 seconds on my machine today :) 16:24
SmokeMachine lizmat: thanks! www.irccloud.com/pastebin/ynCHwfn4/ 17:09
SmokeMachine m: say "bla (ble, bli, blo) blu".subst(/"(" ~ ")" (<-[)]>+)/, -> $/ is copy { "( { $0.Str.split(/\s*,\s*/).sort.join(", ") } )" }, :g) 19:39
camelia 5===SORRY!5===
Unrecognized regex metacharacter , (must be quoted to match literally)
at <tmp>:1
------> 3, -> $/ is copy { "( { $0.Str.split(/\s*7⏏5,\s*/).sort.join(", ") } )" }, :g)
Unable to parse regex; couldn't find final '/'
SmokeMachine what's wrong here? ^^
sena_kun SmokeMachine, `,` symbol. If you want to literaly match it, wrap it with `,`. That's a wild guess though based on what I see, I am not a regex wizard. 19:42
m: say "bla (ble, bli, blo) blu".subst(/"(" ~ ")" (<-[)]>+)/, -> $/ is copy { "( { $0.Str.split(/\s* ',' \s*/).sort.join(", ") } )" }, :g)
camelia bla ( ble, bli, blo ) blu
sena_kun SmokeMachine, ^
SmokeMachine right! thanks sena_kun !
sena_kun Phew, glad I was able to help. :) .oO ( Though Comma did it ). 19:43
Altreus I have an array of objects that all exist in another array. Is there an efficient way of turning this subset into the indices from the superset? 23:16
the perl5 way is a nested loop 23:17
SmokeMachine m: my @a = <a e i o u>; my @b = "a" .. "z"; my %b = @b.kv.reverse; say %b{@a} # Altreus: do you mean something like this? 23:23
camelia (0 4 8 14 20)
jnthn `my %b = @b.antipairs` will be a bit more efficient 23:27
SmokeMachine jnthn: thanks!
Altreus yes except they're objects so I ... I dunno, can I use them as keys? 23:40
jnthn Yes, but declare the hash my %b{Any} 23:47
Altreus okay I shall try this 23:49
dunno how long before I can actually run this code :P