Skip to content

Nullable object #363

@eddelbuettel

Description

@eddelbuettel

In quite some user-space code the R side has something like

weightedLeastSquares(X, y, w)      # ie y ~ X given weights w

where the third argument is options, ie

weightedLeastSquares(X, y, NULL)

In that case we generally cannot have the third strongly typed as NumericMatrix or alike and have to keep it a SEXP in the interface. Nothing wrong with that but a bit of an eyesore.

Following some discussion with @dcdillon I have written a really simple wrapper class Nullable that contains a SEXP as well as a bool for state. With that we can do (stylized)

...., NumericVector & w) {
//...
if (!w.isNull()) {
    // do stuff with w
}

If there is no protest -- or someone reminds of something much better we already have ;-) -- then I'll fold that in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions