From ... From: Erik Naggum Subject: Re: problem with delete Date: 2000/10/02 Message-ID: <3179487227972133@naggum.net>#1/1 X-Deja-AN: 676646596 References: <8r9vam$ie5$1@curofix.ida.liu.se> <2hem1zflv0.fsf@dslab7.cs.uit.no> mail-copies-to: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 970498446 6222 195.0.192.66 (2 Oct 2000 14:54:06 GMT) Organization: Naggum Software; vox: +47 800 35477; gsm: +47 93 256 360; fax: +47 93 270 868; http://naggum.no; http://naggum.net User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 Mime-Version: 1.0 NNTP-Posting-Date: 2 Oct 2000 14:54:06 GMT Newsgroups: comp.lang.lisp * Frode Vatvedt Fjeld | You are _supposed_ to do (setf foo (delete 1 foo)). Simply doing | (delete 1 foo) has an undefined result. No, it is very well defined. It just isn't what some people expect. | To understand this, note that DELETE is a function, and so takes | arguments by value. There is nothing wrong with a delete function that modifies the list such that the variables keeps pointing to a list sans the first element. (delete 1 (vector 1 2 3 4 5)) manages this, remember? | This is a general rule that applies to most (or all?) destructive | functions: They should be called exactly the same way you would call | their non-destructive counterparts. Good point. However, recall that they are allowed to nuke their arguments, so if you got any of those (susceptible) arguments from someone else and you haven't agreed on an object ownership protocol, you'd better be careful not to alter somebody else's objects. #:Erik -- If this is not what you expected, please alter your expectations.