jonthegeek / factory

factory: Build Function Factories
Other
49 stars 6 forks source link

Functions as variables #28

Open TylerGrantSmith opened 4 years ago

TylerGrantSmith commented 4 years ago

May be related to #22

factory_fun <- factory::build_factory(fun = function() f(0), f)
factory_fun(sum)
#> function () 
#> .Primitive("sum")(0)
# expected:
#   function()
#     sum(0)

factory_fun <- factory::build_factory(fun = function() f(0), f)
factory_fun(identity)
#> function () 
#> (function (x) 
#> x)(0)
# expected:
#   function()
#     identity(0)

Created on 2020-06-03 by the reprex package (v0.3.0)

jonthegeek commented 4 years ago

Much like #22, this works more as expected with factory_fun(quote(identity)).

I suspect this can be fixed with either a quote or something like rlang::enexpr somewhere in the code, but I'm not 100% certain and will need more test cases.