日本語 English

Documentation

Contents: Introduction | Design Philosophy | Basic Syntax | Specification Status

Introduction

This is the initial design document for the Cu language. At this stage, it summarizes the philosophy and proposed syntax, and is not a formal language specification. Before starting implementation, ambiguities in syntax, type rules, error handling, and execution model need to be finalized.

Design Philosophy

Three principles serve as the criteria for design decisions.

Basic Syntax (Draft)

The following are under consideration. Not all are finalized or implemented.

File Format

main.cu29

Directives

#mode 
#apply 

Standard Output

Io.print(none: str = "Hello, World!")

Variable Declaration and Initialization

x: int = 1
name: str = "Cu"
pi: float = 3.14
enabled: bool = True

Candidate basic types: int (integer), float (floating-point), str (string), bool (boolean)

Reassignment

x: int = 1

x = 3
x += 1

Direct Value Specification with none

Io.print(none: str = "Cu")

Under consideration. Not confirmed to have the same meaning as None/null in other languages.

Function Definition

fnc: int = init() {
    Io.print(none: str = "a")
    return none: int = 0
}

Multiple Return Values

fnc: (int, str) = get_values() {
    return none: int = 10, none: str = "Cu"
}

a, b = get_values()

Conditional Branching

if: pro = x == 0 {
    Io.print(none: str = "x is 0!")
} elif: pro = x == 1 {
    Io.print(none: str = "x is 1!")
} else {
    Io.print(none: str = "x isn't 0 or 1!")
}

Loop: for

for: pro = 5 {
    Io.print(none: str = "Hello")
}

Loop: while

while: pro = x == 0 {
    Io.print(none: str = "x is 0")
}

while: pro = True {
    Io.print(none: str = "Running")
}

Loop Control

break
continue

Operators and Multi-line Expressions

result: int = 10 + 20
value: int = result * 2

result: int = 10 +
    20

Specification Status

ItemStatus
Language name CuConfirmed
Extension .cu29Confirmed
Initial implementation in PythonPolicy
No classes in initial specPolicy
APC three principlesContent confirmed
Syntax for variables, functions, conditionalsDraft
Meaning of noneNeeds definition
Precise meaning of proNeeds definition
Type systemNeeds design
Memory managementNeeds design
Compilation / execution modelNeeds design
RTOS / hardware control featuresFuture consideration

Important: This is currently an initial design document summarizing the philosophy and syntax proposals of Cu, not a formal language specification.