in reply to Using overload. Any complete (simple) examples?

As for overloading 0+/numeric context, it seemed to work fine when I started using overload for the interface to Math::Symbolic. In stringification context, $obj->to_string('infix') is called, in numeric context (and boolean, too), $obj->value() is called which returns the value of the function or undef if not all variables have a value assigned to them.
If you're interested, have a look at the Math::Symbolic::Base package which has the overloading code and which is, well, the base class for ::Operator, ::Variable, and ::Constant classes/objects.

The overloading doesn't include [] and friends because I couldn't see a good use for that. :) But I suppose the arithmetic overloading is ideal for a thing like symbolic mathematics: $obj + 2 resulting in a new Math::Symbolic tree. Unlike the Big* stuff, the code is all Perl. I like to think of it being fairly well documented, too.

http://search.cpan.org/~smueller/Math-Symbolic/

Steffen
  • Comment on Re: Using overload. Any complete (simple) examples?