From: Yet another Dan
Subject: No array update w/o setf?
Date: 
Message-ID: <eaf279$soa$1@wildfire.prairienet.org>
There's no explicit array update function in CL?
This doesn't work either way (defun or defmacro):

(defun|defmacro ref1 (array row col) (aref array (- row 1) (- col 1)))

(defun getrowcol ()
  ...
  (values row col))

(setf (ref1 *array* (getrowcol)) my-value)

From: Yet another Dan
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <eaf2jo$soa$2@wildfire.prairienet.org>
Yet another Dan wrote:
> (defun|defmacro ref1 (array row col) (aref array (- row 1) (- col 1)))

I mean

;(defun ref1 (array row col) (aref array (- row 1) (- col 1)))
;OR
;(defmacro ref1 (array row col) `(aref ,array (- ,row 1) (- ,col 1)))
From: Pascal Bourguignon
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <87wt9wzvj2.fsf@thalassa.informatimago.com>
Yet another Dan <········@vapornet.com> writes:

> There's no explicit array update function in CL?
> This doesn't work either way (defun or defmacro):
>
> (defun|defmacro ref1 (array row col) (aref array (- row 1) (- col 1)))
>
> (defun getrowcol ()
>  ...
>  (values row col))
>
> (setf (ref1 *array* (getrowcol)) my-value)

What's wrong with aref? 

(setf (aref *array* row col) my-value)


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.
From: Yet another Dan
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <eafcgm$e9$1@wildfire.prairienet.org>
Pascal Bourguignon wrote:
> What's wrong with aref? 

I'm starting index values from 1 instead of 0.
That's what ref1 does (for a 2D array).

I found something that works, but it's not very pretty:

(defmacro ref1 (array row col) `(aref ,array (- ,row 1) (- ,col 1)))

(defun set1 (array row col val) (setf (ref1 array row col) val))

...

(multiple-value-call #'set1 *array* (getrowcol) my-value)
From: Ken Tilton
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <4rKyg.7882$UY2.6160@fe11.lga>
Yet another Dan wrote:
> Pascal Bourguignon wrote:
> 
>> What's wrong with aref? 
> 
> 
> I'm starting index values from 1 instead of 0.

Because your array goes to eleven? I think this is The Real Problem. Why 
on earth do you want an array starting at one? I ask because I think The 
Great Contribution to society of computer science is the news that zero 
should have been the first natural number.

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Darren New
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <YQLyg.55$Vq1.15@tornado.socal.rr.com>
Ken Tilton wrote:
> Great Contribution to society of computer science is the news that zero 
> should have been the first natural number.

Actually, it's more the fact that a computer only does one thing at a 
time, so it can't point to something and increment the counter at the 
same time. So you wind up numbering the spaces between your objects 
instead of numbering the objects themselves.

-- 
   Darren New / San Diego, CA, USA (PST)
     This octopus isn't tasty. Too many
     tentacles, not enough chops.
From: Timofei Shatrov
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <44cbaebf.1956520@news.readfreenews.net>
On Sat, 29 Jul 2006 10:40:00 -0400, Ken Tilton <·········@gmail.com>
tried to confuse everyone with this message:

>
>
>Yet another Dan wrote:
>> Pascal Bourguignon wrote:
>> 
>>> What's wrong with aref? 
>> 
>> 
>> I'm starting index values from 1 instead of 0.
>
>Because your array goes to eleven? I think this is The Real Problem. Why 
>on earth do you want an array starting at one? I ask because I think The 
>Great Contribution to society of computer science is the news that zero 
>should have been the first natural number.
>

The first natural number is one. The zeroth is zero.

-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|
From: Ken Tilton
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <RyTyg.7937$UY2.6997@fe11.lga>
Timofei Shatrov wrote:
> On Sat, 29 Jul 2006 10:40:00 -0400, Ken Tilton <·········@gmail.com>
> tried to confuse everyone with this message:
> 
> 
>>
>>Yet another Dan wrote:
>>
>>>Pascal Bourguignon wrote:
>>>
>>>
>>>>What's wrong with aref? 
>>>
>>>
>>>I'm starting index values from 1 instead of 0.
>>
>>Because your array goes to eleven? I think this is The Real Problem. Why 
>>on earth do you want an array starting at one? I ask because I think The 
>>Great Contribution to society of computer science is the news that zero 
>>should have been the first natural number.
>>
> 
> 
> The first natural number is one. The zeroth is zero.

I like it. But the deeper lesson of CS was to stop counting and start 
measuring offsets.

kt


-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Yet another Dan
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <eagu25$g1r$2@wildfire.prairienet.org>
Ken Tilton wrote:
> Yet another Dan wrote:
>> Pascal Bourguignon wrote:
>>> What's wrong with aref? 
>> I'm starting index values from 1 instead of 0.
> Because your array goes to eleven?

Yea, that's it.  I figured it would work better starting from 1.
From: Ken Tilton
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <yHVyg.7955$UY2.5521@fe11.lga>
Yet another Dan wrote:
> Ken Tilton wrote:
> 
>> Yet another Dan wrote:
>>
>>> Pascal Bourguignon wrote:
>>>
>>>> What's wrong with aref? 
>>>
>>> I'm starting index values from 1 instead of 0.
>>
>> Because your array goes to eleven?
> 
> 
> Yea, that's it.  I figured it would work better starting from 1.

I figured. Well, you came to the right newsgroup. Look forward to your 
next question. :)

ken

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Rob Warnock
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <hOSdnfP6MMMB7VHZnZ2dnUVZ_rCdnZ2d@speakeasy.net>
Ken Tilton  <·········@gmail.com> wrote:
+---------------
| > I'm starting index values from 1 instead of 0.
|
| Because your array goes to eleven? I think this is The Real Problem.    
| Why on earth do you want an array starting at one? I ask because I 
| think The Great Contribution to society of computer science is the 
| news that zero should have been the first natural number.
+---------------
 
Indeed:
    
    "Why numbering should start at zero"
    Edsger W. Dijkstra
    11 August 1982
    http://www.cs.utexas.edu/~EWD/ewd08xx/EWD831.PDF
    http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

Common Lisp's pervasive convention on :START as an inclusive
bound and :END as an *exclusive* bound agrees with Dijkstra's
preferred "convention a)".


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Ken Tilton
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <x73zg.8152$UY2.6790@fe11.lga>
Rob Warnock wrote:
> Ken Tilton  <·········@gmail.com> wrote:
> +---------------
> | > I'm starting index values from 1 instead of 0.
> |
> | Because your array goes to eleven? I think this is The Real Problem.    
> | Why on earth do you want an array starting at one? I ask because I 
> | think The Great Contribution to society of computer science is the 
> | news that zero should have been the first natural number.
> +---------------
>  
> Indeed:
>     
>     "Why numbering should start at zero"
>     Edsger W. Dijkstra
>     11 August 1982
>     http://www.cs.utexas.edu/~EWD/ewd08xx/EWD831.PDF

Wow.

"And the moral of the story is that we had better regard -- after all 
these centuries! -- zero as a most natural number."

Great, now I am a plagiarist.

:)

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Lars Brinkhoff
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <85hd10oe1f.fsf@junk.nocrew.org>
Yet another Dan <········@vapornet.com> writes:
> I'm starting index values from 1 instead of 0.
> That's what ref1 does (for a 2D array).
>
> (defmacro ref1 (array row col) `(aref ,array (- ,row 1) (- ,col 1)))

(defun (setf ref1) (x array row col)
  (setf (aref array (1- row) (1- col)) x))
From: Pascal Bourguignon
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <87hd0zzof6.fsf@thalassa.informatimago.com>
Yet another Dan <········@vapornet.com> writes:

> Pascal Bourguignon wrote:
>> What's wrong with aref? 
>
> I'm starting index values from 1 instead of 0.
> That's what ref1 does (for a 2D array).
>
> I found something that works, but it's not very pretty:
>
> (defmacro ref1 (array row col) `(aref ,array (- ,row 1) (- ,col 1)))
>
> (defun set1 (array row col val) (setf (ref1 array row col) val))
>
> ...
>
> (multiple-value-call #'set1 *array* (getrowcol) my-value)


The Common Lisp style is to use accessor. Use REF1 both to read or to write.
The use of a macro like REF1 above is a quick and dirty hack to do it.

It could be written better as:

(defmacro ref1 (array &rest indices)
   `(aref ,array ,@(mapcar (lambda (index) `(1- ,index)) indices)))

The only drawback is that it cannot be used as a function like:

(mapcar (function aref) '(#(a b c) #(1 2 3) #("Hi" "Howdy" "Hello"))
                        '(1 2 3))

That's why the correct Common Lisp way to do it is to write two
functions, ref1 and (setf ref1), as has been demonstrated. (Better
make them accept any number of indices!)



But really, if you need to start indices from 1, which can be
understandable given some old algorithm, I'd rather lose one slot in
the array:

(loop :for i :from 1 :to (1- (length vector)) :do (process (aref vector i)))

works as well and loses only one slot, while:

(loop :for i :from 1 :to (length vector) :do (process (aref vector (1- i))))

works slower (O(n) substractions instead of 1).  


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Wanna go outside.
Oh, no! Help! I got outside!
Let me back inside!
From: Barry Margolin
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <barmar-276E05.12072229072006@comcast.dca.giganews.com>
In article <············@wildfire.prairienet.org>,
 Yet another Dan <········@vapornet.com> wrote:

> There's no explicit array update function in CL?
> This doesn't work either way (defun or defmacro):
> 
> (defun|defmacro ref1 (array row col) (aref array (- row 1) (- col 1)))


It should work if ref1 is a macro:

(defmacro ref1 (array row col)
  `(aref ,array (1- ,row) (1- ,col)))

SETF is supposed to expand the place as a macro.

> 
> (defun getrowcol ()
>   ...
>   (values row col))
> 
> (setf (ref1 *array* (getrowcol)) my-value)

ref1 requires 3 arguments, you're only providing 2.  You need to use 
MULTIPLE-VALUE-CALL to spread the values into multiple arguments, but 
this only works with functions, not macros, and I don't think SETF 
supports MULTIPLE-VALUE-CALL forms.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Yet another Dan
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <eagtrh$g1r$1@wildfire.prairienet.org>
Barry Margolin wrote:

>  Yet another Dan <········@vapornet.com> wrote:
>> (defun|defmacro ref1 (array row col) (aref array (- row 1) (- col 1)))

> It should work if ref1 is a macro:

multiple-value-call didn't work with a macro.
That's what I was trying to fix.

> ref1 requires 3 arguments, you're only providing 2.  You need to use 
> MULTIPLE-VALUE-CALL to spread the values into multiple arguments, but 
> this only works with functions, not macros, and I don't think SETF 
> supports MULTIPLE-VALUE-CALL forms.

That's what set1 is for.  ref1 is a macro, so it's eval'd before setf,
and set1 is a func, so MVC accepts it.
From: Pascal Costanza
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <4j32rbF62h23U1@individual.net>
Yet another Dan wrote:
> Barry Margolin wrote:
> 
>>  Yet another Dan <········@vapornet.com> wrote:
>>> (defun|defmacro ref1 (array row col) (aref array (- row 1) (- col 1)))
> 
>> It should work if ref1 is a macro:
> 
> multiple-value-call didn't work with a macro.
> That's what I was trying to fix.
> 
>> ref1 requires 3 arguments, you're only providing 2.  You need to use 
>> MULTIPLE-VALUE-CALL to spread the values into multiple arguments, but 
>> this only works with functions, not macros, and I don't think SETF 
>> supports MULTIPLE-VALUE-CALL forms.
> 
> That's what set1 is for.  ref1 is a macro, so it's eval'd before setf,
> and set1 is a func, so MVC accepts it.

The only reason I can see why you'd want both a macro and a function is 
efficiency. In general, it shouldn't be necessary to write macros for 
efficiency, though. Just declare / declaim your functions to be inline:

(declaim (inline ref1 (setf ref1)))

(defun ref1 (...) ...)
(defun (setf ref1) (...) ...)

If you need more control over the inline expansion, you can use compiler 
macros. They are similar to macros, but they are _exclusively_ used for 
efficiency, and more importantly can have the same name as existing 
functions:

(define-compiler-macro ref1 (...) ...)
(define-compiler-macro (setf ref1) (...) ...)

The CL compiler can the optionally use the respective compiler macro 
instead of calling a function, but you can still use the function as a 
first-class value (as in multiple-value-call, for example).

However, the general rule of thumb for optimization applies: your 
guesses at what improves efficiency and what doesn't are probably wrong, 
so don't waste too much time on this. Declaring a function to be inlined 
is straightforward, but anything else requires more work than probably 
pays off.


Pascal

-- 
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/
From: Yet another Dan
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <eajldb$obt$1@wildfire.prairienet.org>
Pascal Costanza wrote:
> The only reason I can see why you'd want both a macro and a function is 
> efficiency.
> (defun ref1 (...) ...)
> (defun (setf ref1) (...) ...)

setf still needs to see aref explicitly, even if it's in the definition.

(defmacro aarc1 () (aref array (- row 1) (- col 1)))

(defun       ref1  (array row col)           (aarc1))
(defun (setf ref1) (array row col val) (setf (aarc1) val))
From: Yet another Dan
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <eajmfc$oj7$1@wildfire.prairienet.org>
Pascal Costanza wrote:
> (defun (setf ref1) (...) ...)

But thanks for pointing out the (setf foo) notation.
I hadn't noticed that in the manual.
From: Lisper
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <1154456087.761485.87070@m79g2000cwm.googlegroups.com>
Yet another Dan wrote:
> There's no explicit array update function in CL?
> This doesn't work either way (defun or defmacro):
>
> (defun|defmacro ref1 (array row col) (aref array (- row 1) (- col 1)))
>
> (defun getrowcol ()
>   ...
>   (values row col))
>
> (setf (ref1 *array* (getrowcol)) my-value)

I tried to write AREF analogue for function which returns multiple
indexes. According your example the code below does precisely what you
want.

(define-setf-expander aref2 (ar form &environment env)
  (let ((row (gensym))
        (col (gensym)))
    (multiple-value-bind (dvars vals newval setter getter)
(get-setf-expansion `(aref ,ar ,row ,col) env)
      (declare (ignore setter))
      (values dvars
              `(,(car vals))
              newval
              `(multiple-value-bind (,row ,col) ,form ((setf aref)
,@newval ,(car dvars) ,row ,col))
              getter))))

(defmacro aref2 (ar form)
 (let ((row (gensym))
       (col (gensym)))
  `(multiple-value-bind (,row ,col) ,form
     (aref ,ar ,row ,col))))

(defun get-row-col () ;; example function returning indexes
  (values 1 1))

(setf *array* (make-array '(10 10) :initial-element 1))

(setf (aref2 *array* (get-row-col)) 15)  => 15
(aref2 *array* 1 1) => 15

The code suitable only for 2D arrays, but it can be modified to work
for any number of indexes and can work without calling GET-ROW-COL to
emulate arrays with indexes started from 1.
From: Pascal Bourguignon
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <87wt9rt0gv.fsf@thalassa.informatimago.com>
"Lisper" <···········@mail.ru> writes:

> Yet another Dan wrote:
>> There's no explicit array update function in CL?
>> This doesn't work either way (defun or defmacro):
>>
>> (defun|defmacro ref1 (array row col) (aref array (- row 1) (- col 1)))
>>
>> (defun getrowcol ()
>>   ...
>>   (values row col))
>>
>> (setf (ref1 *array* (getrowcol)) my-value)
>
> I tried to write AREF analogue for function which returns multiple
> indexes. According your example the code below does precisely what you
> want.
>
> (define-setf-expander aref2 (ar form &environment env)
>   (let ((row (gensym))
>         (col (gensym)))
>     (multiple-value-bind (dvars vals newval setter getter)
> (get-setf-expansion `(aref ,ar ,row ,col) env)
>       (declare (ignore setter))
>       (values dvars
>               `(,(car vals))
>               newval
>               `(multiple-value-bind (,row ,col) ,form ((setf aref)
> ,@newval ,(car dvars) ,row ,col))
>               getter))))
>
> (defmacro aref2 (ar form)
>  (let ((row (gensym))
>        (col (gensym)))
>   `(multiple-value-bind (,row ,col) ,form
>      (aref ,ar ,row ,col))))
>
> (defun get-row-col () ;; example function returning indexes
>   (values 1 1))
>
> (setf *array* (make-array '(10 10) :initial-element 1))
>
> (setf (aref2 *array* (get-row-col)) 15)  => 15

I would say that this is really very bad form.
It's very confusing and contrary to the Common Lisp spirit.

AREF is a function:  (mapcar (function aref) '(#(1 2) #(a b)) '(1 2))


> (aref2 *array* 1 1) => 15
>
> The code suitable only for 2D arrays, but it can be modified to work
> for any number of indexes and can work without calling GET-ROW-COL to
> emulate arrays with indexes started from 1.
>

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

ADVISORY: There is an extremely small but nonzero chance that,
through a process known as "tunneling," this product may
spontaneously disappear from its present location and reappear at
any random place in the universe, including your neighbor's
domicile. The manufacturer will not be responsible for any damages
or inconveniences that may result.
From: Pascal Bourguignon
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <877j1qud58.fsf@thalassa.informatimago.com>
(Sorry, if you see another, incomplete, answer from me, I have
absolutely no idea who gnus sent it when I put my laptop on the
table...)


"Lisper" <···········@mail.ru> writes:
> [...]
> (setf (aref2 *array* (get-row-col)) 15)  => 15
> [...]

I would say that this is really very bad form.
It's very confusing and contrary to the Common Lisp spirit.

- AREF is a function: 

     (mapcar (function aref) '(#(1 2) #(a b)) '(0 1)) --> (1 B)

  but AREF2 is not.


- The arguments to a function are evaluated, and only the first value
  of each is passed to the function, unless you explicitely use
  MULTIPLE-VALUE-CALL.  The behavior of AREF2 is very surprizing.  Any
  normal Common Lisp programmer would expect it to receive only the
  first value returned by GET-ROW-COL.


- There's no reason why it should work only with a fixed number of indices.




If you insist on this way, the correct way to express it would be:

(let ((a #2A((1 2)(3 4)))) 
    (print (multiple-value-call (function aref) a (values 0 1)))
    (setf  (multiple-value-call (function aref) a (values 0 1)) 99)
    (print (multiple-value-call (function aref) a (values 0 1))))

To make it work, you'll just have to define a setf expansion for
MULTIPLE-VALUE-CALL, and then it would even work with other forms,
such as:

 (setf (multiple-value-call (function nth) (values some-index some-list))
       some-value)



Now, if you forgot about multiple values, you could easily use _lists_
of indices:

[26]> (let ((a #2A((1 2)(3 4)))) 
        (print (apply (function aref) a (list 0 1)))
        (setf  (apply (function aref) a (list 0 1))  99)
        (print (apply (function aref) a (list 0 1)))
        :better)

2 
99 
:BETTER


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Wanna go outside.
Oh, no! Help! I got outside!
Let me back inside!
From: Lisper
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <1154961643.684477.147260@i3g2000cwc.googlegroups.com>
Pascal Bourguignon wrote:
> "Lisper" <···········@mail.ru> writes:
> > [...]
> > (setf (aref2 *array* (get-row-col)) 15)  => 15
> > [...]
>
> I would say that this is really very bad form.
> It's very confusing and contrary to the Common Lisp spirit.
>
> - AREF is a function:
>
>      (mapcar (function aref) '(#(1 2) #(a b)) '(0 1)) --> (1 B)
>
>   but AREF2 is not.

You are right on good few. My purpose was to make SETF expansion for
function call returning indexes. Solution is far from being perfect of
course but it does what "Yet another Dan" mean in his first example:

(setf (ref1 *array* (getrowcol)) my-value)

The main motivation was simply to prove (to myself) that in Lisp if you
want - you can solve even such problem. I am not serious SETF macro
hacker in any way ;-)

> - The arguments to a function are evaluated, and only the first value
>   of each is passed to the function, unless you explicitely use
>   MULTIPLE-VALUE-CALL.  The behavior of AREF2 is very surprizing.  Any
>   normal Common Lisp programmer would expect it to receive only the
>   first value returned by GET-ROW-COL.

If he (she) don't know what is AREF2. But I think you are right, this
is abviously not good  Lisp style.

> If you insist on this way, the correct way to express it would be:
>
> (let ((a #2A((1 2)(3 4))))
>     (print (multiple-value-call (function aref) a (values 0 1)))
>     (setf  (multiple-value-call (function aref) a (values 0 1)) 99)
>     (print (multiple-value-call (function aref) a (values 0 1))))
>
> To make it work, you'll just have to define a setf expansion for
> MULTIPLE-VALUE-CALL, and then it would even work with other forms,
> such as:
>
>  (setf (multiple-value-call (function nth) (values some-index some-list))
>        some-value)

It is comprehensible but bulky.


> Now, if you forgot about multiple values, you could easily use _lists_
> of indices:
>
> [26]> (let ((a #2A((1 2)(3 4))))
>         (print (apply (function aref) a (list 0 1)))
>         (setf  (apply (function aref) a (list 0 1))  99)
>         (print (apply (function aref) a (list 0 1)))
>         :better)

How about performance and unneeded consing ?

Anyway thank you for good Lisp style lesson.

Lisper.
From: Pascal Bourguignon
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <87vep4h96w.fsf@thalassa.informatimago.com>
"Lisper" <···········@mail.ru> writes:

>> To make it work, you'll just have to define a setf expansion for
>> MULTIPLE-VALUE-CALL, and then it would even work with other forms,
>> such as:
>>
>>  (setf (multiple-value-call (function nth) (values some-index some-list))
>>        some-value)
>
> It is comprehensible but bulky.

Yes.
Then you can use a macro or macrolet to make it short and easy to type ;-)


>> Now, if you forgot about multiple values, you could easily use _lists_
>> of indices:
>>
>> [26]> (let ((a #2A((1 2)(3 4))))
>>         (print (apply (function aref) a (list 0 1)))
>>         (setf  (apply (function aref) a (list 0 1))  99)
>>         (print (apply (function aref) a (list 0 1)))
>>         :better)
>
> How about performance and unneeded consing ?

Usually, short lived consing is well optimized.

But, if you're managing indices like that, perhaps they'll be longer
lived and the consing won't be unneeded after all.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

HANDLE WITH EXTREME CARE: This product contains minute electrically
charged particles moving at velocities in excess of five hundred
million miles per hour.
From: Lisper
Subject: Re: No array update w/o setf?
Date: 
Message-ID: <1154456946.556006.136230@b28g2000cwb.googlegroups.com>
Emulation of array with indexes started from 1

(define-setf-expander aref-1-based (ar row col &environment env)
    (multiple-value-bind (dvars vals newval setter getter)
(get-setf-expansion `(aref ,ar ,row ,col) env)
      (values dvars
              vals
              newval
              `(let ((,(second dvars) (1- ,row))
                     (,(third dvars) (1- ,col)))
                 ,setter)
              getter)))

(setf *array* (make-array '(10 10) :initial-element 5))
(setf (aref-1-based *array* 1 1) 443) => 443 ;; set elements 1 1
(indexes started from 1)

(aref *array* 0 0) => 443 ;; check at 0 0 (indexes started from 0)