▲ | archargelod 3 days 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.... 1 - https://github.com/nim-lang/Nim/blob/652edb229ae3ca736b19474... 2 - https://nim-lang.org/docs/manual.html#generics-mixin-stateme... |