> With the `list.first = node` assignment, there's no more reference that keeps 
> the node previously pointed to by `first` alive and the cell is thus 
> **immediately destroyed**.

I was confused by the "immediatly destroyed" part as I couldn't find where is 
the old node destroyed, then, examining the generated C, I understood it's 
destroyed in the `=copy` function (`eqdestroy___llbug_u88(colontmp_);`):
    
    
    N_LIB_PRIVATE N_NIMCALL(void, 
eqcopy___llbug_u75)(tyObject_ListNodeObj__bQHnN9ccFzE14H9cD8IIbU3g** dest_p0, 
tyObject_ListNodeObj__bQHnN9ccFzE14H9cD8IIbU3g* src_p1, NIM_BOOL cyclic_p2) {
            tyObject_ListNodeObj__bQHnN9ccFzE14H9cD8IIbU3g* colontmp_;
            colontmp_ = (*dest_p0);
            {
                    if (!src_p1) goto LA3_;
                    nimIncRefCyclic(src_p1, cyclic_p2);
            }
    LA3_: ;
            (*dest_p0) = src_p1;
            {
                    NIM_BOOL T7_;
                    T7_ = (NIM_BOOL)0;
                    T7_ = nimDecRefIsLastCyclicStatic(colontmp_, 
(&NTIv2__bQHnN9ccFzE14H9cD8IIbU3g_));
                    if (!T7_) goto LA8_;
                    eqdestroy___llbug_u88(colontmp_);
                    nimRawDispose(colontmp_, ((NI)8));
            }
    LA8_: ;
    }
    
    
    Run

The `cursor` pragma certainly is dangerous. Thanks again for clarifying this 🙂.

Reply via email to