Hash :
c8eaffa1
Author :
Thomas de Grivel
Date :
2025-05-19T13:18:30
translate using ChatGPT
The KC3 Quote type allows you for code quotes that holds evaluation
by one level. The quote can be made a partial quote using unquote
making the evaluation more eager by one level.
Quoting is necessary for meta-programming where you want to return
a quoted value that will not be evaluated except the quote will be
removed. Unquote produces the inverse, re-enabling evaluation of
macro arguments inside a quote for instance.
Unquote takes parenthesis while quote does not. Quoting with
parenthesis will return you a Call to the paren operator.
Do not do that. Unquote can only be called inside a quote.
ikc3> quote 1 + 1
1 + 1
ikc3> quote quote 1 + 1
quote 1 + 1
ikc3> type(quote 1 + 1)
Call
ikc3> type(quote quote 1 + 1)
Quote
Examples with unquote
ikc3> m = macro (x) { quote 1 + unquote x }
macro(x) { quote 1 + unquote(x) }
ikc3> m(41)
42
Top : KC3 documentation
Previous : 1.17 Ptr
Next : 1.19 Ratio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
# 1.18 Quote
The KC3 `Quote` type allows you for code quotes that holds evaluation
by one level. The quote can be made a partial quote using `unquote`
making the evaluation more eager by one level.
Quoting is necessary for meta-programming where you want to return
a quoted value that will not be evaluated except the quote will be
removed. `Unquote` produces the inverse, re-enabling evaluation of
macro arguments inside a quote for instance.
`Unquote` takes parenthesis while `quote` does not. Quoting with
parenthesis will return you a `Call` to the `paren` operator.
Do not do that. `Unquote` can only be called inside a `quote`.
## 1.18.1 Examples
```elixir
ikc3> quote 1 + 1
1 + 1
ikc3> quote quote 1 + 1
quote 1 + 1
ikc3> type(quote 1 + 1)
Call
ikc3> type(quote quote 1 + 1)
Quote
```
Examples with `unquote`
```elixir
ikc3> m = macro (x) { quote 1 + unquote x }
macro(x) { quote 1 + unquote(x) }
ikc3> m(41)
42
```
---
Top : [KC3 documentation](../)
Previous : [1.17 Ptr](1.17_Ptr)
Next : [1.19 Ratio](1.19_Ratio)