cangjie-const

Explain Cangjie const declarations, expressions, functions, and compile-time evaluation.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers understand and correctly implement const variables, expressions, and functions in the Cangjie language, ensuring compile-time safety and immutability where intended.

Core Features & Use Cases

  • Const Variable Declaration: Learn the syntax and rules for const variables, their immutability, and initialization requirements.
  • Const Expressions: Understand what constitutes an expression that can be evaluated at compile time.
  • Const Functions: Grasp the declaration, rules, and behavior of const functions, including their compile-time vs. runtime evaluation.
  • Const Init: Discover how to define const constructors for structs and classes, enabling compile-time instance creation.
  • Use Case: When encountering complex compile-time computations or ensuring deep immutability in your Cangjie code, this Skill provides the necessary guidance.

Quick Start

Explain the basic syntax for declaring a const variable in Cangjie.

Frequently Asked Questions about cangjie-const

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

FAQPage Schema
How do I declare a const variable in Cangjie and what are the initialization rules?

To declare a const variable in Cangjie, use the const keyword followed by the variable name and a compile-time evaluated initializer. Const variables require deep immutability and must be initialized with constant expressions rather than runtime values.

What is the difference between const and let or var in Cangjie?

The difference between const and let or var in Cangjie is that const enforces compile-time evaluation and deep immutability, whereas let defines an immutable reference evaluated at runtime and var allows runtime mutability.

How do const functions work in Cangjie for compile-time evaluation?

Const functions in Cangjie work by enabling compile-time evaluation when their parameters and internal operations consist solely of constant expressions. They can also execute at runtime if called with non-constant arguments.

What types and expressions are allowed in Cangjie const contexts?

Cangjie const contexts allow numerical types, Bool, Unit, Rune, String, Arrays, Tuples, and enums. Expressions within const contexts must be fully evaluable at compile time using these supported constant types.

Can I define compile-time struct or class instances using const init in Cangjie?

Yes, you can define compile-time struct or class instances using const init in Cangjie. Const init constructors enable compile-time instance creation, provided the constructor logic adheres to constant expression rules.

Does Cangjie const support interface implementation and generic constraints?

Cangjie const supports interface implementation and generic constraints within const contexts. This allows types to enforce compile-time constant behavior while adhering to specified interface contracts and generic type limitations.