Skip to content

Commit 1ff0d41

Browse files
committed
add on-the-fly note
1 parent 9dddb37 commit 1ff0d41

File tree

6 files changed

+38
-18
lines changed

6 files changed

+38
-18
lines changed

README.Rmd

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,37 @@ knitr::opts_chunk$set(
2626
cpp4r helps you to interact with R objects using C++ code.
2727
It is a fork of the [cpp11](https://cran.r-project.org/package=cpp11) package with identical syntax and similar goals.
2828

29-
cpp4r can be used as a replacement for cpp11 in existing or new packages. Think of cpp11 and cpp4r as MySQL and MariaDB: they are almost identical, but cpp4r has some extra features.
29+
⚠️Important⚠️: cpp4r was created to ease writing functions in your own packages and does not offer on-the-fly
30+
compilation for code snippets.
3031

31-
After discussing some [pull requests](https://github.com/pachadotdev/cpp11/pulls/pachadotdev) with Hadley Wickham from Posit, it was mentioned that I should create my own fork to add the following features:
32+
cpp4r can be used as a replacement for cpp11 in existing or new packages. Think of cpp11 and cpp4r as MySQL and MariaDB:
33+
they are almost identical, but cpp4r has some extra features.
34+
35+
After discussing some [pull requests](https://github.com/pachadotdev/cpp11/pulls/pachadotdev) with Hadley Wickham from
36+
Posit, it was mentioned that I should create my own fork to add the following features:
3237

3338
- [x] Convert ordered and unordered C++ maps to R lists.
3439
- [x] Roxygen support on C++ side.
3540
- [x] Allow `dimnames` attribute with matrices on C++ side.
3641
- [x] Support nullable `external_ptr<>`.
3742
- [x] Use values added to a vector with `push_back()` immediately.
3843
- [x] Support bidirectional passing of complex numbers/vectors.
39-
- [x] Provide flexibility with data types (e.g., cpp4r's `as_integers()` and `as_doubles()` accept logical inputs while cpp11's do not).
40-
- [x] Some internal optimizations for better speed (e.g., https://github.com/r-lib/cpp11/pull/463 and https://github.com/r-lib/cpp11/pull/430).
44+
- [x] Provide flexibility with data types (e.g., cpp4r's `as_integers()` and `as_doubles()` accept logical inputs while
45+
cpp11's do not).
46+
- [x] Some internal optimizations for better speed (e.g., https://github.com/r-lib/cpp11/pull/463 and
47+
https://github.com/r-lib/cpp11/pull/430).
4148

4249
## Getting started
4350

44-
Check the [documentation](https://cpp4r.org/) to get started using cpp4r in your scripts, particularly if you are new to C++ programming.
51+
Check the [documentation](https://cpp4r.org/) to get started using cpp4r in your scripts, particularly if you are new to
52+
C++ programming.
4553

4654
## Using cpp4r in a package
4755

4856
Create a new package with `cpp4r::pkg_template("~/path/to/mypkg")` and then edit the generated files.
4957

50-
To add cpp4r to an existing package, put your C++ files in the `src/` directory and add the following to your DESCRIPTION file:
58+
To add cpp4r to an existing package, put your C++ files in the `src/` directory and add the following to your
59+
DESCRIPTION file:
5160

5261
```
5362
LinkingTo: cpp4r
@@ -63,25 +72,32 @@ Then add a roxygen header, for example, to `R/mypkg-package.R`:
6372

6473
Then decorate C++ functions you want to expose to R with `[[cpp4r::register]]`.
6574

66-
cpp4r is a header only library with no hard dependencies and does not use a shared library. It is straightforward and reliable to use in packages without fear of compile-time and run-time mismatches.
75+
cpp4r is a header only library with no hard dependencies and does not use a shared library. It is straightforward and
76+
reliable to use in packages without fear of compile-time and run-time mismatches.
6777

6878
## Vendoring
6979

70-
You can [vendor](https://cpp4r.org/articles/01-motivations.html) the current installed version of cpp4r headers into your package with `cpp4r::vendor()`.
80+
You can [vendor](https://cpp4r.org/articles/01-motivations.html) the current installed version of cpp4r headers into
81+
your package with `cpp4r::vendor()`.
7182

72-
The [cpp4rvendor](https://github.com/pachadotdev/cpp4r/tree/main/cpp4rtest) package shows an example of vendoring cpp4r headers.
83+
The [cpp4rvendor](https://github.com/pachadotdev/cpp4r/tree/main/cpp4rtest) package shows an example of vendoring cpp4r
84+
headers.
7385

74-
Vendoring ensures the headers will remain unchanged until you explicitly update them. The advantage is that your package will not break if there are breaking changes in future versions of cpp4r. The disadvantage is
75-
that you will not get bug fixes and new features unless you update the vendored headers.
86+
Vendoring ensures the headers will remain unchanged until you explicitly update them. The advantage is that your package
87+
will not break if there are breaking changes in future versions of cpp4r. The disadvantage is that you will not get bug
88+
fixes and new features unless you update the vendored headers.
7689

7790
## Getting help
7891

7992
Please open an issue or email me. I will do my best to respond before 48 hours.
8093

8194
## Contributing
8295

83-
Contributions are welcome! Please see the [internals vignette](https://cpp4r.org/articles/15-internals.html) for details about design choices and coding style.
96+
Contributions are welcome! Please see the [internals vignette](https://cpp4r.org/articles/15-internals.html) for details
97+
about design choices and coding style.
8498

8599
## Code of Conduct
86100

87-
Please note that the cpp4r project is released with a [Contributor Code of Conduct](https://cpp4r.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
101+
Please note that the cpp4r project is released with a
102+
[Contributor Code of Conduct](https://cpp4r.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to
103+
abide by its terms.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ cpp4r helps you to interact with R objects using C++ code. It is a fork
1919
of the [cpp11](https://cran.r-project.org/package=cpp11) package with
2020
identical syntax and similar goals.
2121

22+
⚠️Important⚠️: cpp4r was created to ease writing functions in your own
23+
packages and does not offer on-the-fly compilation for code snippets.
24+
2225
cpp4r can be used as a replacement for cpp11 in existing or new
2326
packages. Think of cpp11 and cpp4r as MySQL and MariaDB: they are almost
2427
identical, but cpp4r has some extra features.
@@ -30,7 +33,7 @@ fork to add the following features:
3033

3134
- [x] Convert ordered and unordered C++ maps to R lists.
3235
- [x] Roxygen support on C++ side.
33-
- [x] Allow `dimnames` atribute with matrices on C++ side.
36+
- [x] Allow `dimnames` attribute with matrices on C++ side.
3437
- [x] Support nullable `external_ptr<>`.
3538
- [x] Use values added to a vector with `push_back()` immediately.
3639
- [x] Support bidirectional passing of complex numbers/vectors.

docs/index.html

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ articles:
1919
15-internals: 15-internals.html
2020
16-FAQ: 16-FAQ.html
2121
17-worked-examples: 17-worked-examples.html
22-
last_built: 2025-10-10T23:34Z
22+
last_built: 2025-10-11T15:45Z
2323
urls:
2424
reference: ./reference
2525
article: ./articles

docs/reference/pkg_template.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)