Skip to content

Commit dc33f1a

Browse files
paragraph on control flow and closures
1 parent 20dd583 commit dc33f1a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ can use RStudio's full text search to find where
154154
* only very low-level functions or functions that don't fit in any other file
155155
go to `utils.R`.
156156

157+
### Control Flow
158+
159+
* Conditional statements should always evaluate to `TRUE` or `FALSE`, i.e. we
160+
don't encourage `if (length(x))` but rather `if (length(x) > 0L)`.
161+
* We avoid loops whenever possible and use functions like `purrr::map()` and
162+
friends when possible and prefer them over R base counterparts like
163+
`base::lapply()`.
164+
157165
### Boolean Values
158166

159167
Functions that return Boolean values or variables that hold Boolean values are
@@ -165,3 +173,8 @@ otherwise.
165173

166174
Vectors that hold indices are often suffixed with `idx`. `else_idx` for example
167175
indicates for every row in a parse table whether it contains an `else` token.
176+
177+
### Closures
178+
179+
The use of closures is discouraged. We prefer to prefill a template function
180+
with `purrr::partial()`.

0 commit comments

Comments
 (0)