by PrettyButUgly · 10y ago · 0 comments
if condition:
a, b, c = c, a, b
a, c, b = b, a, c
That really seems much more clear than the gymnastics my mind has to do manually pairing the assignments inside of psetf. I won't argue that it's objectively better syntax, but I still think it is. (define-syntax assign-group!
(ir-macro-transformer
(lambda (x i c)
(let ((vars (cadr x))
(vals (caddr x)))
`(let ,(map (lambda (var val) '(var val)) vars vals)
,@(map (lambda (var)
`(set! ,(i var) ,var)) vars))))))
Mind, I haven't tested this, because I don't have CHICKEN Scheme (the dialect this is written in) in front of me, and I may not have matched all the parens on the end, but it should work like this: (assign-group! (a b c) (c a b))
Giving you your nice assigment syntax you wanted.That's the nice thing about Lisps: if you don't like it, you can change it.
(rotatef a c b) ;; a <-- c <-- b
;; `--->----->-'