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

Kwargs instead of positional args #49

Open
swrobel opened this issue Apr 16, 2020 · 3 comments
Open

Kwargs instead of positional args #49

swrobel opened this issue Apr 16, 2020 · 3 comments

Comments

@swrobel
Copy link
Contributor

swrobel commented Apr 16, 2020

I'm curious why the decision was made to take positional, rather than keyword args in a modern library like this.

internet.post("https://httpbin.org/anything", body: body)

seems preferable to

internet.post("https://httpbin.org/anything", nil, body)
@ioquatix
Copy link
Member

Positional args were at the time slightly more efficient and predictable than kwargs, but I'd be open to changing this if you think there is a significant improvement to interface ergonomics.

@ioquatix
Copy link
Member

I've changed Async::HTTP::Client and Async::HTTP::Server to use keyword arguments.

I'm not sure we can easily change these methods without breaking a ton of stuff.

@ioquatix
Copy link
Member

If we think the ergonimics outweighs the overhead, something like this can work:

def get(_headers = nil, _body = nil, headers: _headers, body: _body)
  # ...
end

and be backwards compatible. As long as the performance cost is insignificant, I'd be willing to accept this for the def get / post / patch convenience methods for Async::HTTP::Internet (but probably not call).

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

No branches or pull requests

2 participants