Path: utzoo!attcan!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!think!redsox!campbell From: campbell@redsox.UUCP (Larry Campbell) Newsgroups: comp.lang.c++ Subject: Re: Improved switch statement Message-ID: <581@redsox.UUCP> Date: 24 Dec 88 03:43:16 GMT References: <6590072@hplsla.HP.COM> <1106@etive.ed.ac.uk> <33528@bbn.COM> <1907@ogccse.ogc.edu> <574@redsox.UUCP> <9245@ihlpb.ATT.COM> <781@auspex.UUCP> <9264@ihlpb.ATT.COM> Reply-To: campbell@redsox.UUCP (Larry Campbell) Organization: The Boston Software Works, Inc. Lines: 28 In article <9264@ihlpb.ATT.COM> nevin1@ihlpb.UUCP (55528-Liber,N.J.) writes: }In article <781@auspex.UUCP> guy@auspex.UUCP (Guy Harris) writes: } }>Well, offhand I'd think a program defining "==" operator that didn't act }>like an equality operator would be a good candidate for an "Obfuscated }>C++ Code" contest; I'd *strongly* suggest they pick some other operator. } }But part of the beauty of C++ is that you don't have to define }operator== as the *C* equality operator! ... followed by an example of a non-commutative == operator ... It is an EXTREMELY bad engineering practice to use deceptive or misleading names in programs. Well-written programs inform and educate the reader -- they do not surprise or deceive him. Remember, operators are just function names. It is possible, but foolish, to define a function called "sqrt" that returns, say, the cube root of its argument. It is also possible, but equally foolish, to define an "==" operator that does something radically different than what most people expect from an equality operator (like not being commutative, not returning a boolean value, etc.) Just because C++ lets you do it doesn't mean it's a good idea! -- Larry Campbell The Boston Software Works, Inc. campbell@bsw.com 120 Fulton Street wjh12!redsox!campbell Boston, MA 02146