1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/arg.R
\name{deprecated}
\alias{deprecated}
\alias{is_present}
\title{Mark an argument as deprecated}
\usage{
deprecated()
is_present(arg)
}
\arguments{
\item{arg}{A \code{deprecated()} function argument.}
}
\description{
Signal deprecated argument by using self-documenting sentinel
\code{deprecated()} as default argument. Test whether the caller has
supplied the argument with \code{is_present()}.
}
\section{Magical defaults}{
We recommend importing \code{lifecycle::deprecated()} in your namespace
and use it without the namespace qualifier.
In general, we advise against such magical defaults, i.e. defaults
that cannot be evaluated by the user. In the case of
\code{deprecated()}, the trade-off is worth it because the meaning of
this default is obvious and there is no reason for the user to call
\code{deprecated()} themselves.
}
\examples{
foobar_adder <- function(foo, bar, baz = deprecated()) {
# Check if user has supplied `baz` instead of `bar`
if (lifecycle::is_present(baz)) {
# Signal the deprecation to the user
deprecate_warn("1.0.0", "foo::bar_adder(baz = )", "foo::bar_adder(bar = )")
# Deal with the deprecated argument for compatibility
bar <- baz
}
foo + bar
}
foobar_adder(1, 2)
foobar_adder(1, baz = 2)
}
|