Bug 16722 - Wishlist: API access to connections
Summary: Wishlist: API access to connections
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2016-02-22 10:59 UTC by Jon Clayden
Modified: 2016-02-22 10:59 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Jon Clayden 2016-02-22 10:59:28 UTC
Package-accessible header file <R_ext/Connections.h> defines the Rconn struct, and methods for reading and writing from connections represented by this struct type. However, it appears not to be possible to obtain such a struct from a suitable SEXP (relevant questions on R-devel and StackOverflow at [1,2]), and neither is there an explicit statement in "Writing R Extensions" that such access is intentionally unavailable.

The most obvious means to make this step appears to be via the non-API function getConnection(), viz.


since the connection is essentially an INTSXP with a "connection" class and external pointer attribute. Adding "getConnection" to the API is therefore one possible solution, if this is deemed desirable.

This would help packages avoid reinventing the wheel in terms of access to files, URLs, etc. (albeit with the proviso about future backwards-compatibility stated in the header).

[1] https://stat.ethz.ch/pipermail/r-devel/2016-February/072336.html
[2] http://stackoverflow.com/questions/35483523/r-reading-from-an-existing-connection-in-compiled-code