-
Notifications
You must be signed in to change notification settings - Fork 2
Quick overview
Ilya Nikitin edited this page Nov 8, 2020
·
19 revisions
# Single-line comment
| Example | Description |
|---|---|
let x = Something(), let x: Int
|
Immutable value declaration |
let x = 42, let x = 'Hello!'
|
Constant value declaration (case of primitive type assignment) |
x = 42, x: Int, x: Int = 42
|
Variable declaration |
(Function body can be omitted if it is not needed)
| Function definition | |
|---|---|
fn greet |
No return value, no parameters |
fn greet (name: Str) |
No return value |
fn greet (name: Str, surname: Str) |
No return value, multiple parameters |
fn get-response -> Str |
With return value, no parameters |
fn response (input: Str) -> Str |
With return value and parameter |
fn makemap[T] (g: T, seq: List[T]) |
Generic function |
| Lambda (anonymous) function | |
fn (arg1: Int, arg2: Int) |
With multiple parameters |
cube = fn (x: int): x ** 3 |
With single named input argument x
|
# while is only loop directly baked in language
while condition
do-something()
# all examples below use macros magic
do
something()
while condition
x times
do-something()
for x in 0..10
Console.write-line(x)
for i = 0; i <= 10; i++
Console.write-line(i)Simple comparison:
digitAsWord = x match
1: "one"
2: "two"
3: "three"
# ...
9: "nine"
_: raise ArgumentOutOfRangeError
Pattern-matching:
alert = notification match
Email(email, title, _): f"Email from {email} with title: {title}"
SMS(number, message): f"SMS from {number}! Message: {message}"
VoiceRecording(name, link): f"Voice Recording from {name}! Click to hear it: {link}"

Expressions
Public compiler interface
-
Units & Modules- TODO -
Compilerclass
Backend
- Lexer (Tokenizer)
- Syntax tree
- Traversing