I realize what I am asking is "Dark magic" and goes against what should be
done. However, with that in mind I would like to create a custom assignment
operator.
var x:int =5
Run
vs.
var x <| 5
Run
or
var x << 5
Run
What I have tried so far...
template `<<` (a, b: untyped): untyped =
system.`=`(a, b)
var a:int
a << 5
echo a
Run
The above code works but,
var a << 5
Run
But the error I get back is:
index.nim(9, 11) Error: type mismatch: got <type int, int literal(5)>
but expected one of:
proc `=`[T](dest: var T; src: T)
first type mismatch at position: 1
required type: var T
but expression 'int' is of type: type int
expression: `=`(int, 5)
Run
Hope this is possible but honestly not sure. Mind you im only barely getting
into Nim so expect some really dumb questions :/