News for hackers. Stuff that matters.
Re:C++ and zombies: a moving question by ribbit243 on Friday October 31, 2014 @03:21PM (#8540595)
Consider a Movable file handle.

File fh = File(fopen("file.txt"));

foo(std::move(fh));

Using fh after foo() would yield a compile error in Rust. It does not in C++.

Re:C++ and zombies: a moving question by meetingcpp on Friday October 31, 2014 @04:01PM (#8540811)
Well, of course accessing the value of fh after foo would be fatal. But how would you then sort a container of moveable-only objects?

An object should be accessible for reassigning a value after its move, as its often needed for algorithms, thats exactly why the C++ Standard mandates this. Move does really only make sense if the class holds a moveable allocation, such as a container, array etc., which makes copying expensive.

Re:C++ and zombies: a moving question by dbaupp on Friday October 31, 2014 @08:39PM (#8541798)
> An object should be accessible for reassigning a value after its move, as its often needed for algorithms, thats exactly why the C++ Standard mandates this.

The same is true in Rust. A moved-from value can be reassigned, but cannot be used (compile enforced) until it is reassigned. :)

Re:C++ and zombies: a moving question by cheez on Friday October 31, 2014 @03:45PM (#8540718)
How often do people make this error? I know, it's a terrible error but I code every day (maybe my opinion is not relevant for this reason) and I rarely come across this issue.
Re:C++ and zombies: a moving question by pjmlp on Friday October 31, 2014 @04:30PM (#8540954)
How big is your team?
Re:C++ and zombies: a moving question by cheez on Sunday November 02, 2014 @01:16AM (#8545708)
I'm sincerely asking since I work alone.
Re:C++ and zombies: a moving question by pjmlp on Sunday November 02, 2014 @02:44AM (#8545976)
Big projects are often composed anywhere from 10 developers up to 100 or more.

Usually with high rotation of developers coming and going, since parts of the project tend to be delegated to be other companies, many times with developers that aren't all at the same skill level.

When you work at this scale, memory errors and misuse of resource are quite common.

No developer is able to have the whole code on his/her head and sometimes also does not have the time to understand the whole codebase.

So mistakes happen quite often.

This is why C got out of love in the enterprise or why companies like Google and JPL have such strict C++ design guide.