type Rc (Rc( U64 , Tuple[] )); rc-magic-number := 423809104_u64; # TODO, if this is a fragment then the hook doesn't work fragment del := λ: Hook+Priority<9999>+DontChain(: x Sized). (: () Nil); rc := λ(: v x). (: ( (let inner (Tuple( v 1_i64 ))) (Rc( rc-magic-number (close inner) )) ) Rc); del := λ: Hook+HookPriority<0>(: v Rc). (: ( (if (==( (.2 v) rc-magic-number )) ( # (let c (-( (.1(open(.1 v))) 1_i64 ))) # (set[]( (as (.1 v) I64[]) 1_u64 c )) # (del (.2(open(.1 v)))) # maybe it does something, maybe not # #TODO free ) ( (if (!=( (.2 v) 0_u64 )) ( (print 'del\[Rc\]\sIs\sNot\sMagic\sAnd\sNot\sNull:\sMemory\sIs\sCorrupt\n_s) (exit 1_u64) ) ()) )) ) Nil); inc := λ(: v Rc). (: ( (let c (+( (.1(open(.1 v))) 1_i64 ))) (set[]( (as (.1 v) I64[]) 1_u64 c )) v ) Rc);