Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!vsi1!wyse!mips!synthesis!len From: len@synthesis.Synthesis.COM (Len Lattanzi) Newsgroups: comp.lang.lisp Subject: Re: what does "destructively sorted" mean in KCL? Message-ID: <24714@mips.mips.COM> Date: 4 Aug 89 21:23:41 GMT References: <3916@phri.UUCP> Sender: news@mips.COM Reply-To: len@synthesis.synthesis.com (Len Lattanzi) Organization: Synthesis Software Solutions Inc, Sunnyvale, CA Lines: 33 In article <3916@phri.UUCP> roy@phri.UUCP (Roy Smith) writes: :>(setq foo '(1 3 9 4 -2 0 9)) :(1 3 9 4 -2 0 9) : :>foo :(1 3 9 4 -2 0 9) : :>(sort foo #'>) Consider that you're handing to sort a cons-cell that looks like [1 . (3 9 4 -2 0 9)] Sort can change the cdr but no matter what foo will still point to this cons-cell and in this case the car will not be smashed by sort. :(9 9 4 3 1 0 -2) : :>foo :(1 0 -2) : : Sort returns a sorted list as its value, but the argument gets :trashed. Is this really the way it's supposed to work? Do I have to do :(setq foo (sort foo #'>)) to get it to work? Yes :-- :Roy Smith, Public Health Research Institute :455 First Avenue, New York, NY 10016 :{att,philabs,cmcl2,rutgers,hombre}!phri!roy -or- roy@alanine.phri.nyu.edu :"The connector is the network" \ Len Lattanzi ({ames,pyramid,decwrl}!mips!synthesis!len) Synthesis Software Solutions, Inc. The RISC Software Company I would have put a disclaimer here but I already posted the article.