Page cover

hand-waveWelcome

Welcome to the official documentation for the Lox2 programming language—a superset of the original Lox toy languagearrow-up-right featuring a multi-pass compiler, optional type checker, and numerous new features. Lox2 is open source and designed for educational purposes; its source code is available on GitHub and is structured for readability, making it accessible for anyone interested in compiler implementation. In addition to its educational value, Lox2 is production-ready, enabling developers to build robust applications using its advanced features and comprehensive standard library.

View on Github

The following example demonstrates how to send a simple asynchronous HTTP request, print the response to the console, and throw an exception if the request fails. This code sample utilizes several Lox2 features, including namespace declaration and import, immutable variable declaration, async/await, string interpolation, and exception handling:

namespace Lox2Example
using clox.std.net.HTTPClient
using clox.std.net.URL

val client = HTTPClient()
val response = await client.getAsync(URL.parse("https://example.com"))

if (response.status != 200) {
    throw Exception("HTTP error! Status: ${response.status}")
}

println("Content: ${response.content}")
client.close()

Jump right in

Last updated