Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Red Baron
Jan 10, 2005

Janin posted:

Oh good, so all I have to do to make reference code safe is...treat every reference as a magical pointer?


The problem is I'm working on code written by people who have been told "pointers are not safe, don't use them, always use references, they are safe!". I wouldn't mind the feature so much if it came with some way to indicate to future readers when it was in use. It's the combination of "any of these hundred function calls could validly change my local stack" and "I don't know which ones".

If the people who worked on the code before you couldn't understand the semantics of references (which is scary enough by itself), I can hardly see how that's the language's fault any more than it would be Java's fault if a programmer couldn't understand the "reference by value" passing that has already been discussed ad nauseum (and I've seen several people who've struggled with exactly that. They were programming 101 students, though). If you violate a function's preconditions or an invariant of the language itself, your program is in an inconsistent state by definition.

Allowing a null reference to be passed is no more a design flaw of C++ than allowing NULL to be passed to strlen is a design flaw of C. They're both precondition violations and will most likely have the same outcome.

Adbot
ADBOT LOVES YOU

The Red Baron
Jan 10, 2005

PHP 5.3: now with goto

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply