Constructors, excessive consing, R7RS Large
Daphne Preston-Kendal 21 Nov 2024 20:34 UTC
I hope Arthur doesn’t mind me answering publically a comment he sent privately, since I think it sums up what may be some common responses to this proposal:
> I have just one non-editor comment: Sometimes, I define several record types in a hierarchy, and they're meant to be used together, i.e. they're part of the same program. In that case, I like having the ability to define a constructor for a subtype that includes all the fields of the supertype. That reduces consing. I hope that R7RS Large won't lose that capability.
1. You can still do this, you just have to explicitly define a constructor procedure which takes the arguments you want; I expect that will be the most common way constructors of subtypes are used in practice, and the one defined by define-record-type itself is just a primitive used to build a slightly more palatable interface.
2. I considered the consing problem but also think that any compiler with a halfway decent inliner should be able to eliminate it in the common case when the first argument to the auto-defined constructor for a subtype is a call to any simple constructor for its supertype. Perhaps I should provide a third sample implementation where you can see that, for example, Chez’s cp0 is already basically capable of this (and that this can be seen with the expand/optimize procedure). The R6RS-based implementation doesn’t do this very well because it has to run circles around the R6RS record system to make it work the way it wants.
3. I have no idea whether this SRFI is destined for R7RS Large. I consider it an experiment in trying to bring R7RS small records closer in terms of features to R6RS records.
Daphne