plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
plum-std/Byte.plum
| a271f34 | 1 | module std |
| ca5fd6f | 2 | import std/Number |
| 73b5e55 | 3 | import std/Bool |
| 29313cb | 4 | import std/Str |
| a271f34 | 5 | |
| a271f34 | 6 | # Byte is an unsigned 8-bit value (0-255) — Plum's counterpart to Go's |
| a271f34 | 7 | # `byte`/`uint8`. `Byte(x)` converts an `Int` (wrapping, not trapping, if `x` |
| a271f34 | 8 | # is outside 0-255) or another `Byte` (a no-op) into one — a compiler- |
| a271f34 | 9 | # recognized conversion, not an ordinary function call, exactly like |
| a271f34 | 10 | # `Int(x)`/`Float(x)` (see `plum-checker`/`plum-wasm-codegen`'s special-cased |
| a271f34 | 11 | # handling of these three names). |
| 5f2f962 | 12 | enum Byte = |
| 5f2f962 | 13 | | Byte |
| 5f2f962 | 14 | |
| a271f34 | 15 | fun toInt(self) -> Int = |
| a271f34 | 16 | Int(self) |
| a271f34 | 17 | |
| a271f34 | 18 | fun toStr(self) -> Str = |
| a271f34 | 19 | Int(self).toStr() |