real quick here is the code for the change
    
    
    macro getCustomPragmaVal*(n: typed, cp: typed{nkSym}): untyped =
     let pragmaNode = customPragmaNode(n)
      result = newTree(nnkPar)
      for p in pragmaNode:
        if p.kind in nnkPragmaCallKinds and p.len > 0 and p[0].kind == nnkSym 
and p[0] == cp:
          if p.len > 1:
            for arg in 1..(p.len-1):
              result.add p[arg]
            return
          else:
            return p[1]
      
      error(n.repr & " doesn't have a pragma named " & cp.repr()) # returning 
an empty node results in most cases in a cryptic error,
    
    
    Run

and the original for reference
    
    
    macro getCustomPragmaVal*(n: typed, cp: typed{nkSym}): untyped =
      let pragmaNode = customPragmaNode(n)
      for p in pragmaNode:
        if p.kind in nnkPragmaCallKinds and p.len > 0 and p[0].kind == nnkSym 
and p[0] == cp:
          return p[1]
      
      error(n.repr & " doesn't have a pragma named " & cp.repr()) # returning 
an empty node results in most cases in a cryptic error,
    
    
    Run

now running the original version with this code 
    
    
    template test_prag(d:int,b:int) {.pragma.}
    
    type
      test_type {.tprag(10,20).} = int
    
    
    var a:test_type = 0
    echo a.getCustomPragmaVal(tprag) # this outputs 10, there is no way to get 
the second value that I know of
    
    
    Run

but with the change it would output 
    
    
    (Field0: 10, Field1: 20)
    
    
    Run

ill be using this myself, but I wanted to get others opinions

Reply via email to