-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardise getters, setters and updaters #5568
Comments
* add `guide_data()` function * add tests * document * rename getter (see #5568) * swap from location-based to panel-based
+1 for this. The consistency proposed here would really help. Don't suppose this could be in 3.5.1? |
I also find the prefix Perhaps So: Instead of: Maybe it's slightly less precise than update, but I feel it's close enough and much more readable |
The code currently uses 'add' as unofficial indicator that it would work by using |
Oh okay, so have |
The expectation for a |
Assume this isn't planned to be implemented for 3.5.1 @teunbrand ? |
I wouldn't count on it. It would probably be fine to include in 3.5.1 as it is backward compatible, but priorities for PR review are fixing regressions, safe bugfixes and doc updates. You can take a look at the milestones to see what is planned (and infer what isn't). |
There are various functions that get or set things, but the names aren't standardised.
Some example getter functions are:
layer_data() layer_grob() layer_scales() # these aren't really related to layers? theme_get() last_plot() get_alt_text()
Some example setter functions are:
Some example of updater functions are:
update_geom_defaults() update_stat_defaults() theme_update() add_ggplot()/ggplot_add()
The non-standardisation of these functions confuse the API somewhat. For example
theme_bw()
is a theme in its own right buttheme_get()
is an interface to the global theme. Likewise,layer_sf()
is a specialty layer, whereaslayer_data()
is not a layer.I'd like to propose that these type of functions always use a
get_
,set_
orupdate_
prefixes so that it is easy to see what getters, setters and updaters are available through tab-completion.For example we'd have:
The text was updated successfully, but these errors were encountered: