A reference type Marc Nieper-Wißkirchen 18 Aug 2022 21:45 UTC

I wonder whether someone would like to write a SRFI describing a
reference type. With SRFI 111/SRFI 195 we have box types, but we don't
have a box-like type that reuses an existing location.

A reference-type-SRFI could contain the following procedures:

* (reference? OBJ)  returns #t is OBJ is a reference
* (mutable-reference? OBJ) returns #t if OBJ is a reference and the
referenced value can be mutated
* (make-reference GETTER) returns a reference where GETTER is called
when the value is asked for
* (make-mutable-reference GETTER SETTER) - returns a mutable reference
with specified getter and setter
* (reference-get REF) - calls the getter of REF and returns its values
* (mutable-reference-set! REF OBJ ...) - invokes the setter of REF on
the values VAL ...

Maybe, the name mutable-reference should be changed into settable-reference.

Maybe, references without setters are not important enough so all
references should be mutable/settable.

Thanks,

Marc