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

Deprecate Keyword.get/3 and Keyword.pop/3 #3132

Closed
josevalim opened this issue Mar 2, 2015 · 5 comments
Closed

Deprecate Keyword.get/3 and Keyword.pop/3 #3132

josevalim opened this issue Mar 2, 2015 · 5 comments

Comments

@josevalim
Copy link
Member

The reason is to avoid the semantic difference between Keyword.get(opts, :foo, :bar) and opts[:foo] || :bar. The latter is preferable because often we don't care about making a distinction between the absence of a value and that value being set to nil.

It is also debatable if we should deprecate similar functions from Enum.

@ericmj
Copy link
Member

ericmj commented Mar 2, 2015

How are you going to make a distinction between false and nil?

@josevalim
Copy link
Member Author

Possibly Keyword.bool/2 will help with that. That's one of the pending issues to be solved.

@whatyouhide
Copy link
Member

Why deprecate Keyword.pop/3 though? You mean turning it into Keyword.pop/2 and using it like

{val, kw} = Keyword.pop(kw, :my_val)
val || :default

?

@josevalim
Copy link
Member Author

@whatyouhide I am not sure on pop yet. It theoretically suffers from the same issue but it cannot be expressed as concisely as get. Let's wait for more feedback before we start working on any of those changes. :)

@josevalim
Copy link
Member Author

We should also look into adding a lazy_put (only puts a value is not there lazily). We need a small overhaul in the Dict API overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants