On Fri, May 28, 2021 at 4:51 PM cheng dong <qq451954...@gmail.com> wrote:
> Thank you for the clarification. > sorry to break the general rule, i'm new to golang-nuts > > as to the question, i figured out i used wrong words, what i need in fact > is1. a hint to tell compiler that some object are safe to alloc on stack(in > case that we use it as interface so it escape from stack) 2. some concept > like unique ptr that when it end it's life time, the object referenced can > be deallocated immediately. > For Go to be memory safe the compiler can't trust your hint because you could be wrong either by a mistake or by changes to future code invalidating some assumption you had. A feature like Rust's unique pointers (and thus also borrowing and lifetimes) would require large changes to the language and completely change what Go is. If you want the features of Rust then use Rust. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAAuPoqf4%3D550o0u%2BatpbWrudzdx-%2B2s5fxL3%2BSecQS%2BTmQucQw%40mail.gmail.com.