Re: Following up on SRFI 179
Bradley Lucier 25 Sep 2021 16:43 UTC
On 9/25/21 9:23 AM, Alex Shinn wrote:
>> 3) (array-append k a1 a2 ...)
>>
>> 4) (array-laminate k a1 a2 ...)
> Both of these are provided by (chibi math linalg):
> https://github.com/ashinn/alschemist/blob/master/chibi/math/linalg.scm
> For consistency with numpy, laminate is called stack, and the axis
> refers to the result dimension so has the more natural domain [0,
> res-dim).
> They are fairly general and I agree should be in the base library
> rather than a linear algebra library.
How about this for names and signatures? Square brackets denote
optional arguments:
(define (array-stack [storage-class
[safe? (specialized-array-default-safe?)
[mutable? (specialized-array-default-mutable?)]]]
k array . arrays)
)
(define (array-append [storage-class
[safe? (specialized-array-default-safe?)
[mutable? (specialized-array-default-mutable?)]]]
k array . arrays)
)
So if you want to specify mutable? you need to specify both
storage-class and safe?.
I don't think storage-class should have a default. If storage-class is
not given then (a) if all arrays are specialized and have the same
storage-class, then that's the storage-class of the result, otherwise
(b) it's an error. Every default I can imagine can lead to surprising
errors down the road.
Because safe? and mutable? must be booleans and k must be an exact
integer, this argument list can be parsed (barely ;-).
Also, I think that these should return a newly allocated specialized
array even if arrays is the empty list.
Thoughts?
Brad