<p>I found <a href="https://play.golang.org/p/wTC00b0pAZ" rel="nofollow">this playground example</a> showing off function overloading.</p>
<p>It claims the //+overloaded comments are necessary to maintain the Go Promise of Compatibility, but as you can see <a href="https://play.golang.org/p/WpwPhdwvD3" rel="nofollow">here</a> it works just fine without those comments. I tested locally on Mac OS Go 1.7.3 with the same result.</p>
<p>Does anyone know what the story is on this?</p>
<hr/>**评论:**<br/><br/>bradfitz: <pre><p>Unicode. I can tell by the pixels.</p></pre>champioj: <pre><p>It use very similar characters to trick you into thinking it's the same name.</p>
<p>edit: Well, it seems a bit more more tricky as the second setVаlue is in ascii "73:65:74:56:1f:6c:75:65". I'm not sure how the control character '1f' comes from 'a' but anyways, it's not function overloading :)</p></pre>hobbified: <pre><blockquote>
<p>Well, it seems a bit more more tricky as the second setVаlue is in ascii "73:65:74:56:1f:6c:75:65". I'm not sure how the control character '1f' comes from 'a'</p>
</blockquote>
<p>Don't know where you're getting that from. The first one is <code>"setValue"</code>, the second one is <code>"setV\u0430lue"</code> aka <code>"setV\xd0\xb0"</code> (with <code>CYRILLIC SMALL LETTER A</code>) and the third is <code>"setVal\U0001d69ee"</code> aka <code>"setVal\xf0\x9d\x9a\x9ee"</code> (with <code>MATHEMATICAL MONOSPACE SMALL U</code>).</p>
<p>As a side note, I wish Go had Perl's <code>\N{CHARACTER NAME}</code> convention for naming Unicode characters in string literals. It's not strictly necessary since source is UTF-8, but then neither are <code>\u</code> or <code>\U</code>... and <code>\N{SNOWMAN}</code> is so much more descriptive than <code>\u2603</code>.</p></pre>whizack: <pre><p><a href="https://play.golang.org/p/q_-mCARvCG" rel="nofollow">https://play.golang.org/p/q_-mCARvCG</a></p></pre>ultra_brite: <pre><p>Why is this upvoted ? the example is a stupid joke at first place, there is no method overloading in Go.</p></pre>icholy: <pre><p>haha you got me!</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传