|
I have a data structure and I'd like for its contents to never be changed,
enforced by the compiler. How do I do this?
One situation I've run into is where I want to initialize an output data
structure parameter. I can't reset it. I can't cheat and base another DS
on it and reset that DS. I can clear the fields individually, but that
sucks, right? This will also be called a ton of times, so I want to pass
the data by reference (so not using a return value). What I ended up doing
is creating a static DS to house all the default values so I can initialize
the output parameter with it. However it does leave the initialization DS
open to being modified.
Another situation is I tend to create data structure arrays, which long ago
would have been compile time tables. Each subfield is an element in an
array (so each element has a given name if I ever need to reference one
specific value). However, these values could be changed, and I have to rely
programmers not changing it (vs the compiler not letting them).
Thoughts on creating a data structure constant?
I'm on v5r4.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.