Experts rejoice, here is an interesting task: Figure out why https://github.com/nim-lang/Nim/pull/23407 does not work on Windows.
The idea behind it is that we can leave the merging of duplicated generic instantiations to the linker and simplify the frontend. If only it would work... :-)
1- __declspec(selectany), which directs the linker to select just one (any one) of multiple definitions for the symbol and discard the rest. MS explicitly state this as a quasi-answer for not exposing weak references to the programmer, but as a commenter notes this is not satisfying – one could hope to be able to declare a single implementation as strong, thus enforcing its selection at build time.
2- The undocumented #pragma /alternatename, found in CRT sources and mentioned in this StackOverflow answer. This one helps mimic a different weak-symbol functionality: initializing the symbol to zero if no definition is found. This also hardly suffices as a replacement.
The idea behind it is that we can leave the merging of duplicated generic instantiations to the linker and simplify the frontend.
This means though that the (c) compiler has to re-parse, re-codegen and potentially re-optimize them leading to quite a lot of extra work for it before it gets to the linking stage. Compile times..