🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
ben_m I wonder why there's no Unicode variant of the feed operator? ==> looks so ugly to me 00:00
Xliff How can I get DBIish to insert a null? 01:45
Type objects seem to confuse it. 01:46
leont r: dd CallFrame().^coerce(val("1")) 02:02
camelia No such method 'WHICH' for invocant of type 'NQPMu'
in block <unit> at <tmp> line 1
Method 'coerce' not found for invocant of class 'Perl6::Metamodel::CoercionHOW'
in block <unit> at <tmp> line 1
leont That error makes no sense
It looks like coerce is returning a value that can't be dd()ed (or actually .raku()d) 02:06
Ah, seems the issue isn't coercion related, but calling CallFrame.new with a too high number gives a very confusing error 02:21
Xliff Is there a phaser that is run even when you ^C out of a running program? 02:36
leont ^C typically sends a SIGINT
You can catch that 02:37
Xliff Yeah, but I want the same code to run at exit.
Ah well, I guess I'll sub it. leont++
rypervenche Actually, rakubrew.org's domain simply needs to be renewed. It expired at the DNS registrar, it seems. 02:55
leont What can possibly go wrong if someone hijacks that… 03:10
Grinnz i'm just imagining if someone domain squatted perlbew.pl with malicious intent... ugh 03:11
perlbrew.pl* 03:12
stanrifkin rakubrew.org still down 06:48
rakudoc still not working
Geth doc: 02b8c0d524 | (Stoned Elipot)++ (committed by Juan Julián Merelo Guervós) | doc/Type/Failure.pod6
Failure.handled() is rw
07:44
linkable6 Link: docs.raku.org/type/Failure
Geth doc: a01d1fbe73 | (Stoned Elipot)++ | doc/Type/Failure.pod6
Add refs to lvalue and 'is rw' routine trait
11:10
linkable6 Link: docs.raku.org/type/Failure
notandinus m: sub t (Str $pass --> Int, Int) {} 11:37
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed return value (return constraints only allowed at the end of the signature)
at <tmp>:1
------> 3sub t (Str $pass --> Int7⏏5, Int) {}
notandinus whats wrong with that ^?
moritz two return values 11:38
if you do a return 1, 2 you are actually returning a List
notandinus i see, if i want to return a list of exactly 2 elements & both being Int then what should be used? 11:40
Geth doc: 3bd691993c | (Stoned Elipot)++ | doc/Type/Failure.pod6
Examples rewrite

Make Failure.{Bool,defined} examples certainly repetitive, but more demonstrative and hopefully more readable.
linkable6 Link: docs.raku.org/type/Failure
Geth ecosystem: e986e87e64 | (Elizabeth Mattijsen)++ | ADOPTERS.md
Start keeping track of module adopters
12:00
notandinus or how do i return 2 Int the correct way? 12:03
lizmat notandinus: you mean, have it type checked that you did in fact return a list with 2 Ints ? 12:06
because returning 2 Ints is as easy as: "return 42,666" 12:07
notandinus lizmat: yeah i want it type checked 12:08
m: sub t (--> List) {} 12:09
camelia ( no output )
notandinus i changed it to ^
but say i want to make sure its returning 2 ints
lizmat you could start with: 12:12
my subset TwoInts of List where { .elems == 2 }; sub a(--> TwoInts) { 42,666 }
and build from there... there isn't any easy syntactic sugar in Raku for this (yet)
notandinus oh i see, i thought i was missing something. i think for now `List' will be fine. 12:13
thanks for ^
lizmat I was checking whether my Rake module could be helpful for that
modules.raku.org/dist/Rake
and ran into what looks like a bug / oversight to make it easy to use for this type of thing 12:14
my idea was that you could say:
my TwoInts = Rake[Int,Int]; sub foo(--> TwoInts) { return TwoInts(42,666) } 12:15
but that won't work currently
notandinus hmm i see, Rake looks good, i'll check it
i see, also `:` is just for immutability right?
lizmat but please not that generally when you need to return more than two values of information
notandinus m: my $k := 1; $k =2 12:16
camelia Cannot assign to an immutable value
in block <unit> at <tmp> line 1
lizmat you're probably better off creating a class for it
:= is binding
notandinus i see, i haven't looked into class and oop things yet
lizmat when you bind a constant to a lexpad entry, it is immutable
until you bind it with something else
docs.raku.org/language/operators#i...g_operator 12:17
notandinus ah i see, thanks 12:18
masak .oO( := is binding, like a legal contract ) 12:22
oh, so a Rake is a tuple type 12:25
Geth doc: 85e7630336 | (Stoned Elipot)++ | doc/Type/Test.pod6
Add ref to testing document
13:03
linkable6 Link: docs.raku.org/type/Test
xinming m: my %x = :a1<a b>; my @h = (|%x<a> // Empty); @h.raku.say; 16:33
camelia [Any]
xinming what is the right way to return "Empty" list, when the value is not defined please? 16:34
m: my %x = :a1<a b>; my @h = (|%x<a> || Empty); @h.raku.say; 16:35
camelia [Any]
xinming m: my %x = :a1<a b>; my @h = (%x<a> ?? |%x<a> !! Empty); @h.raku.say; 16:36
camelia []
xinming the last one work as expected, But a bit tedious really.
stoned75 m: my %x is default(Empty) = :a1<a b>; my @h = |%x<a>; say @h; 16:40
camelia []
codesections yeah, I was about to suggest `is default` too. docs.raku.org/type/Variable#index-...is_default 16:41
codesections (if you can't change the signature for %x and want similar behavior where you declare @h, you can do something like `my Any:D @h = |%x<a> // Empty;`) 16:46
Geth doc: MorayJ self-unassigned "Regex and interpolation is a bit confusing" github.com/Raku/doc/issues/2230
287fe13012 | (Stoned Elipot)++ | doc/Type/Exception.pod6

Do not try if we want to CATCH.
17:48
ben_m Am I the only one who really dislikes the --> syntax for return types? Especially having it inside the parameter list 19:18
lizmat you can also use the "returns" trait 19:19
MasterDuke ben_m: there is also the `sub a($b) returns Int { ... }` syntax, though it's likely to be deprecated a long time from now
leont Or the of trait
lizmat sub a() returns Int { "bad" }; a
m: sub a() returns Int { "bad" }; a
camelia Type check failed for return value; expected Int but got Str ("bad")
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat the reason for --> is that you cannot specify the "returns" trait on blocks easily 19:20
m: my $a = --> Int { "bad" }; $a()
camelia 5===SORRY!5=== Error while compiling <tmp>
Prefix -- requires an argument, but no valid term found.
Did you mean -- to be an opening bracket for a declarator block?
at <tmp>:1
------> 3my $a = --7⏏5> Int { "bad" }; $a()
expecti…
lizmat m: my $a = -> --> Int { "bad" }; $a()
camelia Type check failed for return value; expected Int but got Str ("bad")
in block <unit> at <tmp> line 1
lizmat my $a = --> Int { "bad" }; $a() # hmmm... this should probably be allowed as well? 19:21
ben_m sub f($a, $b --> Int) {} just parses weirdly in my head 19:22
MasterDuke i didn't like it as much either, but i've gotten used to it 19:24
lizmat I like it better because it can be used on subs, methods and blocks 19:36
lizmat although the syntax with subs and methods might give you the idea that it is part of the signature of the sub/method, which it is **NOT** 19:37
v_m_v Hello. I am trying to solve Euler problem with Raku (projecteuler.net/problem=12). My solution is really slow (pastebin.com/Drpq6Nsn). Can I somehow make it faster in Raku? 20:45
MasterDuke v_m_v: well, it's probably not the most expensive thing, but you're calling is-prime twice if the number is in fact prime 20:48
also, do you have to go up to `($number div 2)`, could it be `($number.sqrt.Int + 1)`? 20:50
MasterDuke v_m_v: oh, and you don't want to do `%hash<$candidate>`, that looks for the literal string '$candidate' in the hash. you want `%hash{$candidate}`, that actually looks for the value in the $candidate variable 20:56
i'd fix that first, otherwise your code won't be doing what you want it to 20:57
linkable6 Link: docs.raku.org/type/Exception
chloekek . 21:14
v_m_v @MasterDuke: Thank you. 22:36
@MasterDuke: I have removed the "prime" checking (those numbers are quite big and most of them are not primes). I have also changed $number div 2 to $number.sqrt.Int + 1. It is a way faster now. Still Raku is not the faster programming language but it is awesome. 22:40
guifa v_m_v: it will take time for speed to get to Raku, but it’s been making lots of improvements. Just think how slow JS was until Google, Mozilla, and Microsoft poured literal millions of dollars int work speeding it up 23:04
(and now it’s possible for JS code to be as fast or faster than C for some stuff because of the JIT engine) 23:05
timotimo our good friends on the discord server found out that [+] $foo gets translated directly to $foo.sum, which is wong when $foo contains a list of some kind, since [*] and others won't iterate because scalar 23:40