Lisp: Macros all the way down
One of the great features many Lisp languages share is that they try to have an extremely tiny core language and then just implement everything else in it.
To the point that out of the relatively small standard library of Common Lisp which exports 978 symbols, only 25 of these are special forms that aren’t implemented as functions or macros.
Of these special forms some are meant for specific usecases, I’d be willing to say 18 of these are the ones appearing in all code.
Macros probably hide the best among these
as we do understand that a #'vector or #'+ are functions
however and or defun are not obviously macro
and might easily be mistaken for being part of the language.
and is just a macro expanding to a bunch of if statements, (and x y z) becomes (if (if x y) z).
Even definitions aren’t safe,
in a simplified way (defun foo (x) x) expands to
(setf (symbol-function 'foo) (lambda (x) x)).
And of course defmacro is also just a macro
setting macro.
defstruct is obvious, it expands to functions that register the type.
setf is magical as it has to run everything up to the n - 1th step
and then instead expands to the (setf ...) bound function
to set the resulting place.
So (setf (car (cdr x)) 2) would expand along the lines of
(rplaca (cdr x) 2).
On that note (incf x) is just (setf x (+ 1 x)).
Common Lisp doesn’t have built-in for-loops,
it doesn’t need them, loop is a famous macro which for
things like (loop :for i :to 10 :do (print i))
generates:
This code is obviously simplified, as there are some optimizing constructs in play and many declarations are made to aid efficiency.
The entire object system is a library, control flow is mostly a library, isn’t it beautiful?
The great advantage of this is that when you don’t understand a construct, you don’t have to inspect the binary of the compiler, for the most part desugared Lisp is your assembly in which you can view the world and to which you compile your programs with macros helping along the way.