News for hackers. Stuff that matters.
Re:Some thoughts on Go and Erlang by demallien on Monday April 28, 2014 @01:32AM (#7658342)
For 1), modern C++ style generally frowns upon NULL pointers, preferring to use references, which are guaranteed to be non-NULL.
Re:Some thoughts on Go and Erlang by dbaupp on Monday April 28, 2014 @05:04AM (#7658925)
There is no such guarantee, a NULL reference can be created although it does require a little more effort than creating a null pointer.

However, null is just a special case of "invalid" pointer (e.g. point to freed memory), and it's very easy to create an invalid reference, e.g. take a reference into a vector and then push a pile more elements onto it, causing the vector to reallocate and move in memory, invalidating the reference.

Re:Some thoughts on Go and Erlang by lomnakkus on Monday April 28, 2014 @01:43PM (#7661597)
You're talking about undefined behavior. There's no such thing as a null reference according to the C++ language specification.
Re:Some thoughts on Go and Erlang by dbaupp on Monday April 28, 2014 @05:44PM (#7663312)
So? It's still possible to create one. (There's no such thing as dereferencing an invalid pointer according to the standard, but that still happens.)
Re:Some thoughts on Go and Erlang by lomnakkus on Tuesday April 29, 2014 @11:48AM (#7667765)
If it takes undefined behavior to create a "null reference" then by definition it's not possible to create one and still have a well-defined program. That is, you have bigger problems than "null references" to worry about.
Re:Some thoughts on Go and Erlang by JanneVee on Monday April 28, 2014 @08:49AM (#7659525)
There is no such guarantee. I fixed more than one bug of invalid references.
Re:Some thoughts on Go and Erlang by demallien on Monday April 28, 2014 @05:02PM (#7663036)
My understanding is that it is impossible to have a NULL reference. Can you show us some code that ends up with a NULL reference? I'd be curious to see how that can be done!
Re:Some thoughts on Go and Erlang by ben0x539 on Monday April 28, 2014 @10:03PM (#7664478)
Dereference a NULL pointer and use the result to initialize a reference. Sure, it's undefined behavior, but so are all the problems that result from NULL pointers, and in practice it doesn't crash until you "dereference" the reference by looking at the value, so it's probably as hard to track down as a NULL pointer crash.
Re:Some thoughts on Go and Erlang by JanneVee on Tuesday April 29, 2014 @07:33AM (#7666251)
I'll leave it as an excercise to you. Promise me that I don't have to maintain your C++ code until you completed it.