I often see the "magic" in Nim's standard library, but I don't know it how to implement. For example:
proc `==` *(x, y: string): bool {.magic: "EqStr", noSideEffect.}
This is a piece of code in system module.
who can help me?
Magics are "magic" and not a "proc" which is called somewhere. So it depends for which codegen or at what level of the compiler chain you look at it.
A search for mEqStr ..
Finds for example:
https://github.com/nim-lang/Nim/blob/master/compiler/ccgexprs.nim#L1691
which calls genStrEquals() .. which does this:
https://github.com/nim-lang/Nim/blob/master/compiler/ccgexprs.nim#L1611-L1626
which is simply generates the C code which is being used.
Implementation for JavaScript codegen is here:
https://github.com/nim-lang/Nim/blob/master/compiler/jsgen.nim#L1388
To add to @OderWat's answer. The easiest way to search is via Github: https://github.com/nim-lang/Nim/search?utf8=%E2%9C%93&q=mEqStr&type=Code
On a side note, I find it annoying that you cannot just search for EqStr and get the same results (https://github.com/nim-lang/Nim/search?utf8=%E2%9C%93&q=eqStr&type=Code). But you can find all of the magics in the ast module anyway. I also think it's safe to assume that the name is always prefixed by an 'm'.