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.
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().
Activity
gadenbuie commentedon Sep 21, 2021
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 namedgradethis_settingsand its structure enables auto-complete:I was thinking about a developer-facing interface at the time, hence
gradethis_settingsrather thangradethis_defaultto 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.
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_configorgradethis_optionsalso come to mind, but I went withgradethis_settingssince it's closer togradethis_setup().