Open encukou opened 1 year ago
Why are these called "linear references"? Is there a common definition of that term?
@markshannon, there's some academic background for the term, right? I hope I'm using it correctly :)
Why are these called "linear references"? Is there a common definition of that term?
See https://en.wikipedia.org/wiki/Substructural_type_system#Linear_type_systems
Reference counting (incref/decref) is replaced by what HPy calls handles, and Mark's proposal Opaque, linear references:
PyRef_Close
.PyRef_Dup
. Each must be destroyed (i.e. you can't Close one of them twice).PyRef_Is
, not by a pointer comparisonHPy shows that this enables a moving GC. It does need all users to update all their code, so CPython probably can't ever require this. But we could provide
PyRef_Dup
/PyRef_Close
/PyRef_Is
(implemented asPy_INCREF
/Py_DECREF
/Py_Is
) to allow users to signal that they're using handle semantics, and are (theoretically) compatible with implementations that use a moving GC.