News for hackers. Stuff that matters.
Re:Write Your Own Virtual Machine by labelbias on Saturday August 15, 2020 @08:25AM (#24168386)
I thought that i++ ++i difference is related to the inner data structures of C++ iterators and that when using the former you need to keep 2 states compared to just one for that fraction of execution.
Re:Write Your Own Virtual Machine by labelbias on Saturday August 15, 2020 @02:23PM (#24171049)
thanks for the downvotes, I'm out of here for good!
Re:Write Your Own Virtual Machine by smabie on Saturday August 15, 2020 @02:47PM (#24171235)
What does ++ have to do with C++ iterators?

  int i = 0;
  i++;
How could that possibly involve an iterator? Moreover, C doesn't even have iterators.
Re:Write Your Own Virtual Machine by detaro on Saturday August 15, 2020 @02:53PM (#24171272)
You can use ++ on an iterator. Indeed you often do, e.g. in loops. ++iterator is preferable, and for consistency/so you don't have to think about its often recommended in C++ environments to just generally use pre-increment.

(Copying an iterator might be a lot more expensive than just copying an int, and might not be effectively optimized out by the compiler - e.g. if someone builds an iterator that's referenced-counted to an owning object or something)