Releases: egnha/gestalt
v0.2.0
Breaking changes
-
Formal arguments of
partial(..f, ...)
no longer record the original
default values of..f
(since a default-value expression may reference an
argument that is fixed, and therefore dropped, bypartial()
).
Nevertheless, any default values of..f
not overridden bypartial()
remain in force when the functionpartial(..f, ...)
is called. -
partial(..f, ...)
can still fix arguments that match the...
argument of
..f
(if present), but only when such arguments are specified by name.
Bug fix
- Default argument values of a composite function are now evaluated in the
evaluation environment of the initial function. Essentially, a call like
compose(f, g)(x, y, ...)
is now equivalent to a call like
(function(...) g(f(...)))(x, y, ...)
. (Previously, the initial
function was called with a complete set of formal arguments, which in cases
where formal arguments are mutated or mutually referenced (e.g., in the
formals ofbase::objects()
), could lead the initial function to wrongly
determine the "missingness" of an argument or wrongly evaluate an argument's
default value.) As before, the signature ofcompose(f, ...)
inherits the
signature off
.
v0.1.9
v0.1.8
This is a minor bug fix release.
- The environment of a partial function expression in a
%>>>%
chain
(e.g., the base-3 logarithm inabs %>>>% log(base = 3)
) is now properly
captured. Previously, it was erroneously matched to an rlang data mask, due
to an internal call torlang::eval_tidy()
using positional arguments.
v0.1.7
This is a minor update to rectify failing checks in a strict Latin-1 locale on Debian-clang (affecting the package documentation, but not the package code), and the following issue:
- In a
%>>>%
chain, a point (.
) is now only matched as an argument value when it is a symbol, not a character ("."
) (#27).
v0.1.6
This is a maintenance release to fix CRAN test failures caused by changes in the rlang package.
-
The (minimum) required rlang version has been increased to 0.3.1. This version fixed a bug which prevented certain operator "sections" from being expressed. A chain like
`/`(2) %>>>% sin
(halve and apply sine) now works as expected. -
Formals of primitive functions now agree with those of
base::args()
(#18, #24). This means you can useargs()
to determine the names of arguments when usingpartial()
. Thus,partial(`/`, e2 = 3)
is the same aspartial(`/`, , 3)
is the same as division-by-3. Moreover,%>>>%
chains are verified against the argument names given byargs()
. Thus,`/`(e2 = 2) %>>>% sin
is valid, but`/`(y = 2) %>>>% sin
is invalid—`/`()
viewed as a closure has no argument calledy
. -
Support for R 3.1 has been dropped.
v0.1.5
v0.1.4
New features
-
posure()
is a means of creating efficient variable (i.e., parameterized)
composite functions.In particular, this addresses a shortcoming of the use of the magrittr
%>%
in functions. Instead of writingfunction(..., b = 2, n) { sample(...) %>% log(base = b) %>% rep(n) }
which is inefficient because the function chain is created anew with each
call, you can more directly curry
it by writingposure(b = 2, n ~ { sample %>>>% log(base = b) %>>>% rep(n) })
Not only is the
posure()
version more succinct, it is robuster and faster
than the version with%>%
, thanks to the non-standard mechanism of a
closure that is “partially dynamically scoped.” (Whence the portmanteau
“posure,” due to @henryaj; see the package documentation for details.) -
let()
enables you to create contexts: composable local environments
in which named expressions are lazily resolved in a given order. Tidyverse
quasiquotation of expressions is supported, allowing you to exercise
fine-grained control over the evaluation of subexpressions. -
As a companion to
let()
,run()
evaluates an expression relative to a
context. Unlikebase::with()
,run()
supports quasiquotation and provides
a means of overriding bindings in a given context.
Minor improvements
-
When calling a composite function, the point (
.
) in an implicitly curried
function may now assume any name (#10). This is useful when you want to call
the argument assumed by the point by its original name, e.g., in a
do.call()
orlapply()
invocation. -
partial()
is now literally interpreted by%>>>%
(#11). For instance, you
you can succinctly writeabs %>>>% partial(log, base = 2)
instead of
abs %>>>% !!partial(log, base = 2)
.