After brief discussion on #lisp, I hereby suggest a macro for inclusion in Alexandria. The macro in question is NOTF. ## Reason: An example code (from my own project) for negating the value of a place is: (setf (left-now-p (walk-parent shape)) (not (left-now-p (walk-parent shape)))) This code is problematic because a) it causes double evaluation of place subforms, b) it's long and repetitive. I would rather write: (notf (left-now-p (walk-parent shape))) Lisp has modify macros like INCF/DECF for numbers but does not have such a macro for booleans. It seems like a trivial utility, but also one that might be easily overlooked. ## Upsides: The place is evaluated only once. The resulting code is shorter. ## Downsides None that I can see at the moment. ## Code: ;; Please forgive me - I am not used to making PRs by mail. (export 'notf :alexandria) (define-modify-macro notf () not "Sets the value of PLACE to its logical negation and returns the new value.") ---------------- BR Michal "phoe" Herda
participants (1)
-
phoe@teknik.io