#Does rust use the term primitive?
24 messages · Page 1 of 1 (latest)
primitive is used but it has nothing to do with the size
can you explain?
primitives are used for "native" types (sorry can't think of a better term to explain it ) like i32, u32, bool, etc which are defined directly in the compiler
Rust by Example (RBE) is a collection of runnable examples that illustrate various Rust concepts and standard libraries.
So these types of variables are called primitives
Do you know why the rust book doesn't use the word?
Yeah this makes sense I already associate the term primitive with these types
i'm not sure why the book doesn't use the term
yeah like
types that can't broken down into smaller pieces
hence primitive
makes sense right?
yeah I understand I was just wondering why the book doesn't use the term
It's possibly just because the distinction doesn't have as much practical impact in rust as it does in some languages. Like, in Java, every non-primitive is heap allocated, whereas in rust the only thing that's special about primitives is that they're not defined as compositions of other things
It doesn't use the terms often in the rest of the book but "primitive" is used in the book, in the Data Types section for example
The historical perspective: in late 2015, just before print publication of the first ed book, the term primitive was briefly discussed to potentially be pejorative, and edited out in several places as a small part of a wider edit pass. Nowadays in the book, primitive is only used as the adjectival form, not as a noun.
Oh this is interesting, lots of these discussions make me realize that "terms of art" are not actually very descriptive. Something like "fundamental types" or "intrinsic types" would get the point across better, and have a more clear distinction from user-defined types
also to note that this thread defines primitive types as "types that can't be broken down into smaller pieces" but the Rust Book actually defines tuples and arrays as "primitive compound types", which is... not quite that.
Right, slices and arrays aren't atomic either
There is a module for it https://doc.rust-lang.org/std/primitive/index.html
This module reexports the primitive types to allow usage that is not possibly shadowed by other declared types.
Oh that reminds me, I think I can rip out all the doc(primitive) handling in rustdoc if I change libstd to document the re-exports instead
Oh wait I remember why this is all so complicated, libstd wants to override the core docs rather than appending 🤦
Never mind I am not doing any more product design for rustdoc I refuse
show us on the doll where rustdoc has touched you
we do thank you for all the sacrifice 