Thanks Ian, 

But just to be clear - I do not want to discard _a part_. I want to discard 
a _whole big one_, copying a small needed part that is still "alive" aside. 
Allocator perform it's duties as usual -  allocate a new small array, and 
discard an old one. It is just that compiler invokes this code on defer it 
if knows that there is only one reference to the remaining part, and that 
part is "small"

A.

On Friday, July 19, 2019 at 6:43:41 PM UTC-6, Ian Lance Taylor wrote:
>
> On Fri, Jul 19, 2019 at 5:17 PM Andrey Tcherepanov 
> <xnow4f...@sneakemail.com <javascript:>> wrote: 
> > 
> > I understand that it is very easy on application level... if programmer 
> even thought about it. But my assumption is that compiler has some sort of 
> liveness analysis, and it could be utilized here just to help with disposal 
> of a bitten part. 
>
> The kind of liveness analysis done by the compiler is only helpful in 
> extremely limited circumstances: when the compiler can track the slice 
> from creation to destruction and when the slice never escapes in any 
> way.  I'm skeptical that such a case happens often enough to be worth 
> implementing. 
>
> (And even if we did implement it we would still have the 
> above-mentioned problem that the allocator doesn't support discarding 
> part of an allocation.) 
>
> Ian 
>

-- 
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/b69f101c-0705-466c-96d3-7f1ef0adea74%40googlegroups.com.

Reply via email to