Re:Rust for C++ programmers – part 4: unique pointers
by loup-vaillant on Tuesday April 29, 2014 @11:26AM
(#7667612)
If I had to guess, I'd say "box" is a reference to "boxed values" mentioned in many papers about functional language compilation. Typically, the stack of these implementation would either be "unboxed values", or pointers to "boxes" on the heap.
Clearly, some of those folks have worked on ML or Haskell implementations.
Re:Rust for C++ programmers – part 4: unique pointers
by masklinn on Tuesday April 29, 2014 @01:07PM
(#7668363)
> If I had to guess, I'd say "box" is a reference to "boxed values"
Yes, that's the start of it but it was expanded to multiple box classes (and maybe eventually user-defined ones) rather than just boxed and unboxed values: a developer can currently use box(HEAP) and box(GC) (a bare `box` is an alias for `box(HEAP)`)
Memory safety and static checking.
> A lot of things are renamed. auto->let, new->box, switch->box You get the feeling that effort was put in to make the language explicitly look different from C++
* let comes from ML and similar languages (e.g. Haskell), which are a huge inspiration of Rust (e.g. the type system). Furthermore, let is not auto, it does pattern matching, it's not just a limited form of type inference (or it'd be after the colon, where the type goes).
* match is much the same, it's a pattern-matching construct not just a jump table
* box is for placement box, IIRC it's similar to a universal placement new. For instance it can be used thus: