-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
[Truffle] Error adding Complex to Fixnum #2805
Comments
This is more complicated that with other types as jruby/truffle/src/main/java/org/jruby/truffle/nodes/core/FixnumNodes.java Lines 129 to 137 in 49dc6b4
Where that isn't possible, like divide, we do jruby/truffle/src/main/java/org/jruby/truffle/nodes/core/FixnumNodes.java Lines 552 to 563 in 49dc6b4
|
@chrisseaton I can try to implement this if you haven't done so already |
Yes please |
It's probably much much easier now we have |
@chrisseaton Can you recommend how to add a Specialization like this for a non-core class? e.g. Matrix How would the guard look? Would the specialization go in FIxnumNodes even though this is non-core? I need a Fixnum#/ and I think this can be implemented in terms of Fixnum#* |
I don't see why I think you might find that through coercion, We could do with a solid understanding of this - resist the temptation to special case for @eregon @nirvdrum do you know anything about how this works? |
@chrisseaton The spec that is failing is call the coerce_spec (library/matrix) so I think you are on the right track but I don't know where the coercion happens. 1 / Matrix[[0,1],[-1,0]] |
Rubinius does def divide(o)
Rubinius.primitive :fixnum_div
redo_coerced :/, o
end
alias_method :/, :divide Maybe look at adding a specialisation to |
Yes, this is just the |
I think it's even preferable to not have Rational/Complex specializations unless we need it, since the class check is imprecise and there is a better mechanism already defined by the normal semantics. |
@chrisseaton Added |
Can you try removing them and see what happens? You need to try running any of the benchmarks as well (do |
We don't use Time anymore I think, but the monotonic time. Also, if Process::CLOCK_MONOTONIC fails, |
Adding Fixnum to Complex works but the reverse doesn't.
Do we need to add a RubyComplex class to add a specialization for this? Or how would you resolve this?
This is used in matrix stdlib.
The text was updated successfully, but these errors were encountered: