Le Thu, 6 Nov 2025 12:43:14 +0100,
Marc Nieper-Wißkirchen <xxxxxx@gmail.com> a écrit :
> Hi José,
>
> Thanks for the suggestion!
>
> If I understand correctly, one would use `ephemeron-get' as follows:
>
> (let-values (((key val) (ephemeron-get x)))
> (if key
> <code that can use VAL because the ephemeron was unbroken>
> <code that handles the broken case and ignores VAL>))
yes
> Without `ephemeron-get', this would look like
>
> (let ((val (ephemeron-value x)))
> (if (ephemeron-key x)
> <code using VAL>
> <code ignoring VAL>))
>
> If used in this way, it doesn't seem that `ephemeron-get' saves much
> typing. Maybe, I misunderstood.
I agree.
My idea was that the operation ephemeron-get is "atomic". I'm not sure
but in your definition of GC and weak reference, the collection might
occur at anytime. Then, in your example without ephemeron-get, it may
occur between ephemeron-value and ephemeron-key and give a different
result. That is very theorical I'm admitting.
The other point is that I'm agreeing that reference-barrier is perhaps
not needed and that use of might ephemeron-get make it real.
>
> Marc
>
> Am Do., 6. Nov. 2025 um 06:51 Uhr schrieb jobol <xxxxxx@nonadev.net>:
> >
> >
> > Hi Mark, hi list,
> >
> > I propose to add the procedure 'ephemeron-get' that take one
> > argument, the ephemeron, and that returns 2 values: the key and the
> > value. Equivalent to:
> >
> > (define (ephemeron-get x)
> > (values (ephemeron-key x)(ephemeron-value x)))
> >
> > If implemented by the compiler/interpreter, it might solve race
> > between code and gc, but I'm not sure of that.
> >
> > Regards
> > José