You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we lookup gradethis options via getOption("gradethis.fail", "Fall back default"), which has a few disadvantages:
the correct fallback needs to be used in every case
it clutters the API since the preferred method for setting the defaults is via gradethis_setup()
it isn't easy to differentiate between actively supplied arguments and default values determined from global settings without resorting to sentinel values that further obscure the mechanics
We should add a helper for looking up global default values: gradethis_default()
where the documentation can better direct users to gradethis_setup() where those values are set since both functions would be documented in the same help page.
Internally, gradethis_default() could add an attr() that we could use to determine whether or not the argument value was supplied by the user or looked up from global options.
The text was updated successfully, but these errors were encountered:
I implemented a version of this that — rather than taking the option as a character argument as in gradethis_default("<option>") — is instead a list of functions that access the current default value. The list is named gradethis_settings and its structure enables auto-complete:
I was thinking about a developer-facing interface at the time, hence gradethis_settings rather than gradethis_default to avoid clashes with our internal list of default values.
With a little extra work, we could allow the functions to also operate as setters when provided with a value.
# Set fail.hint default valuegradethis_settings$fail.hint(TRUE)
If we export this object, then the function signature for fail() (and others) would look like this:
I'm not completely sold on the name, gradethis_config or gradethis_options also come to mind, but I went with gradethis_settings since it's closer to gradethis_setup().
Currently, we lookup gradethis options via
getOption("gradethis.fail", "Fall back default")
, which has a few disadvantages:gradethis_setup()
We should add a helper for looking up global default values:
gradethis_default()
where the documentation can better direct users to
gradethis_setup()
where those values are set since both functions would be documented in the same help page.Internally,
gradethis_default()
could add anattr()
that we could use to determine whether or not the argument value was supplied by the user or looked up from global options.The text was updated successfully, but these errors were encountered: