Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
When the array is initialized at compile time I suppose.
Maybe runtime allocation is better?
RememberMe1368350dIt has very precise meanings though
dynamic typing -> type information checked at runtime
dynamic allocation -> allocation size/existence determined at runtime
dynamic routing -> routing paths determined at runtime
dynamic dispatch -> method dispatch at runtime
(Basically dynamic -> at runtime)
dynamic programming -> yeaaaah this is poor naming, means constructing solutions out of solved sub-solutions.
(For your array, it's not the stack/heap that makes the difference, it's that the allocation size depends on factors that are only resolved at runtime. That's a major difference from static allocation where all this is known at compile time).
RememberMe1368350d@Demolishun nothing wrong there. A static pointer means that the *pointer variable* itself is static, not the thing it's pointing to.
I agree though, in general C/C++'s use of the static keyword is an absolute mess. It's generally a lifetime quantifier i.e. that a static thing is guaranteed to be around in the same place in memory for the duration of the program (so static in the sense that it's always guaranteed to stay at the same place, as opposed to C's usual automatic (stack allocated) variables and class members). It's not really the static in "static allocation".
It's also used to define functions that aren't visible outside a c file but I feel that's just inconsistency (in this case static is sort of opposite to extern).
static in the sense of static typing vs dynamic typing is different, it denotes something that is known at compile time. I suppose you could say C/C++ static variables are known at compile time and they always exist for the duration of the program regardless of anything else (i.e. the linker ensures they're there). It's a very different meaning however from const and constexpr, which are to do with the *values* a variable can take.
halfflat225750dStatic really is the way to go.
Ultimately, any program is going to be run on a finite number of inputs. A static-only approach would precompute the answers, and boom! Results in O(1) complexity.
Also would take up much less memory.
@halfflat That would make for an awesome scifi. Where some scientist figures out how to calculate the outcome of humanity on the universe using some quantum computer. He discovers that the universe will be destroyed by mankind so he has to deal with that eventuality. Insert some plot twists, suppression of reality, etc. Maybe end movie with, "We are fucked, but the beer is good!" Insert really dark humor.
it's more of a synonym of "at runtime", than a buzzword.
dynamically generated mesh, for example. mesh that the code creates during runtime, using some algo.