🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). 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 6 September 2022.
00:00 reportable6 left 00:01 reportable6 joined
SmokeMachine Voldenet, lizmat: Do you think it's better like this? github.com/FCO/RakuAST-Matcher/com...c97143910c 00:10
00:19 RakuIRCLogger joined 00:20 lizmat joined 00:23 RakuIRCLogger left, RakuIRCLogger joined 00:26 derpydoo joined 00:29 jpn joined 00:30 jpn left 00:37 raiph joined 00:44 Archenoth is now known as arch 01:16 deoac left 01:26 teatime joined 01:31 andydude joined 02:21 teatwo joined 02:22 teatwo left, teatwo joined 02:25 teatime left 02:28 rypervenche joined 03:28 squashable6 left, unicodable6 left, coverable6 left, bisectable6 left, evalable6 left, releasable6 left, committable6 left, linkable6 left, statisfiable6 left, greppable6 left, bloatable6 left, notable6 left, reportable6 left, sourceable6 left, shareable6 left, tellable6 left, benchable6 left, nativecallable6 left, quotable6 left 03:29 notable6 joined, evalable6 joined, reportable6 joined, benchable6 joined, linkable6 joined 03:30 bloatable6 joined, releasable6 joined, greppable6 joined, shareable6 joined, committable6 joined, sourceable6 joined, quotable6 joined 03:31 nativecallable6 joined, coverable6 joined, statisfiable6 joined, bisectable6 joined, squashable6 joined, tellable6 joined, unicodable6 joined 03:50 raiph left
Voldenet SmokeMachine: definitely a lot easier to maintain, btw you don't need {} in `gather { $needle.visit-children: *.take }` ┐(´~`;)┌ 04:32
04:32 human-blip left
Voldenet but `my @needle = gather { $needle.visit-children: *.take };` would probably allocate large array without iterating anyway 04:34
`my $needles = gather $needle.visit-children: *.take; my $asts = gather $ast.visit-children: *.take; [&&] ($needles.Seq Z $asts.Seq).map(…)` would iterate 04:38
05:32 linkable6 left, evalable6 left 05:35 evalable6 joined 05:36 linkable6 joined 06:00 reportable6 left, reportable6 joined 06:27 andydude left 06:33 lichtkind_ joined 06:50 squashable6 left 06:53 squashable6 joined 07:18 jpn joined
SmokeMachine Voldenet: I've forgotten to add `lazy` before the gather that was my intention 07:29
07:29 jpn left
SmokeMachine Voldenet: Thank you 07:30
Voldenet i'm not a fan of lazy, because it'll still allocate arrays 07:32
which is not needed if it's simply fed to [&&]
07:36 Geth joined 07:37 RakuIRCLogger left, RakuIRCLogger joined
SmokeMachine Voldenet: but I don't think those arrays would ever be very big, how many local children (not descendants) a node usually have? 07:38
m: say gather "1 + 2 + 3 + 4 + 5".AST.visit-children: *.take
camelia (RakuAST::Statement::Expression.new(
expression => RakuAST::ApplyInfix.new(
left => RakuAST::ApplyInfix.new(
left => RakuAST::ApplyInfix.new(
left => RakuAST::ApplyInfix.new(
left => RakuAST::IntLiteral.new(…
SmokeMachine m: say (gather "1 + 2 + 3 + 4 + 5".AST.visit-children: *.take).elems 07:39
camelia 1
SmokeMachine Voldenet: but yes, that makes sense 07:40
Voldenet btw, visit-children is not recursive
SmokeMachine yes, that was my thinking... 07:41
Voldenet in the worst case the matching tree can grow beyond the stack
m: say elems gather "1 + 2 + 3 + 4 + 5".AST.visit: *.take 07:42
camelia 15
SmokeMachine yes, with visit that could be a problem
Voldenet m: say elems gather '[&&] (@needle Z @ast).map({ match(|$_) })'.AST.visit: *.take
camelia ===SORRY!=== Error while compiling
Variable '@needle' is not declared. Perhaps you forgot a 'sub' if this
was intended to be part of a signature?
------> [&&] (⏏@needle Z @ast).map({ match(|$_) })
Voldenet m: say elems gather 'sub match(|c) { }; my @needle; my @ast; [&&] (@needle Z @ast).map({ match(|$_) })'.AST.visit: *.take 07:43
camelia ===SORRY!=== Error while compiling
Confused
------> &&] (@needle Z @ast).map({ match(|$_) })⏏<EOL>
Voldenet m: say elems gather 'sub match(|c) { }; my @needle; my @ast; [&&] (@needle Z @ast).map({ match($_) });'.AST.visit: *.take 07:44
camelia ===SORRY!=== Error while compiling
Confused
------> [&&] (@needle Z @ast).map({ match($_) })⏏;
SmokeMachine I can't do that, I would be comparing many things more times than needed...
07:44 jpn joined
Voldenet either way, visit does iterate and uses queue 07:44
instead of being recursive 07:45
I'm not sure how costly it is in terms of stack usage, but things could get ugly if you use it on large files 07:50
even if locally match used tiny arrays, the arrays may accumulate and get too fragmented to stay in caches in continuous form 07:56
either way, even that gigantic chunk would simply contain pointer, so it doesn't improve data locality anyhow 07:58
I'd still attempt to use visit instead, I'm betting it will handle worst cases better 08:05
08:10 dakkar joined 08:13 sena_kun joined 08:29 Sgeo left 08:36 derpydoo left 09:09 jpn left, jpn joined 10:51 jpn left 11:08 jpn joined 11:34 jpn left 11:37 jpn joined 11:44 jpn left 11:54 fikurimax joined 11:55 fikurimax left 12:00 reportable6 left 12:02 reportable6 joined 12:12 jpn joined 13:05 jpn left 13:55 ProperNoun joined 14:09 ProperNoun left 14:10 ProperNoun joined 14:21 tea3po joined 14:22 Sgeo joined, Sgeo left, tea3po left 14:23 tea3po joined 14:24 teatwo left 14:25 Sgeo joined 14:28 jpn joined 14:33 jpn left 14:38 RandalSchwartz joined, RandalSchwartz left 14:57 ilogger2 left 14:58 ilogger2 joined 15:25 jpn joined 15:30 [Coke] left 15:31 jpn left 15:52 jpn joined 16:05 [Coke] joined 16:22 ab5tract joined 16:36 dakkar left 16:53 ab5tract left
tbrowder__ howdy, all. i have a module "unit class SomeLongName" A" and i would like to refer to the class as, say, S. then do this: my $s = S.new; 16:55
i've tried variants of "our \S is export = SomeLongName" but no luck so far. aliasing subs and other things seems pretty straightforward. 16:57
[Coke] you're trying to create the alias i mthe class def and export it too? 17:02
*in the*
I would expect you'd have have a module with the class and the alias exported, not a top level class in the file 17:03
lucs tbrowder__: Could ⌊class S is SomeLongName {}⌉ be enough? 17:09
tbrowder__ [Coke]: that was just a simple sample 'cause i'm used to the general syntax. 17:25
lucs: great, didn't think of that. i'll give it a try right now. thnx 17:26
[Coke] I would recommend not exporting an alias by default in code you expect others to use. 17:28
lizmat sub EXPORT { Map.new: ( 'SomeLongName' => SomeLongName, 'S' => SomeLongName ) } 17:35
note, I would let the consumer do the aliasing in general
use SomeLongName; my constant S = SomeLongName; 17:36
18:00 reportable6 left 18:01 reportable6 joined
tbrowder__ luc's method works for me so far. 18:25
i put both defs in one module with nothing else. defined the Long class first. then: "class S is Long is export {}" and all is well 18:26
any downside? 18:27
lizmat m: class A { }; class B is A { }; dd B.^name 18:32
camelia "B"
lizmat m: class A { }; my constant B = A; dd B.^name
camelia "A"
lizmat not sure whether that is an upside or a downside
18:36 jpn left
tbrowder__ hm, i like your way better, seems like a real alias to me 18:39
testing again now....
works great, exports fine, thanks 18:43
18:49 jpn joined 18:54 deoac joined 18:55 jpn left
tbrowder__ opinion on a class name, please: "Array1'indexed" <= the apostrophe in a valid name, a very cool Raku feature 19:11
19:12 jpn joined
tbrowder__ m: class A'B { say "cool"}; my $b = A'B.new; say $b 19:12
camelia cool
A'B.new
leont I'm still not sure that was a good idea, but I'm extremely happy that - is legal (they follow the same rules, e.g. an identifier can't begin or end with either) 19:17
avuserow tbrowder__: I would generally not use it. Maybe in math-y code, or generated code to help with namespacing, or for a more inventive domain-specific languages?
though I do agree that kebab-cased variables are excellent 19:18
19:23 jpn left 19:24 deoac left
lucs tbrowder__: Yeah, I prefer lizmat's way too :) 19:44
19:54 jpn joined 20:00 euandreh left
tbrowder__ avuserow: yeah, agree. i think i've settled on "ArrayOneBased" for real name 20:00
lucs: i agree, but yr suggestion led to the solution! 20:01
lucs I kind of knew my answer was a bit off, but I know that Cunningham's law always has a good chance of manifesting itself :) 20:04
20:05 zmoment joined 20:34 jpn left 20:35 jpn joined, jpn left 21:04 squashable6 left, squashable6 joined 21:38 sena_kun left 23:10 andinus left
tbrowder__ i just released Algorithn 23:37
duh, AlgorithmsIT
Anton Antonov @tbrowder Reading it now. More importantly, that package name convinced me that the name I have chosen for my next-to-publish package is correct. 23:57