mlr-org / mlr3misc

Miscellaneous helper functions for mlr3
https://mlr3misc.mlr-org.com
GNU Lesser General Public License v3.0
11 stars 2 forks source link

`crate()` function seems to change behaviour of the byte code compiler #94

Closed sebffischer closed 7 months ago

sebffischer commented 10 months ago
library(mlr3misc)

f = function() NULL
fc = crate(f)

f()
#> NULL
f()
#> NULL

fc()
#> NULL
fc()
#> NULL

f
#> function() NULL
#> <bytecode: 0x55fcfee0baa0>
fc
#> function() NULL
#> <environment: 0x55fcfec76550>

Created on 2023-10-30 with reprex v2.0.2

sebffischer commented 10 months ago
rm(list = ls())
f = function(x) NULL
environment(f) = new.env()

lapply(1:10, f)
#> [[1]]
#> NULL
#> 
#> [[2]]
#> NULL
#> 
#> [[3]]
#> NULL
#> 
#> [[4]]
#> NULL
#> 
#> [[5]]
#> NULL
#> 
#> [[6]]
#> NULL
#> 
#> [[7]]
#> NULL
#> 
#> [[8]]
#> NULL
#> 
#> [[9]]
#> NULL
#> 
#> [[10]]
#> NULL
f
#> function(x) NULL
#> <environment: 0x55e09b2feb38>

Created on 2023-10-30 with reprex v2.0.2