News for hackers. Stuff that matters.
Re:JDK 10: General Availability by fauigerzigerk on Wednesday March 21, 2018 @06:57AM (#16636944)
I remember bugs that were caused by the exact opposite. If p is superceded by updated then it's not a good idea to have both hanging around in the local scope.

You shouldn't be able to doSomethingElse(p) when you actually mean to doSomethingElse(updated).

Re:JDK 10: General Availability by Moter8 on Wednesday March 21, 2018 @09:25AM (#16637779)
So basically, what rust prohibits.
Re:JDK 10: General Availability by fauigerzigerk on Wednesday March 21, 2018 @09:37AM (#16637860)
I don't know Rust very well at all, but I believe that Rust would only prohibit that if p and updated were referencing the same thing. If updated was a modified copy of p then I don't think Rust would help. But I could easily be wrong on that.

What would help is splitting the function up so that you don't have multiple named variables representing multiple versions of the same thing in the same scope:

   Person doSomethingAndDots() {
     Person p = doSomething(...)
     ...
     return p 
   }

   main() {
      doSomethingElse(doSomethingAndDots())
   }
Re:JDK 10: General Availability by andrewaylett on Wednesday March 21, 2018 @10:28AM (#16638238)
If the transformation function consumes p, rather than taking a reference to it, Rust will stop you from using the variable again afterwards.