## Further Thoughts On Real

So, in my first post on this subject I referred to a lingua franca type RealX for the Real role, without specifying what type RealX should be. There was a very good reason for that: I don’t know what type it should be. But I realized today that might be a feature rather than a bug.

My original assumption, when I first started thinking about these issues, was that RealX obviously had to be Num. That’s what the current source effectively does, after all. And Nums are wonderfully versatile.

For a while, though, I worried about precision. Obviously a FatRat can be much more precise than a Num. After consideration, I’m not sure how worried I am about that — as long as you are not doing abstract math, tolerance is still an issue, no matter what, and using FatRat borders on fooling yourself into not worrying about it.

But there is a much bigger catch to using Num. Once Rakudo has proper bignums, it will be child’s play to create an Int which cannot be converted to a meaningful Num. And that seems like a big problem with the idea of using Num for RealX.

On the other hand, FatRat would be a pretty reasonable RealX, I think, except that it doesn’t exist yet!

What to do? Well, look back at my example code for `.RealX` back in the previous post:

```    multi method RealX() {
\$.cents.RealX / 100.RealX;
}
```

What jumps out at me today is that this code works no matter what type RealX is! Basically it’s all a matter of expressing the value of you Real in terms of simpler Real types that already have RealX defined. All you need is for your Perl 6 implementation to define valid RealX methods for Int and Num.

So my proposal is we come up with a better name for the RealX method, and let the type it returns be implementation-defined. With any luck, that would let Rakudo use the practical current solution of Num, and still seamlessly switch over to something like FatRat when it is available.

(BTW, I think if you combine this with a great suggestion from Larry Wall, you also can extend this solution to work for general Numeric types, at least for comparisons. But that’s the subject for another post.)