Closed 1uc closed 1 month ago
In the beginning, we were thinking of the word CONSTANT
as almost a synonym for PARAMETER
but
local to the mod file
same for all instances
More in the realm of what the users expect but not demanded by the language. I guess one could think of it as "constant in space". In the end, this is just an artifact of the limitation of K&R C.
If we change to static const double
, what would the user do if they wanted to change the value in the mod file (e.g. during a call to a function from the interpreter). At the moment I'm leaning toward keeping it as static double
but am easily persuadeable to go the other way, especially if there is no modeldb example that breaks. I have a faint feeling that
people (I?) used CONSTANT because it was at hand for use as static double
and never considered the possibilty of the language enforcing true const ness. To this moment one can
$ nrniv
NEURON -- VERSION 9.0a-295-g3a2336ec6 master (3a2336ec6) 2024-07-12
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2022
See http://neuron.yale.edu/neuron/credits
oc>PI
3.1415927
oc>PI=4
oc>PI
4
oc>
and
$ python
Python 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.pi
3.141592653589793
>>> math.pi=4
>>> math.pi
4
>>>
Thank you for explaining, I'll add the appropriate test to NMODL. I merely wanted to double check that it's working as intended and not a recent regression.
I've not had any new questions and it's behaving like intended. From my side the issue has served it's purpose. Thanks for clarifying.
The following MOD files demonstrates the question:
This haves as expected in that the value is
2.3
beforeh.stdinit()
and24
afterwards.The question: Is this is intentional or just an artifact of the global being implemented as:
instead of:
Note that the MOD file is considered thread-safe: