Feature #3067

complex.c : Question: why Complex#~ is disabled? It's in the doc

Added by Benoit Daloze about 4 years ago. Updated over 1 year ago.

[ruby-core:29167]
Status:Assigned
Priority:Normal
Assignee:Yukihiro Matsumoto
Category:core
Target version:next minor

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
rbdefinemethod(rbcComplex, "~", nucompconj, 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

History

#1 Updated by Yusuke Endoh about 4 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
rbdefinemethod(rbcComplex, "~", nucompconj, 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

#2 Updated by Benoit Daloze about 4 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

#3 Updated by Benoit Daloze about 4 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

#4 Updated by Yusuke Endoh about 4 years ago

  • Category changed from ext to core
  • Assignee set to 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

#5 Updated by tadayoshi funaba about 4 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

#6 Updated by Shyouhei Urabe over 3 years ago

  • Status changed from Open to Assigned

=begin

=end

#7 Updated by Yutaka HARA over 1 year ago

  • Description updated (diff)
  • Target version changed from 2.0.0 to next minor

Also available in: Atom PDF