Feature #3067
closedcomplex.c : Question: why Complex#~ is disabled? It's in the doc
Description
=begin
Hi, this is more of a question than a bug, feature or whatever,
but I wonder why Complex#~ has been removed ?
I can read in complex.c:
#if 0
rb_define_method(rb_cComplex, "~", nucomp_conj, 0); /* gcc */
#endif
gcc would have problems with it? why?
Fixnum#~ and Bignum#~ are not commented and work right.
Maybe the method should be added at a higher level, if possible, if it is a compiler issue ?
B.D.
=end
Updated by mame (Yusuke Endoh) over 14 years ago
=begin
Hi,
2010/4/1 Benoit Daloze redmine@ruby-lang.org:
but I wonder why Complex#~ has been removed ?
I can read in complex.c:
#if 0
rb_define_method(rb_cComplex, "~", nucomp_conj, 0); /* gcc */
#endif
The above definition of Complex#~ returns conjugate complex,
while Fixnum#~ and Bignum#~ are bit inversion operators.
I don't know a suitable definition of bit inversion against
Complex.
But I also wonder what the comment /* gcc */ means.
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Updated by Eregon (Benoit Daloze) over 14 years ago
=begin
The above definition of Complex#~ returns conjugate complex,
while Fixnum#~ and Bignum#~ are bit inversion operators.
I don't know a suitable definition of bit inversion against
Complex.
Sure, I just wanted to show #~ is running for other objects.
B.D.
=end
Updated by Eregon (Benoit Daloze) over 14 years ago
=begin
I tried to compile removing the #if 0 and it works:
irb for ruby-1.9.2-r26319
c = 2+3.i
=> (2+3i)
~c
=> (2-3i)
So it is not a problem on OSX 10.6.3
Can someone test on linux and windows? Then I think we could safely enable this method.
=end
Updated by mame (Yusuke Endoh) over 14 years ago
- Category changed from ext to core
- Assignee set to matz (Yukihiro Matsumoto)
- Target version changed from 1.9.2 to 2.0.0
=begin
Hi,
I forgot to change the target of this ticket to 1.9.x.
I'm sorry if I gave you false hope.
Can someone test on linux and windows?
Then I think we could safely enable this method.
This is not implementation problem, but consistency problem.
Fixnum#~ and Bignum#~ do bit inversion.
I guess some people expects Complex#~ to do the same.
They may think it as a bug if Complex#~ returns conjugate
complex.
But I'm not against for your suggestion.
I pass the ball to matz.
--
Yusuke Endoh mame@tsg.ne.jp
=end
Updated by tadf (tadayoshi funaba) over 14 years ago
=begin
i wrote it.
gcc has the feature.
i disabled it for the time being.
i'm not sure whether we should assign it.
we have much time.
=end
Updated by shyouhei (Shyouhei Urabe) over 14 years ago
- Status changed from Open to Assigned
=begin
=end
Updated by yhara (Yutaka HARA) about 12 years ago
- Description updated (diff)
- Target version changed from 2.0.0 to 2.6
Updated by Eregon (Benoit Daloze) about 10 years ago
- Status changed from Assigned to Closed
I see, it's from https://gcc.gnu.org/onlinedocs/gcc/Complex.html.
As said before, this is potentially confusing so the current behavior of not defining it seems best.