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

WhatHappens should use, as syntax for assignment, ":=" or "<-" #34

Open
rdiaz02 opened this issue Jan 10, 2025 · 0 comments
Open

WhatHappens should use, as syntax for assignment, ":=" or "<-" #34

rdiaz02 opened this issue Jan 10, 2025 · 0 comments

Comments

@rdiaz02
Copy link
Owner

rdiaz02 commented Jan 10, 2025

Problem

WhatHappens, in interventions, uses = (see all examples, and for the parsing see, e.g.,

if (!parser_rwh.compile(rightMostWhatHappens, expression)){
). This is unfortunate.

Why it is unfortunate

For example, something like n_R = 0.8 * n_R could mean "make the new pop. size of R 0.8 of what it was" but it could be an equality comparison (see, e.g., #31 (comment)). And we do allow to use ExprTk's full syntax in other places (fitness specifications, for example, where "=" and "==" are equalities, not assignments) so it is a very bad idea to now use = with such a different meaning.

Options

We should use := or maybe better <- as in R. ExprTk uses :=; using <- will make it more explicit that the assignment to the population on the left is not being done directly by ExprTk (though the expression on the right is processed by ExprTk). In some cases (single population) the assignement could be done by ExprTk, but not in others (when the expression involves the total population size and, thus, we sample from the multiv. hypergeom. to get the new population composition).

Steps

So change code, redo all examples and tests, create deprecation notice, etc.

N.B. And use the opportunity to fix some typos, like "imposible" 😅

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