lean-ja / lean-ja/lean-by-example
マクロ衛生に関して、生の識別子を導入する方法
Open
Nobody has claimed this yet.
オプション
メタプログラミング
宣言的コマンド
- Dominant language
- Lean
- Stars
- 188
- Forks
- 15
- Avg merge
- 9h 8m
- Merged PRs (30d)
- 6
Description
-- マクロ衛生を保つ機能のために、マクロで定義した識別子にアクセスできない例
section
macro "#introcue" : command => `(def foo := 1)
#introcue
-- マクロ衛生のために、マクロ内で導入された識別子の名前が自動的に変更されるので、
-- foo にはアクセスできない
#check_failure foo
-- mkIdent という関数を使うと、マクロ衛生を保つ機能を潜り抜けて生の識別子を導入できる
macro "#introcue'" : command => `(def $(Lean.mkIdent `foo) := 1)
#introcue'
-- foo にアクセスできる!!!!
#check foo
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No target file or test is named. Start by reviewing the macro-hygiene examples in the issue, especially #introcue and #introcue', then determine where this explanation belongs and document how Lean.mkIdent introduces a raw identifier; done means the example clearly explains both behaviors.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100