🦋 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.
Geth doc: 1983eb9425 | Coke++ | xt/01-raku-version.t
Track latest release
01:42
doc: 7a7b51222c | Coke++ | writing-docs/INDEXING.md
Remove currently unused category

  (passes xt/)
Zephyr is there a regex/raku rule to test if given string is an acceptable raku identifier or not? 07:44
not sure what unicode ranges it uses
Nemokosch The language is parsed with Raku grammars so quite surely 07:46
Zephyr could I have a link to the parser to find that part myself?
Nemokosch If only I knew where it was... 07:47
Maybe this? 07:48
github.com/Raku/nqp/blob/master/sr...rammar.nqp
NQP is a subset of Raku, for all intents and purposes 07:50
Zephyr is that it 07:52
oh, think I found it github.com/Raku/nqp/blob/master/sr...r.nqp#L45= 07:56
thanks for the repo <@297037173541175296>
nine Actually Raku's grammar is github.com/rakudo/rakudo/blob/mast...rammar.nqp 08:37
With the RakuAST version at github.com/rakudo/rakudo/blob/raku...rammar.nqp
Nemokosch interesting, it's the same but phrased differently 08:50
waffulus I am a complete noob to raku i tested some regex from the offical site but i keep getting weird outputed characters and I don't know why 09:12
[0] > 'raku' ~~ /rak./; # matches the whole string 09:13
「raku」
Zephyr m: 'raku' ~~ /rak./
Nemokosch ~~it's not a weird character, it's a perfectly valid ó~~ 09:14
waffulus so its supposed to so that?
dutchie something's broken with your unicode handling; raku is trying to print the Match object with japanese-style 「quotes」
waffulus I ran into a problem while trying to set up Readline: Cannot locate native library 'readline.dll': error 0x7e
Falling back to Linenoise (if present)
maybe that is something to do with it
or maybe it is the font i'm using source code pro and have tried ohter fonts 09:15
Zephyr is the bot down
dutchie m: '「'.encode.decode('latin-1') # something like this
camelia ( no output )
dutchie m: '「'.encode.decode('latin-1').say # something like this
camelia ï½¢
dutchie (substitute latin-1 for your local system encoding to perhaps replicate) 09:16
Nemokosch definitely character encoding issue in some way
I don't know if it's supposed to work here but it usually doesn't 09:17
waffulus dutchie i get a ?
dutchie you should make sure your terminal (or console or whatever) is expecting utf-8 output 09:23
waffulus i can type unicode and get the output as is
when i use powershell it outputs the uncode as is 09:24
when i use perl it complains of malformed utf
in an infinite loop
Nemokosch windows be like 09:28
waffulus well maybe but python seems to work 09:29
maybe i should reinstall it
k no longer using something called rakudo-moar loaded up the repl no luck 09:39
Nemokosch how did you install the Raku environment, by the way 09:44
waffulus well i just installed it using the msi downloaded from rakudo.org 09:45
Nemokosch msvc... well idk, doesn't explain 09:46
but rakubrew.org/?platform=win rules 😛
waffulus k i  wil will try that version, ty 09:47
Nemokosch doesn't sound related but who knows 09:48
"good practices"
waffulus sorry can't installed the rakubrew one complaining about shims and shell hooks 09:59
waffulus sorry the rakubrew installation just seems to add even more problems on top of what i already had 10:03
thundergnat m: say $_ ~~ /^<ident>$/ for <raku ok1 42nope>; #  <-- (is there a regex/raku rule to test if given string is an acceptable raku identifier or not?) 10:08
camelia 「raku」
ident => 「raku」
「ok1」
ident => 「ok1」
Nil
Nemokosch you did see the difinition though, no? 10:38
oh right
anyway, the definition is <ident> [[ \-' ] <ident>]*
iirc
discord ate the backslash
but the _three_ characters inside should be: \ - '
meh 11:01
more accurately:
token apostrophe {
<[ ' \- ]>
}
token identifier {
<.ident> [ <.apostrophe> <.ident> ]*
}
moritz so to answer the question, `identifier` parses an identifier, `ident` just a subset of identifiers 11:04
Nemokosch by the way, it seems to me discord cut the backslash again 11:05
not sure if it shows up inside the apostrophe definition? 11:07
moritz yes, the dash is backslash-quoted 11:09
Nemokosch test: [\-']
Nemokosch okay it does work
so is it quoting in the Raku regex as well? 11:10
or escaping
moritz it#s escaping, because the - in a character class usually is a range 11:13
wait no, that was perl 5 semantics 11:14
Nemokosch anyway, you are right, it is escaping 11:17
fingolfin Hello community. I see in docs (docs.raku.org/language/glossary#Stub), that "Stubs define name and signature". But this code doesn't throw error. Why? Is it a bug? 17:12
role A {
    method M(Str $x) { … }
}
class B does A {
    method M(Int $x) { 0 }
}
[Coke] m: role A { method M(Str $x) { ... } }; class B does A { method M(Int $x) { 0 } }; 17:56
camelia ( no output )
[Coke] m: role A { method M(Str $x) { ... } }; class B does A { method M(Int $x) { 0 } }; B.new.M(3);
camelia ( no output ) 17:57
[Coke] in the latter case, you're invoking B's copy of the method. it doesn't need to touch A's version.
m: role A { method M(Str $x) { ... } }; class B does A { method M(Int $x) { 0 } }; A.new.M(3);
camelia Method 'M' must be implemented by A because it is required by roles: A.
in block <unit> at <tmp> line 1
[Coke] but if you pun the role (create an anonymous class out of it), and try to invoke the method, then the fact that it's a stub is noticed. 17:58
m: role A { method M(Str $x) { ... } }; class C does A { }; C.new.M(3);
camelia ===SORRY!=== Error while compiling <tmp>
Method 'M' must be implemented by C because it is required by roles: A.
at <tmp>:1
[Coke] ^^ or if you don't override it.
m: role A { method M(Str $x) { ... } }; class C does A { }; C.new.M("3"); #better
camelia ===SORRY!=== Error while compiling <tmp>
Method 'M' must be implemented by C because it is required by roles: A.
at <tmp>:1
[Coke] I think the fact that you changed the first parameter type doesn't matter unless you try to invoke it: 17:59
m: role A { method M(Str $x) { ... } }; class B does A { method M(Int $x) { 0 } }; B.new.M("three");
camelia Type check failed in binding to parameter '$x'; expected Int but got Str ("three")
in method M at <tmp> line 1
in block <unit> at <tmp> line 1
[Coke] need a multi for that to work. 18:00
Not sure I answer the question you were after.
fingolfin Thank you Coke, I have read your answers carefully. It turns out that if the methods have the same name, but different signatures, is it still the same method? It's a little confusing... It turns out that "method M(Int$x) { 0 }" in my example implements the method "method M(Str $x)", but does it "incorrectly". Why wouldn't raku track down this 18:13
error at the compilation stage?
I am asking this question because in another situation, if the method is not implemented at all, raku reports it at the compilation stage:
m: role A { method M(Str $x) { ... } }; class B does A {  }; 18:14
camelia ===SORRY!=== Error while compiling <tmp>
Method 'M' must be implemented by B because it is required by roles: A.
at <tmp>:1
[Coke] m: role A { multi method M(Str $x) { ... } }; class B does A { multi method M(Int $x) { 0 } }; B.new.M("three");
camelia ===SORRY!=== Error while compiling <tmp>
Multi method 'M' with signature :(B: Str $x, *%_) must be implemented by B because it is required by a role
at <tmp>:1
[Coke] m: role A { multi method M(Str $x) { ... } }; class B does A { multi method M(Int $x) { 0 } }; 18:15
camelia ===SORRY!=== Error while compiling <tmp>
Multi method 'M' with signature :(B: Str $x, *%_) must be implemented by B because it is required by a role
at <tmp>:1
[Coke] (there you go. the multi forces the compile time alert)
fingolfin Thanks, it's getting clearer. But why is there no error without "multi"? Is this behavior correct? 18:22
It seems to me that if a class implements a method with a different signature, then this is essentially a different method. But maybe I don't understand something...
[Coke] that would be my take; they're considered different methods unless you specify multi, which indicates that anything with the same name counts. 18:26
[Coke] but then, because of the stub, the compiler realizes that NOTHING is implementing that specific version of the multi. 18:27
tonyo . 22:51