Feature #3067

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

Added by Eregon (Benoit Daloze) about 2 years ago. Updated about 1 year ago.

[ruby-core:29167]
Status:Assigned Start date:04/01/2010
Priority:Normal Due date:
Assignee:matz (Yukihiro Matsumoto) % Done:

0%

Category:core
Target version:2.0.0

Description

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.

History

Updated by mame (Yusuke Endoh) about 2 years ago

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>

Updated by Eregon (Benoit Daloze) about 2 years ago

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

Updated by Eregon (Benoit Daloze) about 2 years ago

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.

Updated by mame (Yusuke Endoh) about 2 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
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>

Updated by tadf (tadayoshi funaba) about 2 years ago

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.

Updated by shyouhei (Shyouhei Urabe) over 1 year ago

  • Status changed from Open to Assigned

Also available in: Atom PDF