For psetf, if more than one pair is supplied then the assignments of new values to places are done in parallel. More precisely, all subforms (in both the place and newvalue forms) that are to be evaluated are evaluated from left to right; after all evaluations have been performed, all of the assignments are performed in an [color=#FF0000]unpredictable order.[/color]

Unpredictable order?? I can't believe you can't predict the order of such a computer language function output!!

filfil wrote: I can't believe you can't predict the order of such a computer language function output!!

In this context "unpredictable" means that it depends on the implementation and the state of the system as whole, which means that even if you can predict the order in some circumstances, programs depending on that order do not conform to the standard and therefore such programs failing if any of the circumstances change is a bug in the program and not in the language. For example, both implementations for machines that allow only serial memory writes that simulate the parallel assignment and implementations for machines capable of truly parallel assignments are allowed by the standard, but the execution flow of a conforming program should not depend on the type of a machine it runs on.

filfil wrote:If psetf evaluations were done in parallel, I would expect x => (X 1 2 3), and not (X 1 A 3).

Conses in Common Lisp are mutable, and in this example the cons bound to X is mutated to refer to symbol X and the cons chain (that is, a list) bound to Y, which is itself mutated to contain A in second position. Parallel assignment allows the A to be retrieved from the cons bound to X before it is mutated.

Interesting feature. It's like Scheme only that side effects are from left to right Since the standard undefines it it will probably be the same order for each time the same chunk of code is run on the same CL-implementation but the order might even change from one expression to another as a compiler optimization perhaps.

Unpredictable (or any order) is usual a sign that compiler writers are given some space to do it in the most efficient order and a hint that even though it's predictable in your test every time, it might not be in a different environment.

PSETF and SETF are like LET and LET*, if you want to depend on the order, then use the second, and if not the first.

At a higher level, PSETF exists for the same reason as PROG1 (a variant of PROGN that returns the value of the FIRST form and not the last), writing programs that require these types of construct in a language that doesn't supply them requires that your program uses explicit temporary variables, which can make your program less obvious in its behaviour. You only use them when necessary. The trade-off is that the language is a little larger, so people who don't know what they do need to look them up, but aren't we all using lisp because we are happy with that?