nimble-dev / nimble

The base NIMBLE package for R
http://R-nimble.org
BSD 3-Clause "New" or "Revised" License
160 stars 24 forks source link

Skip some macro-related code processing if there are no macros #1506

Closed kenkellner closed 2 days ago

kenkellner commented 3 weeks ago

Considering #1503, maybe we ought to check if there even were any macros in the code before running some of the related post-processing like removeExtraBrackets and constants processing? I'm thinking specifically of everything in the function below this line:

https://github.com/nimble-dev/nimble/blob/f9df240a477a6f0a59dc6b5602f6af5e556d34c1/packages/nimble/R/BUGS_macros.R#L410

It seems like processMacrosInternal could return a TRUE/FALSE if it found any macros and only run the following code if TRUE.

That way if there are any future bugs in the post-processing code they would only affect models with macros and not models in general.

@perrydv @paciorek

paciorek commented 3 weeks ago

Yes, I like this idea for robustness in general and was about to suggest something along these lines this morning and then forgot.

kenkellner commented 3 weeks ago

I'll make a PR tomorrow.