interpreter in go?

blov · · 503 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>So I want to make a small concatenative language interpreter written in Go. I made a small prototype in c++ (<a href="https://github.com/allenj12/nnd" rel="nofollow">https://github.com/allenj12/nnd</a>). I would like the language to be very closely tied to Go if possible using the same primitives, being able to call Go functions etc...</p> <p>Calling Go functions in the standard library does not seem too much of a problem using reflection however if I want to call a function in Go that requires an import it seems I would have to import that library at runtime. I see options like <a href="https://golang.org/pkg/plugin/" rel="nofollow">https://golang.org/pkg/plugin/</a> and <a href="https://github.com/hashicorp/go-plugin" rel="nofollow">https://github.com/hashicorp/go-plugin</a> but I cant find much info on them and am not sure if its the right way to go. Would either of these packages help, or am I going about this the wrong way?</p> <p>EDIT: just realized I could have made the title more descriptive :(</p> <hr/>**评论:**<br/><br/>danredux: <pre><p>To import dynamically, there&#39;s 3 real options.</p> <p>One is to include a Go interpreter and use that for the Go libs. This would be the best solution for your end-users because of the debugging ability and tight integration.</p> <p>Two is to use the &#34;go&#34; tool to write and compile a plugin dynamically that imports the library and wraps it for use by your interpreter. This is the quickest solution but introduces the Go tool as a dependency for using the interpreted language.</p> <p>Third is to import the library and transpile it to your own language, then just run it. This is the best solution because people using the library can either read/use it as Go or as your custom language, but it&#39;s a massive amount of work.</p> <p>I recommend number 2, and if it becomes worth it in the long run, invest the time into number 3.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

503 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传