Frank D. Engel, Jr. wrote:
Actually, overloading of unary operators might be a good idea (leaving apart the rest of the joke :)
Sure, then we can do negation with '+' and square root with '-'!
(another joke, but seriously, if we allow overloading of binary operators, then why not unary ones... but I hardly think overloading the ';' operator is reasonable. There IS a limit.)
I think currently we have 4 unary operators: `+', `-', `not', `@'.
Overloading `@' (BP style address operator) would seem strange to me -- basically because the built-in meaning already accepts all types (as "reference parameters").
Overloading `+' and `-' could be useful (e.g., when implementing your own vector arithmetic etc.), and perhaps `not' as well.
However, overloading `-' for Integers would mean that `-42' gets a different meaning.
New user-defined unary operators would probably cause parsing problems (since an identifier (operator) can occur where other identifiers (variables, constants, functions etc.) are also allowed), though they might be solvable with some effort ...
Frank