[#83773] [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769 — usa@...
Issue #14108 has been updated by usa (Usaku NAKAMURA).
9 messages
2017/11/15
[#83774] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
[email protected] wrote:
[#83775] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— "U.NAKAMURA" <usa@...>
2017/11/15
Hi, Eric
[#83779] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
"U.NAKAMURA" <[email protected]> wrote:
[#83781] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— "U.NAKAMURA" <usa@...>
2017/11/15
Hi, Eric,
[#83782] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
IlUuTkFLQU1VUkEiIDx1c2FAZ2FyYmFnZWNvbGxlY3QuanA+IHdyb3RlOgo+IEhpLCBFcmljLAo+
[ruby-core:83676] [Ruby trunk Feature#14079] Validate argument list without calling method
From:
nathanielsullivan00@...
Date:
2017-11-04 19:06:23 UTC
List:
ruby-core #83676
Issue #14079 has been updated by nate00 (Nate Sullivan).
Oops, I think my description was somewhat misleading. I don't expect `respond_to_arguments?` to check for lines in the method body that might raise an `ArgumentError`. I expect it to check only whether the provided list of arguments matches the method signature.
Maybe this example will clarify:
~~~ruby
class Foobar
def self.hello(str)
raise ArgumentError unless str.is_a?(String)
end
end
Foobar.respond_to_arguments?(:hello, "goodbye") # => true
Foobar.respond_to_arguments?(:hello, 123) # => true, because 123 matches the method signature, even though the method will raise an ArgumentError when you call it.
Foobar.respond_to_arguments?(:hello, "goodbye", "goodbye") # => false, because the method has only one parameter
~~~
So it's right to think of `respond_to_arguments?` as a method very similar to `arity` and `parameters`. Thanks for pointing out `parameters`, Eregon, I'll try that out.
----------------------------------------
Feature #14079: Validate argument list without calling method
https://bugs.ruby-lang.org/issues/14079#change-67700
* Author: nate00 (Nate Sullivan)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I would find it useful to check whether a list of arguments will cause an `ArgumentError` when passed to a method, but without calling that method.
Maybe this method would be called `respond_to_arguments?`. Here's an example, where I check whether I can pass various argument lists to `String#prepend`:
~~~ruby
str = "hello"
# String#prepend accepts 1 argument, not 0 or 2:
str.respond_to_arguments?(:prepend, "foo", "bar") # => false
str.respond_to_arguments?(:prepend, "foo") # => true
str.respond_to_arguments?(:prepend) # => false
# Indeed, we get an ArgumentError if we pass 0 or 2 arguments:
str.prepend("foo", "bar") # raises ArgumentError
str.prepend("foo") # success!
str.prepend # raises ArgumentError
~~~
My use case is a background job processing system. It works like this: I call `MyWorker.perform_async` with some arguments; the arguments are serialized and put into a queue; and then a background worker takes those arguments from the queue, deserializes them and passes them to `MyWorker.perform`. If I passed invalid arguments, I don't know they were invalid until the background worker tries to call `perform`. But I'd like to know immediately when I call `perform_async`.
Perhaps a `respond_to_arguments_missing?` method would be required also.
Maybe `respond_to_arguments?` is a bad name. You could reasonably assume that it takes the same optional second parameter as `respond_to?` (i.e., `include_all`), but my proposal doesn't support an optional second parameter.
Thank you for your consideration!
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>