4 ms·
>"Stack allocation is the default in all practically used languages that actually have a stack (e.g. C, C++), and heap allocation is explicit in all of those as
by bogomipz 10y ago
>"Stack allocation is the default in all practically used languages that actually have a stack (e.g. C, C++), and heap allocation is explicit in all of those as well."
That was my first thought as well when I read that passage. Do you know why the author might have felt the need to state this specific in the context of Rust then?
- paupino_masano 10y agoC# and Java allocate objects to the heap and primitive types to the stack by default so perhaps it may be in context to that (i.e. It's not explicit but rather implicit on the type being used).
- DorothySim 10y ago> C# and Java allocate objects to the heap and primitive types to the stack by default (...) Note that it only applies to local variables. If you have a primitive inside an object then it's allocated on the heap as part of the outer object.
- bogomipz 10y agoI see, that would make sense. Thanks.