Noob question about alias.

blov · · 341 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I sort of get that aliases are going to help with package dependencies. Do similar problem exist in other languages like python?</p> <hr/>**评论:**<br/><br/>justinisrael: <pre><p>Python doesn&#39;t have static typing. So in python if you had a function that accepted a type and used it in a specific way, and the type was refactored into another library, your code will still continue to use it correctly as long as you updated the import. In Go it would be a completely different type, without support for aliasing it to the new refactored location. </p></pre>MarchewaJP: <pre><p>To a some degree, yes. Python has aliases too. </p></pre>DualRearWheels: <pre><p>And as a bonus, I guess it will be possible to extend types from other packages or built in types (create new methods on alias).</p></pre>cs-guy: <pre><p>The <a href="https://github.com/golang/proposal/blob/master/design/18130-type-alias.md" rel="nofollow">new alias proposal</a> targeted for Go 1.9 does not allow defining methods on aliases of built in types or types from other packages. It says:</p> <blockquote> <p>Since T1 is just another way to write T2, it does not have its own set of method declarations. Instead, T1’s method set is the same as T2’s.</p> </blockquote> <p>Where T1 is the alias and T2 is the type it aliases.</p></pre>DualRearWheels: <pre><p>Well they took all the fun out of it.</p></pre>shovelpost: <pre><blockquote> <p>Well they took all the fun out of it.</p> </blockquote> <p>░──▓██████▓██▒─▓▓▓▓▓▒▒▓▓▒▒░▒█▒▒█▓▓▒▒░░▒▒▒███ █░─███████▓▓█▒─▓▓▓▓▓▒▒▓▓░▒▓░▓▒▒██▓▒▒▒▒▒▒████ ▒░▒████▓███▓█▒─▓▒▒▓▓▒▒▓▓░▒▓─▓▓▒██▓▒▓▒▒▒█████ ▒▒▓█████▓███▓▒░▓▒▒▓█▒░▓▓░▒▓─▓█▒██▓▒▒▒░██████ ▒▓██████▓████▓▓▓▒▓▓▓▒░▓▓──▓░▓▓▒██▓▒░░▓██████ ▓█████▓█▓▓████▓▓▒▓▓▓▒─█▓──▓░██░▓█▓▒─▒███████ ▓████▓▓▓▓▓████▓▓▒▒▓▓▒─▓▓─▓▓─▓█▒██▓░▒███████▓ ██████▓█▓▓█████▓▓─▒▓▒─▓▒─▓▓─▒▓░██▒▒████████▓ █████████▓▓█████▓▒▒▒▓─▒▒─░▓─▓▓░██▒▓████████▓ ▓▓███████▓▓███▓██▓▓▓▓─▒▒──▓░▓▓░██▓█████████▓ ▓█████████▓▓██▓██▓▒▓█▓██▒─▓▒▓▓░▓████████▓██▓ ▓█████████▓▓█████▓█████████░░▓▒▓███████▓▒██▓ ▒████████████████▓▓──────▒█▓██▓█████████▓▒██ ▓██▓██▓████████▓░──────────▒▓▒▓██████▓▓▓▓▓██ ▓██▓███▓█████▓▒────────────░▒▓██████▓▓▒▓▓▓▓█ ████████▓█▓▒▒░───░───────────▒▓▓█████▓▓▒▓▒▓█ ████████▓▒▒▒░──░▒▓▓░░──░────░░▒▒▓████▓▓▒▓▓██ ████████▒▒▒▒▒░░▓▓▓▓▒░─░░░░░░░░▒▒▒▒███▓▓▓▒███ ████████▒▒▒▓▒▒▒▓█▒▒▒▒▒▓▒▒▒▒▒░░░░░▒▓████▓▓▓██ ████████▓▓▓▓▓▓▓██▒▒▓▓▓█▓▒▓▒▒░░░░░░▒▒▓███████ ████████▓▓█▓▓███▓▒▒█▓▒██▒▓▒▒▒░░░░░░▒▒▓██████ ███████▓▓▓█▓████▓▒▒█▓▓██▓▓▓▒▒░▒░░░░▒▒▓████▓█ ███████▓▓█▓████▓▓▒▒█▓▓███▓▓▒▒▒░░░░░░▒▒▓█████ █████▓█████████▓█▓▒████████▓▓▒░──░░░░▒▓████▓ █████▓█████████▓▓▓▒████████▓▓▓▒░░░░░▒▒▓█████ ████▓▓█████████▒▓▒▓███████▓▓▓▓▓▓░─▒░▒▒██████ ████▓▓█████████▒▒▒▒███████████▓▓▓▒░░▒▒▓█████ ████▓██████████▒▒▒▒██████████████▒─░░░▒█████ ████▓██████████▓▒░▒████████▓▒░███▓─────▓████ ████▓███▓██▓███▓──▒████████▓▒▒█▓██▓░────▓███ ████▓███▓██▓███▒──░█████████▒▓█████▓░░───▓██ ███▓▓█████████▓────▓████▓▓█▓▓███████▒░░░─░▓█ ███▓██████████▒────▓█████▓▓▓████████▓▒░░──░▓ ███▓█████████──────░█████▓█████████▓▓▓▒░░░░▓ ██▓▓████████▓▒▒░────██████████████▓▒▒▓▒░▒▒░▒ ███▓████████▓▓▓▓▒───░█████████████▓▒▒▒▒▒░░░░ █▓▓████████▓▓█▓██────▒███████████▓▓▒▒▒▓▒░░── ██▓▓██████▓▒▒▓█▓▒─────▓██▓█████▓▓▓▓▒▒░▒▒░░░─ ██▓▓▓████▓▒▒░░▓▓░──────▓██▓█▓▓▓▓▓█▓▒▒░░▒░░── ███▓████▓▒▒▒▒▒██▓░──────▓██▓▓▒▓▓▓▓▒▒▒░░▒▒░── ██▓▓▓███▓▒▒▒▓▓▓▓█▓░──────▒▓▓█▓▒▓█▓▒▒░░░▒░─── ██▓▓▓▓▓▓▒▒▒▓▓▒▒─░▓▓───────▒█▓▓▓▓▒▒▒░░─░▒░─── ███▓███▓▒▒▓▓▒▒▒▒──▓▓░░───▒▓▓▒▒▓█▓▒▒▒░──░░─── ██▓▒▓▓▓▓▒▒▓▓▒▒▓▒▒░░▓▓▒░──▓▓▓▒▒▒▒▒▓▓▓▒░─░──── ███▓▓▓▓▓▒▒▓▓▒▒▓▒▒▒▒▒▓▒▒░─░▓▒─░▓▓▓▒▓▓▓──░──── ███▒▓▓▓▓▓▒▓▓▒▒▒▓▒▓▒▒▓▓░░▒▓▓▒▒░▒▒▒▒▒▒▓▒░───── ▓▓█▓▓▓▓██▓▓▓▒▒▒▒▒▒▓▒▓▓▒░▒▒▒▒▒▓▓▒▒▒▒▒░─────── ███▓▓▓█▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▓▒▒▓▒░▒▓██▓▒▓▓░─────── ███▒▓▓▓█▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▓▓█▓▓▒────────── ███▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▒▒──────────── ████▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░────────── ████▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░▒─░░──────── ████▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒░░░▒▒░░─░░░░──────── ████▓▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒░░▒▒▒░░░─░░───────── █████▒▒▓▒▒▓▓▓▓▓▒▒▒▒▓▒▒▒▒░░░░▒▒▒▒░░░───────── ████▓▒▓▓▓▓▓▓▓▓▓▓▓▓▒▓▒▒▒▒▒▒░░▒▒▒▒░░░───────── ████▓▒▓▓▓▓▓▓▒▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒░░─░───────── ████▓▓▓▓▓▓▒▒▒▒▓▓▓▓▓▓▒▒▓▒▒▒▒▒▒▒░─░░░───────── ████▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░▒░─────────</p> <p><strong>Good!</strong></p></pre>

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

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