design icon indicating copy to clipboard operation
design copied to clipboard

Type checks/fail fast

Open hadley opened this issue 6 years ago • 0 comments

Generally, the first few lines of a function should assert the type specification of the arguments, using some combination of vctrs, S3 is functions, NSE/enquoting functions, and base/rlang scalar type predicates (is_string(), is_symbol(), is_expression() etc). This ensures that the user gets an error message quickly if the function has been fundamentally misspecified.

Don't rely on type errors coming from subsequent function calls because the errors will be less informative.

hadley avatar Jul 15 '19 13:07 hadley