The following code is compiling without error on Linux 64 bits but generates an 
`unknown symbol 'initE'` on Linux 32 bits.

module `a.nim`
    
    
    proc algo*[T] =
      proc a: T =
            result = initE[T]()
            result += 3
      
      echo "algo", a()
    
    
    Run

module `b.nim`
    
    
    import a
    
    proc initE[T: int](): T =
      result = 3
    
    algo[int]()
    
    
    Run

So it seems that 64 bits Nim compiler implicitely declares `initE` as `mixin`, 
while the 32 bit compiler does not. Does it mean that mixin declaration will be 
optional in the future?

According to the documentation, the correct way of writing `a.nim` is: 
    
    
    proc algo*[T] =
      proc a: T =
            mixin initE
            result = initE[T]()
            result += 3
      
      echo "algo", a()
    
    
    Run

This version of the code compiles with both compilers. 

Reply via email to