Skip to content
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

stri_opts_collator(...) #347

Open
hadley opened this issue Mar 13, 2019 · 6 comments

Comments

Projects
None yet
2 participants
@hadley
Copy link

commented Mar 13, 2019

The documentation for stri_opts_collator says that "any other arguments to this function are purposely ignored". This seems like a deliberate design decision, so I was wondering if you could explain why?

The obvious downside is that misspellings are silently ignored:

stringi::stri_opts_collator(normalisation = TRUE)
#> list()
@gagolews

This comment has been minimized.

Copy link
Owner

commented Mar 13, 2019

The arguments to this function are passed - most frequently - via ... from other routines, whose themselves might be extracting some meaningful actual parameters from ellipsis. In this workflow, stri_opts_collator is just a piece of the puzzle and takes care only of those arguments that it can understand, letting other functions be customized too.

However, that normalisation could be adopted as an alias of normalization seems like a good idea.

@hadley

This comment has been minimized.

Copy link
Author

commented Mar 13, 2019

Ah ok, that makes sense. Do you have a concrete example I could look at? I'm working on documenting common ... patterns and this would be a nice case study.

It might also be worth considering ellipsis::check_dots_used() to make sure that every argument to ... is used somewhere.

@gagolews

This comment has been minimized.

Copy link
Owner

commented Mar 13, 2019

If something glamorous come to my mind, I'll give an example.

But isn't this what most graphical (I mean, good-old graphics package-based) functions do? print.default takes a ... argument, calls box, axis, and stuff, and these underlying funs take what they need (and understand) from the arg list

@hadley

This comment has been minimized.

Copy link
Author

commented Mar 13, 2019

I meant a specific example to look at in stringi; doesn't need to be glamorous!

Yes, it's a common pattern in base R, but I think it might be an anti-pattern:

mean(1, 2, 3)
#> [1] 1
weighted.mean(1:3, wt = c(1, 0, 0))
#> [1] 2

Created on 2019-03-13 by the reprex package (v0.2.1.9000)

@gagolews

This comment has been minimized.

Copy link
Owner

commented Mar 13, 2019

Yeah, and:

> sum(1, 2, 3)
[1] 6
> mean(1, 2, 3)
[1] 1
@gagolews

This comment has been minimized.

Copy link
Owner

commented Mar 13, 2019

Hmm... maybe stri_opts_collator (and similar funs) doesn't need to ignore the un-known args after all... I need to take a deeper look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.