Skip to main content
v0.13.0
rfc-0016superseded

Standard Library Foundation

Summary

Define the initial scope and organisation of the Metel standard library: which modules exist, what they contain, and how they are imported. Blocked on RFC-0009 (module system).

Motivation

All v0.1 programs are single-file with no stdlib beyond the built-in functions. A standard library is needed for practical programs: numeric utilities, string manipulation, I/O, and higher-level collections.

Planned Modules

std::math

FunctionSignature
floor(f: Float) -> Float
ceil(f: Float) -> Float
abs(n: Int) -> Int / (f: Float) -> Float
sqrt(f: Float) -> Float
pow(base: Float, exp: Float) -> Float
min, max(a: T, b: T) -> T

std::string

FunctionSignature
split(s: String, sep: String) -> String[]
trim(s: String) -> String
contains(s: String, sub: String) -> boolean
to_upper, to_lower(s: String) -> String

std::io

FunctionSignature
read_line() -> String
read_file(path: String) -> Result<String, String>
write_file(path: String, content: String) -> Result<(), String>

std::collections

  • List<T>: higher-level sequence type on top of Array<T>, with push, pop, map, filter, fold. Requires generics (v0.3).

Built-in Migration

The v0.1 built-in functions (print, println, int_to_string, float_to_string, bool_to_string, string_len, string_concat, array_push, array_len, clock) are an explicit temporary measure. They exist only because v0.1 programs have no module system and no stdlib. When the stdlib ships, these functions move into appropriate stdlib modules and the global built-in form is removed:

Built-inStdlib destination
print, printlnstd::io
int_to_string, float_to_string, bool_to_stringsuperseded by the Display aspect (RFC-0012)
string_len, string_concatstd::string
array_push, array_lenstd::array / std::collections
clockstd::time

This is not a backwards-compatibility question — built-ins are not a stable API surface. Programs written for v0.1 are expected to migrate when stdlib lands.

Open Questions

  • Module path convention: std::math or std/math or something else? Depends on RFC-0009.
  • Generic stdlib functions (min, max, List<T>): require the aspect system for bounds (T: Comparable). Does stdlib ship in phases alongside language versions?
  • Versioning: does the stdlib follow the same language version as the spec, or does it version independently?

Decision

Outcome: (pending)
Target: (blank until accepted)

(Decision rationale goes here when the RFC is evaluated.)