<story><title>Swift Algorithms</title><url>https://swift.org/blog/swift-algorithms/</url></story><parent_chain><item><author>pmiller2</author><text>Sounds to me like a job for a DSL that compiles down to Golang for the final output.  That way, the repeated code only exists in the Golang output and not in the code that humans actually write.</text></item><item><author>coldtea</author><text>One issue with Go&amp;#x27;s lack of generics is exactly that it can&amp;#x27;t have such a package (and have it be type safe, fast, and work across all relevant types), except with repeated code.</text></item></parent_chain><comment><author>setr</author><text>the solution is... to not use Golang!&lt;p&gt;more specifically, fairly basic operations on a list of data does not seem like it should call for the complexity of a DSL. IMO unless you need to do this quite a bit on random datatypes, copy &amp;amp; paste would probably be the better alternative. Unless you&amp;#x27;re referring to a DSL that looks exactly like Golang but with generics &amp;amp; monomorphism.... in which case ok I guess</text></comment>
<story><title>Swift Algorithms</title><url>https://swift.org/blog/swift-algorithms/</url></story><parent_chain><item><author>pmiller2</author><text>Sounds to me like a job for a DSL that compiles down to Golang for the final output.  That way, the repeated code only exists in the Golang output and not in the code that humans actually write.</text></item><item><author>coldtea</author><text>One issue with Go&amp;#x27;s lack of generics is exactly that it can&amp;#x27;t have such a package (and have it be type safe, fast, and work across all relevant types), except with repeated code.</text></item></parent_chain><comment><author>bee_rider</author><text>Googling about this (I assumed the actual &amp;#x27;solution&amp;#x27; would be a to use C-style awful macro kludges) eventually lead me to:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;blog.golang.org&amp;#x2F;generate&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;blog.golang.org&amp;#x2F;generate&lt;/a&gt;&lt;p&gt;Now I&amp;#x27;m wondering if you joke was not actually a joke.</text></comment>