4
$\begingroup$

Rust is famous for its ownership type-system, but requires the programmer to annotate ownership in function signatures. Is it possible to do full program inference of ownership, without any annotations? What would be the pros and cons of such a system?

$\endgroup$
  • 1
    $\begingroup$ The term you might be looking for is partial type inference. The reason why many languages don't have full type inference is that once you go beyond Hindley/Milner let-polymorphism, full type inference is generally undecidable. $\endgroup$ – Martin Berger Jun 29 at 16:41
  • $\begingroup$ @MartinBerger No. Rust already has partial inference. This question is about full inference. $\endgroup$ – Olle Härstedt Jun 29 at 18:24
  • $\begingroup$ I know that Rust has partial type inference. I was just clarifying terminology. $\endgroup$ – Martin Berger Jun 29 at 19:19
  • $\begingroup$ As a general rule of thumb, any dynamic feature of a langauge (ownership at runtime, effects, shape of heap, what is printed out) can only be approximated by a type system that has algorithmic checking or inference, because questions about the dynamic behavior of programs get undecidable really fast. One always ends up balancing expressivity and simplicity. $\endgroup$ – Andrej Bauer Jul 1 at 8:51
  • $\begingroup$ @OlleHärstedt what Andrej said is formalised in the famous Rice's Theorem. $\endgroup$ – Martin Berger Jul 4 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.