4 ms·
> I'm just not sure I actually understand how that distinction is supposed to be implemented by the "semantic indentation" style. Given an expression such as (
by hibbelig 6y ago
> I'm just not sure I actually understand how that distinction is supposed to be implemented by the "semantic indentation" style.
Given an expression such as (foo bar baz), semantic indentation examines foo to determine whether it is a macro or a function, and produces two different indentations depending on the result.
Fixed indentation always produces the same result, regardless of whether foo is a macro or not.
The "semantic" in the name refers to the deeper analysis required: If you see a "defmacro" somewhere then you have to remember that it is a macro.
(I think actually, it's a bit more complicated. Macros can have multiple arguments, and one is often special. Look at the control structure "when": it receives a condition and multiple "statements", and when the condition is true all statements are executed, in order. And semantic indentation knows this. So you get this:
(when CONDITION
STMT-1
STMT-2)
But when you put the condition on an extra line, you get this:
(when
CONDITION
STMT-1
STMT-2)
Fixed indentation has no idea and produces the following hard-to-read thing instead:
(when
CONDITION
STMT-1
STMT-2)
- ulrikrasmussen 6y agoThank you, this makes sense.