Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.c++ Subject: Re: Reference Semantics Message-ID: <10251@socslgw.csl.sony.JUNET> Date: 15 May 89 07:31:37 GMT References: <315@odi.ODI.COM> <9310@alice.UUCP> Sender: news@csl.sony.JUNET Reply-To: diamond@csl.sony.junet (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 21 In article <9310@alice.UUCP> shopiro@alice.UUCP (Jonathan Shopiro) writes: >If you must return a reference >to an object, you can encode the idea that this object is the result >of a failed operation in its state, or (here's a gross hack for you) > > extern Type failedOperationInstanceOfType; > Type& tr = f(); // f can return a reference to the above > if (&tr != &failedOperationInstanceOfType) { > // use the referenced object > } Doesn't look like a gross hack to me. Looks like a perfectly correct, well structured solution, given the premises that a reference must be returned and that exceptional cases cannot be handled out-of-band. -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-implementing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?