plum

#treesitter#compiler#wasm

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

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


plum-std/Byte.plum
module std
import std/Number
import std/Bool
import std/Str

# Byte is an unsigned 8-bit value (0-255) — Plum's counterpart to Go's
# `byte`/`uint8`. `Byte(x)` converts an `Int` (wrapping, not trapping, if `x`
# is outside 0-255) or another `Byte` (a no-op) into one — a compiler-
# recognized conversion, not an ordinary function call, exactly like
# `Int(x)`/`Float(x)` (see `plum-checker`/`plum-wasm-codegen`'s special-cased
# handling of these three names).
enum Byte =
  | Byte

  fun toInt(self) -> Int =
    Int(self)

  fun toStr(self) -> Str =
    Int(self).toStr()