🦋 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.
uzl[m] "When a binding points at a value, that does not mean it is tied to that value forever. The = operator can be used at any time on existing bindings to disconnect them from their current value and have them point to a new one." 13:20
Reading this JavaScript book, and it seems they use "binding" differently to how it's used in Raku. It seems it's used interchangeably with assignment 🥲
Nemokosch Not surprising 13:43
guifa wonders if there could be a way to add a "when" trait 14:11
like `multi sub foo ($,$,$) when $*MODE == 'debug' { … }` 14:12
guifa I guess it could be done with `will run-when{$*MODE eq 'debug'}` and then wrapping the candidate to call the next candidate on fail 14:13
this is nice, except signatures are immutable even when andling traits =\ 14:29
m: multi sub foo(:$ where $*MODE eq 'debug') { say "debug" }; multi sub foo { say "production" }; my $*MODE = 'debug'; foo; $*MODE = 'nodebug'; foo
camelia debug
production
gfldex m: multi sub foo($a, $? where ($*MODE // '') eq 'debug') { say "$a with debug"; }; my $*MODE = 'debug'; foo(42); 14:35
camelia 42 with debug
gfldex you would need a RakuAST macro to turn that into a trait. Right now we can modify signatures at compile time. 14:36
s/can/can't/
unless you are willing to .wrap
guifa Yeah, was hoping to avoid the .wrap 15:51
I was a bit surprised you can do an anonymous named argument but I guess that's Raku for you, strangely consistent 15:52
thowe there's a predefined character class in the docs called <xdigit>, but I'm wondering if it is a mistake in the docs? I found a rosetta code example that uses "hexdigit" and that seems to work where xdigit does not. 15:57
phogg xdigit is a traditional POSIX character class 15:59
thowe phogg: do you know how it differs from <hexdigit> ? 16:01
This rosetta code example uses <hexdigit> to do what it seems xdigit should do: rosettacode.org/wiki/Parse_an_IP_Address#Raku
but attempting to use <xdigit> in place of <hexdigit> doesn't match what it should. Also, <hexdigit> is undocumented as far as I can tell and it's got me scratching my head. 16:02
thowe hm, well maybe <xdigit> works and <:hexdigit> works. the ":" might be the difference, not sure what it means 16:05
phogg thowe: I am no authority on this. That said <:hexdigit> looks like a unicode property matcher to me.
xdigit is 0-9A-Fa-f, so I imagine :hexdigit is at least those codepoints. 16:06
thowe OK, I'll buy that. But this code doesn't define it and it isn't in the docs as far as I can tell. 16:07
unless it is burried someplace the search function can't find it
phogg I expect you have to read unicode docs. 16:09
guifa :Foo selects a character based on a unicode property 16:14
phogg thowe: It would be nice if docs.raku.org/syntax/%3C:property%3E listed every possible property, but even in that example it uses <:Block()> and <:Script()> but doesn't otherwise describe them. 16:15
it does link to the uniprop page, which in turn links ultimately back to unicode-org.github.io/icu/userguid...rties.html
which does document Hex_Digit
guifa Unicode's hex digits are <0123456789ABCDEFabcdef0123456789ABCDEFabcdef>
(those are fullwidth forms, no spaces)
phogg no idea how you would know :hexdigit would work for that, but :Hex_DIgit seems to be the same 16:16
s/I/i/
guifa phogg: I was actually just about to say that the underscore is what I would expect
maybe the underscore is just ignored for those
thowe "hexdigit" also seems to not be in the Unicode docs... What I'm trying to figure out is how would I ever know to use "hexdigit" if I hadn't seen it in this example? I can't seem to draw that line
phogg guifa: maybe Raku allows any s/_//g and ignores case?
guifa phogg: jinx lol
phogg seems it's something like that 16:17
e.g. ASCII_Hex_Digit works, as does asciihexdigit, and ASCII_Hex_Digit, but not ASCII_HexDigit, or even asciihexdigiT 16:18
thowe <:Hex_Digit> does seem to work in the code, but I couldn't find it when googling "Unicode General Category name" I will look at the docs you posted
phogg so the original case, strictly lower case, or either without the _ works for unicode proeprties 16:19
thowe: unicode docs are surprisingly hard to google for. Not well-linked, I expect.
the details are of interest only to a handful of implementers
guifa Looks like the underscore variants are hard coded 16:20
phogg guifa: found the code in the Raku implementation?
thowe I wonder if a link from docs.raku.org/language/regexes#Uni...properties would be helpful
phogg guifa: I would still expect that to be the result of a script.
thowe: I would say so, but there is a link on the uniprops page linked from there, so it's not too hard to find. 16:21
guifa no, just testing around
thowe phogg: that link honestly looked like an error to my eye. I should have looked closer. 16:22
when I saw "class Cool" I thought I landed in the wrong place 16:24
well, that was fun. Thanks for the help! 16:32