local({ previous_options <- options(warn = 2, digits = 8, stringsAsFactors = FALSE) on.exit(options(previous_options), add = TRUE) pending <- 3L handled <- 0L while (pending > 0L && handled < 10L) { pending <- pending - 1L handled <- handled + 1L } cat("handled:", handled, "pending:", pending, "\n") invisible(NULL) })