Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Pratik Gavand
    @pratikgavand01_gitlab
    the fact that functions can have variables. I want to store the function definition and evaluate at later stage
    however before I store I want to parse and catch the malformed expression without actually evaluating variable values
    Solomon White
    @rubysolo
    My initial thought is that you could switch to evaluate! and catch parse errors (vs unbound variable errors)
    I can try to find a better way when I get back to a computer.
    Pratik Gavand
    @pratikgavand01_gitlab
    thanks currently I am using tokenizer.tokenize methods and evaluate to catch errors but was wondering if there is any other better way
    Maciej Mensfeld
    @mensfeld
    Good afternoon
    @rubysolo are you open to an instrumentation code for the AST nodes upon their execution?
    I need to get data from each of the nodes on their input and output and doing the instrumentation (needed for debugging of critical complex rules)
    and I could release it open source
    basically it is wrapping the #value with a notification engine
    pluggable one so no additional deps but api compatible with dry-monitor and rails notifications system
    Solomon White
    @rubysolo
    Sure, that would be great!
    Maciej Mensfeld
    @mensfeld
    o wow you are here
    amazing gem you did there sir
    !
    Solomon White
    @rubysolo
    Thanks! 😊
    Maciej Mensfeld
    @mensfeld
    I would imagine something liek that:
          def value(context = {})
            left = left.value(context)
            right = right.value(context)
            result = left.value(context) || right.value(context)
    
            notifier.instrument(
              left: left,
              right: right,
              node: self,
              result: result
            )
    
            result
          end
    that is an 'OR' example
    I could then hook up a listener and track each node execution
    which is not funny for a OR node :D
    but it certainly is for other things plus hook up some monitoring just in case something unexpected leaks to any of the nodes
    plus with a proper UI magic it could allow building the whole tree with the results
    dunno if you though about that or about any logging engine (that could be done as a instrumentation listener as well to that)
    Solomon White
    @rubysolo
    Well, it’s a slightly different use case, but I’ve been working on a visitor implementation so that you could add your own tree processing.
    Maciej Mensfeld
    @mensfeld
    COuld you elaborate on that?
    Solomon White
    @rubysolo
    But there would probably be some overlap or similarities in the implementation.
    Maciej Mensfeld
    @mensfeld
    you mean a code that would allow you to travers nodes?
    is it somewhere published? I could maybe help and push it forward instead of duplicating your work
    Maciej Mensfeld
    @mensfeld
    I also noticed the AST::DateTime but I didn't find any specs or anything describing what it does
    Solomon White
    @rubysolo
    Also some discussion here: rubysolo/dentaku#151
    Maciej Mensfeld
    @mensfeld
    Quick glance and a question as it seems it could cover my usecase: will it allow to traverse the tree after the execution, before or both? :D
    It seems it will allow me to traverse the AST but not track the execution results
    Maciej Mensfeld
    @mensfeld
    I want to track the exact results to be able to unsolve some of the execution problems if any (logic mistakes, complaints about badly working rules, etc)
    Solomon White
    @rubysolo
    Yeah, currently it’s separate from evaluation, but maybe they could be combined.
    Maciej Mensfeld
    @mensfeld
    I'm investigating this gem for the second day but I feel that this is viable usecase: to be able to figoure out the result and input params for each of the nodes
    Solomon White
    @rubysolo
    For example, perhaps the default evaluator could be a visitor, and instrumentation could be another visitor, and then visitors could be combined for processing a tree.
    Maciej Mensfeld
    @mensfeld
    if you come across Cracow (Poland) I owe you many :beers: for this lib. It saved me weeks of work!
    yes - you would actually kjust reverse my idea :D but your is more fit to an AST based world
    where mine comes from instrumenting frameworks :)
    Solomon White
    @rubysolo
    Cool, I’ll be sure to look you up if I ever get over there! 😎
    Maciej Mensfeld
    @mensfeld
    I hope you will :) pretty nice Ruby community we have here as well ;)
    Maciej Mensfeld
    @mensfeld
    Hey @rubysolo is dentaku thread safe?
    Maciej Mensfeld
    @mensfeld
    It isn't
    nevermind though - did an inline cache for myself
    that is thread safe
    Maciej Mensfeld
    @mensfeld
    Hey @rubysolo is there a chance to disable type casting for Dentaku?
    I'm looking into performacne improvements and since I have the data preprepared with correct types, I would not need the castings
    Maciej Mensfeld
    @mensfeld
    Hey @rubysolo
    ping ^^