2026-04-23 07:05 UTC
On the lesser topic.
There are at least two notable things about `setf'
(the first one smaller, the second one bigger).
I. It eliminates the need for explicit setters.
If you know how to write a form to get something, you automatically know how to write a form to set it.
II. Modify macros become available.
To illustrate with `incf':
(let ((h (make-hash-table)))
(incf (gethash 'foo h 0))
(gethash 'foo h))
works and evaluates to 1.
(Does not fail trying to increment a non-existent element.)
This is noticeably different from the typical operation of `+='.
See also `define-modify-macro'.
I'll leave the greater topic, mutability and immutability, for another day.
_________
Disclosure
I am a descendant of barbarians, who settled in the old Roman province of Thracia.
Civis serdicensis sum.
🙂
#CommonLisp
#Lisp
@simon_brooke@mastodon.scot @janneke@todon.nl @spook@pleroma.m68k.church
@pascal_costanza@functional.cafe
Replies (0)
No replies.