Skip to content

Conversation

DavisVaughan
Copy link
Member

In #202 we decided to deprecate signal_stage(), but as we thought more about it, it seems like this:

lifecycle::signal_stage("superseded", "fn()", "other()")

is quite useful for expressing intent at the call site, even if it doesn't do anything.

We've certainly used this in dplyr, purrr, recipes, and ggplot2, and the community has as well:
https://github.com/search?q=%22lifecycle%3A%3Asignal_stage%22+org%3Acran&type=code

So we've decided to keep it after all, with a few tweaks:

  • The conditionMessage() method emits "", for maximum performance, since it can't be lazy right now. See inline comment below.

  • We do not use signal_stage() in deprecate_*() anymore, for max performance. We also think that if we were to do anything with these functions in the future, it would probably be some kind of static analysis, and we could look for both signal_stage() and deprecate_*() call sites

  • Related to the above, "deprecated" is no longer a valid stage for signal_stage(). This was never documented to be valid, it was only used internally. No one seems to have used this.

  • There is no currently exported way to get at the "data" in the condition itself. It is now purely used to express intent at the call site. We can consider adding something in the future if needed, but it seems unlikely.

Remembering that signal_stage("experimental", ...) will be used in our experimental functions and we don't want a performance penalty there, I'm happy with this performance:

library(lifecycle)

bench::mark(
  signal_stage("experimental", "this()"),
  iterations = 100000
)
#> # A tibble: 1 × 6
#>   expression                                        min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                                   <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 "signal_stage(\"experimental\", \"this()\")"   3.85µs   4.26µs   220657.        0B     17.7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately git diff thinks this is a "new" file

Comment on lines 104 to 124
signal_experimental <- function(when, what, env = caller_env()) {
deprecate_soft(
"1.1.0",
what = "signal_experimental()",
with = "signal_stage()",
id = "lifecycle_signal_experimental"
)
signal_stage("experimental", what, with = NULL, env = env)
}

#' @rdname deprecated-signallers
#' @export
signal_superseded <- function(when, what, env = caller_env()) {
deprecate_soft(
"1.1.0",
what = "signal_superseded()",
with = "signal_stage()",
id = "lifecycle_signal_superseded"
)
signal_stage("superseded", what, with = NULL, env = env)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did leave these as officially soft-deprecated

@DavisVaughan DavisVaughan requested a review from lionel- October 7, 2025 15:41
@DavisVaughan
Copy link
Member Author

DavisVaughan commented Oct 7, 2025

Latest commit tries another approach - making signal_stage() do absolutely nothing.

This makes it clear that it is purely about expressing intent at the call site.

It is also obviously as fast as it gets.

library(lifecycle)

bench::mark(
  signal_stage("experimental", "this()"),
  iterations = 100000
)
#> # A tibble: 1 × 6
#>   expression                                        min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                                   <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 "signal_stage(\"experimental\", \"this()\")"     82ns    205ns  3736394.        0B        0

I did mark the arg env as deprecated() since no one would ever use that at the call site

@DavisVaughan DavisVaughan merged commit e3d7fa3 into main Oct 9, 2025
14 checks passed
@DavisVaughan DavisVaughan deleted the feature/bring-back-signal-stage branch October 9, 2025 19:37
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.

2 participants