Well, operator overloading is always risky business: you have to balance the syntactic convenience against the potential confusion... Adequate documentation is IMHO a good palliative, but you may differ.
Anyway, to a mathematician at least, the basic semantics of `+' is commutativity, and that is violated as soon as you define addition of strings to mean concatenation.
Moreover, it becomes hard to make any sensible use of operator overloading once you can't reliably predict which lfun will be called in evaluating (say) `a+b', without inspecting all the surrounding code...
/ rjb
Previous text:
2003-04-17 23:00: Subject: lfun::`+=()
You will be able to tell the difference if o->t is a couple of megabytes and you're adding lots of small strings to it, I promise.
OTOH there seems to be no problem in defining a lfun::`+() that acts destructively (returns `this')...
Please don't do that. It doesn't follow the semantics of the + operator, and so will seriously confuse anyone who is using your class. Just name your destructive function something like "append" or "add" instead.
/ Martin Stjernholm, Roxen IS