# macro/splice
Inline the elements of a list into the surrounding form during macro
expansion. Also written `macro/unquote-splice`.
`[macro/splice $list]` (or `[macro/unquote-splice $list]`) is used inside
`macro/quote` or `macro/syntax-quote` to spread a list's elements as
individual arguments, rather than inserting the list as a single value.
## Syntax
[macro/splice $expr] # canonical [macro/unquote-splice $expr] # alias
`macro/splice` must use `[...]` brackets. Deft's `( ... )` parens are
infix-only — `(macro/splice $x)` is a syntax error.
## Example
defmacro call-with {|func @args| [macro/quote [macro/unquote $func [macro/splice $args]]] } [call-with str "a" "b" "c"] # expands to [str "a" "b" "c"] → "abc"
The macro's `@args` rest-collector binds to `@{"a" "b" "c"}`. Inside the
quoted call, `[macro/splice $args]` inlines the three elements as
separate arguments to `str`.
## Without macro/splice
Inserting the list directly lands the whole vector as a single arg:
defmacro call-with-broken {|func @args| [macro/quote [macro/unquote $func $args]] } [call-with-broken str "a" "b" "c"] # expands to [str @{"a" "b" "c"}] → wrong!
## macro/splice vs spread
`macro/splice` operates at compile time during macro expansion — it
inlines AST elements. The `..$xs` spread operator operates at
runtime when calling a function:
def f {|a b c| ($a + $b + $c)} def xs @{1 2 3} [f ..$xs] # runtime spread — passes 1, 2, 3 as three args
Use `macro/splice` inside `macro/quote`/`macro/syntax-quote` to shape the
generated code; use `..$xs` at runtime to spread a list across a
function's params.
## See Also
`macro/quote`, `macro/syntax-quote`, `macro/unquote`, `defmacro`