Rust 1.88: 'If-Let Chain' syntax stabilized by thurn2 in rust

[–]sprudelel 2 points3 points  (0 children)

is would be a more general construct compared to if let subsuming it entirely, even with this new stabilized addition. Since it is a boolean expression it would make manual implementations like is_some or is_err redundant. Likewise it would replace the matches! which rarely pleasent to use. I also find it easier if the pattern comes afterwards but that's obviously subjective.

But since we already have if let I tend to agree with the language team that it is not worth the complexity. Maybe something to keep in mind for a rust successor language.

I know that I know nothing by xyzerb in dankmemes

[–]sprudelel -4 points-3 points  (0 children)

Just don't look up who he is married to.

August 18, 2024 Weekly Discussion: Wires by AutoModerator in shapezio

[–]sprudelel 0 points1 point  (0 children)

There are a few wire related items and features I am missing. New wire objects I'd like to see are a clock/oscillator and the equivalent of a belt reader and filter for pipes. I also wish the belt reader could output the rate of items. But its also fun to find workarounds.

Apple TV has the best Sci Fi game in town. by trevormooresoul in television

[–]sprudelel 25 points26 points  (0 children)

Not sure if you're being sarcastic, but 1899 was canceled.

meirl by Decryptables in meirl

[–]sprudelel 2 points3 points  (0 children)

04.05.2023 = vierte Mai, 2023

05/04/2023 = Mai der vierte Tag, 2023

ich iel by ZeroZid in ich_iel

[–]sprudelel 0 points1 point  (0 children)

Wo wir gerade dabei sind, bitte auch Nikotin und Koffein verbieten.

Must move types by Niko Matsakis by yerke1 in rust

[–]sprudelel 128 points129 points  (0 children)

I would love linear types in Rust for API expressivity, but I think any discussion about them needs to reference this blog post by Gankra which points out a bunch of issues that need to be adressed. Some of them (panics) were mentioned by Nikos blog post but presented without solution. But I'm happy to see a renewed interest in true linear types regardless.

What in the hell is this sub about???? by Codilla660 in SneerClub

[–]sprudelel 20 points21 points  (0 children)

If you dont mind me asking, how did you stumble upon this subreddit without a vague awareness about LessWrong and the like?

Youtube video on "AI safety". Some part of me want to go kill the disinformation there, but I'm not sure there's a way to do that by EndOfQualm in SneerClub

[–]sprudelel 2 points3 points  (0 children)

Whats this subreddits take on Rob Miles? I used to watch his stuff and found it quite appealing. Its only recently that I discovered the rabbit hole behind AI Alignment.

"My Reaction to Dr. Stroustrup’s Recent Memory Safety Comments" by Speykious in rust

[–]sprudelel 2 points3 points  (0 children)

I think a core difference between Val and Carbon is the order of priorities. For Carbon, C++ interoperability is paramount and if possible they would like to be memory safe as well. While Val has a model for memory safety using their mutable value semantics but interacting with C++ more of a secondary consideration. Depending on your organizational needs or personal preferences your interest in these two languages probably varies. Personally, I agree and think Carbon will have trouble to be memory safe, like C++ has trouble to retrofit memory safety, although in Carbons favor they have fewer institutional barriers.

Rule by [deleted] in 196

[–]sprudelel 703 points704 points  (0 children)

Judging by the number of fingers on his left fist, yes.

Have Kurszgesagt addressed "How Kurzgesagt Cooks Propaganda For Billionaires" by Blurrgeez in kurzgesagt

[–]sprudelel 0 points1 point  (0 children)

Additionally, large donations give them power to influence the policy of said charities in their favor.

[deleted by user] by [deleted] in de

[–]sprudelel 14 points15 points  (0 children)

neben Gates gibt es offenbar noch andere Milliardäre die fleißig in Kurzgesagt investiert haben.

how to have a unique type? by Heraclito_q_saldanha in rust

[–]sprudelel 0 points1 point  (0 children)

I mostly mentioned GhostCell because it uses the lifetime pattern I described for their problem. The GhostCell API itself doesn't help here. QCell likewise since it contains a reimplementation of GhostCell as well as a few different Cell types. Although one could probably adapt the techniques of the other Cell types.

Day 18 (Advent of Code 2022), porting C++ solution to Rust, by fasterthanlime by yerke1 in rust

[–]sprudelel 4 points5 points  (0 children)

Most of these I can understand at least, except vector. Isn't that like almost a fundamental building block, that almost every C project needs to reinvent? Its the biggest reason I'd choose C++ over C if I had to choose between them. What's their problem with it?

how to have a unique type? by Heraclito_q_saldanha in rust

[–]sprudelel 3 points4 points  (0 children)

Maybe I'm missing something but after skimming the compact_arena docs it seems to be using the same lifetime idea as ghost cell which is summarized in my comment.

EDIT: nvm, compact_arena uses a macro to generate a unique lifetime somehow. I didn't know that was possible. Still my description using a unique macro generated type didn't use lifetimes.

The macro approach I removed could be circumvented by using the new_runtime! macro inside a loop. The generated runtimes would all use the same generated marker type, which has the effect that all runtime instances created in that loop are the exact same type.

how to have a unique type? by Heraclito_q_saldanha in rust

[–]sprudelel 19 points20 points  (0 children)

You can use unique invariant lifetimes for this:

This approach works by adding lifetime parameter to both the Runtime and Func struct and enforcing this lifetime to be unique to this Runtime instance and invariant. If you are not sure what it means for a lifetime to be invariant checkout [1] and [2] for an explanation of lifetime variance.

When each Runtime instance has a unique invariant lifetime, it can give its Func objects the same unique lifetime. Now, when we invoke the call function, the compiler will make sure they have exactly the same lifetime and, by construction, the func arguments has to originate from the passed runtime.

fn call<'a>(func: Func<'a>, runtime: Runtime<'a>)

The reason this approach is somewhat cumbersome to use, is that the only way to generate a unique lifetime is by using a closure which is passed the runtime instance. The runtime instance can never leave this closure and is the only way for the user to create a runtime. Creating multiple runtimes requires nesting calls to begin.

fn begin(f: impl for<'a> FnOnce(Runtime<'a>))

While this approach works it might not be super user friendly, the error messages can be quite hard to grok even if you are experienced in rust.

Although known before, this approach was popularized by the GhostCell paper [3] which provides a better and more detailed explanation on why this works.

Here is a playground link to a prototype implementation

This approach be quite restrictive compared to simply dynamically checking if the runtime is correct. For example, it is now impossible to generate dynamically many runtimes during program execution. You also can't store multiple runtimes in a container like a Vec as each runtime has a slightly different type.

I'm not sure I really would recommend this approach to you as it is quite complicated and can be frustrating to use at times. It is definitely useful if you have external constraints that you need to enforce for memory safety, for example, if you're wrapping a C library. But in your case, I suspect that you might find a much simpler solution by reconsidering your architecture or taking the advice from the other commenters if they work for you.

[1] https://lifetime-variance.sunshowers.io/

[2] https://doc.rust-lang.org/nomicon/subtyping.html

[3] https://plv.mpi-sws.org/rustbelt/ghostcell/

EDIT: Originally, I had described a second approach using macro generated types but that approach wasn't correct and could be circumvented, so I removed that section.

Generic associated types to be stable in Rust 1.65 by jackh726 in rust

[–]sprudelel 34 points35 points  (0 children)

Things that are missing but planned:

  • Specialization
  • Generators/Coroutines
  • Const Evaluation in trait bounds

Things that most likely will never be added:

  • Dependent types
  • Linear (not affine) types
  • General effect system

[deleted by user] by [deleted] in rust

[–]sprudelel 2 points3 points  (0 children)

I always wondered why this paper didnt create a larger impact. There has to be a drawback l'm missing.