Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Lisp > Re: delete comm...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 45 of 64 Topic 12469 of 13603
Post > Topic >>

Re: delete command weirdness

by tar@[EMAIL PROTECTED] (Thomas A. Russ) May 15, 2008 at 09:14 AM

Don Geddis <don@[EMAIL PROTECTED]
> writes:

> Namely: Why wasn't DELETE defined to be a macro like PUSH and POP?
> There are all the usual tradeoffs between macros and functions, like
> the lack of ability to FUNCALL macros, etc.  But the real question is:
> why did the decision come down differently for DELETE than it did for
> PUSH and POP?  The functionality of the three seems roughly analogous,
> suggesting that the macro/function tradeoffs would be the same.

Well, PUSH and POP really have to be macros, or else they don't make any
sense at all.  Without the rebinding of the value, they would be the
same as CONS and CAR.


> Is it merely for historical consistency?  Or is there a deeper reason
why
> DELETE was a function (leading to the OP's confusion) but PUSH/POP were
> able to have "more convenient" implementations?

If you want DELETE to be a macro, then symmetry would also dictate
that REMOVE should be a macro as well.  But then you lose some
functionality:

1.  You can't use higher-order functions like MAP, MAPCAR, etc. because
    they require functions as arguments, not macros.
2.  You lose the flexibility to assign the result to a different
    variable.  Now this is likely not a big issue with DELETE, since you
    can't really trust what is in the old variable, but with REMOVE it
    can be a major issue, where you may want to keep pointers to both
    before and after.  And you can't do that if the operators
    "helpfully" rebind the inputs for you.
3.  You are then also limited in what arguments you can pass to DELETE,
    since it has to be a SETF-able place.  So that means that the
    following code would break:
       (DELETE 'a (list 'a 'b 'c 'd 'e))
    because the list is not something you can setf.

Now I have seen people define additional macros to provide the
convenience that you request.  Something along the lines of 

(defmacro deletef (item place &rest other-args)
  `(setf ,place (delete ,item ,place ,@[EMAIL PROTECTED]
)))

I suppose that there are some potential issues with the simple macro
because of multiple evaluation of PLACE.  I'm not quite sure what the
solution to that would be, though.  Is there a way to improve it so that 

  (deletef 'a (aref table (incf i)))

would work properly?



-- 
Thomas A. Russ,  USC/Information Sciences Institute
 




 64 Posts in Topic:
delete command weirdness
Nathaniel Calloway <nt  2008-05-12 22:06:22 
Re: delete command weirdness
christopher.jay.jones@[EM  2008-05-12 20:18:16 
Re: delete command weirdness
vanekl <vanek@[EMAIL P  2008-05-12 20:30:24 
Re: delete command weirdness
Ken Tilton <kennytilto  2008-05-12 23:43:31 
Re: delete command weirdness
Nathaniel Calloway <nt  2008-05-13 01:18:20 
Re: delete command weirdness
Barry Margolin <barmar  2008-05-13 01:37:14 
Re: delete command weirdness
Barry Margolin <barmar  2008-05-13 01:42:59 
Re: delete command weirdness
Nathaniel Calloway <nt  2008-05-13 01:57:29 
Re: delete command weirdness
Peter Hildebrandt <pet  2008-05-13 09:51:03 
Re: delete command weirdness
usenet2.3.CalRobert@[EMAI  2008-05-13 20:59:47 
Re: delete command weirdness
usenet2.3.CalRobert@[EMAI  2008-05-13 19:06:55 
Re: delete command weirdness
Nathaniel Calloway <nt  2008-05-13 01:29:49 
Re: delete command weirdness
pjb@[EMAIL PROTECTED] (P  2008-05-13 15:50:36 
Re: delete command weirdness
Paul Donnelly <paul-do  2008-05-13 01:49:29 
Re: delete command weirdness
Ken Tilton <kennytilto  2008-05-13 09:50:31 
Re: delete command weirdness
Nathaniel Calloway <nt  2008-05-13 12:01:12 
Re: delete command weirdness
Rainer Joswig <joswig@  2008-05-13 18:22:44 
Re: delete command weirdness
Peter Hildebrandt <pet  2008-05-13 18:28:33 
Re: delete command weirdness
Ken Tilton <kennytilto  2008-05-13 13:35:10 
Re: delete command weirdness
Nathaniel Calloway <nt  2008-05-13 13:58:57 
Re: delete command weirdness
pjb@[EMAIL PROTECTED] (P  2008-05-14 12:21:22 
Re: delete command weirdness
Ken Tilton <kennytilto  2008-05-13 12:32:23 
Re: delete command weirdness
Geoffrey Summerhayes <  2008-05-13 01:06:51 
Re: delete command weirdness
Tomas Zellerin <zeller  2008-05-13 07:35:01 
Re: delete command weirdness
Peter Hildebrandt <pet  2008-05-13 17:58:20 
Re: delete command weirdness
David Crawford <crawfo  2008-05-13 09:16:36 
Re: delete command weirdness
kodifik@[EMAIL PROTECTED]  2008-05-13 09:53:06 
Re: delete command weirdness
Rainer Joswig <joswig@  2008-05-13 21:09:39 
Re: delete command weirdness
Kent M Pitman <pitman@  2008-05-13 15:45:57 
Re: delete command weirdness
Matthias Benkard <mulk  2008-05-13 10:38:56 
Re: delete command weirdness
Matthias Benkard <mulk  2008-05-13 10:42:29 
Re: delete command weirdness
Matthias Benkard <mulk  2008-05-13 11:14:46 
Re: delete command weirdness
Barry Margolin <barmar  2008-05-14 00:06:12 
Re: delete command weirdness
danb <sogwaldan@[EMAIL  2008-05-13 13:51:59 
Re: delete command weirdness
Mark Wooding <mdw@[EMA  2008-05-14 11:50:12 
Re: delete command weirdness
pjb@[EMAIL PROTECTED] (P  2008-05-14 14:27:46 
Re: delete command weirdness
Barry Margolin <barmar  2008-05-14 17:01:36 
Re: delete command weirdness
pjb@[EMAIL PROTECTED] (P  2008-05-15 12:16:09 
Re: delete command weirdness
tar@[EMAIL PROTECTED] (T  2008-05-14 14:23:02 
Re: delete command weirdness
Don Geddis <don@[EMAIL  2008-05-14 10:21:20 
Re: delete command weirdness
pjb@[EMAIL PROTECTED] (P  2008-05-15 12:28:05 
Re: delete command weirdness
Kent M Pitman <pitman@  2008-05-15 19:18:21 
Re: delete command weirdness
pjb@[EMAIL PROTECTED] (P  2008-05-16 09:45:07 
Re: delete command weirdness
tar@[EMAIL PROTECTED] (T  2008-05-16 09:43:25 
Re: delete command weirdness
tar@[EMAIL PROTECTED] (T  2008-05-15 09:14:35 
Re: delete command weirdness
Kent M Pitman <pitman@  2008-05-15 19:20:58 
Re: delete command weirdness
Don Geddis <don@[EMAIL  2008-05-15 13:37:16 
Re: delete command weirdness
Lars Brinkhoff <lars.s  2008-05-17 09:22:21 
Re: delete command weirdness
"Steven M. Haflich&q  2008-05-12 22:06:07 
Re: delete command weirdness
Nathaniel Calloway <nt  2008-05-13 01:43:34 
Re: delete command weirdness
Kent M Pitman <pitman@  2008-05-13 05:42:39 
Re: delete command weirdness
usenet2.3.CalRobert@[EMAI  2008-05-13 19:42:57 
Re: delete command weirdness
Kent M Pitman <pitman@  2008-05-14 00:54:58 
Re: delete command weirdness
kodifik@[EMAIL PROTECTED]  2008-05-13 05:48:34 
Re: delete command weirdness
Leandro Rios <leandrop  2008-05-13 10:03:12 
Re: delete command weirdness
pjb@[EMAIL PROTECTED] (P  2008-05-13 15:56:28 
Re: delete command weirdness
Leandro Rios <leandrop  2008-05-13 11:07:01 
Re: delete command weirdness
Kent M Pitman <pitman@  2008-05-13 15:35:05 
Re: delete command weirdness
kodifik@[EMAIL PROTECTED]  2008-05-13 07:13:40 
Re: delete command weirdness
rpw3@[EMAIL PROTECTED] (  2008-05-13 23:04:47 
Re: delete command weirdness
danb <sogwaldan@[EMAIL  2008-05-12 22:39:32 
Re: delete command weirdness
Kent M Pitman <pitman@  2008-05-13 06:27:32 
Re: delete command weirdness
danb <sogwaldan@[EMAIL  2008-05-13 04:10:36 
Re: delete command weirdness
tar@[EMAIL PROTECTED] (T  2008-05-13 15:53:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 2:08:53 CDT 2008.