Inheritable Behaviors
Codegen uses a set of core behaviors that can be inherited by code elements. These behaviors provide consistent APIs across different types of symbols.
This guide explains the key behaviors and how to use them effectively.
Core Behaviors
- HasName: For elements with names (functions, classes, variables)
- HasValue: For elements with values (variables, parameters)
- HasBlock: For elements containing code blocks (functions, classes)
- Editable: For elements that can be safely modified (learn more)
Working with Names
The HasName behavior provides APIs for working with named elements:
Working with Values
The HasValue behavior provides APIs for elements that have values:
Working with Code Blocks
The HasBlock behavior provides APIs for elements containing code:
Working with Attributes
The get_attribute method provides APIs for attribute access:
Learn more about working with Attributes here.
Behavior Combinations
Many code elements inherit multiple behaviors. For example, a function typically has:
Was this page helpful?