Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review NMODLs name collision handling. #1506

Open
1uc opened this issue Oct 9, 2024 · 0 comments
Open

Review NMODLs name collision handling. #1506

1uc opened this issue Oct 9, 2024 · 0 comments

Comments

@1uc
Copy link
Collaborator

1uc commented Oct 9, 2024

The situation in NOCMODL is relatively simple. User-defined identifiers start with [a-zA-Z]. Which leaves all variables that start with _[a-z] free (_[A-Z] are taken by the compiler/standard library).

This is then used to implement simple mnemonic schemes, for example LOCAL is f"_l{var_name}", all function arguments are prefixed with _, e.g. _iml, _ml, _nt, etc. (if none of them starts with _l they can't clash with LOCALs).

For NMODL I don't fully understand how it avoids naming collisions systematically. For example: LOCAL variables are just double {var_name} and same for internal variables, e.g. id (for _iml), nt (for _nt), etc.

Therefore,

INITIAL { LOCAL id
    x = 42.0
}

results in:

            for (int id = 0; id < nodecount; id++) {
                // ...
                double id;
                inst->x[id] = 42.0;
            }

Similar collisions can be created for a number of other internal variables, I tested nt, ml and inst.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant