🦋 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.
SmokeMachine RakuCron now uses Lumberjack as logging framework, internally but you can also use it for your jobs (ex: github.com/FCO/RakuCron/blob/main/...kuconfig). Now I'm thinking in a way to reuse the rules when the configuration file changes (currently it drops all the rules and created new ones). Is there a way to se if 2 Callables are equivalent? Because that's the thing avoiding it to know if a rule has changed or not 03:38
m: my &a := { 42 }; my &b := { 42 }; say &a env &b 03:39
camelia ===SORRY!=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> my &a := { 42 }; my &b := { 42 }; say &a⏏ env &b
expecting any of:
infix
infix stopper
postfix
statement …
SmokeMachine m: my &a := { 42 }; my &b := { 42 }; say &a eqv &b
camelia False
SmokeMachine maybe I should store the AST of the current version and compare if that's the same as the new one... 03:40
leont Just noticed fez seems to support reset-password but not change-password, that seems wrong 12:38
vrurg .tell SmokeMachine Saw your question about callables. I don't know what and how RakuCron does, but if your callables were generated from a source then why wouldn't you preserve it (or it's hashsum) and compare the source? 13:29
tellable6 vrurg, I'll pass your message to SmokeMachine
SmokeMachine . 14:21
tellable6 2023-08-13T13:29:17Z #raku <vrurg> SmokeMachine Saw your question about callables. I don't know what and how RakuCron does, but if your callables were generated from a source then why wouldn't you preserve it (or it's hashsum) and compare the source?
SmokeMachine vrurg: because I don’t want to say it’s different if the only thing that has changed is a comment, for example. 14:22
vrurg AST may not be capable of parsing the code yet because RakuAST is not complete. But otherwise it's an option. 14:26
SmokeMachine vrurg: currently, what I do is: I have a supply from notification on the file changes, then for each change I EVAL its content and emit the generated object, and just use .squish to avoid repeating objects one after the other. That’s made by my Configuration module, but RakuCron have Callables inside those objects… then it thinks all objects are different… 14:30
My idea with the ast would be compare it before running the code, as a new step… but yes, if it may not run every code, that’s not a solution yet… 14:33
vrurg SmokeMachine: There is more reliable but implementation-dependent solution. You can produce textual dump of AST using the compiler and get a digest from it. Slower path is to use `rakudo --target='ast' -e <your code>`. Faster path is to get the compiler object and do like EVAL does. 14:34
Except that EVAL is using :from<stage>, you'd need :target<ast> and then .dump the resulting QAST tree. 14:37
SmokeMachine vrurg: interesting… I’ll try that… 14:41
antononcube @SmokeMachine This partial statement by vrurg: “I don't know what and how RakuCron does […]” can be used as a motivator to write a mission statement for “RakuCron”. 14:44
SmokeMachine antononcube: English is not my primary language and I’m quite bad on it. That’s the reason most of my projects have bad documentation (if any) and I usually left to write it when I’m sure of the API, to not have to write that again… but I do agree that’s needed. I’ll try to spend some time doing that. Thanks 14:57
antononcube Good luck! Also, excuses, excuses… use use OpenAI/ChatGPT or Bard/PaLM to jump-start documentation and/or correct grammar. 15:05
Xliff \o 15:32
SmokeMachine: Consider taking the string representation of your code, running it through .AST and then walking the tree and dropping all of the comment nodes. 15:35
Then you can use the result for your comparisons.
m: q|my $a = 1; #`( why would I ever write an inline comment here? ); my $b = 2|.AST.gist.say 15:36
camelia RakuAST::StatementList.new(
RakuAST::Statement::Expression.new(
expression => RakuAST::VarDeclaration::Simple.new(
sigil => "\$",
desigilname => RakuAST::Name.from-identifier("a"),
initializer => RakuAST::Initia
Xliff Hmm...
That comment turned into a RakuAST::Statement::Empty, which you can strip from any StatementList. 15:37
SmokeMachine: You might even be able to use your ASTGrepper for that, yes? 15:38
SmokeMachine Xliff: yes, in theory you could… maybe I need to complete that module… :( 15:47
Xliff :) 15:49
SmokeMachine If a callable stored its own asteroid it would be easier to write a eqv to it… :( 15:54
(And it would also make my life much easier with Red…) 15:58
Xliff I've actually been asking for that. 15:59
SmokeMachine What would be the problem of that? Besides the size of blocks? 16:10
Xliff Don't underestimate the amount of bloat that would cause.
You'd basically be asking for everyone to at least double the size of every Raku program in memory. 16:11
At least.
SmokeMachine Yes… maybe that’s not feasible…
Xliff I think a better way might be to identify such callables by trait.
And only use it on those callables that would benefit from or require that their ASTs are available at run-time. 16:12
s/it/said trait/
SmokeMachine For Red I’m thinking on trying to write a slang that would make all `.map({…})` into `.map({…}, :red-ast($red-ast-version-of-block))` map methods that are not from Red::ResultSeq will just ignore it and the Red::ResultSeq ones will use it to create the sql… (same for grep and first) 16:17
Xliff SmokeMachine: Good luck! 17:39
SmokeMachine But not sure if it would work… 17:44