3 ms·
Why not call it Pointer or Point?
by thomasahle 6y ago
Why not call it Pointer or Point?
- otachack 6y agoIn game or graphical development a Point struct/object is usually reserved for Cartesian coordinates. Pointer seems too long. C's use of "*" and "&" remain my favorite though beginners may have more difficulty understanding it, similarly to Rust's Box.
- wwright 6y agoA Box is not a pointer. It is an object with regular one-owner, no copies semantics. Semantically, it just breaks the object out so that it isn’t “internal” to whatever contains it (useful for keeping individual objects small or working around the requirement that a type have a known, finite size). A pointer and a heap allocation are the obvious choice for implementing this, but the semantics are notably different than just being a pointer. Rust also does have pointer types which represent true pointers.
- umanwizard 6y agoAFAICT, Box has exactly the same semantics as C++‘s unique_ptr.
- temac 6y agoWhere it can have the same semantics, yes. But if you look at the details, not exactly. For example Box is not nullable, but a not-nullable C++ equivalent is hard to do given the rest of the language.
- umanwizard 6y agoGood point on the nullability; yes, that is indeed different from std::unique_ptr.