Joshua Juran wrote:

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?

Well, at the surface these are opcodes like:

  cos Px, Py

OTOH you can use it as a method too:

  Px = Py."cos"()

or as a class method:

  cl = getclass "Float"
  Px = cl."cos"(Py)

There's not a fixed set of numerical types -- consider bignums and complex numbers.

Sure. And therfore Complex.cos() is a different thingy, when implemented.

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

Yes. But the problem is locating the cos() function. It's just a matter of putting Float.cos() into the "Integer" namespace too.

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

$angle = 60 degrees;

That's something for fancy HLL modules.

Josh

eo

Reply via email to