Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.38 KB | None | 0 0
  1. type
  2.   Vec[N: static[int], T] = object
  3.     data: array[N, T]  
  4.  
  5. proc newVec[N: static int, T](arr: array[N, T]): Vec[N,T] = discard
  6.  
  7. proc `+`[A: Vec](a: A; t: A.T): string = "A"
  8. proc `+`[A: Vec](t: A.T; a: A): string = "B"
  9.  
  10. let v = newVec([0.0])
  11. echo v + 1.0            # no problem
  12. echo 1.0 + v            # error:  Cannot instantiate Vec[N,T] inside of type definition `+`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement