getter argument of register-getter-with-setter! Shiro Kawai (30 Jul 2020 11:59 UTC)
Re: getter argument of register-getter-with-setter! Taylan Kammer (30 Jul 2020 23:50 UTC)
Re: getter argument of register-getter-with-setter! Arthur A. Gleckler (30 Nov 2020 19:45 UTC)
Re: getter argument of register-getter-with-setter! Taylan Kammer (01 Dec 2020 22:15 UTC)
Re: getter argument of register-getter-with-setter! Arthur A. Gleckler (20 Jan 2021 01:36 UTC)
Re: getter argument of register-getter-with-setter! Arthur A. Gleckler (08 Apr 2021 17:30 UTC)
Re: getter argument of register-getter-with-setter! Shiro Kawai (08 Apr 2021 19:31 UTC)
Re: getter argument of register-getter-with-setter! Arthur A. Gleckler (08 Apr 2021 20:00 UTC)

Re: getter argument of register-getter-with-setter! Taylan Kammer 30 Jul 2020 23:50 UTC

On 30.07.2020 13:59, Shiro Kawai wrote:
> The srfi text says 'getter' argument of register-getter-with-setter!
> takes two arguments, the object and the field identifier.
>
> The reference implementation, however, may call 'getter' with three
> arguments, if the object is sparse or 'ref' is called with the default
> argument.
>
> Typically srfi text is definitive, but in this case, limiting getter to
> two arguments makes it impossible to implement three-argument 'ref'.  So
> I suggest this should be post-finalization correction.

You seem to be right.  It's been a long time since I wrote the SRFI so I
can't be sure what was going on in my mind but from what I can tell it
seems to have simply an oversight.  I probably wasn't very careful in
defining 'register-getter-with-setter!' because it's kind of a hack.

The following paragraph:

```
The getter will be called with two arguments: the object whose field
should be accessed, and an object identifying the field to be accessed.
The setter will be called with one additional argument which is the
value to be assigned to the given field of the given object.
```

Should be changed to this, I think:

```
If sparse? is false, the getter will be called with two arguments: the
object whose field should be accessed, and an object identifying the
field to be accessed.  If sparse? is true, the getter might be called
with a third argument, the default value, which the getter must return
in case the given object has no value associated with the given field.

If an implementation of this SRFI ever calls the getter of a sparse type
with two arguments, and the

The setter will always be called with three arguments: the object that
is to be mutated, an object identifying which field of the object is to
be mutated, and the new value that is to be assigned to that field.
```

Does that sound right?  Am a bit tired so the more eyes the better. :-)

I wasn't sure whether it should specify that the getter of sparse types
*will* be called with three args or *may* be called with three args.
The reference implementation always passes three args, but a smarter
implementation might know that some getters raise their own meaningful
error condition when no default value is given and call them with two
arguments...

- Taylan