4 ms·
With function overloading, templates and late static binding. You just use a `hash` function in your library code and user has to implement a version of it tha
by archargelod 2y ago
With function overloading, templates and late static binding.
You just use a `hash` function in your library code and user has to implement a version of it that accepts the Foo type.
To resolve the scope problem, Nim uses templates[1] and a `mixin`[2] statement to bind user-defined hash procedure.
0 - https://github.com/nim-lang/Nim/lib/pure/collections/tables.nim https://github.com/nim-lang/Nim/lib/pure/collections/tables....
1 - https://github.com/nim-lang/Nim/blob/652edb229ae3ca736b19474cd315f28a9e0893a2/lib/pure/collections/tables.nim#L236-L244 https://github.com/nim-lang/Nim/blob/652edb229ae3ca736b19474...
2 - https://nim-lang.org/docs/manual.html#generics-mixin-statement https://nim-lang.org/docs/manual.html#generics-mixin-stateme...