🦋 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 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 8 June 2022.
Voldenet regarding improving camelia: consider handling discord-raku-bot's `m:` statement 00:41
otherwise it's minor pain for people using discord 00:42
(I'm not sure where would I suggest this) 00:43
kawaii method mint(UInt $value) { 10:01
if !self.is-frozen {
Transaction.^create(batch => UUID.new, :$value, from-account => 'mint', to-account => self.account, termination-point => 'system');
say "✓ minted $value tokens for account: $!account";
} else {
X::Mint::Account::IsFrozen.new(:$!account).throw;
CATCH { when X::Mint::Account::IsFrozen { .resume } }
}
}
ah why did that paste directly
I think I have some misconception about Exceptions in Raku, I want to both display the error message from the exception to the user, without also killing the program?
try/CATCH both seem to swallow the .message from my exception however 10:02
I seem to either only be able to have my exception print it's .message in the console and kill the program, or not kill the program but provide no output :( 10:03
moritz m: sub dangerous { die "oh noez"} ; try dangerous(); say $! if $!; say "I'm still standing" 10:07
camelia oh noez
in sub dangerous at <tmp> line 1
in block <unit> at <tmp> line 1

I'm still standing
moritz kawaii: ^^ something like that?
I think in your sample code the .resume is wrong
just print it there? or do nothing 10:08
kawaii moritz: so you're right in the sense that doing this works `CATCH { when X::Mint::Account::IsFrozen { say("✗ account '$!account' is frozen and thus immutable") } }` but it makes me wonder why I would bother to have any error message in the Exception itself at all `class X::Mint::Account::IsFrozen is Exception { has $.account; has $.message = "✗ account '$!account' is frozen and thus immutable"; }` 10:12
moritz kawaii: the point is that as the author of the code that raises the exception, you cannot be sure it'll only be called in context where it is specifically caught 10:31
so you give it a good message in case it's raised and not caught, and also makes debugging easier 10:32
or maybe somebody catches many possible exception classes, logs the error
Voldenet Error message in Exception is not necessary in any language 10:35
but a lot of times you define exceptions that aren't this precise 10:36
moritz in python, anytime any value is slightly unexpected, it's a ValueError. Easy to remember, hard to distinguish between different ValueErrors 10:38
it's tradeoffs all the way down :D 10:39
kawaii I think I understand a little better now, thanks for the explanations
moritz you're welcome 10:44
Xliff Does anyone know if you can create a derivative Signature from another Signature? 11:48
Xliff m: sub a ("a", "b", $c, :$d) { }; Signature.new( params => &a.signature.params[1..*] ).gist.say 12:13
camelia ("b", Any $c, Any :$d --> Mu)
Xliff That looks promising.
&a.signature.head.say 12:14
m: &a.signature.head.say
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
a used at line 1
Xliff m: sub a ("a", "b", $c, :$d) { }; &a.signature.head.say 12:15
camelia ("a", "b", $c, :$d)
Xliff m: sub a ("a", "b", $c, :$d) { }; &a.signature.params.head.say
camelia "a"
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2022/06/14/2022-...ence-2022/ 12:20
sienet_ja_LSD[m] nice, nice
Xliff How many tests are currently in roast? 12:24
lizmat Files=1353, Tests=116312 12:29
Xliff Oh. 900 files left for RakuAST. Nice round number! ;) 12:33
sienet_ja_LSD[m] how do I coerce a scalar (that could be either Int or Rat) to uint8? there's no method like .Int 13:07
lizmat m: my uint $a = $value.Int 13:09
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$value' is not declared. Did you mean '&values'?
at <tmp>:1
------> my uint $a = ⏏$value.Int
lizmat m: my uint $a = 4.5.Int
camelia ( no output )
lizmat m: my uint $a = 255.5.Int; say $a
camelia 255
lizmat m: my uint $a = 256.5.Int; say $a
camelia 256
lizmat m: my uint8 $a = 256.5.Int; say $a
camelia 0
lizmat sienet_ja_LSD[m] ^^ 13:10
sienet_ja_LSD[m] alright, that should do it. thank you
[Coke] m: my uint $a = 121; dd $a.WHAT 14:00
camelia Int
[Coke] m: my uint $a = 121; put $a.WHAT 14:01
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.

in block <unit> at <tmp> line 1
[Coke] If I do $a.WHAT in the REPL, I get Cannot invoke object of type 'NQPMu' 14:02
m: my uint $a = 121; say $a.WHAT
camelia (Int)
[Coke] I can't seem to get it to explode here
uzl[m] patrickb: The "Think X" series is more CS and programming basics than language-centric per se. I think Laurent Rosenfeld did a great job at both teaching the CS concepts discussed in the book through a Raku lense 14:06
lizmat++ for the weekly! 14:07
Xliff If I have a parameter that is constant. How can I pull out that value? 14:50
I am speaking in terms of the Parameter class.
Xliff So in "sub a ("b") { ... }", I can get the parameter by "$p = &a.signature.params[0]", but how do I get $p to print "b"? 14:51
moritz it's in .constraints 14:52
MasterDuke m: sub a ("b") { ... }; my $p = &a.signature.params[0]; say $p.constraints
camelia all(b)
MasterDuke m: sub a ("b") { ... }; my $p = &a.signature.params[0]; say $p.constraint_list 14:53
camelia (b)
moritz m: sub a ("b") { ... }; my $p = &a.signature.params[0]; say $p.constraint_list[0]
camelia b
Xliff Ah, thanks! 14:54
Geth ecosystem/add-raku-mint-module: 4ed73776d4 | (Keyn Valentayn)++ (committed using GitHub Web editor) | META.list
Add Mint module to ecosystem

  github.com/shuppet/raku-mint
14:56
ecosystem: kawaii++ created pull request #605:
Add Mint module to ecosystem
14:57
Voldenet m: sub a ("b") { … }; my $str; { my $*OUT = class :: { method print($b) { $str = $b.trim; } }.new; say &a.signature.params[0]; }; say $str 15:03
camelia "b"
Voldenet Does the job in this case, otherwise entirely useless
i found it funny though 15:05
Geth ecosystem: 4ed73776d4 | (Keyn Valentayn)++ (committed using GitHub Web editor) | META.list
Add Mint module to ecosystem

  github.com/shuppet/raku-mint
15:08
ecosystem: ca2ca916ea | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list
Merge pull request #605 from Raku/add-raku-mint-module

Add Mint module to ecosystem
uzl[m] m: say 0 max False 15:34
camelia 0
uzl[m] m: say False max 0 15:35
camelia False
Geth doc: uzluisf++ created pull request #4084:
Make &[max] and &[min] return LHS for ties
15:39
[Coke] uzl[m]++ 15:50
I may have a small edit on that to specifically call out Rakudo version, but otherwise seems fine.
(we have a long standing request about having a specific way to mark items that deal with specific versions but we don't have to solve that before applying this commit.) 15:51
uzl[m] [Coke]: That sounds fine to me 👍️ 17:34
Note there's a small discrepancy between my commit message and the one is documenting, namely the "return [LHS|RHS] for ties" part. Probably codesections made a typo there, and used RHS instead of LHS 17:36
<uzl[m]> "codesections: Do you mind..." <- ^ I asked codesections for clarification but he's not around apparently... However from the behavior described and the example, it seems LHS is the right terminology here 17:38
lizmat [Coke]: anything with natives in the REPL will fail like that 18:58
melezhik .tell jjatria I am having problem with running HTTP::Tiny put method 22:42
tellable6 melezhik, I'll pass your message to jjatria 22:43
melezhik I've create ticket on gitlab
gitlab.com/jjatria/http-tiny/-/issues/14 22:45
jjatria .tell melezhik interesting! I'll take a look. Thanks for the report! 23:14
tellable6 jjatria, I'll pass your message to melezhik