Files
quartz-research-note/content/モジュールの名前環境解決を考慮した評価文脈.md
Matsuura Tomoya(Windows) 40a652e455
All checks were successful
Build / build (push) Successful in 22m38s
[obsidian] vault backup: 2026-02-02 23:23:19[
2026-02-02 23:23:20 +09:00

34 lines
958 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
何度目だという[[評価環境]]の実装。
モジュールも考慮して、名前空間のOpenとかも含めた評価環境を実装したい。
名前の側で正規化するのがいいのか?
```rust
//Environment全体をSlotMapで管理する
struct Environment<V>{
namespace:Option<Symbol>
parent: Option<EnvKey>
children: Vec<EnvKey>,
span:Range<u64>,
binds: Vec<(Symbol,V)>
}
```
letでスコープを広げたときはnamespaceなしで辿ることにする
最終的にはLanguage ServerでSpanからEnvironmentの位置を補足したいということになる。
基本的に、子環境のEnvironmentは常に親のEncより狭い範囲のSpanを持つはず。そして子要素同士のSpanは交差しないはず。
親から子要素を二分探索で辿って行ってSpanは交差しないからPartialOrdにできるはず
```rust
fn get_completions(arena:SlotMap<_>,root_env:EnvKey,span:Span){
}
```