TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

126 pointsby generichumanalmost 2 years ago

4 comments

epagealmost 2 years ago
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 未加载
samsquirealmost 2 years ago
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 未加载
cultofmetatronalmost 2 years ago
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__almost 2 years ago
&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 未加载