dang-internals

Analyze Dang compiler invariants for hoisting, dynamic-scope cells, and Module.Eq subtyping.

23|9|Updated Jul 13, 2025
One-click install
npx skills add https://github.com/vito/dang --skill dang-internals
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dang-internals
Source: https://github.com/vito/dang/tree/main/.agents/skills/dang-internals
Command: npx skills add https://github.com/vito/dang --skill dang-internals

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dang's internals expose subtle invariants in the compiler, including multi-pass hoisting, the interaction between copy-on-write mutation and closures, and the Module.Eq subtyping rules.

Core Features & Use Cases

  • Explains multi-pass hoisting: top-level type-like declarations are hoisted before bodies are inferred, enabling mutual references.
  • Details scoping mechanics: Clone, Fork, and the dynamic-scope cell model that shares self across a method call and how NewDynamicScope / SetDynamicScope control mutation visibility.
  • Documents Module.Eq subtyping and how asymmetry affects assignment and interface/union relationships. Use when editing pkg/dang/ infer/eval/scope code, adding a new type-like declaration, or debugging mutation/scoping issues.

Quick Start

Explain the forward-reference handling and hoisting order for a new type-like declaration in Dang.

Frequently Asked Questions about dang-internals

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does multi-pass hoisting work in the Dang compiler?

Multi-pass hoisting in the Dang compiler hoists top-level type-like declarations before bodies are inferred, enabling mutual references. This ensures forward references are resolved correctly during the inference phase.

How do I debug dynamic-scope cell interactions and mutation visibility in Dang?

Debug dynamic-scope cell interactions in Dang by analyzing Clone, Fork, NewDynamicScope, and SetDynamicScope operations. These control how self is shared across method calls and manage copy-on-write mutation visibility.

What is Module.Eq subtyping and how does it affect assignment in Dang?

Module.Eq subtyping in Dang defines how asymmetry affects assignment and interface/union relationships. Understanding these rules is crucial for maintaining correct type-like declarations and avoiding scoping pitfalls.

How do I add a new type-like declaration to the Dang compiler pkg/dang code?

To add a new type-like declaration in pkg/dang, implement forward-reference handling and follow the multi-pass hoisting order. This ensures the declaration is hoisted before body inference, maintaining mutual reference compatibility.

Why are my closure mutations not visible in Dang's dynamic scope?

Closure mutation visibility issues in Dang's dynamic scope often stem from incorrect NewDynamicScope or SetDynamicScope usage. Check how Clone and Fork manage copy-on-write behavior to ensure mutations propagate correctly.

Can I use this Skill to debug scoping issues without editing pkg/dang infer/eval code?

Yes, the Skill explains Dang's internal compiler invariants and common pitfalls for scoping and mutation. It provides checks and guidance to evaluate scope behavior and debug issues without necessarily modifying the core infer/eval code.