Usually, you would define `action` as `proc(l,r: T): T`. But this does not work 
for `xor` because of this paragraph in the manual ([see 
also](https://github.com/nim-lang/Nim/issues/2172)):

> Assigning/passing a procedure to a procedural variable is only allowed if one 
> of the following conditions hold:
> 
> * The procedure that is accessed resides in the current module.
> 
> * The procedure is marked with the procvar pragma (see procvar pragma).
> 
> * The procedure has a calling convention that differs from nimcall.
> 
> * The procedure is anonymous.

`xor` is not in the current module, not marked with `{.procvar.}`, has the 
calling convention `nimcall` and is not anonymous, so it may not be passed to a 
procedural variable.

You can, however, use a template:
    
    
    template bitWise*[T](buff: openArray[T], action: untyped, mask: 
openArray[T]): seq[T] =
      var result = newSeq[T]()
      for i in 0..<buff.len:
        result.add(action(buff[i], mask[i]))
      result
    
    echo bitWise([1, 0, 0], `xor`, [1, 0, 1])
    

Reply via email to