News for hackers. Stuff that matters.
Re:Four limitations of Rust's borrow checker by IshKebab on Tuesday December 24, 2024 @09:41AM (#42502183)
Yeah I think this becomes more true the closer your type system gets to "formal verification" type systems. It's essentially trying to prove some fact, and a single mistake anywhere means it will say no. The error messages also get worse the further along that scale you go (Prolog is infamous).

Not really unique to Rust though; I imagine you would have the same experience with e.g. Lean. I have a similar experience with a niche language I use that has dependent types. Kind of a puzzle almost.

It is more work, but you get lots of rewards in return (including less work overall in the long term). Ask me how much time I've spent debugging segfaults in C++ and Rust...

Re:Four limitations of Rust's borrow checker by binary132 on Tuesday December 24, 2024 @10:47AM (#42502632)
That’s not what OP is discussing. OP is discussing corner cases in Rust’s typesystem that would be sound if the typesystem were more sophisticated, but are rejected because Rust’s type analysis is insufficiently specific and rejects blanket classes of problems that have possible valid solutions, but would need deeper flow analysis, etc.
Re:Four limitations of Rust's borrow checker by IshKebab on Tuesday December 24, 2024 @12:46PM (#42503477)
Yes I know. You get the same effect with type systems that are closer to formal verification. Something you know is actually fine but the prover isn't quite smart enough to realise until you shift the puzzle pieces around so they are just so.
Re:Four limitations of Rust's borrow checker by binary132 on Tuesday December 24, 2024 @09:29PM (#42506449)
Ahh, I see what you mean
Re:Four limitations of Rust's borrow checker by ykonstant on Tuesday December 24, 2024 @10:34AM (#42502540)
Lean is far more punishing even for simple imperative code. The following is rejected:

  /- Return the array of forward differences between consecutive
     elements of the input. Return the empty array if the input
     is empty or a singleton.
  -/

  def diffs (numbers : Array Int) : Array Int := Id.run do
    if size_ok : numbers.size > 1 then
      let mut diffs := Array.mkEmpty (numbers.size - 1)
      for index_range : i in [0:numbers.size - 2] do
        diffs := diffs.push (numbers[i+1] - numbers[i])
      return diffs
    else
      return #[]