[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: name an array function
From: |
Daniel Llorens |
Subject: |
Re: name an array function |
Date: |
Thu, 15 Dec 2016 12:12:58 +0100 |
On 23 Nov 2016, at 21:48, David Pirotte <address@hidden> wrote:
> Le Wed, 23 Nov 2016 17:07:30 +0100,
> Daniel Llorens <address@hidden> a écrit :
>
>> On 21 Nov 2016, at 14:56, address@hidden wrote:
>>
>>> I (politely) disagree: the most "commonly" used function is
>>> already array-ref, so you would seldomly use array-from/slice
>>> for a scalar result (the rank-0 result will be more frequent,
>>> because there's no substitute). But hey, as I said.
>>
>> I don't use array-ref/set! anymore since array-from/amend! generalize them. I
>> actually use a further generalization in a separate library :p
>>
>> But I have a proposal below that makes this discussion moot, I hope.
>>
>> | master (current) | meaning | proposal
>> |
>> |---------------------+----------------------------------+----------------------|
>> | array-from* | look up subarray, even #0(x) | array-slice
>> |
>> | array-from | look up cell, so x and not #0(x) | array-cell-ref
>> |
>> | array-amend! | set cell | array-cell-set!
>> |
>> | array-for-each-cell | iterate over subarrays |
>> array-for-each-slice |
>
> I'd use
>
> array-slice-ref/set!
> array-slice-for-each
>
> Unless I miss understood something :)
>
> Cheers,
> David
The slice/cell distinction is to be able to use the array as a list of items
regardless of whether the items have rank 0 or not.
array-slice doesn't need -ref or -set! variants because it always returns an
array object, so you can do (array-copy! B (array-slice A ...)) or (array-copy!
(array-slice A ...) B). On the other hand array-cell-ref may return a non-array
object so the -set! variant is necessary.
array-for-each-cell -> array-slice-for-each is ok I think b/c it really does
iterate over slices and not cells.
So what about this? if there's no comment in a week or so I'll take it as
settled.
| master (current) | meaning | proposal
|
|---------------------+----------------------------------+----------------------|
| array-from* | look up subarray, even #0(x) | array-slice
|
| array-from | look up cell, so x and not #0(x) | array-cell-ref
|
| array-amend! | set cell | array-cell-set!
|
| array-for-each-cell | iterate over subarrays | array-slice-for-each
|
Thanks
Daniel
- Re: name an array function,
Daniel Llorens <=