Re: [Ironruby-core] Code Review: Better error messages

2009-01-25 Thread Jim Deville
I feel that it is redundant. JD -Original Message- From: Shri Borde Sent: Saturday, January 24, 2009 11:21 PM To: Tomas Matousek; Jim Deville; IronRuby External Code Reviewers Cc: ironruby-core@rubyforge.org Subject: RE: Code Review: Better error messages The test below actually shows th

Re: [Ironruby-core] Code Review: Better error messages

2009-01-24 Thread Shri Borde
The test below actually shows that the singleton to_f is not called. Similarly, a string like "1.0" gets converted to a Float even after undef-ing String#to_f. So the library methods are *not* calling to_f on strings at all, but are directly converting the string contents to a Float value. The

Re: [Ironruby-core] Code Review: Better error messages

2009-01-24 Thread Tomas Matousek
I believe Jim is right. Library methods performing conversions (or other operations) do so either by calling internal C methods or using regular Ruby method dispatch. The former can't be detected from Ruby except for using a tracing proc (set_trace_func). Method dispatch goes to the singleton of

Re: [Ironruby-core] Code Review: Better error messages

2009-01-24 Thread Jim Deville
Tomas, correct me if I'm wrong, but Ruby uses a message based method dispatch. When to_f is called, the message to_f gets sent to the object, and then normal method resolution occurs. There is no way to bypass that resolution. You can't call String#to_f instead of the singleton class's to_f. You

Re: [Ironruby-core] Code Review: Better error messages

2009-01-24 Thread Tomas Matousek
The question is whether we need to copy the exact error reporting for argument mismatch, or whether best effort approach isn't good enough. The advantage of the current behavior is a simpler binder. We can certainly add attributes that will prioritize some overloads but it would make the binder

Re: [Ironruby-core] Code Review: Better error messages

2009-01-24 Thread Shri Borde
Agreed, this is a negative scenario and exact error reporting is not a priority in such contrived scenarios. -Original Message- From: Tomas Matousek Sent: Saturday, January 24, 2009 3:03 PM To: Shri Borde; Jim Deville; IronRuby External Code Reviewers Cc: ironruby-core@rubyforge.org Subj

Re: [Ironruby-core] Code Review: Better error messages

2009-01-24 Thread Shri Borde
Jim, using should_not_receive sounds like a good idea. Will do the change. But we still need all those specs including the one using hijack_String_to_f. It is not testing method dispatch. Ruby method dispatch only controls which method body will be called. It does not do argument conversions. Th

Re: [Ironruby-core] Code Review: Better error messages

2009-01-23 Thread Jim Deville
it "coerces string argument with Float() without calling singleton to_f" do s = MathSpecs.string_with_singleton_to_f("0.5", 0.5) Math.acos(s).should be_close(Math.acos(0.5), TOLERANCE) ScratchPad.recorded.should == nil # to_f should not be called end it "coerces string argume