From: Gavin Sinclair Date: 2003-02-04T22:27:41+09:00 Subject: Re: Native rational and complex number implementations? On Tuesday, February 4, 2003, 11:33:10 PM, Tobias wrote: > On Tue, 4 Feb 2003, Gavin Sinclair wrote: >> I believe it would be beneficial to have Rational and Complex >> as built-in classes. > Could you tell some concrete expectations from making them built-in, i.e. > the reasons why you think it would be beneficial? Small benefit, really. It would be easier to document because everything is designed to interoperate up-front. The current state is: you require some files which butcher the existing classes. Thus the API documentation is split. Not that I expect anything to change for that reason; I'm just curious, really. I do think it would be elegant to include them, and that's a good, but not sufficient, reason. > All that I would like to have built in is a ruby literal for specifying > complex numbers (a literal for purely imaginary numbers would be > sufficient, of course) because it's tedious to write > Complex(2,3) if what you want is 2+3i True, but how many literals do you really define? Numbers tend to be kept internal to algorithms. Also, alias C Complex :) > I don't think significant performance gains are possible by making Complex > built-in because of the templated nature of the Complex class (real and > imaginary part can be any Numeric except Complex itself). Probably not, but if a method is creating lots of complex #s then what would you prefer: Ruby methods to create them, or machine code? Again, just curious to see if there are good reasons to keep them out, apart from the "too busy; leave me alone" reason, which is very good. Gavin