plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


a968899 — Peter John 2026-09-04T20:46:39+05:30
remove website

Generated files not shown: website/package-lock.json

website/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- # build output
2
- dist/
3
- # generated types
4
- .astro/
5
-
6
- # dependencies
7
- node_modules/
8
-
9
- # logs
10
- npm-debug.log*
11
- yarn-debug.log*
12
- yarn-error.log*
13
- pnpm-debug.log*
14
-
15
-
16
- # environment variables
17
- .env
18
- .env.production
19
-
20
- # macOS-specific files
21
- .DS_Store
website/.vscode/extensions.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "recommendations": ["astro-build.astro-vscode"],
3
- "unwantedRecommendations": []
4
- }
website/.vscode/launch.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "version": "0.2.0",
3
- "configurations": [
4
- {
5
- "command": "./node_modules/.bin/astro dev",
6
- "name": "Development server",
7
- "request": "launch",
8
- "type": "node-terminal"
9
- }
10
- ]
11
- }
website/astro.config.mjs DELETED
@@ -1,53 +0,0 @@
1
- import { defineConfig } from "astro/config";
2
- import starlight from "@astrojs/starlight";
3
-
4
- // https://astro.build/config
5
- export default defineConfig({
6
- integrations: [
7
- starlight({
8
- title: "👾 pacos.sh",
9
- social: {
10
- github: "https://github.com/pyrossh/pacos.sh",
11
- },
12
- sidebar: [
13
- {
14
- label: "Basic Types",
15
- link: "/primitive-types",
16
- },
17
- {
18
- label: "Reference Types",
19
- link: "/reference-types",
20
- },
21
- {
22
- label: "Declarations",
23
- items: [
24
- { label: "Records", link: "/declarations/records" },
25
- { label: "Traits", link: "/declarations/traits" },
26
- { label: "Enum", link: "/declarations/enum" },
27
- { label: "Type Alias", link: "/declarations/aliases" },
28
- { label: "Functions", link: "/declarations/functions" },
29
- ],
30
- },
31
- {
32
- label: "Statements",
33
- items: [
34
- { label: "Constants", link: "/statements/constants" },
35
- { label: "Variables", link: "/statements/variables" },
36
- { label: "If", link: "/statements/if" },
37
- { label: "While", link: "/statements/while" },
38
- { label: "For", link: "/statements/for" },
39
- { label: "Match", link: "/statements/match" },
40
- ],
41
- },
42
- {
43
- label: "Operators",
44
- link: "/operators/logical",
45
- },
46
- {
47
- label: "Comments/Documentation",
48
- link: "/operators/logical",
49
- },
50
- ],
51
- }),
52
- ],
53
- });
website/package.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "name": "website",
3
- "type": "module",
4
- "version": "0.0.1",
5
- "scripts": {
6
- "dev": "astro dev",
7
- "start": "astro dev",
8
- "build": "astro build",
9
- "preview": "astro preview",
10
- "astro": "astro"
11
- },
12
- "dependencies": {
13
- "@astrojs/starlight": "^0.20.1",
14
- "astro": "^4.3.5",
15
- "sharp": "^0.32.5"
16
- }
17
- }
website/public/favicon.svg DELETED
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M81 36 64 0 47 36l-1 2-9-10a6 6 0 0 0-9 9l10 10h-2L0 64l36 17h2L28 91a6 6 0 1 0 9 9l9-10 1 2 17 36 17-36v-2l9 10a6 6 0 1 0 9-9l-9-9 2-1 36-17-36-17-2-1 9-9a6 6 0 1 0-9-9l-9 10v-2Zm-17 2-2 5c-4 8-11 15-19 19l-5 2 5 2c8 4 15 11 19 19l2 5 2-5c4-8 11-15 19-19l5-2-5-2c-8-4-15-11-19-19l-2-5Z" clip-rule="evenodd"/><path d="M118 19a6 6 0 0 0-9-9l-3 3a6 6 0 1 0 9 9l3-3Zm-96 4c-2 2-6 2-9 0l-3-3a6 6 0 1 1 9-9l3 3c3 2 3 6 0 9Zm0 82c-2-2-6-2-9 0l-3 3a6 6 0 1 0 9 9l3-3c3-2 3-6 0-9Zm96 4a6 6 0 0 1-9 9l-3-3a6 6 0 1 1 9-9l3 3Z"/><style>path{fill:#000}@media (prefers-color-scheme:dark){path{fill:#fff}}</style></svg>
website/src/assets/houston.webp DELETED
Binary file
website/src/content/config.ts DELETED
@@ -1,6 +0,0 @@
1
- import { defineCollection } from 'astro:content';
2
- import { docsSchema } from '@astrojs/starlight/schema';
3
-
4
- export const collections = {
5
- docs: defineCollection({ schema: docsSchema() }),
6
- };
website/src/content/docs/declarations/aliases.md DELETED
@@ -1,11 +0,0 @@
1
- ---
2
- title: Type Alias
3
- description: These are basic types
4
- ---
5
-
6
-
7
- ```rs
8
- type Size = int
9
- type Metre = float
10
- type MapString[T] = Map[String, T]
11
- ```
website/src/content/docs/declarations/enum.md DELETED
@@ -1,49 +0,0 @@
1
- ---
2
- title: Enum
3
- description: These are basic types
4
- ---
5
-
6
- An Algebraic Data Type
7
-
8
- ```rs
9
- enum Ordering: ToStr {
10
- LT
11
- EQ
12
- GT
13
- } {
14
- override fn toStr(): Str {
15
- match self
16
- LT -> "LT"
17
- EQ -> "EQ"
18
- GT -> "GT"
19
- }
20
- }
21
-
22
-
23
- enum Shape {
24
- Circle(int)
25
- Square(int)
26
- Rectangle(int, int)
27
- } {
28
- fn toStr(): Str {
29
- match self
30
- Circle(r) -> printLn("Circle(${r})")
31
- Square(s) -> printLn("Square(${s})")
32
- Rectangle(w, h) -> printLn("Rectangle(${w}, ${h})")
33
- }
34
-
35
- fn area(): Float {
36
- match self
37
- Circle(r) -> PI * r * r
38
- Square(s) -> s * s
39
- Rectangle(w, h) -> w * h
40
- }
41
-
42
- fn draw(): Float {
43
- match self
44
- Circle(r) -> PI * r * r
45
- Square(s) -> s * s
46
- Rectangle(w, h) -> w * h
47
- }
48
- }
49
- ```
website/src/content/docs/declarations/functions.md DELETED
@@ -1,28 +0,0 @@
1
- ---
2
- title: Functions
3
- description: These are basic types
4
- ---
5
-
6
- ```rs
7
- fn fib(n: int) -> int =
8
- match n
9
- 0 | 1 -> n
10
- _ -> fib(n - 1) + fib(n - 2)
11
-
12
- fn log(level: str, msg: str) =
13
- printLn("${level}: ${msg}")
14
-
15
- pub fn info(msg: str) =
16
- log("INFO", msg)
17
-
18
- pub fn warning(msg: str) =
19
- log("WARN", msg)
20
-
21
- fn addLists(a: List[T], b: List[T]): List[T] =
22
- a.concat(b)
23
-
24
- // Variadic function
25
- fn addItems(items ...str) =
26
- for i, v := range items
27
- printLn("${i} ${v}")
28
- ```
website/src/content/docs/declarations/records.md DELETED
@@ -1,58 +0,0 @@
1
- ---
2
- title: Records
3
- description: These are basic types
4
- ---
5
-
6
- A record is a collect of data indexed by fields. It is a reference type and reference counted.
7
-
8
- ```rs
9
- record Cat(name: str, age: int) where
10
- static fn withName(name: str) Cat =
11
- Cat(name: name, age: 0)
12
-
13
- fn fullname() str =
14
- name + age.toStr()
15
-
16
- fn talk() =
17
- printLn("cat ${name} says meow")
18
-
19
- override fn plus(other: Cat) Cat =
20
- Cat(...self, age: self.age + other.age)
21
-
22
- override fn toStr() str =
23
- "Cat<${fullname()}, ${age}>"
24
-
25
- record Map[K, V](items: List[Pair[K, V]]) where
26
-
27
- static fn of[K, V](kvs: ...Pair[K, V]) Map[K, V]
28
- Map[K, V]().add(kvs)
29
-
30
- fn range(yld: fn(k: K, v: V): bool) bool
31
- `allows the range operator to iterate over the Map
32
- for item := range self.items
33
- if !yld(item.k, item.v)
34
- false
35
- true
36
-
37
- fn add(kvs: ...Pair[K, V]) =
38
- `adds the specified elements to the start of the list
39
-
40
- fn get(k: K): Option[V] =
41
- `get a value from the Map using key k
42
- for k, v := range m
43
- if k == k
44
- return v
45
- None
46
-
47
- fn set(k: K, v: V) =
48
- `put a value into the Map
49
- for pair := range self.items
50
- if pair.k == k
51
- pair.v = v
52
- return
53
- self.items.add(k, v)
54
-
55
- fn putIf(k: K, v: V) =
56
- `put a value into the Map if its not already present
57
- pass
58
- ```
website/src/content/docs/declarations/traits.md DELETED
@@ -1,48 +0,0 @@
1
- ---
2
- title: Traits
3
- description: These are basic types
4
- ---
5
-
6
- Traits are used to implement static/dynamic dispatch
7
-
8
- ```rs
9
- trait Equatable[A] where
10
- fn eq(other: A): bool
11
- fn ne(other: A): bool
12
-
13
- enum Compare =
14
- | Less
15
- | Equal
16
- | Greater
17
-
18
- trait Comparable[A: Ord] where
19
- fn compareTo(other: A): Compare
20
-
21
- trait ArithmeticOperator[A] where
22
- fn add(other: A): A
23
- fn subtract(other: A): A
24
- fn multiply(other: A): A
25
- fn divide(other: A): A
26
- fn remainder(other: A): A
27
-
28
- trait UnaryOperator[A] where
29
- fn unaryPlus(): A
30
- fn unaryMinus(): A
31
- fn increment(): A
32
- fn decrement(): A
33
-
34
- trait LogicalOperator[A] where
35
- fn and(other: A): A
36
- fn or(other: A): A
37
- fn not(): A
38
-
39
- trait AssignmentOperator[A] where
40
- fn assign(other: A) A
41
-
42
- trait BitwiseOperator[A] where
43
- fn bitwiseAnd(other: A): A
44
- fn bitwiseOr(other: A): A
45
- fn bitwiseXor(): A
46
- fn bitwiseLeftShift(): A
47
- fn bitwiseRightShift(): A
48
- ```
website/src/content/docs/index.mdx DELETED
@@ -1,162 +0,0 @@
1
- ---
2
- title: 👾 pacos-lang
3
- description: A statically typed, imperative programming language inspired by rust, koka
4
- template: splash
5
- hero:
6
- tagline: A statically typed, imperative programming language inspired by rust, koka. With plans to be compiled to WASM.
7
- image:
8
- file: ../../assets/houston.webp
9
- actions:
10
- - text: Checkout the Documentation
11
- link: /primitive-types
12
- icon: right-arrow
13
- variant: secondary
14
- ---
15
-
16
- ### Here is some sample code, please enjoy,
17
-
18
- ```rs
19
- module lambda
20
-
21
- import std/list
22
- import std/math
23
- import std/http
24
-
25
- const DELTA = 11
26
-
27
- fn sum(a: int, b: int): int = a + b + DELTA
28
-
29
- fn sumAll(series: list[int]): int =
30
- series.reduce(0, |v| v + 1)
31
-
32
- fn fib(n: int): int =
33
- match n
34
- 0 | 1 -> n
35
- _ -> fib(n - 1) + fib(n - 2)
36
-
37
- fn fib(n: int): int =
38
- if n == 0 || n == 1
39
- n
40
- else
41
- fib(n - 1) + fib(n - 2)
42
-
43
- fn factorial(n: int): int =
44
- match n
45
- a -> 1
46
- _ -> n * factorial(n - 1)
47
-
48
- fn firstItem(items: list[int]): option[int] =
49
- items.get(0)
50
-
51
- fn toCelsius(f: float): float =
52
- (f - 32) * (5 / 9)
53
-
54
- // Variadic function
55
- fn addItems(items ...str) =
56
- list.add(items)
57
-
58
- trait ToStr where
59
- fn toStr(): str
60
-
61
- // `Cat is a speciecs of felidae
62
- struct Cat is ToStr, Equal, Comparable =
63
- | name: str
64
- | age: int
65
-
66
- fn Cat(name: str, age: int) =
67
- self.name = name
68
- self.age = age
69
-
70
- fn Cat.withName(name: str): Cat =
71
- `Create a cat with only name
72
- Cat(name: name, age: 0)
73
-
74
- fn fullname(): str =
75
- name + age.toStr()
76
-
77
- fn talk() =
78
- printLn("cat ${name} says meow")
79
-
80
- fn toStr(): str =
81
- "Cat<${fullname()}, ${age}>"
82
-
83
- enum Temperature where
84
- | celsius(float)
85
- | fahrenheit(float)
86
-
87
- fn toStr(): str =
88
- match self
89
- celsius(t) && t > 30 -> "${t}C is above 30 celsius"
90
- celsius(t) -> "${t}C is below 30 celsius"
91
- fahrenheit(t) && t > 86 -> "${t}F is above 86 fahrenheit"
92
- fahrenheit(t) -> "${t}F is below 86 fahrenheit"
93
-
94
- alias MapCallback = fn(v: a): v
95
-
96
- struct DB where
97
- let conn_url: str
98
-
99
- fn connect(): Result[unit, DatabaseError] =
100
- `connect to the database
101
- online := status()
102
- if !online
103
- Err(NotOnline(conn_url))
104
- else
105
- Ok(unit)
106
-
107
- fn status(): bool =
108
- `check if the database is running
109
- res := exec("select 1")
110
- if res == None
111
- false
112
- else
113
- true
114
-
115
- fn exec(q: str): Result[unit] =
116
- `exec some stuff
117
- printLn("Going to exec q")
118
-
119
- #[error]
120
- enum DatabaseError =
121
- NotOnline(conn_url: str)
122
- RowReadFailure(query: str)
123
-
124
- fn newDB(conn_url: str) result[DB, DatabaseError] =
125
- db := DB(conn_url: str)
126
- online := db.status()
127
- if !online
128
- err(NotOnline(conn_url))
129
- else
130
- db
131
-
132
- fn (d: DB) status(): bool =
133
- res := d.exec("select 1")
134
- if res == None
135
- false
136
- else
137
- true
138
-
139
-
140
- #[test]
141
- primitive CatTest
142
- fn talk(t: TestHelper) =
143
- c := Cat(name: "123", age: 1)
144
- c2 := Cat(...c, age: c.age + 1)
145
- c.talk()
146
-
147
- fn fullname(t: TestHelper) =
148
- Assert.equal(Cat("rabby", 21).fullname(), "rabby21")
149
-
150
- fn toStr() =
151
- items := [Cat("Molly", 9), Cat("Fenton", 6)]
152
- .retain(|p| p.name.size > 5)
153
- .map(|p| describe(p))
154
- .each(|d| printLn(d))
155
- Assert.equal(items[0].toStr(), "Cat<Fenton, 6>")
156
-
157
- suite "diagonal" do
158
- test "3 4 5" do
159
- Assert.equal 5.0 (diagonal 3.0 4.0)
160
- test "5 12 13" do
161
- Assert.equal 5.0 (diagonal 3.0 4.0)
162
- ```
website/src/content/docs/naming-convention.md DELETED
@@ -1,19 +0,0 @@
1
- ---
2
- title: Naming Convention
3
- description: Naming Convention
4
- ---
5
-
6
- | Item | Convention |
7
- | ------------------------ | ----------------------- |
8
- | Modules | kebab-case |
9
- | Types/Traits/Enum | UpperCamelCase |
10
- | Fields/Functions/Methods | lowerCamelCase |
11
- | Local variables | snake_case |
12
- | Constants | SCREAMING_SNAKE_CASE |
13
- | Generics | single uppercase letter |
14
-
15
- ## Rules
16
-
17
- - Function parameters are passed by value only. You cannot modify a parameter. The compiler will throw an error if you try to.
18
- - Strict naming convention
19
- - Only one way of doing things ex: loops, condition
website/src/content/docs/operators/logical.md DELETED
@@ -1,83 +0,0 @@
1
- ---
2
- title: Operators
3
- description: These are basic types
4
- ---
5
-
6
- ### Arithmetic
7
- ### Relational
8
- ### Logical
9
- ### Bitwise
10
- ### Assignment
11
- ### Precedence
12
-
13
- **assignment operator**
14
-
15
- ```go
16
- x, y := 5, 3
17
- z := x + y // 8
18
- ```
19
-
20
- **not operator**
21
-
22
- ```rb
23
- !a
24
- !true
25
- ```
26
-
27
- **ternary operator**
28
-
29
- ```rb
30
- x ? a : b
31
- ```
32
-
33
- **safe navigation operator**
34
-
35
- ```rb
36
- a?.b?.c?.d
37
- ```
38
-
39
- **elvis operator**
40
-
41
- ```rb
42
- x ?: y
43
- ```
44
-
45
- **cascade operator (remove??)**
46
-
47
- ```dart
48
- paint := Paint()
49
- ..color = Colors.black
50
- ..strokeCap = StrokeCap.round
51
- ..strokeWidth = 5.0
52
-
53
- v := list.of(1, 2, 3)
54
- ..add(4, 5)
55
- ..get(0)
56
- ```
57
-
58
- **range operator**
59
-
60
- ```rs
61
- trait Rangeble where
62
- fn range[V](yield: fn(V): bool): bool
63
-
64
- trait RangebleKV where
65
- fn rangeKV[K, V](yield: fn(K, V): bool): bool
66
-
67
- record Tree[E](
68
- value: E
69
- left: Option[Tree] = None
70
- right: Option[Tree] = None
71
- )
72
-
73
- fn (Tree->Rangeble) range(yld: fn(E): bool): bool =
74
- t.left?.range(yld) && yld(t.val) && t.right?.range(yld)
75
-
76
- let tree = Tree(
77
- value: 10,
78
- left: Tree(20, Tree(30), Tree(39)),
79
- right: Tree(40),
80
- )
81
- for t := range tree
82
- printLn(v)
83
- ```
website/src/content/docs/primitive-types.md DELETED
@@ -1,55 +0,0 @@
1
- ---
2
- title: Basic Types
3
- description: These are basic types
4
- ---
5
-
6
- ## bool
7
-
8
- A bool can be either `true` or `false`. It is used in logical operations and conditional statements.
9
-
10
- ```rb
11
- assert true != false
12
-
13
- if true || false
14
- print("works")
15
- ```
16
-
17
- ## byte
18
-
19
- A byte represents an unsigned 8-bit number. It is mainly used to represent strings and binary data.
20
-
21
- ```go
22
- up_event := 'a'
23
- key_code := 102
24
- ```
25
-
26
- ## int
27
-
28
- An int is a signed 64-bit number. It can be represented in various ways,
29
-
30
- | Notation | Type | Base | Example |
31
- | -------- | ----------- | ------- | ------------------------- |
32
- | 0b | Binary | Base 2 | `0b00101010`, `0b1_1111` |
33
- | 0x | Hexadecimal | Base 16 | `0xff00ff`, `0xFF80_0000` |
34
- | number | Standard | Base 10 | `98762`, `98_762` |
35
-
36
- ## float
37
-
38
- A float represents a 64-bit floating point [IEEE-754-2008](https://en.wikipedia.org/wiki/Double-precision_floating-point_format).
39
-
40
- | Type | Example |
41
- | ----------- | ----------------- |
42
- | Normal | `1.2`, `-0.4` |
43
- | With suffix | `15.03f`, `12.0f` |
44
- | E notation | `2.7e-12`, `1e10` |
45
-
46
- ## dec
47
-
48
- A dec is a decimal floating-point numbering format which is 64-bit data type.
49
- It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations.
50
- It supports 16 decimal digits of significand and an exponent range of −383 to +384.
51
-
52
- | Type | Example |
53
- | ---------- | ----------------- |
54
- | Normal | `2.4d`, `-13.3d` |
55
- | E notation | `2.7e-12`, `1e10` |
website/src/content/docs/reference-types.md DELETED
@@ -1,150 +0,0 @@
1
- ---
2
- title: Reference Types
3
- description: These are basic refernce types
4
- ---
5
-
6
- ## any
7
-
8
- The any type is an empty trait and is used to represent all types
9
-
10
- ## error
11
-
12
- The error type is a trait that represents all Error types
13
-
14
- ## str
15
-
16
- A str represents an array of runes or unicode code points. It is encoded to UTF-8 by default.
17
- It supports interpolation of variables/values that implement the ToStr interface.
18
-
19
- ```go
20
- import std/os.{printLn}
21
-
22
- sed := "Hello World"
23
- name := "Pacos"
24
- age := 1
25
- printLn("Name ${name} age ${age}")
26
- ```
27
-
28
- ## list
29
-
30
- ```py
31
- import std/list
32
-
33
- a := List.of(1, 2, 3) # List[int]
34
- b := List.of( # List[List[int]]
35
- List.of(1),
36
- List.of(2),
37
- List.of(3),
38
- )
39
- c := List.of(1, 2, 3 * 4, 8, n)
40
-
41
- actors := List.of("Krabs", "Squidward")
42
- actors.add("Spongebob")
43
- actors.length() // ==> 3
44
- actors.contains("Krabs") // ==> true
45
- actors.get(0) // => "Krabs"
46
- actors.get(5) // => nil
47
-
48
- items
49
- .map(|v| v + 1)
50
- .each(|v| printLn("v", v))
51
- .reduce(0, |v| v + 1)
52
- ```
53
-
54
- ## map
55
-
56
- ```rs
57
- import std/map
58
-
59
- nums := Map.of("one" => 1, "two" => 2)
60
- map.get("one") // => some(1)
61
- map.get("unknown") // => none
62
- friends_tree := Map.of(
63
- "value" => "Fred",
64
- "left" => Map.of(
65
- "value" => "Jim",
66
- ),
67
- "right" => Map.of(
68
- "value" => "Shiela",
69
- "left" => Map.of(
70
- "value" => "Alice",
71
- ),
72
- "right" => Map.of(
73
- "value" => "Bob"
74
- ),
75
- ),
76
- )
77
-
78
- friends_tree
79
- .map(|k, v| v)
80
- .each(|k, v| printLn("v", v))
81
- .reduce(0, |k, v| v + 1)
82
- ```
83
-
84
- ## option
85
-
86
- An option is a type that represents either value present `some` or nothing present `none`
87
-
88
- ```go
89
- import std/option
90
-
91
- c := some(2)
92
-
93
- match c
94
- none -> print("no car")
95
- some(c) -> print("${c}")
96
-
97
- if some(count) = c
98
- printLn("Hello ${count}")
99
- else
100
- printLn("nothing")
101
- ```
102
-
103
- ## result
104
-
105
- A result is a type that represents either success `ok` or failure `err`
106
-
107
- ```rs
108
- import std/str
109
- import std/result
110
-
111
- #[error]
112
- record FetchError()
113
-
114
- #[error]
115
- record IOError()
116
-
117
- #[error]
118
- record JsonParseError()
119
-
120
- #[error("Version is nil")]
121
- record ParseVersionError()
122
-
123
- #[json]
124
- record UserData(
125
- id: int,
126
- name: str,
127
- roles: List[str]
128
- )
129
-
130
- fn parseVersion(header: List[int]): result[int, ParseVersionError] =
131
- header.get(0) ?: ParseError()
132
-
133
- fn doubleNumber(s: str): result[int] =
134
- number_str.parse_int().map(|n| 2 * n)
135
-
136
- fn fetchData(route: str): result[UserData] =
137
- response := fetch(route)?
138
- data := response.body.readAll()?
139
- parseJson(data)?
140
-
141
- fn main(): result[int] =
142
- n := doubleNumber("10")?
143
- version := parseVersion(list.of(1, 2))?
144
- res := fetchData()
145
- match res
146
- Ok(u) -> return Ok(u.id)
147
- Err(IOError(e)) -> printLn("IO failed")
148
- Err(e) -> printLn("generic error ${e.msg()}")
149
- Ok(0)
150
- ```
website/src/content/docs/statements/constants.md DELETED
@@ -1,25 +0,0 @@
1
- ---
2
- title: Constants
3
- description: These are basic types
4
- ---
5
-
6
- Constants can be declared at the top level of a program. They cannot be reassigned.
7
-
8
- - Primitive values like`int, float, str` are directly replaced in code.
9
- - Reference values like `list, map, records` are initialized at program start and passed by reference when used. Their data can be modified.
10
-
11
- ```rb
12
- const START_YEAR = 2101
13
- const PI = 3.14159
14
- const NAME = "pacos"
15
- const DEBUG_ENABLED = true
16
- const COUNT = count(10)
17
- const COUNTRIES_LIST = List.of("US", "INDIA", "CANADA")
18
- const COUNTRY_CODES = Map.of(
19
- "in" => "INDIA",
20
- "us" => "United States",
21
- "ca" => "Canada"
22
- )
23
-
24
- fn count(n: int): int = n * 1
25
- ```
website/src/content/docs/statements/for.md DELETED
@@ -1,19 +0,0 @@
1
- ---
2
- title: For Statement
3
- description: These are basic types
4
- ---
5
-
6
- ```rb
7
- for i := range 10
8
- sum += i
9
-
10
- n := 5
11
- for i := range n
12
- sum += i + 5
13
-
14
- for k, v := range json_map
15
- sum += k + v
16
-
17
- for v := range list
18
- sum += k + v
19
- ```
website/src/content/docs/statements/if.md DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- title: If Statement
3
- description: These are basic types
4
- ---
5
-
6
- ```py
7
- if name == "Andreas"
8
- printLn("What a nice name!")
9
- else if name == "Pacman"
10
- printLn("Game from the 80s")
11
- else if name == ""
12
- printLn("Don't you have a name?")
13
- else
14
- printLn("Boring name...")
15
- ```
website/src/content/docs/statements/match.md DELETED
@@ -1,28 +0,0 @@
1
- ---
2
- title: Match
3
- description: These are basic types
4
- ---
5
-
6
- ```rs
7
- fn getPerimeter(shape: Shape): Result[float] =
8
- match shape
9
- Rectangle(r) -> Ok(2 * r.length() + 2 * r.width())
10
- Circle(c) -> Ok(2 * c.radius() * PI)
11
- _ -> Err(RuntimeError("expected shape but found ${@TypeName(shape)}"))
12
-
13
- match x, y
14
- 1, 1 -> "both are 1"
15
- 1, _ -> "x is 1"
16
- _, 1 -> "y is 1"
17
- _, _ -> "neither is 1"
18
-
19
- match n
20
- 2 | 4 | 6 | 8 -> "This is an even number"
21
- 1 | 3 | 5 | 7 -> "This is an odd number"
22
- _ -> "I'm not sure"
23
-
24
- match _
25
- cmp > 0 -> low = mid + 1
26
- cmp < 0 -> high = mid
27
- cmp == 0 -> return mid, true
28
- ```
website/src/content/docs/statements/variables.md DELETED
@@ -1,18 +0,0 @@
1
- ---
2
- title: Variables
3
- description: These are basic types
4
- ---
5
-
6
- Variables can be declared only at the local scope of a function as they are mutable. They are references/pointers to data.
7
- We use the Short Variable Declaration Operator `:=` to declare a variable
8
-
9
- ```rb
10
- low, mid, high := 0, 0, n.numItems
11
- x := 10
12
- y := 20
13
- xy_list := List.of(1, 2, 3)
14
- xy_map := Map.of(1 => "one", 2 => "two")
15
- a := 1 + n
16
- b := 1 * n
17
- a * b
18
- ```
website/src/content/docs/statements/while.md DELETED
@@ -1,20 +0,0 @@
1
- ---
2
- title: While Statement
3
- description: These are basic types
4
- ---
5
-
6
- ```rb
7
- low, mid, high := 0, 0, n.size
8
- while low < high
9
- mid = (low + high) / 2
10
- low = cmp > 0 ? mid + 1 : low
11
- high = cmp < 0 ? mid : high
12
- if cmp == 0
13
- return mid, true
14
-
15
- while a > b
16
- a += 1
17
-
18
- while Some(top) = stack.pop()
19
- printLn(top)
20
- ```
website/src/env.d.ts DELETED
@@ -1,2 +0,0 @@
1
- /// <reference path="../.astro/types.d.ts" />
2
- /// <reference types="astro/client" />
website/tsconfig.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "astro/tsconfigs/strict"
3
- }