2
$\begingroup$

In the chapter 4 of Pierce's TAPL which discusses the implementation of untyped arithmetic expressions, the author said

The most important [for the implementation requirements] are automatic storage management... and... pattern matching over structured data types.

Indeed, which the recursive type is natural in ML, it is not allowed in Rust, e.g.

type Info = String;

enum Term {
    ...
    TmIf(Info, Term, Term, Term),
    ...
}

instead Term should be boxed as

enum Term {
    ...
    TmIf(Info, Box<Term>, Box<Term>, Box<Term>),
    ...
}

Similarly, in C/C++, we must use pointers for members in such a recursive type.

While Rust is region-based (and C/C++ is manual) memory management, I wonder whether or not automatic (garbage collection) memory management is obligatory for a language which is capable to represent naturally recursive types?

$\endgroup$
  • $\begingroup$ MLKit uses regions. I think you'd be interested in reading its documentation or the papers about it. $\endgroup$ – Gilles 'SO- stop being evil' Aug 9 '19 at 9:50

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.