Use Readonly instead of constant.
Years ago I started doing exactly that, only to discover strange bugs. I then completely abandoned Readonly, opting to use normal variables in all caps - it gives variables that interpolate and that can be overridden for testing. And since I mostly publish libraries where such variables are typically undocumented package variables, if someone chooses to reach into my package and break something by changing "constants", it's their fault. And yes, this philosophy only works when you don't have many users and those users are programmers...
| [reply] |
The module ReadonlyX claims to be a drop-in replacement for Readonly which fixes many of the bugs and avoids the time penalty. Unfortunately, it is not an exact "drop-in". It may be a good solution to your problem.
| [reply] |
DB<35> *RO=\5
DB<36> p $RO
5
DB<37> $RO=6
Modification of a read-only value attempted at (eval 51) ...
HTH! :)
| [reply] [d/l] |