🦋 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.
El_Che I am not enough of a C programmer to appreciate make, but if your language's project need it, you are doing somethiung wrong :) twitter.com/jjmerelo/status/1541505956986724352 08:05
I have a few colleagues that used make to build go programs (a one liner), guess who put flames into that :) 08:06
guifa trying to convert ECMA Regex to Raku regex is more complex than it seems at first 08:14
Nemokosch Does it seem simple? 08:48
guifa Yeah, you'd think it'd be
but the most complicated one so far has been on the surface devilishly simple
how would you convert ECMA /(a(b))(c)/ to Raku? 08:49
guifa In ECMA, $0 = 'abc', $1 = 'ab', $2 = 'b', $3 = 'c'. In Raku, $0 = 'ab', $0[0] = 'b', $1 = 'c', 08:54
nine Just linearize the Match objects into a list using depth first search 08:57
guifa nine: yeah, I thought about that, but ultimately went the lazy route, and keep an @*positional and %*named index on hand, and at the end of the regex, apply a role that overrides the AT-POS and AT-KEY methods 🙃 09:00
ECMA /(?<a>a)(b)/ becomes 09:15
` /:my (@*POSITIONAL,%*NAMED);{@*POSITIONAL.push: $/}$<a>=(a{%*NAMED<a> = $/})(b{@*POSITIONAL.push: $/}){$/ does anon role ECMA-Match {method AT-POS($pos){@*POSITIONAL[$pos]};method AT-KEY($key){%*NAMED{$key}}}}/ `
admittedly, hideous, but since no end user will ever see it, meh :-) 09:16
melezhik 0/ 09:21
El_Che big head today? 09:22
melezhik Yeah, I don't how to do the small one ))) 09:23
Don't know
Not an irc geek he-he )))
El_Che o/
~o|~ 09:24
help, I can' t swim
melezhik Need to copy paste )))
What's up
El_Che no "o" in a cyrillic keyboard?
melezhik o/ 09:25
Is it better?
... it is )))
Should have done lower case )))
What's actually up? Slowly preparing sparkyci + alpine packages for Raku modules integration 09:26
I have an idea that people would need fast installation of their modules system wide using alpine apk 09:29
Nemokosch Is the order of captures different? 09:31
guifa Nemokosch: Yeah. EMCA does flat ordering, and Raku nests 09:32
tellable6 guifa, I'll pass your message to Nemokosch
melezhik . 09:35
Nemokosch Huh 09:47
guifa Just lots of little gotchas — like . in ECMA is equivalent to <-[\n]> in Raku 10:01
melezhik So, I am testing a water with potential application of sparkyci for other languages , I raised a question on HN, a feedback would be appreciated - news.ycombinator.com/item?id=31998812 10:05
melezhik . 10:08
Geth ecosystem: f5f1764b87 | (Elizabeth Mattijsen)++ | META.list
Fix URL of the Digest module (again)
10:17
abraxxa Util: thank you for www.youtube.com/watch?v=rSP_GgcHQ0Q ! I'm no fan of YouTube comments which might not reach you. 12:49
Geth ecosystem: b5e6be17f9 | (Elizabeth Mattijsen)++ | META.list
Physics::Measure lives in the zef ecosystem now
13:02
guifa well that's surprisingly Englis-like 13:31
`state @ = eager gather take self and find-matches-in self, :type<positional>;`
abraxxa Raku remembers the type initially defined for a scalar variable, e.g. my Int $speed = 125; how can I display this type enforcement? 14:38
does the raku repl have some sort of autocomplete? double-tab or ? doesn't do anything 14:39
guifa m: my Int $speed; say $speed.WHAT 14:45
camelia (Int)
[Coke] that's not exactly right: 15:12
m: my Numeric $a; $a = 3; dd $a.WHAT; dd $a.VAR.WHAT
camelia Int
Scalar
[Coke] (note that "Numeric" as the restriction isn't there.)
m: my Numeric $a; dd $a.WHAT; $a = 3; dd $a.WHAT; dd $a.VAR.WHAT
camelia Numeric
Int
Scalar
[Coke] er, not there post-assignment.
m: my Numeric $a; dd $a.WHAT; $a = 3; dd $a.WHAT; dd $a.VAR.WHAT; dd $a 15:17
camelia Numeric
Int
Scalar
Int $a = 3
[Coke] (and dd only has the current type, not the type restriction also)
guifa [Coke] eh yeah, you're right. I typed without thinking 15:34
in other news, for making slangs, I just wrote a script to automagically namespace (and denamespace) a grammar
ECMA regexen here we come 15:35
[Coke] you can get it back by assigning Nil, checking the variable's type (Then Numeric), but that isn't helpful 15:38
m: my Numeric $a; dd $a.WHAT; $a = 3; dd $a.WHAT; $a = Nil; dd $a;
camelia Numeric
Int
Numeric $a = Numeric
nine m: my Numeric $a; $a = 3; dd $a.VAR.of
camelia Numeric
[Coke] OF!
Thank you, nine!
nine Turns out, implementing a compiler frontend teaches you a _lot_ about a language
[Coke] docs.raku.org/type/Scalar#method_of 15:39
:)\
er, :)
nine I guess reading the docs would do the same :D
Arguably writing a compiler is more fun though ;)
abraxxa where is .of documented? I was looking the type tree up to docs.raku.org/type/Mu as I thought it must be defined there so every type has the method but can't find it 15:55
also I was expecting the methodname to be all uppercase like WHAT
[Coke]: ah, didn't grasp that your message was about my question, thanks 15:56
so not all types have a type restriction I can check using .of?
Array has .of but defined directly and not subclassed from somewhere upwards the class hierarchy 15:58
same for Hash
Rat is missing of! 16:00
ah, of is a method of Scalar which isn't a base class of Str, Int, ... but the thing the VAR method returns?! 16:02
which isn't documented ;-( 16:03
dutchie abraxxa: see docs.raku.org/language/containers
abraxxa or at least it's documented here docs.raku.org/language/mop#VAR but not in the type docs which is always the place I look at when I want to know what methods a type has 16:04
doesn't the container have the type constraint which dictates what it can hold? 16:05
dutchie exactly, that's the Scalar that .VAR accesses 16:06
abraxxa so for example a variable my $a = 'foo'; is of type Scalar, holds a, no idea what it's called, of type Str? 16:07
no, because then I would be able to call .of on the container object
container -> Scalar -> Str? 16:08
so three objects for a single var?
dutchie the container is the Scalar (by default with a constraint of Any), holding the Str
m: my $a = 'foo'; say $a.VAR.of; say $a.WHAT
camelia (Mu)
(Str)
dutchie oh, apparently Mu, not Any 16:09
abraxxa so why would I need to call .VAR on the Scalar to call one of its methods?
dutchie because normally the Scalar hides itself 16:10
abraxxa so $a is the Scalar which decontainerizes to the Str it holds for all method calls and if you want to get at the Scalar itself you'd need .VAR to get at it?
dutchie exactly
abraxxa Oh man!
every time I look at Raku I get turned down by the type system!
and I managed to grap and digest Typescript in just months
can you improve the docs so they contain EVERY method a type has? 16:12
tonyo . 16:43
nine abraxxa: as far as I can tell thats already the case 16:57
tellable6 nine, I'll pass your message to abraxxa
[Coke] Sorry, which method was missing from where? 17:16
Note that VAR isn't technically a method 17:23
[Coke] points to docs.raku.org/language/typesystem#...thod_names 17:37
TIL about "is hidden" 17:42
m: class A is hidden { method m {say "eek"} }; class B is A { method m { nextsame }}; B.new.m 17:43
camelia ( no output )
jjatria Ok, so this should let me implement SameSite: gitlab.com/jjatria/publicsuffix 19:32
Xliff m: my %hash; role HashDefault[\T] { method AT-KEY (\k) { callwith(k) // T }; }; class C { }; %hash does HashDefault[C]; %hash<a> = 1; %hash<a>.say; %hash<b>.say; %hash.^name.say 20:54
camelia 1
(C)
Hash+{HashDefault[C]}
tellable6 2022-07-05T14:39:57Z #raku <dakkar> Xliff: github.com/LLFourn/p6-CompUnit-Uti...-exporting may help make your life easier
Xliff .tell dakkar Thanks
tellable6 Xliff, I'll pass your message to dakkar
Xliff Hash with a default value. Anybody see any obvious holes? 20:55
japhb m: my %hash is default(42); say %hash<foo> # Xliff 21:00
camelia 42
Voldenet Xliff: there is one obvious hole 22:25
m: my %hash; role HashDefault[\T] { method AT-KEY (\k) { callwith(k) // T }; }; class C { }; %hash does HashDefault[C]; %hash<a> = Nil; %hash<a>.say; %hash<b>.say; %hash.^name.say
camelia (C)
(C)
Hash+{HashDefault[C]}
Voldenet m: my %hash; role HashDefault[\T] { method AT-KEY ($k, |) { self.EXISTS-KEY($k) ?? nextsame() !! T }; }; class C { }; %hash does HashDefault[C]; %hash<a> = Nil; %hash<a>.say; %hash<b>.say; %hash.^name.say 22:35
camelia (Any)
(C)
Hash+{HashDefault[C]}
Voldenet double lookup
but :p is also supported which is nice
m: my %hash; role HashDefault[\T] { method AT-KEY ($k, |) { self.EXISTS-KEY($k) ?? nextsame() !! T }; }; class C { }; %hash does HashDefault[C]; %hash<a> = Nil; %hash<a b>.say; %hash<a b>:p.say; %hash.^name.say 22:36
camelia ((Any) (C))
(a => (Any))
Hash+{HashDefault[C]}
Voldenet nevermind, :p works either way ┐(´~`;)┌ 22:37