This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
00:05
Kaipei left
05:58
Heptite left
08:10
Kaipei joined
09:00
samebchase left
10:33
Heptite joined
11:44
Kaipei left
11:54
Kaipei joined
12:40
Heptite left
15:03
Heptite joined
16:31
Kaipei left
17:02
ab5tract joined
|
|||
Anton Antonov | What is the Raku equivalent of the Perl5 code `qr/((z|r)|((?<=[ab])(k|m)))$/;` ? | 17:14 | |
Nahita | `rx/ ( (<[zr]>) || ( <?after <[ab]>> <[km]> ) ) $ /` is one, i think | 17:26 | |
`rx/ ( ( <[zr]> ) || ( <?after <[ab]>> <[km]> ) ) $ /` is one, i think | |||
matches at the end of string either | 17:28 | ||
- z or r | |||
or | |||
- k or m following a or b | |||
Anton Antonov | <@836605577400549436> Thank you! I just found the relevant fragment docs.raku.org/language/5to6-nutshe...%3E_syntax , and your suggestion helps a lot! | 17:31 | |
How about this one : `qr/[^$A][$A]+[^$A]+[$A].*(?<=z)r?$/;` ? | 17:37 | ||
(I do not expect to ask more of these kind of questions today... 🙂 ) | 17:38 | ||
Nahita | np | 18:02 | |
`rx/ <-[$A]> $A+ <-[$A]>+ $A .* <?after 'z'> 'r'? $ /` | |||
matches at the end of string | |||
- anything but $A | |||
- one or more of $A | |||
- one or more of anything but $A | |||
- $A | |||
- anything 0 or more, prefer more as much as possible | |||
- z which is optionally followed by r | |||
lookbehind seems not necessary so can write `'z' 'r'?` there instead i think | 18:03 | ||
but the original one has it, so... | 18:04 | ||
Nemokosch | is [] not a character set in Perl regexes? | ||
Nahita | i wish a regex visualizer, explainer for the Raku regexes | ||
like regex101 has for some dialects | 18:05 | ||
couldn't find a regexp::debugger kind of thing in modules land either | |||
i thought of attempting one (and failing) but not familiar with Raku regexes sufficiently and not familiar with grammars really | 18:06 | ||
which i assume is needed for such an application | |||
Anton Antonov | <@836605577400549436> Thank you -- you saved me lots of time! | 18:13 | |
Nemokosch | I wonder which is the harder part - reading regex or writing it? | 18:14 | |
Perhaps reading it... | |||
Anton Antonov | I think, I can read Raku regexes -- _if_ I already know the expressed functionality. | 18:15 | |
To somewhat comment of what <@836605577400549436> said -- I prefer using grammars more. | 18:17 | ||
19:33
Kaipei joined
21:06
ab5tract left
22:30
Heptite left
|
|||
stevied | what's the easiest/recommended way to constraint check class attributes besides using "where *". I'd like to have nice error messages. Should I just use "submethod BUILD" or is there a better way? | 22:51 | |
Nemokosch | > to constraint check class attributes | 22:54 | |
could you please reiterate? | |||
stevied | yeah, let's say I want to make sure a file passed in exists and is readable | 23:10 | |
yeah, let's say I want to make sure a file string passed in to the new function exists and is readable as an IO object | 23:11 | ||
Nemokosch | I'm tempted to say just create a fallback multi candidate | 23:14 | |
Not a particularly original thought I guess but it's cheap at least | |||
stevied | I've been playing around to see if I could get trait_mod to work: `has Str:D $.file is checked = '';` | 23:16 | |
and then `multi sub trait_mod:<is>(Attribute:D $r, :$checked)` | |||
but can't seem to get it to work | |||
Nemokosch | even if you write `:$checked!` ? | 23:17 | |
stevied | I want to run file tests and maybe check the contents of the file to make sure it's legit and throw an error message if it isn't | 23:19 | |
I can't seem to get at the contents of $.file in the `trait_mod()` sub | |||
heretofore I've done this in the constructor methods, but I'd like to try to find a more elegant solution | 23:20 | ||
Nemokosch | pfff, clueless | 23:22 | |
but this doesn't sound much like a type check in the classic sense, at least | |||
stevied | no, I'm not just checking to see if it's an Int or something | 23:23 | |
these are "constraint checks" from what I gather | |||
Nemokosch | maybe there is something better than the "failed constraint" Failure and we just don't know about it <:cameliathink:897316667653247057> | 23:25 | |
23:40
Heptite joined
23:59
kjp left
|