»ö« 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 moritz on 22 December 2015.
lookatme :) 00:53
hythm_ p6: my %h1 = a => { b => True }, c => { d => True }, e => { f => True, g => True }; my %h2 = c => { d => False }, h => { i => True }, e => { f => False }; my %h3 = %h2 »=» %h1; say %h3; 02:54
camelia {c => {d => True}, e => {f => True}, h => {i => (Any)}}
hythm_ is it possible to merge two hashes, %h1 and %h2, combining the keys recursively, with %h2 values overwriting %h1 if keys are same?,,, for the above output, %h3 should be: %h3 a => { b => True }, c => { d => False }, e => f => False, g => True }, h => { i => True } 02:57
MasterDuke m: my %h1 = a => { b => True }, c => { d => True }, e => { f => True, g => True }; my %h2 = c => { d => False }, h => { i => True }, e => { f => False }; my %h3 = %h1, %h2; say %h3 03:02
camelia {a => {b => True}, c => {d => False}, e => {f => False}, h => {i => True}}
MasterDuke hm. that loses 'g' 03:03
lookatme It has a inner hash 03:04
hythm_ wondering if hyper operator can help in this case, I tried a few ways but I could not make it work 03:05
Qwerasd Hey, is there some kind of wizardry that would allow me to see what parameters a callable accepts? 03:42
Like programmatically.
Qwerasd Nvm got it, Block.signature 03:57
Geth doc: 224a0bcf01 | (JJ Merelo)++ | doc/Language/testing.pod6
Completes preamble to fix compilation errors

Fixes #2055
05:15
synopsebot Link: doc.perl6.org/language/testing
Geth doc: bc8b41d69d | (JJ Merelo)++ | doc/Language/variables.pod6
Adds info on possible distro names closes #2054
05:56
doc: b0ac6c8771 | (JJ Merelo)++ | doc/Language/variables.pod6
Changed anchors and added a few missing ones
synopsebot Link: doc.perl6.org/language/variables
jmerelo squashable6: status 05:57
squashable6 jmerelo, Next SQUASHathon in 7 days and ≈4 hours (2018-06-02 UTC-12⌁UTC+14). See github.com/rakudo/rakudo/wiki/Mont...Squash-Day
jmerelo o/ 07:03
jmerelo Another SO question with a problem I bumped into today stackoverflow.com/questions/505243...d-identity 08:06
m: say (1,1) === (1,1)
camelia False
jmerelo Related to that above, but also to how set membership works.
donpdonp my $a = (1,1); $a === $a => true 08:09
=== is more about pointer equality
(1,1) eqv (1,1) => true
note I know little of what I speak, but I had the same sort of structural comparison question (two Bufs) and solved it with eqv
jmerelo donpdonp: that seems to be the case; the problem is that set membership seems to be using that instead of eqv or == 08:10
So the strange behavior I point to in the SO question occurs...
Geth doc: 169d2127db | (JJ Merelo)++ | doc/Language/math.pod6
Adds exact Rational arithmetic
08:15
doc: 34ec3dcb0c | (JJ Merelo)++ | doc/Language/math.pod6
Adds approximate equality, refs #114
synopsebot Link: doc.perl6.org/language/math
doc: d670de3250 | (JJ Merelo)++ | 2 files
Adds content to the sequences section

Also learns new words. Refs #114
Qwerasd How do I print an error in a catch block? 08:39
nvm 08:40
jmerelo Qwerasd: inside a catch block? 08:44
Qwerasd Figured it out that it was placed in $_ rather than $!
jmerelo Qwerasd: right. It's contextualized, so you can access it via $_ or using .say, for instance. 08:45
Qwerasd How can I remove an element from an array when looping through it with a for loop? 08:56
lookatme Qwerasd, using slice 09:04
Qwerasd How do I do that with like for @array -> $elem {}
lookatme sorry, splice 09:05
Qwerasd, no, it would not work in that form
Qwerasd How would I do that though? I don't have the index.
lookatme Using while I think
Qwerasd I don't really want to use the long c-style for loop if I don't have to.
lookatme It's UB in Perl 6 that remove element from Array you are iterating 09:07
Qwerasd UB?
lookatme yeah, I think
undefined behavior, you must heard it from C 09:08
AlexDaniel Qwerasd: how big is the array? Can't you just use grep? 09:12
or map
Qwerasd I just bit the bullet and used loop(;;) 09:13
AlexDaniel right, that will work
lizmat Qwerasd: what's wrong with just 'loop { }' ?
Qwerasd loop(;;) and in loop(my $i = 0; $i < @arr.elems; $i++) 09:14
as in*
buggable New CPAN upload: Test-Declare-0.0.2.tar.gz by DARRENF modules.perl6.org/dist/Test::Declar...an:DARRENF 09:43
Geth doc: e29fe251a2 | (JJ Merelo)++ | 2 files
Eliminates link to code

Rewrites paragraph to show clearly the nature of these values. Closes #2054.
Also reflows that paragraph (ref #2056) (and some others) and makes some typographic changes, changing to periods and capitalizing where needed.
10:33
tbrowder_ m: Uni.new(x2000).NFC.list.base(16) 10:46
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
x2000 used at line 1
tbrowder_ m: Uni.new(0x2000).NFC.list.base(16) 10:47
camelia No such method 'base' for invocant of type 'Seq'. Did you mean any of these?
Hash
asec
hash
race

in block <unit> at <tmp> line 1
tbrowder_ m: say Uni.new(0x2000).NFC.list.base(16) 10:49
camelia No such method 'base' for invocant of type 'Seq'. Did you mean any of these?
Hash
asec
hash
race

in block <unit> at <tmp> line 1
tbrowder_ m: say Uni.new(0x2000).NFC.list 10:50
camelia (8194)
geekosaur m: say Uni.new(0x2000).NFC.list>>.base(16)
camelia (2002)
tbrowder_ m: say Uni.new(0x2000).NFC.list.map(*.base(16)); 10:53
camelia (2002)
tbrowder_ m: say Uni.new(0x2000 .. 0x200A).NFC.list.map(*.base(16)); 10:55
camelia (2002 2003 2002 2003 2004 2005 2006 2007 2008 2009 200A)
tbrowder_ say Uni.new(0x2000) 10:57
evalable6 Uni:0x<2000>
Geth doc/master: 4 commits pushed by (JJ Merelo)++ 11:15
Geth doc: e3182d93cf | (JJ Merelo)++ | 2 files
Fleshes out system file
11:49
jmerelo m: say $*ARGFILES.filename; 12:50
camelia No such method 'filename' for invocant of type 'IO::ArgFiles'
in block <unit> at <tmp> line 1
moritz m: $*AGFILES.^methods(:local) 12:51
camelia ( no output )
moritz m: say $*AGFILES.^methods(:local) 12:52
camelia (DESTROY AT-POS AT-KEY defined handled Capture Int Num Numeric Set SetHash Bag BagHash Mix MixHash mess sink self CALL-ME FALLBACK STORE new Bool Str gist perl exception backtrace BUILDALL)
moritz m: say $*AGFILES.^name
camelia Failure
moritz ARG
m: say $*A$GFILES.^name
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3say $*A7⏏5$GFILES.^name
expecting any of:
infix
infix stopper
postfix
statement end
statement mod…
jmerelo moritz: yes :-)
jkramer :D
moritz m: say $*ARGFILES.^name
camelia IO::ArgFiles
moritz m: say $*ARGFILES.^methods(:local)
camelia ()
moritz m: say $*ARGFILES.^methods
camelia (write on-switch lines encoding IO t slurp-rest seek path out-buffer opened handles getc flush words split slurp readchars put printf print-nl open gist print nl-in perl native-descriptor eof comb DESTROY tell say read next-handle new get chomp lock M…
moritz at least I noticed that I was confused :) 12:53
jmerelo Related to this: github.com/perl6/doc/issues/2058
It's probably path...
Instead of filename, I guess...
m: say $*ARGFILES.path; 12:54
camelia IO::Special.new("<STDIN>")
Geth doc: 4ae64b89f2 | (JJ Merelo)++ | doc/Language/5to6-perlvar.pod6
:zap: filename → path closes #2058
12:56
synopsebot Link: doc.perl6.org/language/5to6-perlvar
buggable New CPAN upload: Net-servent-0.0.1.tar.gz by ELIZABETH cpan.metacpan.org/authors/id/E/EL/...0.1.tar.gz 13:23
jkramer Inside a class that is an Array, can I use shortcuts for self like $.foo etc, but for accessing elements of the array? $.[0] doesn't seem to work 13:52
timotimo you could give the invocant a shorter name by putting it into the signature 13:53
lucasb I wonder if this lines were removed: github.com/rakudo/rakudo/blob/mast...2147-L2150 14:15
then $.[5] would be possible
lizmat and what would that mean ? 14:17
lucasb same as self.[5] 14:18
inside Positional classes
lizmat hmmm... 14:19
jkramer Hmm I'll just use self for now :) 14:20
timotimo m: class Test is Array { method test(\S: $a) { S[$a] } }; Test.new(1, 2, 3).test(1) 14:21
camelia ( no output )
timotimo m: class Test is Array { method test(\S: $a) { S[$a] } }; say Test.new(1, 2, 3).test(1)
camelia 2
timotimo jkramer: does that make things better?
jkramer timotimo: I don't really need to save those bytes :) I just assumed $.[0] would work since .[0] with $_ does and I was curious 14:23
timotimo m: class Test is Array { method test($_: $a) { .[$a] } }; say Test.new(1, 2, 3).test(1)
camelia 2
timotimo you can have it your way :D
jkramer Unrelated question: are there words for the directions of diagonals? Like / (top-right to bottom-left) and \ (top-left to bottom-right)
lucasb yes! I compiled a list of those aliases! haha 14:24
just a sec
diagonal names: 14:26
[\] main, major, principal, primary, leading
[/] anti, minor, counter, secondary, trailing
jkramer Ha, wonderful :D Thanks!
lucasb naming things is hard
Luneburg Does perl6 have a Fibonacci function in the standard library? 14:55
b2gills .tell Qwerasd `for @arr.kv -> $i, $_ { @arr.splice($i,1) when 5 }`
yoleaux b2gills: I'll pass your message to Qwerasd.
b2gills m: .say for 1, 1, * + * ... *; # no need, it is easy to create a Fibonacci sequence 14:56
camelia (timeout)1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14:57
jkramer Is there a variant of zip/Z that works on partials? So when one lists is shorter than the other it still continues
b2gills jkramer: roundrobin
Luneburg b2gills: Thanks
jkramer b2gills: Sweet, thanks! 14:58
Luneburg m: my $sequence = "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGCC";loop (my $i = 0; $i <= $sequence.chars; $i++) { say $sequence[$i];} 15:25
camelia AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGCC
Index out of range. Is: 1, should be in 0..0
in block <unit> at <tmp> line 1
Luneburg Is there any way to loop through a string? 15:26
geekosaur you want substr, not indexing
a Str is a single entity, not a fake list
timotimo what you really want is .comb, it looks like
geekosaur or that, yes
Luneburg geekosaur: Thanks, what does .comb actually do though? I can see it adds spacing between the characters? 15:28
jkramer Without arguments it returns a list of the single characters 15:29
geekosaur that's just how a list is rendered by default. it explodes the Str into a list of characters
Luneburg Thanks ;) 15:30
geekosaur you can use .perl to see what the value actually looks like, or use "dd" instead of "say" to get even more internal detail (usually too much unless you're debugging) 15:31
m: say "abc".comb.perl
camelia ("a", "b", "c").Seq
geekosaur (Seq is a read-only, one-shot list; saves memory and garbage collection time for most ephemeral lists) 15:32
b2gills Luneburg: rather than `loop (my $i = 0; $i <= $sequence.chars; $i++) {…}` use `for 0..$sequence.chars -> $i {…}` or better yet in this case `for $sequence.comb { say $_ }` 15:34
timotimo m: say "abcdefghijklmnop".comb(3).perl 15:35
camelia ("abc", "def", "ghi", "jkl", "mno", "p").Seq
timotimo also a very useful feature of comb
b2gills Basically you should almost never use `loop (;;)`, as you are probably doing something that is easier done another way.
Geth doc/master: 5 commits pushed by (JJ Merelo)++ 17:14
doc: 4a162095c8 | (JJ Merelo)++ | 3 files
Finishes first full version of the system interaction page.

Refs #114. It's rather brief and not (never) perfect, but it's a good guide on how to interact with the system. I'll check this page now and move on to the next one.
17:15
jmerelo releasable6: status 17:21
releasable6 jmerelo, Next release in ≈22 days and ≈1 hour. 1 blocker. 0 out of 19 commits logged (⚠ 9 warnings)
jmerelo, Details: gist.github.com/7729c6305faa4a4dea...fc1f7ff713
jmerelo So we have a new version... 17:22
El_Che mm 17:30
didn't know that
El_Che let's spin some packages on travis and see how it goes :) 17:33
lucasb whenever you want to call methods on a new anonymous state var, you have to wrap it in parentheses, right? like ($).foo, (@).bar and (%).baz 17:47
because otherwise it would be interpreted as calls to the object/class the code is inside: $.foo, @.bar, %.baz 17:48
jmerelo lucasb: say what? 17:49
raschipi I didn't see any other idiom to do that, you get to create one.
lucasb *except* when the call is a subscripts, like @.[...] or %.{...}, %.<...>, in this case you are calling on the anonymous state var
jmerelo lucasb: is that documented?
lucasb jmerelo: which part? :) 17:50
El_Che why would you use anonymous vars if you reference the later? Is there an added value there?
jmerelo lucasb: well, pretty much everything...
lucasb ok, let me conclude, then I go back to the raised issues :D 17:51
What I'm suggesting is that syntax like @.[42] %.{'key'}, %.<key> be changed to mean access to the current object/class the code is within 17:52
m: $.foo
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable $.foo used where no 'self' is available
at <tmp>:1
------> 3$.foo7⏏5<EOL>
expecting any of:
term
jmerelo lucasb: $.foo is syntactic sugar for self.foo 17:53
lucasb obviously, *if* the objects are of the type Associative and Positional, etc.
jmerelo that's probably the reason why you have to put the () around, to disambiguate
lucasb jmerelo: you are correct. the same way @.foo and %.foo also are
jmerelo: correct. and I want that to stay the same 17:54
in things like @.[42] %.{'key'}, %.<key>, it should be required to put () around too!
(@).[42] (%).{'key'}, (%).<key> if you want to access the anonymous state var, otherwise let this syntax mean access to the current self object 17:55
jmerelo lucasb: so what you are saying is try to extend that same criterium to other "bracketing" things, so that $. == self whenever possible. 17:56
lucasb yes, exactly :)
jmerelo so @.[42] would be self[42] if that makes any sense.
lucasb except that there's a problem with "$." being the old P5 special var, so I took it out of the examples 17:57
jmerelo lucasb: OK, it's not a documentation problem then :-), although it might be good if you open an issue with some example where disambiguation needs to be done.
lucasb: old p5 special vars are not really a problem.
lucasb: maybe you should open a discussion in the rakudo repo, after checking what the specification says about that. If it's not specced, it might be reasonably argued. 17:58
Zoffix AlexDaniel++ samcv++ # release 18:01
jmerelo AlexDaniel++ samcv++ and the rest of the team
Zoffix lucasb: why add a gazillion variants of some cryptic syntax? Especially one that's close to anon vars. 18:02
Reminds me of a joke I heard on Twitter: "Perl 6 is what happens when the answer to every bikeshedding session is: 'Let's do both!'"
jmerelo Zoffix: now that you mention twitter... twitter.com/jjmerelo/status/1000069722224852992 18:03
Zoffix jmerelo: what am I looking at?
jmerelo Zoffix: the official extraofficial announcement of perl 6 2018.05 18:04
lucasb Zoffix: my suggestion would make things more orthogonal than they currently are 18:05
Zoffix lucasb: and especially one that's close to attribute syntax that isn't entirely trivial for newcomers to understand. It's quite a lot of mental processing required to discern $.<foo> between anon state var, attribute access or just a method call on self.
jmerelo Zoffix: I mean, if you're looking at that Twitter URL.
Zoffix I don't know why folks use $.foo syntax for non-attribute method calls. Seems like a good way to confuse the reader
lucasb well, maybe folks have a usecase, since self.foo is different from $.foo :) 18:07
They are contextualizers, right? $.foo is $(self.foo), @.foo is @(self.foo), %.foo is %(self.foo) 18:08
m: class { method foo { 1,2,3 }; method bar { self.foo } }.bar.perl.say
camelia (1, 2, 3)
lucasb m: class { method foo { 1,2,3 }; method bar { $.foo } }.bar.perl.say
camelia $(1, 2, 3)
Zoffix lucasb: because it's not just %.<foo>. It's also %».<foo>, %».+<foo>, %».*, %».+, %.&bar and dozens more variants. Which of those would mean `self` and which would mean a static anon? Or will you now force all static var use to use parens? 18:09
Zoffix In fact, when $.+foo syntax was being argued for, I said, no don't add it, because then we'll start going insane. And here we are, proposing more things. And how many people used $.+foo syntax? One? 18:10
lucasb I'm suggesting only method-ish calls
Zoffix lucasb: why the omission then?
This is all special casing: %.<foo> works, but only (as you earlier said) `self` is an Associate and now only with "method-ish" calls, which I don't even know the definition of. 18:11
lucasb currently, %.<foo> always means (%).<foo> 18:12
currently, $.foo always means $(self.foo)
I'm not suggesting *if and only if* classes are Positional, Associative, etc. 18:13
El_Che "it's not just %.<foo>. It'sit's not just %.<foo>. It's also %».<foo>, %».+<foo>, %».*, %».+, %.&bar and dozens more variants" <-- that's what I meant with a big language some days ago :)
lucasb The syntax should be invariant
Zoffix mst: would you be able to add a link to our second logger to the /topic of #perl6-dev #moarvm #perl6-toolchain : colabti.org/irclogger/irclogger_logs/perl6 or give one of the non-op regulars ops so they could do it themselves? 18:14
uhh 18:15
mst it ... seems to be in /topic ? 18:15
Zoffix mst: I think it's three different links actually: colabti.org/irclogger/irclogger_logs/perl6-dev colabti.org/irclogger/irclogger_logs/moarvm and colabti.org/irclogger/irclogger_log...-toolchain but the logger people want us to add to the topic before they start logging
AlexDaniel: right?
mst: only in this channel, but not in #perl6-dev, #moarvm, and #perl6-toolchain 18:16
mst ah
AlexDaniel correct, this channel is fine 18:17
mst Zoffix: right, you now have access to all four to do '/msg chanserv op' 18:18
Zoffix mst++ thanks
AlexDaniel mst++
mst and I stole #moarvm from diakopter and gave jnthn perms there too
if anybody wants anybody else adding, just shout
actually 18:19
mst adds AlexDaniel to all four
AlexDaniel thanks
mst AlexDaniel: well volunteered, my main objective here is that if your bots go nuts you can kick/ban/unban them etc.
samcv thanks for the well wishing of the release :) 18:20
Zoffix u: butterfly 18:22
unicodable6 Zoffix, U+1F98B BUTTERFLY [So] (🦋)
AlexDaniel u: abnteh
unicodable6 AlexDaniel, Found nothing!
AlexDaniel hm, was it always that fast? 18:23
Zoffix »ö« 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! 🦋
Zoffix (just added 🦋 after "unicode is our friend") 18:23
Did it work? Doesn't show up right in the irc logs (and I don't see those chairs in my terminal) 18:24
I mean chars
But I don't see any chairs either
AlexDaniel shows up correctly: colabti.org/irclogger/irclogger_log...05-25#l494
moritz looks fine here
Zoffix cool 18:25
AlexDaniel but yeah, not here: irclog.perlgeek.de/perl6/2018-05-25#i_16206699 18:25
skids ⑁⑁⑁⑁ 18:30
raschipi u: ⑁ 18:31
unicodable6 raschipi, U+2441 OCR CHAIR [So] (⑁)
Geth doc: 6c41a4b120 | (JJ Merelo)++ | 2 files
Start rewriting of the hashmap language page

Follows #1682 advice of moving the top-heavy part of the Hash type to this page. That part has been rewritten in similarity to Array, by making references to its general behavior using parallelisms between them. This also goes towards fulfillment of the roadmap #114
18:35
Geth doc: a484eb9149 | (JJ Merelo)++ | doc/Language/hashmap.pod6
Reflows and adds maps info where necessary

Since this document now talks about hashes *and* maps, some sentences must include them. Refs #1682.
18:51
synopsebot Link: doc.perl6.org/language/hashmap
moritz IRC logging is a huge privacy nightmare; I might have to stop doing that if the GDPR really hits 18:57
masak :( 18:59
moritz: it strikes me that I've had immense use of the IRC logs over the years. mille grazie 19:00
moritz masak: my pleasure. So far I don't have concrete plans to shut them down, but... 19:01
there are so many unsolved problems 19:02
* GDPR requires explicit consent before processing data. Getting consent from every IRC user is simply impossible
* It's not clear if nick names automatically consistitute personally identifiable information
* It's not clear to me how to process requests for data removal without destroying the whole context of a conversation 19:03
masak right
moritz on the plus side, I'm not logging any IP addresses 19:04
masak are you allowed to mark in some way if a conversation has had messages removed?
moritz I'm pretty sure I do
so I could replace all removed messages with nickname (removed) and line (removed) 19:05
AlexDaniel I wonder what Matrix folks figured out regarding GDPR and their freenode bridge
moritz it gets really murky if somebody has messages (partially) bounced off of bots
AlexDaniel but through that bridge you can't get messages from before you joined the channel
raschipi I'm not logging any IP addresses --> You're required to do that by Brazillian law, btw 19:06
jmerelo The GDPR could potentially affect even bots
If you somehow log whoever is asking and what they asked... 19:07
AlexDaniel rrrrrrrrrrrrrrrrrrriight
moritz raschipi: how charming :-)
AlexDaniel quotable6 actually caches irc logs…
moritz fwiw on the webserver side I delete the last octet of IPs in the logs 19:08
raschipi But Freenode is the one required, not people that archive the messages. 19:09
moritz (and the last 4 bytes for IPv6 addresses)
masak .oO( we're letting you know that your processing^Wprivacy is important to us )
raschipi Anonymity is forbidden by the constitution in Brazil. 19:10
moritz is that why they fought with WhatsApp? 19:11
comborico1611 I find it sadly amusing that nations call themselves republics when they don't even pretend to be. At least in America, we pretend to be a republic.
raschipi Well, not specifically using the Constitution directly, but the laws implement the constitutional mandate saying they need to point which IP adress said what and when. 19:12
With the IP number and the timestamp, after a WHOIS, you can go to the ASN and they need to point which customer it came from. 19:13
s/ASN/AS/ 19:14
moritz ... unless there's a NAT inbetween
raschipi Well, if the ISP keeps the NAT, they need to keep records. If the client has it, that will narrow the investigation to a very small area. And it doesn't deal with a VPN and much less Tor. 19:21
But most people aren't that sofisticated and they regularly inprison people for what they said on the internet. 19:23
translate.google.com/translate?sl=...policia%2F 19:25
At least they don't jail people for their political opinions like the UK does.
lucasb raschipi: hehe, daora topar com outros brasileiros aqui. que legal que vc tbm curte P6 :) 19:30
raschipi Outro zuca é o SmokeMachine 19:31
SmokeMachine \o/ 19:32
ktown m: sub got ( $x where ^10) { say $x.perl } ; got "1" ; 20:14
camelia "1"
ktown m: sub got ( $x where ^10) { say $x.perl } ; got "2" ;
camelia Constraint type check failed in binding to parameter '$x'; expected anonymous constraint to be met but got Str ("2")
in sub got at <tmp> line 1
in block <unit> at <tmp> line 1
ktown m: sub got ( $x where ^10) { dd $x } ; got "1" ; 20:15
camelia Str $x = "1"
ktown m: sub got ( $x where ^10) { dd $x } ; got "2" ;
camelia Constraint type check failed in binding to parameter '$x'; expected anonymous constraint to be met but got Str ("2")
in sub got at <tmp> line 1
in block <unit> at <tmp> line 1
sjn m: sub got ( $x where ^10) { dd $x } ; got(2) ; 20:21
camelia Int $x = 2
ktown m: sub got ( $x where ^10) { dd $x } ; got "0" ;
camelia Str $x = "0"
ktown m: sub got ( $x where ^10) { dd $x } ; got 11 ;
camelia Constraint type check failed in binding to parameter '$x'; expected anonymous constraint to be met but got Int (11)
in sub got at <tmp> line 1
in block <unit> at <tmp> line 1
Herby_ \o 20:27
o/ 20:31
ktown m: sub got ( $x where ^10) { dd $x } ; got split(/\,/,"1,1")[0] ; 20:33
camelia Str $x = "1"
ktown m: sub got ( $x where ^10) { dd $x } ; got split(/\,/,"2,1")[0] ;
camelia Constraint type check failed in binding to parameter '$x'; expected anonymous constraint to be met but got Str ("2")
in sub got at <tmp> line 1
in block <unit> at <tmp> line 1
ktown is this odd? 20:34
timotimo m: say "9" ~~ ^10 20:37
camelia False
timotimo m: say 9 ~~ ^10
camelia True
timotimo i don't find it terribly odd
you can have a coercive type constraint in the signature, though
m: sub got ( Int() $x where ^10) { dd $x } ; got split(/\,/,"2,1")[0] ;
camelia 2
ktown m: say "9" == ^10 20:38
camelia False
timotimo oh, i don't think i saw correctly
ktown m: say 9 == ^10
camelia False
timotimo say "1" ~~ ^10
evalable6 True
timotimo yeah, that is kind of weird
say "2" ~~ ^10
evalable6 False
timotimo s: ^10, "ACCEPTS", ("2")
SourceBaby timotimo, Something's wrong: ␤ERR: Cannot resolve caller sourcery(Range, Str, Str); none of these signatures match:␤ ($thing, Str:D $method, Capture $c)␤ ($thing, Str:D $method)␤ (&code)␤ (&code, Capture $c)␤ in block <unit> at -e line 6␤␤
timotimo s: ^10, "ACCEPTS", \("2")
SourceBaby timotimo, Sauce is at github.com/rakudo/rakudo/blob/847d...e.pm6#L429
lucasb not "1" before 0 20:39
oops, sorry
ktown in the signature, the right side is an int
oooh, where is eq not ==
timotimo no, where is ~~
lucasb m: say not "1" after 10 20:40
camelia True
lucasb m: say not "2" after 10
camelia False
timotimo m: say "01234567890".comb.grep(^6)
camelia (0 1 2 3 4 5 0)
timotimo is it lexicographical sorting that messes this up? 20:41
m: say "01234567890".comb.grep(45..69)
camelia (5 6)
timotimo looks like
that looks a lot like a trap
ktown i have seen a few example that use $x where ^10 to check an int 0..10, but in a case where I split a string and pass to method it's not happy 20:43
timotimo yeah, it's doing lexicon comparison 20:44
the numbers have to come after 0 but before 10 in the lexicon, but 10 comes before 2
so the only numbers that would fit in ^10 would be 0 and 1 20:45
lucasb github.com/rakudo/rakudo/blob/mast...#L498-L504
ktown in p5 it was always clear the operater coerces the arguments 20:46
lucasb before and after always do str comparison
should they have different multis for doing different comparisons?
timotimo aren't before and after DWIM comparisons? 20:47
leg and friends always do str comparison
lucasb well, 'cmp' is Stringy
timotimo s: &infix:<cmp>, \(1, 2)
SourceBaby timotimo, Sauce is at github.com/rakudo/rakudo/blob/847d...er.pm6#L46
lucasb oops, sorry, mixed with Perl 5 20:48
timotimo i was about to say
lucasb :)
I think this multi get selected for this case: github.com/rakudo/rakudo/blob/mast...m6#L10-L13 20:50
and so, ends up being Stringy comparison 20:51
timotimo s: &infix:<cmp>, \(1, "2")
SourceBaby timotimo, Sauce is at github.com/rakudo/rakudo/blob/847d...er.pm6#L15
timotimo s: &infix:<cmp>, \("2", 1)
SourceBaby timotimo, Sauce is at github.com/rakudo/rakudo/blob/847d...er.pm6#L22
ktown is there a numberic version of where in the signature? 20:51
timotimo actually, the two below it, but it comes out the same way
you can use the coercion type i showed above 20:52
m: sub got ( Int() $x where ^10) { dd $x } ; got split(/\,/,"2,1")[0];
camelia 2
timotimo this one
ktown timotimo: yes but that is not obvious from the docs on signatures or the examples 20:53
timotimo "where" uses smartmatch semantics, so you have to search for that 20:54
if there isn't a link from "where" to "smartmatch" that's worth an issue in the issue tracker
ktown reads docs.perl6.org/type/Signature again 20:57
timotimo The where clause doesn't need to be a code block, anything on the right of the where-clause will be used to smart-match the argument against it. So you can also write:
that's where the link is
docs.perl6.org/language/operators#infix_~~ 20:58
though i'd even say it should link to ACCEPTS instead?
huh
that only handles ranges overlapping
that seems like a major oversight
When smart-matching a Range of integers with a Cool (string) the ACCEPTS methods exploits the before and after operators in order to check that the Cool value is overlapping the range: 20:59
ktown down around the "sub can-turn-into" stuff
timotimo not sure what part of that is relevant here 21:06
ktown in javacript you need parseInt because there is no hint for the coercion. p5 never had that issue. But here I passed a string to an Int comparison and got an error sometimes (0 and 1 are special) 21:09
timotimo smartmatch is not int comparison, it's dwim comparison 21:10
ktown yes...
Kaiepi i love how you can pretty well do whatever you want with roles hastebin.com/cezazuyeja.pl
timotimo if you want it a different way, you can also have "where 0 <= * < 10
" in the signature 21:11
that will be a numeric comparison and that will work as you expect it to
ktown yah, that would be the note to add to the docs to force a numeric range comparison the "where ^10" or "where 0..10" did not do what I expected 21:13
I always thing "10" is a string but 10 is an int but in this case it's not 21:15
*think 21:16
timotimo it is surprising to have string comparison there, yeah
ktown m: 10 ~~ "10" 21:20
camelia ( no output )
ktown m: say 10 ~~ "10"
camelia True
ktown i'm not completely (just mostly) crazy 21:21
raschipi I don't see why Numeric.ACCEPTS or Range.ACCEPTS can't convert strings to numbers before testing them. 21:23
raschipi They know their own type... 21:31
lucasb Maybe infix:<cmp>(Real, Any) should do numeric comparison and infix:<cmp>(Any, Real) should do string comparison. IOW, do different things depending on the type of the first operand. 21:37
they way they are now, both do string comparison, regardless of the order of the operands
*the way 21:38
raschipi But ~~ doesn't use cmp, does it?
lucasb iiuc, in this case it does 21:39
raschipi The documentation says they first coerce the arguments to numeric, then do numeric comparisson. If they just call cmp between the operands, that should be pointed out, I think. 21:41
Then what cmp does is another question, currently it prefers string comparisson as was pointed above. Is it supposed to be a transitive operator? 21:42
lucasb do you mean transitive or symmetric? :) 21:46
raschipi transitive too
Geth doc: d0fbecd26c | (Ben Davies)++ | doc/Language/js-nutshell.pod6
Fix some redundancy in JS nutshell bitwise operators section
21:47
synopsebot Link: doc.perl6.org/language/js-nutshell
lucasb hmm, dunno
is there a negation/toggle operator for Order values? More->Less, Less->More, Same->Same ? 21:48
masak m: say -More 21:49
camelia -1
raschipi Yes, negate it
Oh, already answered 21:50
lucasb ok, works, but lost the enum value 21:51
*type
masak m: say Order(-More) 21:56
camelia Less
lucasb right :) 21:58
so, I guess I can say that 'cmp' is symmetric in the sense that "A cmp B" is equivalent to "OrderNegation(B cmp A)" 21:59
if it did different types of comparison depending on the type of the first operand, the above property wouldn't hold true anymore 22:00