> How about having a compiler that detects this pattern and emits the
> necessary pointer comparisons? Then you could write your code cleanly
> (without exceptions, flags or comparisons), and the compiler can emit
> whatever code is most efficient for its runtime.
One could surely do this, especially if the compiler "sees" that only one
or a few arguments of a constructor change: then checking for physical
identity would allow it to return the "original" value.
But I am not sure whether this is generally a good idea, because the
compiler cannot predict runtime behaviour: it may well be that you use sets
without ever inserting already existing elements into them. Then all these
checks are superfluous.
The good thing about the version with exceptions is that you do not need
the checks for physical equality anymore, which quickly pays with
increasing data amounts and is not really so "unclean".
Best regards,
Markus Mottl
-- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
This archive was generated by hypermail 2b29 : Wed May 17 2000 - 19:34:24 MET DST