Static Metaprogramming
**Metaprogramming** refers to code that operates on other code as if it were data. It can take code in as parameters, reflect over it, inspect it, create it, modify it, and return it. ***Static* metaprogramming** means doing that work at compile-time, and typically modifying or adding to the program based on that work. Today it is possible to do static metaprogramming completely outside of the language - using packages such as [build_runner][build_runner] to generate code and using the analyzer apis for introspection. These separate tools however are not well integrated into the compilers or tools, and it adds a lot of complexity where this is done. It also tends to be slower than an integrated solution because it can't share any work with the compiler. ## Sample Use Case - Data Classes The [most requested open language issue][data_classes_issue] is to add data classes. A data class is essentially a regular Dart class that comes with an automatically provided constructor and implementations of `==`, `hashCode`, and `copyWith()` (called `copy()` [in Kotlin][kotlin_copy]) methods based on the fields the user declares in the class. The reason this is a *language* feature request is because there’s no way for a Dart library or framework to add data classes as a reusable mechanism. Again, this is because there isn’t any easily available abstraction that lets a Dart user express “given this set of fields, add these methods to the class”. The `copyWith()` method is particularly
Posted by jakemac53 on Mar 1, 2021, 4:08 PM
Tags
Related issues
- [Meta] Feedback on granular control over Copilot changes
- unexpected status 401 Unauthorized issue
- [MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
- [CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
- Video stops playing after some minutes
- [MODEL] Claude verbose code comments by default — ignores instructions to stop.
Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments
github (Software)
[Meta] Feedback on granular control over Copilot changes
unexpected status 401 Unauthorized issue
[MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
[CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
Video stops playing after some minutes
[MODEL] Claude verbose code comments by default — ignores instructions to stop.
Scope Codex VS Code chats to the current workspace/project
Update on "Co-authored-by: Copilot" in commit messages
Static Metaprogramming
**Metaprogramming** refers to code that operates on other code as if it were data. It can take code in as parameters, reflect over it, inspect it, create it, modify it, and return it. ***Static* metaprogramming** means doing that work at compile-time, and typically modifying or adding to the program based on that work. Today it is possible to do static metaprogramming completely outside of the language - using packages such as [build_runner][build_runner] to generate code and using the analyzer apis for introspection. These separate tools however are not well integrated into the compilers or tools, and it adds a lot of complexity where this is done. It also tends to be slower than an integrated solution because it can't share any work with the compiler. ## Sample Use Case - Data Classes The [most requested open language issue][data_classes_issue] is to add data classes. A data class is essentially a regular Dart class that comes with an automatically provided constructor and implementations of `==`, `hashCode`, and `copyWith()` (called `copy()` [in Kotlin][kotlin_copy]) methods based on the fields the user declares in the class. The reason this is a *language* feature request is because there’s no way for a Dart library or framework to add data classes as a reusable mechanism. Again, this is because there isn’t any easily available abstraction that lets a Dart user express “given this set of fields, add these methods to the class”. The `copyWith()` method is particularly
Comments (0)
No comments yet. Start the discussion.