Skip to content

support switch (which becomes nSwitch)#200

Merged
perrydv merged 1 commit into
mainfrom
nSwitch
Jun 5, 2026
Merged

support switch (which becomes nSwitch)#200
perrydv merged 1 commit into
mainfrom
nSwitch

Conversation

@perrydv

@perrydv perrydv commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

This is fairly straightforward. It supports switch in the DSL compatible with nimble's switch. This will be used in implementing model$getParam.

The use is switch(expr, IDs, ...) where expr is the value to switch on, IDs (compile-time) is a vector of integer IDs for the cases, and ... gives code for each case in order, in {} if there is more than one line.

This is oriented towards C++ and is different from R's switch. There is no return value.

nSwitch for R execution is also provided, with a bit more care and error handling that in nimble.

There is an issue with clunkiness when one wants default IDs (simply a sequence for the number of options in ...), one must enter IDs = NULL. Leaving it blank doesn't work. That may be addressed later as a minor but annoying issue in the matchDef system.

This has passed tests so I am going through a PR to leave a record but plan to merge.

@perrydv perrydv merged commit c905af8 into main Jun 5, 2026
5 checks passed
@perrydv perrydv deleted the nSwitch branch June 5, 2026 23:09
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

Successfully merging this pull request may close these issues.

1 participant