Gabriel Becker
2021-Mar-16 21:04 UTC
[Rd] Undefined (so far as I can tell?) behavior of browser when called at top level of sourced script?
Hi all, I was asked a question about why browser() was behaving a specific way, and it turned out that it was being called in a script (rather than in a function). Putting aside the design considerations that lead to that, the behavior is actually a bit puzzling, and so far as I have been able to see, completely undocumented. My suspicion is that this behavior should be considered undefined, but I wanted to make sure I wasn't missing something. (To be perfectly honest I was a bit surprised it wasn't an error). Some experimentation (done in 4.0.1 because that is what I have available, R script attached) has lead me to conclude that if browser is called at the top level, 'n' will just continue to the end, *except* in the case where the next expression is a conditional ** which has a consequent that is evaluated** or a loop, in which case it walks through the consequent/loop body however many number of times and then the 'n' that steps out of that continues on. Should something be added to the documentation that either describes this behavior, declares explicitly that using browser at the top level leads to undefined behavior, or both? I can prepare a patch to that effect if desired. ~G