I have no idea how to fix the issue with calling a proc with args using only 
templates.

I tried using the `*` operator: 
<https://nim-lang.github.io/Nim/manual_experimental.html#pattern-operators-the-nimstar-operator>
 like
    
    
    import std / [macros]
    {.hint[Pattern]:off.}
    
    macro `.?`(args: varargs[untyped]): untyped =
      echo args.repr
    
    template condAcc{ `.?` * a }(a: untyped): untyped = `.?`(a)
    
    type
      Data = ref object
        val: int
      
      Obj = ref object
        data: Data
    
    var obj = Obj()
    obj.data = Data()
    obj.data.val = 10
    
    proc foo(d: Data): int =
      d.val
    
    proc bar(d: Data, val: int): int =
      d.val + val
    
    obj.?data.?bar(1)
    
    
    Run

but `condAcc` doesn't match first. The `.?` macro matches and prints `obj .? 
data, bar(1)` instead of `obj, data, bar(1)`.

I tried switching the `.?` macro to: 
    
    
    proc `.?`(args: varargs[NimNode]): NimNode =
      echo args.repr
    
    
    Run

but I get an: `Error: undeclared identifier 'data'` since the pattern matches 
after semantic checking.

So I'm going to resort to a macro solution.

Reply via email to