AGL (AnotherGoLang) Description AGL is a language that compiles to Go. It uses Go's syntax, in fact its lexer/parser is a fork of the original Go implementation, with a few modifications The main differences are: Functions return only a single value. This makes it possible to use types like Option[T] and Result[T] , and to support automatic error propagation via an operator. and , and to support automatic error propagation via an operator. To make returning multiple values easy, a Tuple type has been introduced. For example: Result[(u8, string, bool)] AGL can be used as a scripting language Notable change: number types are int i8 i16 i32 i64 uint u8 u16 u32 u64 f32 f64 features Tuple Enum Error propagation operators ( ? for Option[T] / ! for Result[T]) for Option[T] / for Result[T]) Concise anonymous function with type inferred arguments ( other := someArr.Filter({ $0 % 2 == 0 }) ) ) Array built-in Map/Reduce/Filter/Find/Sum methods Operator overloading Compile down to Go code VSCode extension & LSP (language server protocol) Shell "shebang" support How to use go build // Build the "agl" executable . / agl main . agl // Output Go code in stdout . / agl run main . agl // Run the code directly and output the result in stdout . / agl build main . agl // Create a main.go file Error propagation Result propagation package main import "fmt" func getInt () int ! { // `int!` means the function return a `Result[int]` return Ok ( 42 ) } func intermediate () int ! { num := getInt () ! // Propagate 'Err' value to the caller return Ok ( num + 1 ) } func main () { num := intermediate () ! // crash on 'Err' value fmt . Println ( num ) } Option propagation package main import "fmt" func maybeInt () int ? { // `int?` means the the function return an `Option[int]` return Some ( 42 ) } func intermediate () int ? { num := maybeInt ()? // Propagate 'None' value to the caller return Some ( num + 1 ) } func main () { num := intermediate ()? // crash on 'None' value fmt . Println ( num ) } ...
First seen: 2025-06-28 21:32
Last seen: 2025-06-29 02:35