lean-ja / lean-by-example

コード例で学ぶ Lean 言語
https://lean-ja.github.io/lean-by-example/
MIT License
15 stars 5 forks source link

macro コマンド使用例: バッククォートによるマクロ #354

Open Seasawher opened 1 week ago

Seasawher commented 1 week ago
macro "#foo" : command => `(
  #check Nat
  #eval 1 + 1
  def x := 0
)

#foo

一見してシンプルな文字列置換にみえるが,実はそうではなくて健全なマクロになっている.おもしろい

Seasawher commented 5 days ago

衛生的なマクロ、が正しいっぽい