NewLisp & Rust 在內存管理䇿略上的相似性

抽空回 NewLisp 看了看,然後忽然幾現 NewLisp 的 ORO (one reference only) 內存管理好像在別的地方听到过⋯⋯

NewLisp 的 ORO:

newLISP follows a one reference only (ORO) rule. Every memory object not referenced by a symbol is obsolete once newLISP reaches a higher evaluation level during expression evaluation. Objects in newLISP (excluding symbols and contexts) are passed by value copy to other user-defined functions. As a result, each newLISP object only requires one reference.

Rust 的 Ownership:

There is strict ownership semantics involved so each value can only and only have one owner at a particular time. When you pass a value to a function, you move the ownership of that value to the function argument and similarly, when you return a value from a function, you pass the ownership of the return value to the caller.

两者最大的区別在于,NL 是纯解釋性的,內存分配都是动态发生,Rust 的內存分配则是编译時计算好的。

实际上 ORO 在 1991 年就以 Linear Lisp 的形式出現了。两者的內存管理䇿略都是从 Linear Logic 发展出來的。

才300多k的体积吸引了我.....

那天弄到我的单片机里面跑跑..