Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!sharam@munnari.oz.au From: sharam@munnari.oz.au (Sharam Hekmatpour) Newsgroups: comp.lang.c++ Subject: Re: references to dereferenced null pointers Message-ID: <3374@munnari.oz.au> Date: 19 Mar 90 03:51:51 GMT References: <33209@brunix.UUCP> Sender: news@cs.mu.oz.au Reply-To: sharam@munnari.oz.au Lines: 40 From article <33209@brunix.UUCP>, by sdm@cs.brown.edu (Scott Meyers): > [...] > Of course, I also > tend to believe that references are an idea whose time should never have > come. Maybe someone can enlighten me: what do references offer besides > syntactic sugar? Nothing. But the syntactic sugar offered by references is so important in that you can't eliminate them without losing much of the convenience of C++. I can name two things: [1] Efficient implementation of overloaded operators that involve large objects (eg, matrices) requires the operands to be references. Pointers simply won't work. [2] A call to a function that returns a reference is an lvalue. This syntactic sugar is very useful. > From my limited vantage point, they're just like > pointers, but you can't new/delete them, you can't reassign them, and you > can't compare them against 0. There are things that you can do using references but not pointers. See my previous posting for an example involving a 'delete' that zeros pointers. > Don't get me wrong: I like sugar as much as > anybody else, but syntactic sweetness has never been C++'s strong suit. In > the case of references, I find that the confusion outweighs the > convenience. I disagree. High level languages are all about syntactic sugaring; eliminate them and what you end up with is an assembler-like language. > Scott > sdm@cs.brown.edu Sharam Hekmatpour sharam@munnari.oz.au