On Jun 24, 2005, at 8:07 AM, Chip Salzenberg wrote:

On Fri, Jun 24, 2005 at 08:21:25AM +0200, Leopold Toetsch wrote:
The plan is to move these methods to classes/scalar.pmc

Last I remember, I asked for a number.pmc for Integer and Float to
derive from.  A Number isa Scalar.  Is there some problem with Number?

Forgive my C++ bias, but why are these methods at all? Shouldn't mathematical functions be functions? Shouldn't the transcendentals take floating point values (converting from integers) and others be overloaded for both types as appropriate?

Having asked the question, here's my answer (which I'm making up and may not be accurate):

There's not a fixed set of numerical types -- consider bignums and complex numbers. In C++ you would provide overloaded operators and functions along with the type declaration, but like Perl 5, Parrot blurs the distinction between operator and function, and method call vs. function call, so the effect is the same.

Having read my answer, I'd say that transcendentals (e.g. cos()) belong to Float-based types and any other types for which it makes sense to define them. If you just happen to be dealing with an integral number of radians (probably zero), which just happens to be stored in an Integer, convert it to a Float first.

Speaking of radians, are there any plans for unit analysis? It would be helpful to be able to write:

$angle = 60 degrees;
print cos $angle, "\n";
# prints 0.5

Josh

Reply via email to