When did function overloading get slipped in?

agolangf · · 389 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<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&#39;s the same name.</p> <p>edit: Well, it seems a bit more more tricky as the second setVаlue is in ascii &#34;73:65:74:56:1f:6c:75:65&#34;. I&#39;m not sure how the control character &#39;1f&#39; comes from &#39;a&#39; but anyways, it&#39;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 &#34;73:65:74:56:1f:6c:75:65&#34;. I&#39;m not sure how the control character &#39;1f&#39; comes from &#39;a&#39;</p> </blockquote> <p>Don&#39;t know where you&#39;re getting that from. The first one is <code>&#34;setValue&#34;</code>, the second one is <code>&#34;setV\u0430lue&#34;</code> aka <code>&#34;setV\xd0\xb0&#34;</code> (with <code>CYRILLIC SMALL LETTER A</code>) and the third is <code>&#34;setVal\U0001d69ee&#34;</code> aka <code>&#34;setVal\xf0\x9d\x9a\x9ee&#34;</code> (with <code>MATHEMATICAL MONOSPACE SMALL U</code>).</p> <p>As a side note, I wish Go had Perl&#39;s <code>\N{CHARACTER NAME}</code> convention for naming Unicode characters in string literals. It&#39;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

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