Skip to content

Commit

Permalink
Removing the export of masks for . and j (#6198)
Browse files Browse the repository at this point in the history
* removing problematic masks

* small changes

* Update NAMESPACE

Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>

* Update R/data.table.R

Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>

* Update NEWS.md

Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>

* updated test

* updated test

* updated test

---------

Co-authored-by: nitish jha <nitishjha@nitishs-MacBook-Air.local>
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
  • Loading branch information
3 people authored Jun 23, 2024
1 parent 2e0928a commit 4e6ad97
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export(tstrsplit)
export(frank)
export(frankv)
export(address)
export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, ., J, measure, patterns)
export(.SD,.N,.I,.GRP,.NGRP,.BY,.EACHI, measure, patterns)
# TODO(#6197): Export these.
# export(., J)
export(rleid)
export(rleidv)
export(rowid)
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@

16. `print.data.table` gains new argument `show.indices` and option `datatable.show.indices` that allows the user to print a `data.table`'s indices as columns without having to modify the `data.table` itself. Thanks @MichaelChirico for the report and @joshhwuu for the PR.
17. `.`, `J`, `measure`, and `patterns` are now exported for use within `[` and `melt()`, for consistency with other NSE exports like `.N` and `:=`, [#5604](https://github.com/Rdatatable/data.table/issues/5604). Package developers can now import these names to avoid `R CMD check` `NOTE`s about them being undefined variables. Thanks to @MichaelChirico and @ylelkes for the suggestions and @Nj221102 for implementing.
17. The `measure` and `patterns` functions are now exported for use within `[` and `melt()` to ensure consistency with other non-standard evaluation (NSE) exports like `.N` and `:=`. This change addresses [#5604](https://github.com/Rdatatable/data.table/issues/5604), allowing package developers to import these names and avoid `R CMD check` `NOTE`s about undefined variables. Thanks to @MichaelChirico and @ylelkes for their suggestions, and to @Nj221102 for the implementation.
We plan to export similar placeholders for `.` and `J` in roughly one year (e.g. data.table 1.18.0), but excluded them from this release to avoid back-compatibility issues. Specifically, some packages doing `import(plyr)` _and_ `import(data.table)`, and/or with those packages in `Depends`, will error when data.table starts exporting `.` (and similarly for a potential conflict with `rJava::J()`). We discourage using data.table (or any package, really) in Depends; blanket `import()` of package is also generally best avoided. See `vignette("datatable-importing")`.
## TRANSLATIONS
Expand Down
1 change: 1 addition & 0 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,7 @@ address = function(x) .Call(Caddress, eval(substitute(x), parent.frame()))
stopf('Check that is.data.table(DT) == TRUE. Otherwise, :=, `:=`(...) and let(...) are defined for use in j, once only and in particular ways. See help(":=").')
}

# TODO(#6197): Export these.
J = function(...) {
stopf("J() called outside of [.data.table. J() is only intended for use in i.")
}
Expand Down
4 changes: 3 additions & 1 deletion inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,9 @@ if (ncol(DT)==2L) setnames(DT,c("A","B")) # else don't stop under torture with s
test(714, DT[,z:=6:10], data.table(A=1:5,B=5,z=6:10))

# Test J alias is now removed outside DT[...] from v1.8.7 (to resolve rJava::J conflict)
test(715, J(a=1:3,b=4), error="J() called outside of [.data.table. J() is only intended for use in i.")
test(715, J(a=1:3,b=4), error=base_messages$missing_function("J"))
# future:
# test(715, J(a=1:3,b=4), error="J() called outside of [.data.table. J() is only intended for use in i.")

# Test get in j
DT = data.table(a=1:3,b=4:6)
Expand Down

0 comments on commit 4e6ad97

Please sign in to comment.