I hope your proposal is never implemented. Manual memory management is the cause of far too many bugs. And I say that as someone who started programming in the mid 1970's (more than forty years ago). If you want manual memory management there are plenty of languages which provide it.
As a data point I spent a couple of years recently trying to modernize the Korn shell (ksh) source code. When I finally replaced the AST Vmalloc subsystem with the platform/compiler malloc implementation that allowed using tools like Valgrind and Address Sanitizer (asan). Those tools identified multiple bugs in the ksh implementation. Including use after free, double free, and returning a pointer to a stack allocated var that survived the termination of the function. And that was for a mature project that was (is?) widely used. On Thu, May 27, 2021 at 7:03 PM cheng dong <qq451954...@gmail.com> wrote: > 1. first case > > ```go > func do(x SomeInterface) {...} > func outer() { > var x = new(A) > do(x) > markDelete(x) // explicit delete x if we know x's lifetime end here > } > ``` > > if we know in advance that x's lifetime will finish when outer end. can we > mark delete x. and the compiler can safely alloc x on stack. > > 2. second case > > ```go > func loop(ch <-chan *A) { > for x := range ch { > use(x) > markDelete(x) > } > } > ``` > > most times, we know which objects could safely be deallocated just like in > lang without gc, could we delete them immediately to relief gc pressure ? > > -- > 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/dd5aba59-512c-4b9b-b365-2b509edd74e7n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/dd5aba59-512c-4b9b-b365-2b509edd74e7n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- 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/CABx2%3DD_d%3DGGfnYD546Ut%3DZNQreCiDK8%2BZt2jPbZTVZs8RwqQ6A%40mail.gmail.com.