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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

What Vale taught me about linear types, borrowing, and memory safety

126 点作者 generichuman将近 2 年前

4 条评论

epage将近 2 年前
I feel like I&#x27;ll have to read up some more to have the background to fully understand the article but one thing I wanted to point out is a difference between `fn rand_int(rand: &amp;mut Random) -&gt; i64` and `fn rand_int(ran: Random) -&gt; (i64, Random)`, at least in Rust. With the version that moves `Random`, the return type is bigger and may spill over from registers to the stack which may cause a significant slow down, more than the code of Vale&#x27;s generation check, I suspect.<p>I&#x27;ve run into this with my parser combinator library, winnow [0], and am considering switching from the nicer functional model of moving to the more imperative model of `&amp;mut` [1].<p>[0]: <a href="https:&#x2F;&#x2F;docs.rs&#x2F;winnow&#x2F;latest&#x2F;winnow&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;winnow&#x2F;latest&#x2F;winnow&#x2F;</a><p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;winnow-rs&#x2F;winnow&#x2F;issues&#x2F;72">https:&#x2F;&#x2F;github.com&#x2F;winnow-rs&#x2F;winnow&#x2F;issues&#x2F;72</a>
评论 #36184011 未加载
samsquire将近 2 年前
This is really interesting verdagon, thank you.<p>I wrote a multithreaded reference passing implementation that runs at runtime. If you have the reference you can use it, the condition is that you have to give it back when you&#x27;re finished with it.
评论 #36179075 未加载
cultofmetatron将近 2 年前
can&#x27;t believe he managed to get though this entire article without once mentioning the artifact by name. its called the rosetta stone and its currently held in the ancient history museum of London. definitely worth seeing in person.
评论 #36180234 未加载
__stdcall__将近 2 年前
&gt; If you&#x27;ve used a language like Rust before, this might feel familiar: own-lending is semantically equivalent to borrowing a &amp;mut Random and passing it around.<p>Is this a typo? I trust the author meant `Random` by move, or are they speaking to low level behavior where moves are elided to nothing where possible (and thus looks like a borrow)
评论 #36176071 未加载