> Richard Kenner wrote: >> It would be good to have a way to mark things as "write once, then >> readonly" IMO. It's very common, and you can do some of the same >> optimizations on such things that you can do on true Readonly objects. > > We used to do this in RTL and it caused all sorts of problems. > > One is that supposed you have such a variable in a function and then > you inline the function into a loop. Now all of a sudden, it's written > more than once.
Wouldn't the ability to differentiate between the following be a good thing: - constant variables (which need to be dynamically allocated & initialized) vs. - static constants (which don't need to be dynamically allocated/initialized themselves, but may be accessed to initialize non-static constants or variables, representing compile time defined static data.) (As it would certainly be necessary if a target needed to treat their accesses differently based on how/where their values were stored. And would correspondingly be necessary to preserve the ability to differentiate any indirect references to them as may be specified, passed, or returned as arguments from function calls.)