»ö« 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.
pmmmm Quick question. How do I create an empty sequence? I am trying to flatmap every element in a directory where every element maps to sequence of many element or one element or zero element. 01:12
MasterDuke pmmmm: Seq.new doesn't work? 01:14
raschipi m: .say for Seq.new 01:20
camelia Too few positionals passed; expected 2 arguments but got 1
in block <unit> at <tmp> line 1
raschipi MasterDuke: No 01:23
timotimo why not ().Seq? 01:41
or "lol" xx 0
m: say ("lol" xx 0).^name
camelia Seq
timotimo m: say ().Seq.^name 01:42
camelia Seq
pmmmm timotimo: Thanks. That indeed works. 01:47
timotimo put some very intricate and complicated expression in front of the xx to make it extra funny when the reader gets the joke 01:49
timotimo 'night 01:56
pmmmm timotimo: goodnight and thanks again.
Xliff \o 04:11
Anyone read -> www.wired.com/story/microsoft-gith...oderation/ 04:13
Xliff That bothers me, greatly. 04:15
uzl .tell hythm_ class A { has $.letter }; class B { has A @.objs }; my %h; %h<vowels>.push(A.new(letter => $_)) for <a e i o u>; my $b = B.new(objs => |%h<vowels>); 05:08
yoleaux uzl: I'll pass your message to hythm_.
uzl p6: class A { has $.letter }; class B { has A @.objs }; my %h; %h<vowels>.push(A.new(letter => $_)) for <a e i o u>; my $b = B.new(objs => |%h<vowels>); 05:10
camelia ( no output )
uzl p6: class A { has $.letter }; class B { has A @.objs }; my %h; %h<vowels>.push(A.new(letter => $_)) for <a e i o u>; my $b = B.new(objs => |%h<vowels>); say $b;
camelia B.new(objs => Array[A].new(A.new(letter => "a"), A.new(letter => "e"), A.new(letter => "i"), A.new(letter => "o"), A.new(letter => "u")))
buggable New CPAN upload: Inline-Perl5-0.34.tar.gz by NINE modules.perl6.org/dist/Inline::Perl5:cpan:NINE 09:14
jmerelo Role and traits are conceptually the same thing; however, they have different keywords and work differently in Perl 6. Would it be correct to say that traits are added at compile time, roles at runtime? 09:40
moritz NO 09:41
El_Che are they the same thing?
moritz sorry, capslock, didn't meant to shout :-)
roles are an OO feature
traits are a language modification hooks
traits often use roles as mixins to modify behavior, but that doesn't need to be the case 09:42
jmerelo traits are language modification hooks... because they work at runtime.
sorry, compile time.
moritz yes, but roles are also often used at compile time 09:43
class Rat does Rational[int64, Int] { ... } # role used at compile time
jmerelo Roles _can_ be used at compile time, but traits are _always_ used at compile time.
moritz you can also call traits at run time 09:44
jmerelo Hum.
Example?
moritz m: class A { }; class B { }; trait_mod:<is>(B, A); # not sure if that works 09:45
camelia Parents cannot be added to class 'B'after it has been composed
in block <unit> at <tmp> line 1
moritz m: my $f = sub () { 42 }; trait_mod:<returns>($f, Int)
camelia ( no output )
moritz I've post-declared the return type of $f with a run-time call to the "returns" trait 09:46
jmerelo hum.
moritz and if you write something framework-like, it's not that uncommon 09:47
jmerelo OK. Let's see this: Roles access the `self` variable, while traits can access only the public API of the object they are mixed in. 09:48
moritz why are you trying to list differences that don't capture the essence?
roles are a way to structure classes and objects 09:49
traits are hooks that the compiler calls for you
jmerelo I'm trying go put the essence into an easy-to-understand single sentence. 09:49
moritz (note that some other programming languages use the word "traits" for our roles; that's a potential source of confusion)
jmerelo our roles _are_ traits conceptually. And traits are also traits. 09:50
Or both are mixins.
moritz if you phrase it that way, you're confusing everybody :-) 09:51
jmerelo I don't want to phrase it that way.
"Perl 6 roles are traits that are structurally part of classes (and objects), while Perl 6 traits are hooks that the compiler calls for you" 09:52
"Perl 6 roles are traits that are structurally part of classes (and objects), while Perl 6 traits are hooks that the compiler calls for you. However, they are conceptually mixins, also called traits in other languages" 09:53
moritz Perl 6 roles are a mechanism for code reuse, and thus for structuring classes and objects. Some other languages call them "traits".
Perl 6 traits, however, are hooks that the compiler calls for you. 09:54
jmerelo traits can also be used for code reuse. 09:55
moritz well, if you try, you can make things more confusing
traits are mostly useful for defining concise APIs
and sure, that has some implications for code reuse
jmerelo The problem is mixing in one single adversative sentence use (on one hand) and concept (in the other hand) 09:56
Roles are used for this, while traits are that.
moritz why do you even try to describe both in a single sentence? 09:57
jmerelo Roles are structure, while traits are... Hum.
moritz: well, to avoid confusion, and make clear when one should use one or the other. Make a precise use case for any of them.
Roles can't change internal representation, while traits can. 09:58
Roles can access self, while traits in principle only receive the public interface of the object. 09:59
That would be two sentences, but I believe both are true. Two sentences is less awesome than a single one, but build up to a good use case. 10:00
Also, "is" applies a trait to an object in compile time, while "does" can be used at compile or runtime. 10:02
Three sentences.
moritz jmerelo: but who confuses roles and traits in the first place?
jmerelo moritz: Mr Newt B. Ye 10:03
moritz: It's for the (all new) traits page in the documentation. 10:04
moritz jmerelo: be careful, there's an infix:<does> operator and a "does" trait 10:05
the operator runs at runtime, the trait at compile time
jmerelo moritz: OK, let's start all over again. 10:06
moritz: looking at this stackoverflow.com/questions/925609...vs-traits, would you say that roles are mixins, and traits are, unsurprisingly, traits? 10:07
moritz jmerelo: I'd say that Perl 6 roles have aspects of traits (explicit conflict resolution, flattened), but unlike traditional CS traits, the can contain state 10:11
I don't see any relation between a Perl 6 trait and a CS trait
jmerelo moritz: So roles are mixins and (from some point of view) traits, and traits are... what? 10:12
moritz jmerelo: trait are compiler hooks
... as I've been saying for the last half hour
jmerelo moritz: OK. Thanks for your patience. 10:13
moritz: I was trying to reconcile the fact that they are called "traits" seeing how that concept applied to them. And also to roles... 10:14
moritz jmerelo: afaict, the naming of p6 traits comes more from natural language than from CS 10:15
you define some properties (aka traits) of an object that way, for example the return type of a function, the parents of a class etc 10:16
jmerelo moritz: it would have been less confusing to call it properties or features. But one has to work with what's already there... 10:17
moritz many programmers associated "properties" with our "attributes" 10:20
naming is not easy :(
jmerelo moritz: we should have invented a new word. "trooks" 10:21
"wraits", as in "hook" and "traits"
moritz don't give TimToady any ideas :)
jmerelo I'll change it everywhere in Rakudo and make a pull request.
moritz (and the people who write trooks will be called trookers, right?) 10:22
jmerelo moritz: anyway, it's been really helpful. I'll put the conversation, as is, in the documentation :-)
moritz: I mean, _you_ have been really helpful.
moritz: I would so *love* that :-) 10:23
And then we'll sing the song "Minnie the trooker" www.youtube.com/watch?v=8mq4UT4VnbE
moritz :) 10:24
damaxi araraloren: Hi!:) 10:37
araraloren hi 10:39
araraloren what's going on damaxi 10:43
El_Che discussions about roles and traints: pbs.twimg.com/media/DfPbUBOXUAA-YOl.jpg 10:49
jeromelanteri someone use spacemacs for dev perl6 codes ? 10:50
(hello) 10:51
El_Che a merelo anagram? 10:53
moritz neearly, missing an e :-)
jeromelanteri: not me; I use down-to-earth vim :D
El_Che jinetea merelo 10:54
jeromelanteri: there are some emacs users here. Stick around
jmerelo El_Che: that would be me...
jeromelanteri moritz, i use vim to usually, but i'm trying to start to use emacs and specificaly spacemacs. layer for perl6 seems to failed, maybe there is something good for perl6 to use with spacemacs ? 10:55
jmerelo I mean, I use plain old emacs
El_Che space emacs is like emacs on drugs?
how is that different?
jeromelanteri bah i'm an emacs beginner... but i can see that spacemacs embed directly most of packages i need (and more)... for example vim keys bindings with evil 10:56
spacemacs should be a kind of emacs for newbie with special leader key and facilities...
the idea is to not loose to much time to learn emacs also. 10:57
El_Che it probably has the same perl6 setup as regular emacs, I presume 10:58
jmerelo if it's basically emacs there's a perl6 mode you can use.
jeromelanteri yes, i see perl6-mode and also perl6 layer... perl6 layer test failed for spacemacs (so i presume maybe also for just emacs) 10:59
jmerelo El_Che: jmerelo is unanagrammable
moritz: I'm realizing there's then a confusion throughout all the documentation.
(maybe more, but at least this one) 11:00
El_Che m: say 'jemerelo'.split('').permutations 11:02
camelia (( j e m e r e l o ) ( j e m e r e l o) ( j e m e r e o l ) ( j e m e r e o l) ( j e m e r e l o) ( j e m e r e o l) ( j e m e r l e o ) ( j e m e r l e o) ( j e m e r l o e ) ( j e m e r l o e) ( j e m e r l e o) ( j e m e r l o e) ( j e m e …
El_Che I like jemereól
jmerelo m: say 'jmerelo'.split('').permutations 11:03
camelia (( j m e r e l o ) ( j m e r e l o) ( j m e r e o l ) ( j m e r e o l) ( j m e r e l o) ( j m e r e o l) ( j m e r l e o ) ( j m e r l e o) ( j m e r l o e ) ( j m e r l o e) ( j m e r l e o) ( j m e r l o e) ( j m e r o e l ) ( j m e r o e l…
jmerelo It's badly unagrammable, then. 11:04
moritz m: say 'jmerelo'.split('').perl 11:05
camelia ("", "j", "m", "e", "r", "e", "l", "o", "").Seq
moritz if you use .comb instead, you get fewer bogus/redundant permutations
El_Che m: say 'jemerelo'.split('').comb
camelia ( j e m e r e l o )
moritz m: say 'jmerelo.comb.permutations.map(*.join)
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in single quotes; couldn't find final "'" (corresponding starter was at line 1)
at <tmp>:1
------> 3y 'jmerelo.comb.permutations.map(*.join)7⏏5<EOL>
expecting …
moritz m: say 'jmerelo'.comb.permutations.map(*.join)
camelia (jmerelo jmereol jmerleo jmerloe jmeroel jmerole jmeerlo jmeerol jmeelro jmeelor jmeeorl jmeeolr jmelreo jmelroe jmelero jmeleor jmelore jmeloer jmeorel jmeorle jmeoerl jmeoelr jmeolre jmeoler jmreelo jmreeol jmreleo jmreloe jmreoel jmreole jmreelo jm…
El_Che nice! 11:06
jmerelo jmeleor could be a Lord of the Rings character 11:07
Anyway
moritz: most documentation is wrong, I was saying, regarding traits.
The talk about the "is rw" trait, or things like that 11:08
but the trait is actually "is", "does" or "will".
"is rw" is an instantiation of the trait.
right?
in general, only "is" is referred to as "trait". "does", "will" ... are just stuff. 11:09
moritz not 100% sure on this nor
nor about how much value this extra precision actually gives us 11:10
jmerelo moritz: not sure about how it's reflected in the documentation or not sure about what should be properly called a trait?
For instance "does" is a trait, but documentation directs us to the definition of "roles". "does" has only one multi, which does what it does (no pun intended), but it can do so much more... 11:11
If you define a proto, I guess you can define as many roles as you want. I mean, differentiating between traits and trait instances gives us some insigh on actual use cases. 11:12
Besides, it gives us a hint on how traits should be best used. You can define trait_mod:<is> any way you want on new types, but we should give some advice or best practice on how best to use it. 11:13
When to use "does" instead of "is", for instance.
perlawhi1l hi perlers 11:18
jmerelo hi 11:19
araraloren hi
perlawhi1l i think i got a bug here
my %hash = :zero(0), :one(1); say so %hash<zero>:exists; say 'zero' ∈ %hash;
evalable6 True
False
perlawhi1l looks like it's booling the value, which is 0, resulting in False
for ∈
jmerelo m: my %hash = :zero(0), :one(1); say so %hash<zero>:exists; say 'zero' ∈ %hash.keys;
camelia True
True
araraloren my %hash = :zero(2), :one(1); say so %hash<zero>:exists; say 'zero' ∈ %hash;
evalable6 True
True
jmerelo m: my %hash = :zero(0), :one(1); say so %hash<zero>:exists; say 'zero' ∈ %hash.kv; 11:20
camelia True
True
jmerelo m: my %hash = :zero(0), :one(1); say so %hash<zero>:exists; say 'zero' ∈ %hash.values;
camelia True
False
jmerelo There you go
m: my %hash = :zero(0), :one(1); say set(%hash); say so %hash<zero>:exists; say 'zero' ∈ %hash.values;
camelia set(one => 1 zero => 0)
True
False
jmerelo m: my %hash = :zero(0), :one(1); say set(%hash); say so %hash<zero>:exists; say 'zero' ∈ set(%hash);
camelia set(one => 1 zero => 0)
True
False
jmerelo ∈ is coercing a hash to a set, and that's the result. 11:21
m: my %hash = :zero(0), :one(1); say set(%hash).perl; say so %hash<zero>:exists; say 'zero' ∈ set(%hash);
camelia (:one(1),:zero(0)).Set
True
False
jmerelo m: my %hash = :zero(1), :one(1); say set(%hash).perl; say so %hash<zero>:exists; say 'zero' ∈ set(%hash); 11:22
camelia (:one(1),:zero(1)).Set
True
False
jmerelo m: my %hash = :zero(1), :one(1); say set(%hash).perl.elems; say so %hash<zero>:exists; say 'zero' ∈ set(%hash);
camelia 1
True
False
jmerelo Hum, it's a junction. 11:23
perlawhi1l bisectable6: my %hash = :zero(0), :one(1); say 'zero' ∈ %hash;
bisectable6 perlawhi1l, On both starting points (old=2015.12 new=c940a0e) the exit code is 0 and the output is identical as well
perlawhi1l, Output on both points: «False␤»
perlawhi1l ok 11:24
tobs fwiw, that behaviour makes more sense if you think of Set as a special type of Bag :-) 11:25
perlawhi1l yeah... just seems odd that 'one' ∈ %hash is true, but 'zero' ∈ is false
i guess the rule is, don't use setops to test hash membership :D 11:26
that's what :exists is for
jmerelo perlawhi1l: looks fair
perlawhi1l the "hash coerces to set" doesn't hold water if you try 'one' ∈ set(%hash), which is fault, because that creates a set of pairs 11:30
instead i presume it's doing %hash.Set
my %hash = :zero(0), :one(1); say %hash.Set
evalable6 set(one)
perlawhi1l which makes that set... hence 'one' ∈ %hash is true
jmerelo perlawhi1l: that's what I call coercing to Set.
perlawhi1l yes :D 11:31
I agree
I am tired... i meant... based on your notes above... it's not creating a set from the hash (ie. set(%hash)), but instead coercing. 11:32
ok, all is understood now
jmerelo perlawhi1l: :-)
Zoffix More accurately, `zero` doesn't make it to the created Set, because it's false. So you end up with a Set that only has `one` and you're then trying to test if it has `zero` in it. 11:40
You could test membership of keys instead: 11:41
m: my %hash = :zero(0), :one(1); dd say 'zero' ∈ keys %hash
camelia True
Bool::True
perlawhi1l yeah, figured that... i just incorrectly assumed ∈ on a hash would check the keys... but a hash with numeric values does not a QuantHash make 11:43
jmerelo perlawhi1l: in fact, that behavior is documented: docs.perl6.org/type/Set#Creating_Set_objects 11:53
Geth doc: 39fe1e46e6 | (JJ Merelo)++ | doc/Language/traits.pod6
Restructures the traits page

With a better definition given by @moritz Also restructures. Refs #1957
11:56
synopsebot_ Link: doc.perl6.org/language/traits
Geth doc: 02669a0be4 | (JJ Merelo)++ | doc/Type/List.pod6
Documents list → on the list side, closes #1245
synopsebot_ Link: doc.perl6.org/type/List
moritz jnthn: re your last blog post, any reason not to use (|) as the signature in discard-and-nil? I thought that was faster than (*@, *%) 12:36
jnthn moritz: It's NQP code, and NQP doesn't have |. 12:39
moritz jnthn: ah, but it's less costly as the Perl 6 slurpy
no objections then :-)
jnthn Yeah, NQP also doesn't wrap the two up in a higher level object, or have any concept of flattening, so its *@foo is more like Perl 6 **@foo except lower level :) 12:40
moritz also, from reading the blog post, it looks like a pretty cool mechanism 12:46
considering that those spesh plugins are just a few lines each
Juerd jnthn: It's interesting that Bool.pick is faster than rand > .5 :) 13:03
jdv79 is there a web irc log alternative? that's one of the only ways i know what's going on:( 13:04
moritz jdv79: there's a link in the topic 13:05
jnthn Juerd: It probably avoids that coercion that I mentioned :) It's also prettier. Should probably have used that :) 13:07
Juerd jnthn: Nah, this is a better comparison to the other rand call, for which I don't think a prettier option is available 13:08
Maybe Bag.pick, though
Why does rand not return a Rat anyway? :D 13:10
damaxi araraloren: fine 13:40
araraloren okay :)
mahafyi good day all! I asked a question here : stackoverflow.com/questions/507751...n-in-perl6 14:11
timotimo mahafyi: the problem is that you can't combine prefix-for and postfix-for in one line like that 14:12
it's either something like
m: say "hi $_" for <a b c d>
camelia hi a
hi b
hi c
hi d
timotimo or something like
m: for <a b c d> { last when "c"; say "hi $_" }
camelia hi a
hi b
timotimo does that help? 14:13
mahafyi timiotimo: oh ok thanks. There isn't any problem really, just wanted to see if it can be done like that...
yes it is fine
timotimo the $i thing can be done "for you", too, with the .kv method 14:14
m: for <a b c d>.kv -> $k, $v { say "k is $k, v is $v. yay!" }
camelia k is 0, v is a. yay!
k is 1, v is b. yay!
k is 2, v is c. yay!
k is 3, v is d. yay!
mahafyi last unless $_ is needed else it goes into an infinite loop 14:15
timotimo you're getting input from a user? if so, they will have to ctrl-d for the .lines() iterator to exit 14:16
mahafyi i posted on stackoverflow, per jmerelo idea yday, that questions there can offer some SEO and help others down the line maybe
timotimo : no it is input from another program. I use it to capture default system variables passed by asterisk pbx daemon to an AGI script. 14:17
timotimo hm, i wouldn't expect an infinite loop under that condition 14:22
mahafyi i followed the perl5 asterisk adi module. I was not getting an <<RX in the asterisk log at all if i use slurp or if i do not use the -> last when "" condition , plus the telephony channels does not execute the next statement which means the program never exited. I see it running in output of 'ps -ef ' also. 14:25
in fact, i am thinking of tring to make a change to use whenever and then log the stdin string to text. as of now i can only look for any output in asterisk log / debug. 14:28
log to a file i meant
Tison \o 15:47
timotimo o/ 15:48
Geth doc: 2cd9fd07d9 | (JJ Merelo)++ | doc/Language/traits.pod6
Reorganizes and adds info on «is» for classes. Refs #1957
17:17
synopsebot_ Link: doc.perl6.org/language/traits
hythm_ p6: class C { has $!a; has $!b; submethod BUILD(:$!a = qx<hostname>, :$!b = False,) { } }; my $c = C.new; say $c; C.new 20:45
yoleaux 05:08Z <uzl> hythm_: class A { has $.letter }; class B { has A @.objs }; my %h; %h<vowels>.push(A.new(letter => $_)) for <a e i o u>; my $b = B.new(objs => |%h<vowels>);
camelia qx, qqx is disallowed in restricted setting
in sub restricted at src/RESTRICTED.setting line 1
in sub QX at src/RESTRICTED.setting line 11
in submethod BUILD at <tmp> line 1
in block <unit> at <tmp> line 1
MasterDuke e: class C { has $!a; has $!b; submethod BUILD(:$!a = qx<hostname>, :$!b = False,) { } }; my $c = C.new; say $c; C.new 20:46
evalable6 C.new
hythm_ the above code works fine, but if added "chomp" on front of qx<hostname> it gives misleading error,..
# class C { has $!a; has $!b; submethod BUILD(:$!a = chomp qx<hostname>, :$!b = False,) { } }; my $c = C.new; say $c; # this errors out
e: class C { has $!a; has $!b; submethod BUILD(:$!a = chomp qx<hostname>, :$!b = False,) { } }; my $c = C.new; say $c; 20:47
evalable6 (exit code 1) Cannot modify an immutable Pair (b => (Any))
in submethod BUILD at /tmp/C4TuNnFHsH line 1
in block <unit> at /tmp/C4TuNnFHsH line 1
MasterDuke hythm_: can you use TWEAK instead of BUILD? does that change anything? 20:50
b2gills e: class C { has $!a; has $!b; submethod BUILD(:$!a, :$!b = False,) { $!a //= chomp qx<hostname> } }; my $c = C.new; say $c;
evalable6 C.new
hythm_ MasterDuke TWEAK gives same error 20:51
b2gills I don't know why you are using private attributes. 20:53
e: class C { has $.a = chomp qx<hostname>; has $.b = False; }; my $c = C.new; say $c;
evalable6 C.new(a => "superserver", b => Bool::False)
b2gills e: class C { has $!a; has $!b; submethod BUILD(:$!a = chomp(qx<hostname>), :$!b = False,) { } }; my $c = C.new; say $c; 20:56
evalable6 C.new
b2gills hythm_: The problem you were facing is that all of `qx<hostname>, :$!b = False,` were arguments to chomp 20:57
hythm_ ah, makes sense now. Thanks b2gills. 20:58
masak maybe it's time to reach outside of the echo chamber about Perl 6 no longer running on the Parrot VM: news.ycombinator.com/item?id=17275038 21:44
(apologies to anyone who still runs Perl 6 on Parrot on a daily basis.)
El_Che in production
AlexDaniel c: 2014.01 say 42 22:23
committable6 AlexDaniel, ¦2014.01: «42␤» 22:24
AlexDaniel fwiw that's the first working rakudo on moar ↑
I was able to build it fairly recently, but I think it no longer works on systems where perl5 is too new 22:30