From: SourceForge.net <no...@so...> - 2011-12-05 16:43:26
|
Bugs item #3451264, was opened at 2011-12-05 03:40 Message generated for change (Comment added) made by sds You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101355&aid=3451264&group_id=1355 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: clisp Group: lisp error >Status: Pending >Resolution: Invalid Priority: 5 Private: No Submitted By: Vladimir Lidovski (litwr) >Assigned to: Sam Steingold (sds) Summary: odd error with sort Initial Comment: It is about GNU CLISP strange behaviours. The version 2.33/2.48/2.49 were tested. Can anybody explain this oddness? (defun xsort (l) (sort l #'<)) ;XSORT (setq l '(3 1 2)) ;(3 1 2) (xsort l) ;(1 2 3) l ; surprize! (1 2 3) The ordinal lisp function XSORT takes its argument by value but the presence of SORT-function in its body converts argument to passed by reference! Are there any reasonable explanation? BTW the POP-function doesn't make surprize: (defun xpop (l) (pop l)) ;XPOP (setq l '(3 1 2)) ;(3 1 2) (xpop l) ;3 l ;(3 2 1) ---------------------------------------------------------------------- >Comment By: Sam Steingold (sds) Date: 2011-12-05 08:43 Message: This is the way lisp works. sort is a destructive function, it modifies the list structure. other CL implementations use different modifications, so l might not be the sorted list. however, both behaviors are standard-compliant. try this: (setq m l) (setq s (xsort l)) (eq m l) ==> t, because xsort cannot modify l (eq s l) ==> t, because that's how clisp works pop is a macro, so it modifies the its argument's value. xpop is a function, so it cannot modify the value of l. ---------------------------------------------------------------------- Comment By: Sam Steingold (sds) Date: 2011-12-05 08:43 Message: This bug report is now marked as "pending"/"invalid". This means that we think that the problem you report is not a problem with CLISP. Unless you - the reporter - act within 2 weeks, the bug will be permanently closed. Sorry about the inconvenience - we hope your silence means that you agree that this is not a bug in CLISP. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101355&aid=3451264&group_id=1355 |