ExtendingNumeric

Whether (and how) extending the Numeric class

I am looking a Ruby as a "front end" for some numeric structured array processing. In truth, NArray seems to do some of what I might look for, but I also have some additional functionality to add, which doesn't seem easy to do with current NArray implementation. But I'm not afraid of a re-factoring/re-implementation (using the NArray stuff as a guide).

However, let us assume that I have a class of these numeric objects. Let's just call the zoltars... It seem to me I get all sorts of extra value if I subclass from Numeric...

(by the bye, it would nice if the wiki had a "source code" designator... I would be more likely to use that then say bold italics)

Class Zoltar << Numeric

The intention is that I could be able to write things like

z = Zoltar.new :value => [0...12]

zpp = z + 1

# which might even allow something like

z += 1

# working just fine.

Of course I would need to implement Numeric (or more likely Integer and Float) versions of to_zoltar. Do I just explicitly add them to the capbilities? With a Module / Mixin? (Excuse the less than precise language, I'm still working on things).

Class Integer

end

Hmmm maybe I could just add it to Numeric directly and therby let the .new :value allow all the different things to be handled.

And of course I'll also need a "coerce" implementation as well.

Is there something wrong with this? Namespace issues?