yes, i immediately got the point(it is far different from golang ) after i type these words. so sorry to disturb
On Friday, May 28, 2021 at 3:39:25 PM UTC+8 Jesse McNelis wrote: > On Fri, May 28, 2021 at 4:51 PM cheng dong <qq451...@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/b94031e3-0f09-4f6f-aff7-1d9b01b66413n%40googlegroups.com.