h2o-3 icon indicating copy to clipboard operation
h2o-3 copied to clipboard

Improve handling of ... (aka 'dots') parameter in R functions

Open sebhrusen opened this issue 1 year ago • 2 comments

In many places in our R API, the dots parameter is immediately converted to a R list (using list(...)) which causes the evaluation of all the parameters passed in this dots param and is not a good practice given that R evaluates parameters lazily.

Wherever this is not necessary—it is especially used as a way to deprecate old parameters so they don't appear in signature—, we should try to avoid this kind of conversion and try to maintain the lazy evaluation by using the built-in ...length(), ...names() and ...elt(idx) functions.

See h2o.partialPlot in models.R for a proper lazy handling of the dots param.

sebhrusen avatar Nov 06 '23 11:11 sebhrusen

see discussion https://github.com/h2oai/h2o-3/pull/15895#discussion_r1383176940

Let's try to encapsulate all the deprecation logic into a reusable object/function

sebhrusen avatar Nov 06 '23 11:11 sebhrusen

Note that ...names() has been introduced in R v4.1.0 (see https://cran.r-project.org/bin/windows/base/old/4.1.0/NEWS.R-4.1.0.html) so we may not be able to implement this for now.

sebhrusen avatar Nov 06 '23 15:11 sebhrusen