Description
Still a newbie so bear with me...
Not sure why heap access is necessary or even desirable for const
and static
's values. That they are binary embedded values seems like a very tight abstraction where compile time evaluation is merely another way to building such values (byte patterns) as part of the binary construction process. In particular, alignment and other runtime constraints aren't truly relevant but if they are they can be easily accommodated by dedicated code. For instance, converting a byte array
to an i64
can have code to align on construction or conversion since both the value and the shape of the result are known. Ultimately, the heap, stack, and registers are strictly runtime resources and making them otherwise complicates the load, align, and execute at entry point abstraction. It also doesn't make sense in terms of libraries for it to somehow populate the heap at load time. However, I may be missing something...
Additionally, when const
and static
's only affect the binary then what they can do in generating results becomes conceptually unlimited only by time and security considerations, though all such constructed values must now be access by reference. Interestingly, static mut
becomes a possible way to have self modifying binaries.