From: SRS
Subject: Two Questions
Date: 
Message-ID: <91fqea$rn6$1@nnrp1.deja.com>
I have two (unrelated) questions, but I thout I would submit them in
one post.

Firstly, why is the function last not an accessor? I would, for
example, like to change the end of a list by doing
    (setf (rest (last some-list)) new-ending)
but this is not possible, I must use
    (setf some-list (nconc some-list new-ending))

Secondly, why are the functions notany and notevery _not_ deprecated?
In the 'deprecation spree' of X3J13 vote TEST-NOT-IF-NOT:FLUSH-ALL many
functions such as
    (remove-if-not ...) were deprecated because they could be written as
    (remove-if (complement ...) ...)
This is also the case with notany and notevery, so why were they not
deprecated? I think they should be, the are superfluous, and removing
them will reduce the size of CLtS.

Thanks in advance.

-- SRS


Sent via Deja.com
http://www.deja.com/

From: Tim Bradshaw
Subject: Re: Two Questions
Date: 
Message-ID: <nkjzohwv5qp.fsf@tfeb.org>
SRS <·····@my-deja.com> writes:

> I have two (unrelated) questions, but I thout I would submit them in
> one post.
> 
> Firstly, why is the function last not an accessor? I would, for
> example, like to change the end of a list by doing
>     (setf (rest (last some-list)) new-ending)
> but this is not possible, I must use
>     (setf some-list (nconc some-list new-ending))
> 

I think this works.  It's not an issue of whether LAST has a SETF
method, actually, it's an issue of whether REST has, and it does.


> Secondly, why are the functions notany and notevery _not_ deprecated?
> In the 'deprecation spree' of X3J13 vote TEST-NOT-IF-NOT:FLUSH-ALL many
> functions such as
>     (remove-if-not ...) were deprecated because they could be written as
>     (remove-if (complement ...) ...)
> This is also the case with notany and notevery, so why were they not
> deprecated? I think they should be, the are superfluous, and removing
> them will reduce the size of CLtS.
> 

I think this is academic because no one seems to want remove-if-not
and so on to go away any more.

--tim
From: Tim Bradshaw
Subject: Re: Two Questions
Date: 
Message-ID: <nkjy9xgv5js.fsf@tfeb.org>
Tim Bradshaw <···@tfeb.org> writes:

> I think this works.  It's not an issue of whether LAST has a SETF
> method, actually, it's an issue of whether REST has, and it does.
> 

Incidentally, here's why it isn't about LAST:

(defun my-rest (l)
  (cdr l))

(defun (setf my-rest) (new l)
  (rplacd l new)
  new)

--tim
From: SRS
Subject: Re: Two Questions
Date: 
Message-ID: <91g8c8$5k1$1@nnrp1.deja.com>
In article <···············@tfeb.org>,
  Tim Bradshaw <···@tfeb.org> wrote:
> SRS <·····@my-deja.com> writes:
>
> > I have two (unrelated) questions, but I thout I would submit them in
> > one post.
> >
> > Firstly, why is the function last not an accessor? I would, for
> > example, like to change the end of a list by doing
> >     (setf (rest (last some-list)) new-ending)
> > but this is not possible, I must use
> >     (setf some-list (nconc some-list new-ending))
> >
>
> I think this works.  It's not an issue of whether LAST has a SETF
> method, actually, it's an issue of whether REST has, and it does.
>

Sorry, you are right. What I meant to say is that something similar to
the following code does not work. Why doesn't it?
    (setf (last some-list) new-ending)

-- SRS


Sent via Deja.com
http://www.deja.com/
From: Arseny Slobodjuck
Subject: Re: Two Questions
Date: 
Message-ID: <3a3c2d45.2434620@news.online.ru>
On Sat, 16 Dec 2000 17:22:20 GMT, SRS <·····@my-deja.com> wrote:

>> > Firstly, why is the function last not an accessor? I would, for
>> > example, like to change the end of a list by doing
>> >     (setf (rest (last some-list)) new-ending)
>> > but this is not possible, I must use
>> >     (setf some-list (nconc some-list new-ending))
>> >
>>
>> I think this works.  It's not an issue of whether LAST has a SETF
>> method, actually, it's an issue of whether REST has, and it does.

Some time ago I asked similar question and considered 
using some pretty cool expression for pushing of 1 element 
to the end of list 

(defun push-end(list last)
      (rplacd (last list) (list last)))

Unfortunately, it doesn't work on an empty list.

>
>Sorry, you are right. What I meant to say is that something similar to
>the following code does not work. Why doesn't it?
>    (setf (last some-list) new-ending)

Really don't know. But you may use last but one element since 
cdr of cons is accessor. Next expression works 
only when (list-length some-list) > 1

(rplacd  (last  2 some-list) new-ending)
From: Erik Naggum
Subject: Re: Two Questions
Date: 
Message-ID: <3185968261469225@naggum.net>
* SRS <·····@my-deja.com>
| Firstly, why is the function last not an accessor?

  Because (setf (last x n)) == (setf (cdr (last x (1+ n)))) in the specific
  case where you can modify the cdr of the cons pointing to the last cons
  because (last x n) is different from (last x (1+ n)).  When they return
  the same value, you have a problem.

  Besides, you aren't asking for last, but rest or cdr and both of those
  are certainly accessors in the language.  Maybe they aren't in your
  implementation, but if so, that's a reportable non-conformance bug.

#:Erik
-- 
  The United States of America, soon a Bush league world power.  Yeee-haw!