Re: array-copy, array-stack, array-append: What should the defaults be?
Alex Shinn 04 Oct 2021 21:34 UTC
On Mon, Oct 4, 2021 at 11:27 PM Bradley Lucier <xxxxxx@math.purdue.edu> wrote:
>
> On 10/4/21 4:23 AM, Alex Shinn wrote:
>
> In April you wrote something I now think I didn't understand:
>
> >> 2. If the default is implementation dependent, then every program, no
> >> matter how it wants default-mutable? and default-safe? to be set, is
> >> going to have to start with calls to
> >>
> >> (specialized-array-default-safe? <whatever>)
> >> (specialized-array-default-mutable? <whatever>)
> >>
> >> which is, in my opinion, unfortunate.
> >
> > Safety is a little vague and implementation-specific to begin with,
> > so it may be OK to leave as a parameter, but I think using such a
> > dynamic parameter at all for mutable? was a mistake. The default
> > should be built into the constructor procedures themselves.
> >
> > The situation is made worse that these are not explicitly SRFI 39
> > or R7RS parameters.
>
> I responded to this last sentence by making
> specialized-array-default-safe? and specialized-array-default-mutable?
> parameters, but now I suspect that's not your first choice.
Sorry, that was not worded clearly. By "built into the constructor" I was
suggesting signatures of:
make-specialized-array interval [ storage-class generic-storage-class
] [ safe? #f ]
array-copy array [ storage-class generic-storage-class ] [ mutable? #t
] [ safe? #f ]
where the defaults are specified by the standard and can't be changed.
Note it's easier to remember if the defaults are all #f, so we could change
mutable? to immutable?:
array-copy array [ storage-class generic-storage-class ] [ immutable?
#f ] [ safe? #f ]
or split into separate procedures:
array-copy array [ storage-class generic-storage-class ] [ safe? #f ]
array-immutable-copy array [ storage-class generic-storage-class ] [ safe? #f ]
It's especially mutability which needs to be prescribed by the SRFI or
you lose portability.
The safety setting shouldn't have any effect on a correct program,
so that makes more sense to keep as a parameter. I don't have a
preference there. I was just noting that if you want to make it an
object that acts like a parameter it's best to explicitly make it a
parameter.
--
Alex