On further reflection and discussion (and some prodding from Art), I agree that accessors of a parent type must be able to return the payload of a child type, just because an object of a child type *is* an object of a parent type.  I will leave open, ex silentio, the question of whether the reverse is true.

Art, please change lines 131-133 from:

such that the objects returned by <em>constructor</em> satisfy <tt>reia?</tt>
and the payload of objects returned by <tt>make-reia</tt> can be accessed
using <em>accessor</em>.


such that the objects returned by <em>constructor</em> satisfy <tt>reia?</tt>
and their payload can be accessed using <tt>reia-ref</i>.


On Sat, Oct 29, 2016 at 3:33 AM, Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:

On Mon, Oct 24, 2016 at 8:34 AM, Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:
This (the parent accessor can access the payload of a subtype) is certainly what is needed for using this SRFI in the real world. For example, it would be impossible to implement a record-type system à la SRFI 131 and 136 on top of SRFI 137 if it didn't provide this.

N.B.: For demonstration purposes, the current "reference" implementation of SRFI 136 is now built on top of SRFI 137 (with parent accessors being able to access payloads of subtypes).
On reflection, I think it has to do both: a base-type accessor should be able to access the payload of an object of a derived type, and a derived-type accessor should be able to access the payload of an object of the base type.  No?

On first sight, this looks a bit smelly to me, and it may be bad when it comes to encapsulation requirements. I also don't think that it is really needed because the code defining the parent type can export a well-defined interface that client code can import to access a parent instance's payload.

Or do you have an application in mind where this wouldn't suffice?


John Cowan          http://vrici.lojban.org/~cowan        xxxxxx@ccil.org
Newbies always ask:
  "Elements or attributes?
Which will serve me best?"
  Those who know roar like lions;
  Wise hackers smile like tigers.         --a tanka, or extended haiku