If I want to fork Go to add generics, where is the best place to start?

xuanbao · · 24 次点击    
<p>I wrote custom compilers in the past, so that&#39;s nothing new to me. </p> <hr/>**评论:**<br/><br/>joncalhoun: <pre><p>Rather than forking Go, it would probably be easier to write a pre-processor that allows you to write code that &#34;has generics&#34; and converts it into valid Go code. Then you don&#39;t have to worry about your code not working with other Go code and we could at least explore the use cases for generics and see how much they get used in the wild.</p> <p>Edit: I can&#39;t answer your original question, just suggesting an alternative approach to solving the same problem</p></pre>Jelterminator: <pre><p>Tools that do this already exist though:</p> <ul> <li><a href="https://github.com/cheekybits/genny" rel="nofollow">https://github.com/cheekybits/genny</a></li> <li><a href="https://clipperhouse.github.io/gen/" rel="nofollow">https://clipperhouse.github.io/gen/</a></li> </ul></pre>joncalhoun: <pre><p>While both of these have their uses, I don&#39;t think either do what OP or I had in mind. These tools could possibly used for what I mean, but they aren&#39;t a complete solution.</p> <p>What I am referring to would be writing code as if generics were in the language - so maybe writing code that looks like:</p> <pre><code>var a List&lt;int&gt; </code></pre> <p>And having a tool automatically detect that you need an integer version of your list generated doing so, and then replacing your occurrences of that type before building your code with standard go tools. </p> <p>It would be like building a new language that compiles into go code and then into a binary.</p> <p>I suspect doing this would be a little easier than trying to fork go and add generics yourself with little knowledge of the codebase, and it would give us all a tool to experiment with to see what works well and what doesn&#39;t when it comes to generics and Go. </p> <p>It is also possible this is a shitty idea, but if I wanted to add generics to the language I would start here before forking.</p></pre>gac_web: <pre><p>Everybody wrote custom compilers. Have you ever implemented generics in a compiled language? because that&#39;s a totally different endeavor.</p></pre>TheMerovius: <pre><p>Ian Lance Taylor wrote a <a href="https://github.com/golang/proposal/blob/master/design/15292/2013-12-type-params.md" rel="nofollow">proposal for type parameters</a> which is very good and also contains extensive implementation notes. So, I&#39;d start with that.</p> <p>When it comes to &#34;what are the specific steps to add a new feature like that&#34;, I&#39;d watch <a href="https://www.youtube.com/watch?v=vLxX3yZmw5Q" rel="nofollow">Robert Griesemer&#39;s Talk</a> from dotGo about prototyping go designs. He outlines a bunch of useful steps that you can work from.</p> <p>I&#39;d also think very hard about how you intend to maintain your fork. You need people to actually use it, so you should build a good community around it from the start. Otherwise it&#39;s just going to be a lot of wasted efforts… This part is going to be the hardest but also the most important.</p></pre>dlsniper: <pre><p>How do you plan to add generics? What kind of generics? Which problems do they solve? What are the disadvantages of your solution? What are the benefits? How does it compare with the 4 decline implementation of generics in Go proposed by one of the Go Team members? </p></pre>kalekold: <pre><p>This is the sort of thing you see the Go team asking to park the idea indefinitely. It&#39;s been done in many languages and solves many problems. Just fork and implement the damn thing!</p></pre>dlsniper: <pre><p>And destroy everything while you are at it. Because who cares for engineering when you have brilliant minds forking and just implementing? I hate that this language is becoming so much more popular with people like this.</p></pre>TheMerovius: <pre><blockquote> <p>Just fork and implement the damn thing!</p> </blockquote> <p>I agree. You are now, in this thread, already at least two people (you and OP) willing to put in the work to do it. I suggest setting up an E-Mail list and invite them, to coordinate the work.</p></pre>lstokeworth: <pre><p>If you understand the compiler details enough to complete this task, then you will also know where to start.</p></pre>Jelterminator: <pre><p>I think this is just a lame answer. There&#39;s a big difference in knowing how to write generics support for a compiler and knowing where to start writing them in a code base you haven&#39;t worked on before.</p></pre>IgnoranceComplex: <pre><p>The best place to start is the “fork” button on Github. I don’t think there is any board or secret group you need to get permission from. </p></pre>IgnoranceComplex: <pre><p>To go further off this. If you need to ask such a question you simply do not currently have the knowledge / know how needed to do so.</p></pre>
24 次点击  
加入收藏 微博
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet