🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
patrickb I seem to recall there was a (now unmaintained PSGI stack for Raku. 05:13
antononcube Maybe someone should do a design or motivational document for "Raku SGI" similar to this one: metacpan.org/dist/PSGI/view/PSGI/FAQ.pod 12:41
ugexe raku.land/cpan:HANENKAMP/Smack was an experiment with something more raku-specific 12:47
antononcube 👍 12:55
Xliff_ \o 13:55
Good morning! I'm trying to port some Javascript that wants to use a Map with object keys. I thought this would work, but it doesn't...
m: class A { }; my $c = Hash[A, Mu].new; my $aa := A.new; my $bb = A.new; $c{$aa} = 1; $c{$bb} = 2; $c.gist.say; $c.keys.map( *.^name ).gist.say
camelia Type check failed in assignment to ; expected A but got Int (1)
in block <unit> at <tmp> line 1
Xliff_ m: class A { }; my $c = Hash[A, Mu].new; my $aa = A.new; my $bb = A.new; $c{$aa} = 1; $c{$bb} = 2; $c.gist.say; $c.keys.map( *.^name ).gist.say
camelia Type check failed in assignment to ; expected A but got Int (1)
in block <unit> at <tmp> line 1
Xliff_ I'm a little concerned about the "assignment to ;". Can someone help? 13:56
Odd... this does! 13:58
m: class A { has $.a }; my $c = Hash[Mu, Mu].new; my $aa := A.new( a => 42 ); my $bb = A.new( a => 23 ); $c{$aa} = 1; $c{$bb} = 2; $c.gist.say; $c.keys.map( *.a ).gist.say
camelia {A.new(a => 42) => 1, A.new(a => 23) => 2}
(23 42)
ugexe m: class A { }; my %c{A}; my $aa := A.new; my $bb = A.new; %c{$aa} = 1; %c{$bb} = 2; %c.gist.say; %c.keys.map( *.^name ).gist.say 16:27
camelia {A.new => 2, A.new => 1}
(A A)
ugexe m: class A { }; my $c = Hash[Mu, A].new; my $aa := A.new; my $bb = A.new; $c{$aa} = 1; $c{$bb} = 2; $c.gist.say; $c.keys.map( *.^name ).gist.say; $c{1} = 1 16:28
camelia {A.new => 2, A.new => 1}
Type check failed in binding to parameter 'key'; expected A but got Int (1)
in block <unit> at <tmp> line 1

(A A)
ugexe m: raku -e 'class A { }; my $c = Hash[Mu, A].new; my $aa := A.new; my $bb = A.new; $c{$aa} = 1; $c{$bb} = 2; $c.gist.say; $c.keys.map( *.^name ).gist.say 16:29
camelia ===SORRY!=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> raku -e⏏ 'class A { }; my $c = Hash[Mu, A].new;
expecting any of:
infix
infix stopper
postfix
statement …
ugexe m: class A { }; my $c = Hash[Mu, A].new; my $aa := A.new; my $bb = A.new; $c{$aa} = 1; $c{$bb} = 2; $c.gist.say; $c.keys.map( *.^name ).gist.say
camelia {A.new => 2, A.new => 1}
(A A)
ugexe anyway you can do `my Hash %c{A}` or you need to reverse the parameters to Hash i.e. Hash[Mu, A] instead of Hash[A, Mu]
Xliff_ ugexe: Thanks... so it has to be '$' sigil'd and Hash[<val>, <key>] ? 17:11
ugexe my %c{A}; %c{$a} = 1; or my $c = Hash[valType, keyType].new 18:24