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:14
NemokoschKiwi joined
00:27
NemokoschKiwi left
00:28
MasterDuke joined
04:10
deadmarshal_ left
04:44
deadmarshal_ joined
05:31
sivoais left,
sivoais joined
05:55
deoac left
08:10
Manifest0 joined
08:21
tea3po joined
08:24
teatwo left
|
|||
leomehraban | I'm having a bit of trouble with a method in a class that is supposed to tell wether the result of self.peek, a method witch returns a length 1 Str, is an alphabetical character or an underscore. The method is method isalpha(-->Bool){ return (self.peek ge "A" && self.peek le "Z") || (self.peek ge "a" && self.peek le "z") || self.peek == "_"; } When I try to run this, I get Cannot convert | 11:56 | |
string to number: base-10 number must begin with valid digits or '.' in '⏏_' (indicated by ⏏) in method isalpha at main.raku line 39. I'm confused because I don't know why it's trying to convert a string to a number in a context where it should only be comparing strings. I looked at the documentation for ge and le, and found nothing about converting to numbers. What am I doing wrong | |||
gfldex | `self.peek == "_"` == is a numerical comparator | 12:00 | |
`self.peek ~~ /<[A..Za..z_]>/` does the same and is more readable to my eyes. | 12:04 | ||
leomehraban | thanks. I'm just not used to regexes, so that thought didn't even cross my mind. I'll make sure to remember that next time | 12:06 | |
gfldex | m: say so /<[A..Za..z_]>/ with <A z _ 1>.all | 12:10 | |
camelia | False | ||
gfldex | Regex.Bool is funky. :-> | ||
13:00
hythm joined
|
|||
Tirifto_ | What would be the neat way to have object-specific (or object-defined) methods in a class? As far as I know, methods are always shared between all instances, while attributes are specific to (and potentially definable by) each instance, right? So if I want to do the same with methods/code, I need to have Method (or Routine etc.) objects as attributes… and if I want to preserve the standard method semantics, I should define a ‘real’ m | 13:51 | |
ethod which only passes its arguments on to that attribute for each object. Is that kinda correct? | |||
lizmat | Tirifto_: perhaps you're looking for docs.raku.org/language/operators#infix_does ? | 14:07 | |
Tirifto_ | lizmat, oh, I hadn’t thought of that! (Though I was just reading about roles yesterday.) I’ll see how that can work; thank you! | 14:12 | |
lizmat | yw! | ||
Tirifto_ | lizmat, so the mixing works well, but seems to be free of any constraints. That is, when the class has a method with a given signature (and even when it fills a role with a given signature), the role I mix in can just override that method with its own, where the signature can be seemingly anything. I guess roles won’t do the trick if I want to be strict about that? `o` | 15:56 | |
(role with a given signature → role with a given signature on said method) | |||
17:12
deoac joined
|
|||
lizmat | Tirifto_: is the method in the class a "multi" method or not? Are you trying to mix in a multi method with the same name but different signature ? | 17:17 | |
Tirifto_ | I tried mixing in a non-multi method (forgot what the appropriate name was) with the same name and different signature, and that worked. | 17:40 | |
lizmat | hmmm.. could you create a gist of what did not work for you ? | 17:54 | |
deoac | Has anyone created a robust regex for a Raku comment? One that takes into account the '#' may be in a string, etc.? I can't find something similar to CPAN's Regexp::Common | 18:24 | |
antononcube | @deoac Maybe one of DrForr's packages has that. | 19:01 | |
nemokosch | would the input be valid Raku? | 19:14 | |
frankly, I don't know if that can be done significantly cheaper than the parsing of that Raku, in which case parsing into RakuAST will be an easy win | 19:16 | ||
20:21
teatwo joined
20:22
teatwo left
20:23
teatwo joined
20:24
teatwo left,
tea3po left
20:25
teatwo joined
|
|||
deoac | How would i make a regex to match a letter followed by any number of characters which are not that particular letter? | 20:35 | |
Variables don't interpolate inside <-[...] | |||
.> | |||
antononcube | @deoac There have to be several ways to do that. Here is one way / (\w) (\w+) <!{ $1.Str.contains($0.Str)} / . | 20:43 | |
gfldex | m: say '#1234' ~~ / :my $thing; [.] { $thing = "/<-[{$/.Str}]>/".EVAL; } (<$thing>+) /; | 21:05 | |
camelia | 「#1234」 0 => 「1234」 |
||
gfldex | deoac: You can interpolate character classes, so long you are willing to dance with the devil. :-> | 21:06 | |
deoac | Oh, sweet! Thank you | 21:08 | |
21:08
deoac left
21:24
deoac joined
21:36
hythm left
23:11
Manifest0 left
|