News for hackers. Stuff that matters.
Re:What's a reference in Rust? by jcelerier on Wednesday November 29, 2017 @05:38AM (#15805896)
> Rust references 1) are first-class

what makes them more first-class than C++ references ? eg in C++ given a type T, you can use `std::add_lvalue_reference<T>`, `std::remove_reference<T>`, overload on references, check if a type is a reference to another...

Re:What's a reference in Rust? by Sharlin on Wednesday November 29, 2017 @07:11AM (#15806204)
C++ reference types are first-class. But instances of reference types are not first-class values. References are not objects, in standard speak, they do not have a memory location, you can't take their address, you can't pass them to functions (a reference parameter means passing a value by reference, not a reference by value). And so on. Rust references are more like C/C++ pointers or Java references in that they are actual values, and AFAIK Rust functions, like Java and C functions, are strictly pass-by-value.
Re:What's a reference in Rust? by wyldfire on Wednesday November 29, 2017 @09:42AM (#15807110)
This is a really helpful distinction, thanks for clarifying.
Re:What's a reference in Rust? by kimundi on Wednesday November 29, 2017 @07:14AM (#15806214)
I think they just meant that Rust references are like normal first-class generic types. Eg, you can nest them to get a &mut &T for example, since they behave more like a pointer in that regard.

C++ references on the other hand are more like modificators of a type, eg you can have a T or a T&, but having a (T&)& does not make sense. (Outside of templates, where it gets folded down to a T&.)