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
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
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
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
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
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
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
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