On Wed, Apr 02, 2003 at 08:53:37PM +0200, Frank Heckenbach wrote:
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").
Wouldn't it also clash with the ISO meaning of `@' ?
Overloading `+' and `-' could be useful (e.g., when implementing your own vector arithmetic etc.), and perhaps `not' as well.
That's what I had in mind.
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 ...
Apart from the parentheses, new user-defined unary operators are just about the same as unary functions, so they are probably not worth the trouble.
Emil
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html