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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Extending Rust's Effect System

151 点作者 egnehots超过 1 年前

9 条评论

mbStavola超过 1 年前
I think there is a lot of value in exploring this idea, even though it&#x27;s a &quot;big idea.&quot; Rust already has a history of taking PLT ideas system programmers don&#x27;t care about and making it practical <i>and</i> appealing. This could be another one of those things where the effort pays off many fold and we all wonder why other languages don&#x27;t do this. It could be as important as generics, traits, or even lifetimes, who knows!<p>That said, it <i>is</i> incredibly complex and a lot to grok. It&#x27;s a completely alien concept to most programmers and there is still some confusion over what this feature even entails. As many people have said, it&#x27;s questionable if you could truly unify some of these &quot;effects&quot; in a way that is useful or even coherent; you might have a sync and async version of a function that ostensibly does the same thing, but the implementation details could diverge a lot to the point where you might as well have just written two different functions. This sort of feature really needs an exploration of what it would look like in practice for existing, popular APIs, and not just toy examples.<p>I really am looking forward to the full RFC with the hopes that they nail the sweet spot here and we end up getting a nice effect system that helps me write beautiful, correct, and performant APIs (more so than I can already do today). At the same time, I also want one of the &quot;correct&quot; outcomes of the RFC to be &quot;let&#x27;s not do this at all.&quot; I worry with the amount of excitement and promotion this initiative has that this may end up being adopted by default. I really have no basis for thinking that, but I do keep seeing this pop up and a lot of people have valid questions and concerns that just go unanswered.
评论 #39334770 未加载
评论 #39360356 未加载
pavlov超过 1 年前
The structure of this article makes it unreadable if you don’t already know what effects mean in this context.<p>The introduction promises that the talk will explain what effects are. Finally, some 75% in, after discussing topics like “what happens when we can’t be generic over effects”, it does get around to answering the question of what effects actually are. But the answer is rather unsatisfying if you don’t know these definitions already. For example:<p>“A lot of languages which have effects provide both effect types and effect handlers. These can be used together, but they are in fact distinct features. In this talk we&#x27;ll only be discussing effect types.”<p>This doesn’t really clarify much.
infogulch超过 1 年前
Related:<p>A lowering strategy for control effects in Rust | 26 days ago | 40 comments | <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=39005780">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=39005780</a><p>Let futures be futures | 7 days ago | 96 comments | <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=39242962">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=39242962</a><p>Also this thread on the Rust Internals forum has some recent discussion about async effect in particular: Case against &quot;maybe async&quot; | <a href="https:&#x2F;&#x2F;internals.rust-lang.org&#x2F;t&#x2F;case-against-maybe-async&#x2F;20144" rel="nofollow">https:&#x2F;&#x2F;internals.rust-lang.org&#x2F;t&#x2F;case-against-maybe-async&#x2F;2...</a>
vmchale超过 1 年前
&gt; We&#x27;ve added major features such as the try operator (?), const generics, generic associated types (GATs), and of course: async&#x2F;.await. Out of those four features, three are what can be considered to be &quot;effects&quot;.<p>I wouldn&#x27;t call the try operator an effect, Result is a monad but it&#x27;s quite different from the I&#x2F;O monad in Haskell
评论 #39332505 未加载
评论 #39333329 未加载
daxfohl超过 1 年前
Could this be done more simply by how go does exceptions: just return the effect and let the caller handle it (or not)?<p>So a function that has exceptions would return &quot;value, error&quot;. A function that is async would return &quot;value, future&quot;. A function that yields would return &quot;value, tail&quot;.<p>I&#x27;m sure I&#x27;m missing something though.
rpigab超过 1 年前
Nice maybe future result of RFC!
IshKebab超过 1 年前
&gt; Not being able to use ? inside of arbitrary closures is an example of an effect mismatch.<p>Yes! This is probably the most annoying thing about Rust in day to day use IMO. You can work around it but it&#x27;s always a pain.
Ericson2314超过 1 年前
Algebraic effects always struck me as an overrided fad. I would much rather they first spend time and something old and proven like higher kinded types.
评论 #39331472 未加载
carterschonwald超过 1 年前
Basically rust needs to be able to express generics that have the interface popularly known at monads.
评论 #39330352 未加载
评论 #39337211 未加载