TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Constraints in Go

211 点作者 gus_leonel7 个月前

3 条评论

pansa27 个月前
I&#x27;m surprised by the complexity of Go&#x27;s generic constraints, given the language&#x27;s focus on simplicity. Things like the difference between &quot;implementing&quot; and &quot;satisfying&quot; a constraint [0], and exceptions around what a constraint can contain [1]:<p>&gt; <i>A union (with more than one term) cannot contain the predeclared identifier comparable or interfaces that specify methods, or embed comparable or interfaces that specify methods.</i><p>Is this level of complexity unavoidable when implementing generics (in any language)? If not, could it have been avoided if Go&#x27;s design had included generics from the start?<p>[0] <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;77445861&#x2F;whats-the-difference-between-types-implements-and-types-satisfies" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;77445861&#x2F;whats-the-diffe...</a><p>[1] <a href="https:&#x2F;&#x2F;blog.merovius.de&#x2F;posts&#x2F;2024-01-05_constraining_complexity&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.merovius.de&#x2F;posts&#x2F;2024-01-05_constraining_compl...</a>
评论 #42164048 未加载
评论 #42164982 未加载
评论 #42164801 未加载
评论 #42164004 未加载
评论 #42176376 未加载
indulona7 个月前
i have been writing Go exclusively for 5+ years and to this day i use generics only in a dedicated library that works with arrays(slices in Go world) and provides basic functionality like pop, push, shift, reverse, filter and so on.<p>Other than that, generics have not really solved an actual problem for me in the real world. Nice to have, but too mush fuss about nothing relevant.
评论 #42163244 未加载
评论 #42165141 未加载
评论 #42163834 未加载
评论 #42165680 未加载
评论 #42163415 未加载
评论 #42165270 未加载
评论 #42163189 未加载
评论 #42164296 未加载
评论 #42163694 未加载
评论 #42164983 未加载
guilhas7 个月前
I like in Go how the code looks like a execution graph, by avoiding smarts and just copying code, when you have an error in the log you can generally just follow it through the code as there is only one path to get there. In C# I would have mostly to debug to understand where did it came from<p>Not just because of the language, but of the simplify culture. Let&#x27;s see how generics will change that