-
Notifications
You must be signed in to change notification settings - Fork 42
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
what should the default value for $sep be for @array->join #244
Comments
Personally I would lean to making join() with no separator fatal. Really if someone does not fill it in they are either making an assumption about a default (Which as you have all said, what would someone expect?) or they forgot it. If we add a default and they just forgot it then it can be a subtle hard to track bug. If it is fatal, specially with croak or even confess it removes the chance for a bug, and points to where you made your mistake. |
We could also add a second function. @Array->join(default to ', '), @Array->concat(default to ' '). or if concat already exists and has '' (what I would expect) then @Array->sentance( default to ' ' ) and when given a seperator they all act identically Note, I can't think of good method names for this, and think it is probably over-kill I still think fatal on no seperator is best. |
We're straining REALLY HARD to make join have a default. Keep in mind things don't have to have defaults.
I think the most damning part is that there's no sensible rule which predicts what the default will be. Its essentially the result of whatever conversation we have right now. If we pick In sum, defaults should either be A) immediately obvious or B) easy to remember once you've looked them up or C) throw an error to let you know you have to supply a value. This is neither A nor B, so it must be C. In the best case, we're saving the user from writing |
I think the obvious default for join is |
+1 for using $" that makes much more sense as it already is the expected value and will continue to remain the expected value when overridden. |
My thoughts on Pro: It's the default behavior of "@foo". Con: It ties the local behavior of a method to a global variable. That con is a major interface no-no. If somebody somewhere in the code changes And, back to the root, do we need a default here? |
My 2 cents: if we must have a default use
|
This is an extension of #241
Currently join defaults to undef, causing warnings. Is it really what
mostusers would expect. I can think of more cases where I've joined on a space then I joined on nothing, thus I think that to be a tad more useful in the future [read v3] that we could default to something like q{ }, though this will alter the current behavior. Thus the open ended question of what does the group think.The text was updated successfully, but these errors were encountered: