Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Language Guide

A tour of Han's syntax — variables, functions, conditionals, and loops. For deeper coverage of any single feature, see the dedicated pages under "Language Reference" in the sidebar.

Variables and Constants

변수 이름 = 42              // mutable variable
변수 메시지 = "안녕하세요"     // string variable
상수 파이 = 3.14            // immutable constant

With explicit type annotations:

변수 나이: 정수 = 25
변수 키: 실수 = 175.5
변수 이름: 문자열 = "홍길동"
변수 활성: 불 = 참

Functions

함수 더하기(가: 정수, 나: 정수) -> 정수 {
    반환 가 + 나
}

함수 인사(이름: 문자열) {
    출력("안녕하세요, " + 이름)
}

Conditionals

Han still supports the older minimal conditional form, but the Korean-default docs style uses 이면:

만약 점수 >= 90 이면 {
    출력("A")
} 아니면 점수 >= 80 이면 {
    출력("B")
} 아니면 {
    출력("C")
}

Loops

For loop (반복):

반복 변수 i = 0; i < 10; i += 1 {
    출력(i)
}

While loop (동안):

SOV:

변수 n = 0
n < 5 동안 {
    출력(n)
    n += 1
}

SVO alternative:

변수 n = 0
동안 n < 5 {
    출력(n)
    n += 1
}

Loop control멈춰 (break) and 계속 (continue):

반복 변수 i = 0; i < 100; i += 1 {
    만약 i == 50 이면 {
        멈춰
    }
    만약 i % 2 == 0 이면 {
        계속
    }
    출력(i)
}

Keyword Reference

KeywordMeaningEnglish Equivalent
함수function definitionfn / function
반환return valuereturn
변수mutable variablelet mut / var
상수immutable constantconst
만약conditionalif
이면conditional markerthen / if-then
아니면else branchelse
그리고and (logical)&&
또는or (logical)`
반복for loopfor
동안while loopwhile
멈춰break loopbreak
계속continue loopcontinue
boolean truetrue
거짓boolean falsefalse
출력print to consoleprint
입력read from consoleinput

Type System & Operators

TypeDescriptionLLVM TypeExamples
정수64-bit integeri6442, -10
실수64-bit floatf643.14, -0.5
문자열UTF-8 stringi8*"안녕하세요"
booleani1, 거짓
없음void / no valuevoid(function return type)
OperatorDescription
+, -, *, /, %Arithmetic
==, !=Equality
<, >, <=, >=Comparison
&&, ||, !, 그리고, 또는Logical
=, +=, -=, *=, /=Assignment