From: SourceForge.net <no...@so...> - 2011-12-07 08:05:55
|
Bugs item #3451264, was opened at 2011-12-05 03:40 Message generated for change (Comment added) made by litwr 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: Open 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: Vladimir Lidovski (litwr) Date: 2011-12-07 00:05 Message: Thank you. These behaviours of SORT can produce nightmare side effects. The SORT is destructive. This is ok but XSORT is programmed as normal function! IMHO these odd things should be well documented. IMHO this is severe bug without proper documentation. ---------------------------------------------------------------------- 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 |