Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uupsi!sunic!lth.se!newsuser From: dag@control.lth.se (Dag Bruck) Newsgroups: comp.lang.c++ Subject: Re: Null references Summary: Exception handling will help you. Message-ID: <1991Feb15.072317.4856@lth.se> Date: 15 Feb 91 07:23:17 GMT References: <1991Feb13.224743.1123@lia> Sender: newsuser@lth.se (LTH network news server) Organization: Department of Automatic Control, Lund, Sweden Lines: 22 In article <1991Feb13.224743.1123@lia> jgro@lia.com (Jeremy Grodberg) writes: >... For example, suppose I want to implement a look-up >table, and my find() function needs to return an object. It is much >more efficient to return an object reference, but I would like to return >NULL if I can't find the requested object. I guess this is the most common problem with references, and that it will be solved (in most cases) when we get exception handling implemented. Instead of returning a NULL reference, you would throw NOT_FOUND to indicate when the lookup routine cannot find the object. I find the notion that (1) references are always bound to something, and (2) references are never re-bound, very useful. I must admit that I have used NULL references too, when I ran into trouble. Dag Bruck -- Department of Automatic Control E-mail: dag@control.lth.se Lund Institute of Technology P. O. Box 118 Phone: +46 46-104287 S-221 00 Lund, SWEDEN Fax: +46 46-138118