🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
elcaro nvm... found a work around... bind the Proxy to `OUR::{'$varname'}` 00:00
elcaro I can dynamically define a module sub like so `OUR::{"&$name"} := sub { ... }`, but can I define multi sub's? 02:01
samebchase Hi, I need some assistance with Red. I've described the problem here: github.com/FCO/Red/issues/543 06:23
moon-child SmokeMachine: 06:24
tbrowder wish i could help, but i have my own problems this morning :-( 11:14
lizmat wishes tbrowder strength 11:15
tbrowder thnx, i'm getting a weird error about Mu while iterating over an array. 11:16
the algo is like this: while @a.elems { say @a.tail.value // ''; @a.pop} 11:20
at some point i get this error which i will show in a minute (i forgot to note it).... 11:21
"No such method 'value' for invocant of type Mu" 11:22
tbrowder i think i need to put a test higher up...gotta run. but does anyone know if Larry or Damian will be in Houston? 11:24
lizmat say @a.pop.value // "" while @a.elems 11:47
pop returns the last value... so no need to do a .tail
tbrowder ok, thnx 12:04
samebchase Hi, I have a Red model, in which a column is of the Json type, and can be null in some situations. When I fetch the rows, I get the "Use of uninitialized value element of type Any in string context." message printed on the console, seems to be coming from github.com/FCO/Red/blob/master/lib...son.pm6#L5 where from-json is called on 17:03
the Nil value.
What can I do here, to prevent this from being printed. I'm trying various default values, but no luck so far.
lizmat I have no idea, perhaps try the #red channel? 17:04
samebchase wow, didn't know 17:05
joining it
tonyo fez has had more than 40k downloads 17:15
lizmat wow 17:16
japhb Nice! 17:25
patrickb tonyo: Is that # of modules downloaded from the fez eco, or # of downloads of fez itself? 17:28
tonyo from the fez eco 17:29
patrickb k
patrickb c: my %h = a => [1,2]; my @b = %h<a>; dd @b; 18:40
committable6 patrickb, ¦my: «Cannot find this revision (did you mean “nom”?)»
patrickb m: my %h = a => [1,2]; my @b = %h<a>; dd @b;
camelia Array @b = [[1, 2],]
patrickb How is this mechanic called? (Arrays coming out of hashes need to be slipped to be iterated or assigned.) 18:42
Is that documented? I've been unable to find any hint about this in the docs. 18:43
ugexe its the same as my @a = $[1,2]; my @b = @a; 18:47
dunno about the vernacular though 18:49
patrickb m: my @a = 1, 2; my %h = a => @a; my @b = %h<a>; dd @b; 18:50
camelia Array @b = [[1, 2],]
patrickb I'm unsure which bit of information I need to remember to not be confused the next time I want to iterate a list I've pulled out of a Hash. 18:53
tonyo i just think of it as `my @x = ` always surrounds its args with [].. 18:55
m: my @a = 1,2,3; dd @a;
camelia Array @a = [1, 2, 3]
patrickb m: my @a = 1,2; my %h = :@a; say $_ for %h<a>;
camelia [1 2]
patrickb my @a = 1,2; say $_ for @a;
evalable6 1
2
lizmat the list in the hash is itemized, and that's why it won't iterate 18:56
m: my %h = a => [1,2]; my @b = %h<a><>; dd @b
camelia Array @b = [1, 2]
lizmat m: my %h = a => [1,2]; my @b = @%h<a>; dd @b 18:57
camelia Array @b = [Failure.new(exception => X::AdHoc.new(payload => "Type List does not support associative indexing."), backtrace => Backtrace.new)]
lizmat m: my %h = a => [1,2]; my @b = @(%h<a>); dd @b
camelia Array @b = [1, 2]
patrickb So the basic rule to remember is that I always have to put a "|" before a hash access if I want to get the list/array out the same as I put it in. 18:58
Is that a good rule to remember? Or is the actual thing to be aware of something else?
patrickb tries to grasp the deeper concept. 18:59
ugexe if you don't care about copying just using binding 19:00
m: my %h = a => [1,2]; my @b := %h<a>; dd @b;
camelia [1, 2]
thundergnat m: sub plural ($x, $n) { $x ~ ($n - 1 ?? 's' !! '') }; say "$_ { plural 'dog', $_ }" for ^3; 19:05
camelia WARNINGS for <tmp>:
0 dogs
1 dog
2 dogs
Potential dead code, the '?? !!' is gobbling up the result of the '&infix:<->' (line 1)
thundergnat ?? There's no dead code there. 19:06
bisectable: old=2021.10 new=HEAD sub plural ($x, $n) { $x ~ ($n - 1 ?? 's' !! '') }; say "$_ { plural 'dog', $_ }" for ^3;
bisectable6 thundergnat, Bisecting by output (old=2021.10 new=7dc3add) because on both starting points the exit code is 0
thundergnat, bisect log: gist.github.com/344e42bec8bed2259d...8852b29973
thundergnat, (2021-12-16) github.com/rakudo/rakudo/commit/71...7d13855ce1
ugexe well it did qualify it with "potential"
patrickb ugexe, tonyo, lizmat: Thanks for your explanations and examples. Let's see how long I'll remember this. 19:07
thundergnat Hmm. I think that code needs a little more tweaking.
lizmat hmmm... I wonder if it would make sense to make a SlippyHash module, that would automatically turn any List into a Slip, and every hash into a Slip of Pairs 19:08
tonyo thundergnat: it looks ilke that's being interpreted as `sub plural ($x, $n) { $x ~ ($n - (1 ?? 's' !! '')) }`
thundergnat It now warns for anything that treats an integer like a boolean.
lizmat thundergnat: how about $x ~ ('s' if $n != 1)
tonyo but it's working correctly ^
thundergnat m: say 3 % 1 ?? 'odd' !! 'even' 19:09
camelia WARNINGS for <tmp>:
even
Potential dead code, the '?? !!' is gobbling up the result of the '&infix:<%>' (line 1)
lizmat mL sub m($x,$n = 1) { $x ~ ('s' if $n != 1) }; say m dog
thundergnat That broke about 15 - 20 scripts I have out in the wild.
lizmat m: sub m($x,$n = 1) { $x ~ ('s' if $n != 1) }; say m dog
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
dog used at line 1. Did you mean 'log'?
lizmat m: sub m($x,$n = 1) { $x ~ ('s' if $n != 1) }; say m 'dog'
camelia dog
lizmat m: sub m($x,$n = 1) { $x ~ ('s' if $n != 1) }; say m 'dog',2 19:10
camelia dogs
lizmat m: sub m($x,$n = 1) { $x ~ ('s' if $n != 1) }; say m 'dog',0
camelia dogs
thundergnat The problem is with the bogus warning on ternaries.
m: say 3 % 1 ?? 'odd' !! 'even'
camelia WARNINGS for <tmp>:
even
Potential dead code, the '?? !!' is gobbling up the result of the '&infix:<%>' (line 1)
thundergnat There is no dead code there. ^^ 19:11
And that worked without warnings until github.com/rakudo/rakudo/commit/71...7d13855ce1
lizmat m: say # % 1
camelia ===SORRY!===
Argument to "say" seems to be malformed
at <tmp>:1
------> say⏏ # % 1
Other potential difficulties:
Unsupported use of bare "say". In Raku please use: .say if you meant
to call it as a method on $_, or …
lizmat m: say 3 % 1
camelia 0
thundergnat Its the ternary 19:12
lizmat thundergnat: please make an issue for it... so that we can revert before 2022.01
Voldenet m: my $rows = 2; my $columns = 5; my $vertical = True; say(10 % $vertical ?? $columns !! $rows) 19:16
camelia WARNINGS for <tmp>:
2
Potential dead code, the '?? !!' is gobbling up the result of the '&infix:<%>' (line 1)
Voldenet there could be uses for this warning
m: say (3 % 1) ?? 'odd' !! 'even' 19:17
camelia even
ugexe code is either dead or its not 19:20
lizmat
.oO( only when you look at it :-)
19:21
Voldenet well, the original case from the commit `"a = " ~ $a ?? "true" !! "false"` is certainly not containing any dead code 19:23
m: class Uh { }; multi infix:<~>(Str $a, Uh $b){ };my $a = Uh.new; say "a = " ~ $a ?? "true" !! "false" 19:26
camelia false
Voldenet m: class Uh { }; multi infix:<~>(Str $a, Uh $b){ }; my $a = "ok"; say "a = " ~ $a ?? "true" !! "false" 19:28
camelia true
Voldenet …i'm quite sure this fix doesn't work as expected
moon-child m: my $a = "ok"; say "a = " ~ ($a ?? "true" !! "false") 19:34
camelia a = true
moon-child it parenthesizes as ("a = " ~ $a) ?? "true" !! "false"
I think master has a warning for that
moon-child oh, you know about that. I need to read more than 1 line of scrollback 19:35
sorry
thundergnat m: say 3 %% 2 ?? 'even' !! 'odd' 19:40
camelia odd
thundergnat m: say 3 % 2 ?? 'odd' !! 'even'
camelia WARNINGS for <tmp>:
odd
Potential dead code, the '?? !!' is gobbling up the result of the '&infix:<%>' (line 1)
thundergnat It only seems to warn about expressions that aren't explicitly a boolean 19:41
issue filed: github.com/rakudo/rakudo/issues/4719 19:42
MasterDuke yes, that's what this conditional is trying to do github.com/rakudo/rakudo/commit/71...96f32R1523
if anyone has an idea for how to tighten it up i'm all ears 19:43
thundergnat MasterDuke: I'm not against the warning in principle, but it kind of spoils some DWIMery I tend to lean on. See the Issue I filed for links to multiple script in the wild this affects. 19:45
MasterDuke well, it also exposes a *completely* unrelated bug, so it's at least likely to get reverted before the next release 19:47
m: my $v = 3; my $sign = $v +> 31 ?? -1 !! 1; say $sign
camelia (signal SEGV)
MasterDuke happens in the optimizer in the code i added, but the fault lies somewhere else 19:48
Voldenet m: my $a = 2.rand.Int; say "a = " ~ $a ?? "true" !! "false"; 19:49
camelia WARNINGS for <tmp>:
true
Potential dead code, the '?? !!' is gobbling up the result of the '&infix:<~>' (line 1)
Voldenet i think it only makes sense to warn in case: Str ~ Str ?? … !! … 19:50
or even Str ~ … ?? … !! … 19:51
MasterDuke it isn't a property of the operands, but the operator 19:52
m: my $a = 2.pick; say 1 ~ $a ?? "odd" !! "even"
camelia WARNINGS for <tmp>:
odd
Potential dead code, the '?? !!' is gobbling up the result of the '&infix:<~>' (line 1)
thundergnat Voldenet: opinions differ. rosettacode.org/wiki/I_before_E_ex...ter_C#Raku <-- This was written by TimToady more than 7 years ago and now warns 19:53
MasterDuke where's the warning (i thought it would be the last line, but it isn't) 19:55
Voldenet If that's the property of the operator then ~ can always warn 19:56
thundergnat MasterDuke: Argh. It is the last line, but the version I was looking at uses string concatenation rather than the comma separated list. So that one isn't in the wild. Red herring. 19:59
Anton Antonov Is the #red channel I have reachable with Discord? 20:24
lizmat gfldex might know 20:28
Anton Antonov @lizmat Thanks! 20:32
Geth doc: codesections++ created pull request #4015:
Expand qq docs re esc sequences
22:42