Skip to content

Add keyword arguments to async #1040

Open
@reeganviljoen

Description

@reeganviljoen

Feature request

Add support for keyword arguments when using async

From the docs

class Echo
  include [Concurrent](https://ruby-concurrency.github.io/concurrent-ruby/1.2.3/Concurrent.html)::Async

  def echo(msg)
    print "#{msg}\n"
  end
end

horn = Echo.new
horn.echo('zero')      # synchronous, not thread-safe
                       # returns the actual return value of the method

horn.async.echo('one') # asynchronous, non-blocking, thread-safe
                       # returns an IVar in the :pending state

horn.await.echo('two') # synchronous, blocking, thread-safe

but if i modify it to use named arguments like so it doesn't work

class Echo
  include [Concurrent](https://ruby-concurrency.github.io/concurrent-ruby/1.2.3/Concurrent.html)::Async

  def echo(msg: )
    print "#{msg}\n"
  end
end

horn = Echo.new
horn.echo(msg: zero')      # synchronous, not thread-safe
                       # returns the actual return value of the method

horn.async.echo(msg: 'one') # asynchronous, non-blocking, thread-safe
                       # returns an IVar in the :pending state

horn.await.echo(msg: 'two') # synchronous, blocking, thread-safe

#when I try to get the value 
horn.await.echo(msg: 'two').value #nil
horn.await.echo(msg: 'two').reason #<ArgumentError: wrong number of arguments (given 1, expected 0)>

I appreciate any future feedback from the maintainers on this 🙏

System information

* Operating system:                mac
* Ruby implementation:             Ruby
* `concurrent-ruby` version:       1,2,3
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used:     no

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions