context dependent operators

rmsaai.mit.edu rmsaai.mit.edu
Mon Feb 5 21:03:31 PST 1990


Recently this list was sent a proposal for numerical operators which
suggested that the meaning of an operator would depend on the context
in which the value of the expression was used.

I think this is a bad idea.  The fact tht the type of any expression
can be determined from the expression itself is good both for
implementing compilers and for understanding programs.

Moreover, there can be contexts which fail to indicate a desired type.
For example, inside sizeof, or inside a cast.  (Actually, any unary
operator causes such a problem, but one could imagine propagating the
context back through them to solve it.)

You might say that sizeof and casts don't matter because these
operators aren't very useful there.  However, macros use these things;
do you want to have macros that fail mysteriously on certain
expressions?  Also, this is a matter of luck; extensions can introduce
new contexts of difficulty where the operators are not so seemingly
useless.

So I will strongly oppose any proposal to add operators whose meaning
or result-type depends on how the value will be used.



More information about the Numeric-interest mailing list