cangjie-struct

Explain Cangjie struct definitions, constructors, mutability, and mut function rules.

2|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/zhenzhizhi12/NexusAgent --skill cangjie-struct-zhenzhizhi12
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-struct
Source: https://github.com/zhenzhizhi12/NexusAgent/tree/main/.opencode/skills/common-skill-l1/struct
Command: npx skills add https://github.com/zhenzhizhi12/NexusAgent --skill cangjie-struct-zhenzhizhi12

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers understand and correctly implement struct definitions, constructors, value semantics, and mutability rules in the Cangjie programming language, preventing common errors and ensuring robust code.

Core Features & Use Cases

  • Struct Definition: Learn basic syntax, member variables (instance/static), static initializers, and constructors (init/primary).
  • Member Functions & Properties: Understand instance vs. static functions, prop definitions, and access modifiers.
  • Value Semantics & Mutability: Grasp how structs are copied, the conditions for modifying instances, and the purpose and restrictions of mut functions.
  • Use Case: When encountering a complex data structure requirement in Cangjie, use this Skill to define the struct accurately, ensuring correct initialization and modification behavior.

Quick Start

Explain how to define a struct named 'Point' with two Int64 members, 'x' and 'y', and a primary constructor.

Frequently Asked Questions about cangjie-struct

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

FAQPage Schema
How do I define a struct in Cangjie with member variables and a primary constructor?

To define a struct in Cangjie, declare the struct name and member variables, then use a primary constructor to initialize them. This ensures correct setup of instance properties like 'x' and 'y' coordinates upon creation.

What are the mutability rules and restrictions for mut functions in Cangjie structs?

Cangjie struct mut functions allow modifying struct instances, but they carry specific restrictions regarding variable declarations and interface interactions. Understanding these rules prevents common mutability errors during value modification.

Can I define recursive structs in the Cangjie programming language?

Cangjie imposes specific restrictions on recursive structs. Developers must understand these limitations when designing complex data structures to prevent compilation errors related to self-referencing types.

How does value semantics affect struct copying and modification in Cangjie?

Cangjie structs use value semantics, meaning instances are copied upon assignment. Modifying a copied instance requires specific conditions, ensuring the original struct remains unchanged unless explicitly handled with mut functions.

How do I use static initializers and static member variables in a Cangjie struct?

Cangjie structs support static member variables and static initializers. Use these features to define shared state across all instances of the struct, initialized once when the struct is first accessed.

What access modifiers and properties are available for Cangjie struct members?

Cangjie struct members support access modifiers and property definitions using the 'prop' keyword. These features control visibility and encapsulate instance or static function logic within the struct.