Only this pageAll pages
Powered by GitBook
1 of 33

docs

Loading...

Getting Started

Loading...

Loading...

Loading...

Loading...

Basics

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Advanced Features

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Version Release Notes

Loading...

Read before Proceeding

Credits: The Gauntlet programming language and this accompanying documentation were written solely by TricolorHen061.

What you need to know about Gauntlet

  • Gauntlet is in it's alpha phase. Please expect (and !) bugs.

  • Non-parser error messages are do not contain line numbers. This will be implemented in a future update.

  • There is little typechecking. Better typechecking will be implemented in the future.

  • All Gauntlet type names are the CamelCase version of it's corresponding Go type name. For instance:

    • String type in Gauntlet -> string type in Golang

    • Float64 type in Gauntlet -> float64 type in Golang

  • The only two exceptions to the above rule are:

    • Unit, which is equivalent to ()

    • Null, which is equivalent to nil

  • You can import and use any library from the Golang ecosystem without writing a binding. Though at this point in time, Gauntlet does not perform type-checking on them.

    • When referring to a function from a module, use camelCase to refer to it. Use PascalCase for everything else.

What you need to know about this documentation

  • Anything wrapped in <> signifies a required placeholder

  • Anything wrapped in [] signifies an optional placeholder

  • The type of casing that should be used is reflected in placeholder names. For instance, if something LooksLikeThis , it means PascalCase should be used.

Useful Links

  • Join the Discord server

  • Take a look at the GitHub repository

  • Check out the Visual Studio Code extension

Common placeholders throughout documentation

  • Generics

    • Syntax: [TypeConstraint ParamName, ...]

    • Example: [T : String, U: Any]

Int type in Guantlet -> int type in Golang

GenericsInstantiation

  • Syntax: [Type1, Type2, ...]

  • Example: [String, Int]

  • Parameters

    • Syntax: ParamName : ParamType, ...

    • Example: num1 : Int, num2 : Int

  • varPattern

    • Syntax: varName1, varName2, etc

    • Example: firstName, lastName

  • report
    here
    here
    here

    Running Gauntlet

    All Gauntlet files end in .gaunt

    Transpiling Code

    To transpile Gauntlet code to Go code, simply provide the target .gaunt file. If no errors are found, Gauntlet will put your transpiled code in a .go file (in the same folder as your Gauntlet one) with the corresponding name. In the example below, the file name is MyTestFile.gaunt, which means MyTestFile.go will contain the resulting code.

    Example

    Run Immediately After Transpiling

    You can run your transpiled code immediately after it's created by utilizing the run command.

    Example

    Skipping formatting

    By default, your transpiled code will be formatted with go fmt. If, for some reason, you don't want this, you can stop it from happening with the --no-format flag.

    Example

    -OR-

    ./gauntlet MyTestFile.gaunt
    .\gauntlet.exe MyTestFile.gaunt
    ./gauntlet MyTestFile.gaunt run 
    .\gauntlet MyTestFile.gaunt run 
    ./gauntlet MyTestFile.gaunt run --no-format
    .\gauntlet MyTestFile.gaunt run --no-format
    ./gauntlet MyTestFile.gaunt --no-format
    .\gauntlet MyTestFile.gaunt --no-format

    Installation

    For the sake of organization, it's recommended that you make a Gauntlet folder (e.g. Gauntlet test) to put the gauntlet executable in, along with your .gaunt files.

    Go must be installed on your computer for Gauntlet to work

    Installing Gauntlet

    1

    Head to the and download for your OS

    • The GitHub Releases page is the only official source for distributing Gauntlet

    Linux, Windows, and MacOS are supported

  • Be sure to download the most recent version

  • 2

    Prepare for usage

    • Rename the file you just downloaded to gauntlet for easy access

      • You can use your file manager to do this

    • Mark the file as executable (only required on Linux and MacOS)

      • chmod +x gauntlet

    • Move to PATH for universal access (optional)

      • There are plenty of articles online for how you can do this for your respective OS

    3

    Verify Installation Works

    • In the same folder as the gauntlet file, run:

      • Linux/MacOS: ./gauntlet test

      • Windows: .\gauntlet.exe test

    • If you see You've successfully installed Gauntlet!, then you're all set!

    • If you don't see that message, then join the and ask for help

    GitHub Releases page

    Introduction To Gauntlet

    💡What is Gauntlet?💡

    Gauntlet is a programming language made to tackle Golang’s most frustrating design choices. It transpiles exclusively to Go, fully supports all of its features, and integrates seamlessly with its entire ecosystem — without the need for bindings.

    👊What Go Issues does Gauntlet Fix?👊

    • Annoying "unused variable" error

    • Verbose error handling (if err ≠ nil everywhere in your code)

    • Annoying way to import and export (e.g. capitalizing letters to export)

    • Lack of ternary operator

    ⚡Language Features⚡

    • Transpiles to maintainable, easy-to-read Golang

    • Interoperates with entire Go ecosystem. No bindings required.

    • Consistent and familiar syntax

    • Near-instant conversion to Go

    📈 Status of Gauntlet 📈

    Gauntlet is in the alpha phase - meaning it has just been released without thorough testing. As such, it will inevitably contain bugs. If you run into one, please open an issue on the .

    🤔Why is it called "Gauntlet"?🤔

    Because I snapped Go's issues out of existence

    Scope Variables

    There are two types of scope variable bindings in Gauntlet:

    Both types of variables are mutable

    For syntax of varPattern see

    1. let-variables

    let-variables use the := operator under the hood. It's syntax is:

    2. zero-variables

    Zero-variables create an instance of a type's "zero" value. In Gauntlet, the syntax is:

    Working Example

    Constants

    You can only declare constants at the toplevel scope

    Constant Declaration Syntax

    [export] const <CONST_NAME_HERE> = <expr>

    Working Example

    VSCode Extension

    Gauntlet Visual Studio Code Extension Installation

    Open Visual Studio Code, navigate to the Extensions tab (on the left bar), and then search "Gauntlet". Select the one with the green fist and hit "Install".

    It will provide your code with beautiful syntax highlighting:

    Discord server
    Lack of expressional switch-case construct
  • Complicated for-loops

  • Weird assignment operator (whose idea was it to use :=)

  • No way to fluently pipe functions

  • Easy install with a singular self-contained executable

  • Beautiful syntax highlighting on Visual Studio Code

  • Shares exact conventions/idioms with Golang. Virtually no learning curve.

  • GitHub page
    Common placeholders throughout documentation
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let a, b, c: Int = (1, 2, 3)
      let myName = "Bobby"
      fmt.println(myName)
    
      zero myZeroVar: Int
      fmt.println("The number below should be 0, since it's Int's 'zero' value:")
      fmt.println(myZeroVar)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	var a, b, c int = 1, 2, 3
    	myName := "Bobby"
    	fmt.Println(myName)
    	var myZeroVar int
    	fmt.Println("The number below should be 0, since it's Int's 'zero' value:")
    	fmt.Println(myZeroVar)
    	// Eliminates any 'unused variable' errors
    	_, _, _, _, _ = a, b, c, myName, myZeroVar
    
    }
    
    package main
    
    import "fmt" as fmt
    
    const PI = 3.14
    const MY_NAME = "Bob"
    
    fun main(): Unit {
      fmt.println("My name is " + MY_NAME + ". And pi is approximately:")
      fmt.println(PI)
    }
    package main
    
    import fmt "fmt"
    
    const pI = 3.14
    const mY_NAME = "Bob"
    
    func main() {
    	fmt.Println("My name is " + mY_NAME + ". And pi is approximately:")
    	fmt.Println(pI)
    
    }
    
    let <varPattern> [: TypeName] = <expression>
    zero <varPattern>: <TypeName>
    Bobby
    The number below should be 0, since it's Int's 'zero' value:
    0
    My name is Bob. And pi is approximately:
    3.14

    Welcome

    Welcome to the official documentation for the Gauntlet Programming Language.

    Gauntlet was made so you can overcome Golang's frustrating design choices. Have a look:

    package main
    
    // Seamless interop with the entire golang ecosystem
    import "fmt" as fmt
    import "os" as os
    import "strings" as strings
    import "strconv" as strconv
    
    
    // Explicit export keyword
    

    Like what you see? Hit the "Introduction To Gauntlet" button below.

    Switch-Case

    Switch-Case Syntax (Expressions)

    switch <expr> {
        case <expr> : {
            <case body>
        }
        case <expr> : {
            <case body>
        }
        // The default case is optional
        default : {
            <default case body>
        }
    }

    Switch-Case Syntax (Types)

    Working Example

    Loops

    Gauntlet supports two types of loops

    For syntax of varPattern see Common placeholders throughout documentation

    break and continue are supported

    1. For-loops

    Syntax for-loop (traditional style)

    Working Example

    Syntax for for-loop (shorthand style)

    Working Example

    2. While-loops

    While-loop syntax:

    Working Example

    Select-Case

    Select-Case Syntax

    Working Example

    package main
    
    import "fmt" as fmt
    
    fun Unit main() {
      let ch1 = make(chan String, 1)
      let ch2 = make(chan String, 1
    

    Functions

    Function Declaration Syntax

    [exported] fun <functionName>[Generics]([Parameters]): <ReturnType> {
        <function body>
    }

    For syntax of Generics and Parameters - Common placeholders throughout documentation

    Working Example

    If Statements

    If-statement syntax

    Working Example

    package main
    
    import "fmt" as fmt
    
    
    fun main(): Unit {
      let isInRelationship = false
      let isProgrammer = true
      if isProgrammer && !isInRelationship {
    
    package main
    
    import fmt "fmt"
    import os "os"
    import strings "strings"
    import strconv "strconv"
    
    func GetTrimmedFileLines(fileName string) ([]string, error) {
    	fileContent, err := os.ReadFile(fileName)
    	if err != nil {
    		return nil, err
    	}
    	fileContentStrVersion := string(fileContent)
    	trimmedLines := strings.Split(strings.TrimSpace(fileContentStrVersion), "\n")
    
    	// Eliminates any 'unused variable' errors
    	_, _, _, _ = err, fileContent, fileContentStrVersion, trimmedLines
    	return trimmedLines, nil
    
    }
    
    func main() {
    	a := 1
    	lines, err := GetTrimmedFileLines("example.txt")
    	if err != nil {
    		panic(err)
    	}
    	properWord := (func() string {
    		if len(lines) > 1 {
    			return "lines"
    		}
    		return "line"
    	})()
    	stringLength := strconv.Itoa(len(lines))
    	fmt.Println("There are " + stringLength + " " + properWord + ".")
    	fmt.Println("Here they are:")
    	for i, line := range lines {
    		fmt.Println("Line " + strconv.Itoa(i+1) + " is:")
    		fmt.Println(line)
    		// Eliminates any 'unused variable' errors
    		_, _ = i, line
    	}
    	// Eliminates any 'unused variable' errors
    	_, _, _, _, _ = a, err, lines, properWord, stringLength
    
    }
    
    Whats
    the
    meaning
    of 
    life
    There are 5 lines.
    Here they are:
    Line 1 is:
    Whats
    Line 2 is:
    the
    Line 3 is:
    meaning
    Line 4 is:
    of 
    Line 5 is:
    life
    switch typeof <expr> {
        case <Type> : {
            <case body>
        }
        case <Type> : {
            <case body>
        }
        // The default case is optional
        default : {
            <default case body>
        }
    }
    select {
        case <expr> : {
            <case body>
        }
        // or, you can declare variable(s) 
        case let <varPattern> = <expr> : {
            <case body>
        }
        // default is optional
        default: {
            <case body>
        }
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	ch1 := make(chan string, 1)
    	ch2 := make(chan string, 1)
    	ch1 <- "Hello from ch1"
    	var msg string
    	var ok bool
    	select {
    	case msg, ok := <-ch1:
    		{
    			if ok {
    				fmt.Println("Case 1:", msg)
    			} else {
    				fmt.Println("ch1 closed")
    			}
    			// Eliminates any 'unused variable' errors
    			_, _ = msg, ok
    		}
    	case <-ch2:
    		{
    			fmt.Println("Case 2: received from ch2")
    		}
    	default:
    		{
    			fmt.Println("Default case: nothing ready")
    		}
    	}
    	// Eliminates any 'unused variable' errors
    	_, _, _, _ = ch1, ch2, msg, ok
    
    }
    
    if <expr> {
        <if statement body>
    }
    elif <expr> {
        <else if statement body>
    }
    else {
        <else statement body>
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	isInRelationship := false
    	isProgrammer := true
    	if isProgrammer && !isInRelationship {
    		fmt.Println("Makes sense")
    	} else if !isProgrammer && isInRelationship {
    		fmt.Println("Makes sense")
    	} else if !isProgrammer && !isInRelationship {
    		fmt.Println("It's ok, it won't be hard for you to find a relationship")
    	} else {
    		fmt.Println("Stop lying")
    	}
    	// Eliminates any 'unused variable' errors
    	_, _ = isInRelationship, isProgrammer
    
    }
    
    export fun getTrimmedFileLines(fileName: String): ([]String, Error) {
    // try-with syntax replaces verbose `err != nil` error handling
    let fileContent, err = try os.readFile(fileName) with (null, err)
    // Type conversion
    let fileContentStrVersion = (String)(fileContent)
    let trimmedLines =
    // Pipes feed output of last function into next one
    fileContentStrVersion
    |> strings.trimSpace(_)
    |> strings.split(_, "\n")
    // `nil` is equal to `null` in Gauntlet
    return (trimmedLines, null)
    }
    fun main(): Unit {
    // No 'unused variable' errors
    let a = 1
    // force-with syntax will panic if err != nil
    let lines, err = force getTrimmedFileLines("example.txt") with err
    // Ternary operator
    let properWord = @String len(lines) > 1 ? "lines" : "line"
    let stringLength = lines |> len(_) |> strconv.itoa(_)
    fmt.println("There are " + stringLength + " " + properWord + ".")
    fmt.println("Here they are:")
    // Simplified for-loops
    for let i, line in lines {
    fmt.println("Line " + strconv.itoa(i + 1) + " is:")
    fmt.println(line)
    }
    }
    Evaluating the result of (1 + 2) - 1 ...
    It's two
    And also...
    1 is an Int!
    package main
    
    import "fmt" as fmt
    
    fun Unit main() {
      fmt.println("Counting to 10...")
      for let a = 1; a <= 10; a++ {
        fmt.println(a)
      }
      fmt.println("Done!")
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	fmt.Println("Counting to 10...")
    	for a := 1; a <= 10; a++ {
    		fmt.Println(a)
    		// Eliminates any 'unused variable' errors
    		_ = a
    	}
    	fmt.Println("Done!")
    
    }
    
    )
    ch1 <- "Hello from ch1"
    zero String msg
    zero Bool ok
    select {
    case let msg, ok = <-ch1: {
    if ok {
    fmt.Println("Case 1:", msg)
    } else {
    fmt.Println("ch1 closed")
    }
    }
    case <-ch2: {
    fmt.Println("Case 2: received from ch2")
    }
    default: {
    fmt.Println("Default case: nothing ready")
    }
    }
    }
    package main
    
    import "fmt" as fmt
    import "golang.org/x/exp/constraints" as constraints
    
    fun isOver[T: constraints.Integer](a: T, b: T): Bool {
      return a > b
    } 
    
    fun createGreeting(firstName: String, lastName: String): String {
      return "Hello " + firstName + " " + lastName + "!"
    }
    
    fun main(): Unit {
      let age = 28
      let firstName = "John"
      let lastName = "Doe"
      let greeting = createGreeting(firstName, lastName)
      let isAdult = isOver(age, 18)
      fmt.println("Greeting:")
      fmt.println(greeting)
      fmt.println("Adult Status:")
      fmt.println(isAdult)
    }
    fmt.println("Makes sense")
    }
    elif !isProgrammer && isInRelationship {
    fmt.println("Makes sense")
    }
    elif !isProgrammer && !isInRelationship {
    fmt.println("It's ok, it won't be hard for you to find a relationship")
    }
    else {
    fmt.println("Stop lying")
    }
    }
    package main
    
    import "fmt" as fmt
    
    fun Unit main() {
      let result = (1 + 2) - 1 
      fmt.println("Evaluating the result of (1 + 2) - 1 ...")
      switch result {
        case 1: {
          fmt.println("It's one")
        }
        case 2: {
          fmt.println("It's two")
        }
        case 3: {
          fmt.println("It's three")
        }
        default: {
          fmt.println("It's not one, two, or three.")
        }
      }
    
      fmt.println("And also...")
      
      let Any a = 1
    
      switch typeof a {
        case String: {
          fmt.println("1 is a String!")
        }
        case Int: {
          fmt.println("1 is an Int!")
        }
      }
    
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	result := (1 + 2) - 1
    	fmt.Println("Evaluating the result of (1 + 2) - 1 ...")
    	switch result {
    	case 1:
    		{
    			fmt.Println("It's one")
    		}
    	case 2:
    		{
    			fmt.Println("It's two")
    		}
    	case 3:
    		{
    			fmt.Println("It's three")
    		}
    	default:
    		{
    			fmt.Println("It's not one, two, or three.")
    		}
    	}
    	fmt.Println("And also...")
    	var a any = 1
    	switch a.(type) {
    	case string:
    		{
    			fmt.Println("1 is a String!")
    		}
    	case int:
    		{
    			fmt.Println("1 is an Int!")
    		}
    
    	}
    	// Eliminates any 'unused variable' errors
    	_, _ = a, result
    
    }
    
    for let <varPattern> = <expr>; <terminal expr>; <expr run after every iteration> {
        <loop body>
    } 
    Counting to 10...
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Done!
    for let <varPattern> in <iterable> {
        <loop body>
    }
    package main
    
    import "fmt" as fmt
    
    fun Unit main() {
      fmt.println("Iterating through every letter in the word 'Hello'")
      for let _, c in "Hello" {
        fmt.println((String)(c))
      }
      fmt.println("Done!")
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	fmt.Println("Iterating through every letter in the word 'Hello'")
    	for _, c := range "Hello" {
    		fmt.Println(string(c))
    		// Eliminates any 'unused variable' errors
    		_ = c
    	}
    	fmt.Println("Done!")
    
    }
    
    Iterating through every letter in the word 'Hello'
    H
    e
    l
    l
    o
    Done!
    for <terminal expr> {
        <loop body>
    }
    package main
    
    import "fmt" as fmt
    
    fun Unit main() {
      fmt.println("The program will terminate if you say the magic word...")
      
      let magicWord = "please"
      zero String input
      
      while input != magicWord {
        fmt.println("What's the magic word?")
        fmt.scan(&input)
      }
      fmt.println("You said it!")
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	fmt.Println("The program will terminate if you say the magic word...")
    	magicWord := "please"
    	var input string
    	for {
    		if !(input != magicWord) {
    			break
    		}
    		fmt.Println("What's the magic word?")
    		fmt.Scan(&input)
    	}
    	fmt.Println("You said it!")
    	// Eliminates any 'unused variable' errors
    	_, _ = magicWord, input
    
    }
    
    The program will terminate if you say the magic word...
    What's the magic word?
    Gauntlet
    What's the magic word?
    Go
    What's the magic word?
    Life
    What's the magic word?
    please
    You said it!
    Case 1: Hello from ch1
    package main
    
    import fmt "fmt"
    import constraints "golang.org/x/exp/constraints"
    
    func isOver[T constraints.Integer](a T, b T) bool {
    
    	return a > b
    
    }
    
    func createGreeting(firstName string, lastName string) string {
    
    	return "Hello " + firstName + " " + lastName + "!"
    
    }
    
    func main() {
    	age := 28
    	firstName := "John"
    	lastName := "Doe"
    	greeting := createGreeting(firstName, lastName)
    	isAdult := isOver(age, 18)
    	fmt.Println("Greeting:")
    	fmt.Println(greeting)
    	fmt.Println("Adult Status:")
    	fmt.Println(isAdult)
    	// Eliminates any 'unused variable' errors
    	_, _, _, _, _ = age, firstName, greeting, isAdult, lastName
    
    }
    
    Greeting:
    Hello John Doe!
    Adult Status:
    true
    Makes sense

    Ternary Operator

    Ternary operator syntax:

    Working Example

    package main
    
    import "fmt" as fmt
    import "strconv" as strconv
    
    fun main(): Unit {
      let isProgrammer = true
      let mood = @String isProgrammer ? 
    
    package main
    
    import fmt "fmt"
    import strconv "strconv"
    
    func main() {
    	isProgrammer := true
    	mood := (func() string {
    		if
    

    File Setup & Hello World

    Starting a File

    Gauntlet mirrors Go's package-based compilation model. As such, every file must start with package <name>.

    Importing and Using Modules

    Gauntlet's import syntax is:

    It is required that you give an alias to every module you import.

    Once you have imported it, you can use it like you normally would in Golang.

    If you imported fmt as such:

    Then you must access it using whatever is on the right side of the "as" keyword (fmt):

    The "main" Function

    Functions are explained in more detail later

    The main function is the entry point of every Gauntlet program; it is not required in every file. It must have a return type of Unit.

    Working Hello World Example

    Methods

    Method Syntax

    def <methodName>(<receiverParamName>: ReceiverType, Parameters): <ReturnType> {
        <method body>
    }

    For syntax of Parameters - Common placeholders throughout documentation

    Methods can be implemented only on wrapper types and structs.

    Working Example

    Structs

    Struct Declaration Syntax

    For syntax of Generics - Common placeholders throughout documentation

    Struct Construction

    Working Example

    Embedded fields can only be accessed off of the embedded type. They are not a part of the "overall" type. For instance, if B with field C is embedded into A, then C can only be accessed by A.B.C, not A.C.

    While generics were not needed in this specific example, they were used to showcase syntax

    Aliases

    Alias Syntax

    Working Example

    Interfaces

    Interface Declaration Syntax

    For syntax of Generics and Arguments -

    Lambdas

    Lambda Syntax

    For syntax of Parameters -

    Working Example

    When-Cases

    When-Case syntax

    A when-case is equivalent to a switch case, except:

    1. when-cases are expressions, not statements

    2. The default

    @<ReturnType> <test expr> ? <success value> : <failure value>
    [export] struct <StructName>[Generics] {
      [export] <FieldName>: <FieldType> [`FieldTag`] // Syntax of fields
      <EmbeddedInterfaces> // Syntax of embedded interfaces
      <EmbeddedStructs> // Syntax of embedded structs
    }
    <StructName>[GenericsInstantiation]{Field1 = Value1, etc}
    "depressed"
    :
    "happy"
    fmt.println("Because it is " + strconv.formatBool(isProgrammer) + " that I am a programmer, I am " + mood)
    }
    isProgrammer {
    return "depressed"
    }
    return "happy"
    })()
    fmt.Println("Because it is " + strconv.FormatBool(isProgrammer) + " that I am a programmer, I am " + mood)
    // Eliminates any 'unused variable' errors
    _, _ = isProgrammer, mood
    }
    package main
    
    import "fmt" as fmt
    import "strconv" as strconv
    
    struct Person {
      FirstName: String
      LastName: String
      Money: Int
      Happy: Bool  
    }
    
    def getSummary(person: Person): String {
      let fullName = person.FirstName + " " + person.LastName
      return fullName + " has $" + strconv.Itoa(person.Money) + ". It is " + strconv.FormatBool(person.Happy) + " that he is happy."
    }
    
    fun main(): Unit {
      let person = Person{FirstName = "John", LastName = "Doe", Money = 10000, Happy = true}
      fmt.println(person.getSummary())
    }
    package main
    
    import "fmt" as fmt
    import "golang.org/x/exp/constraints" as constraints
    
    struct BankAccount[T : constraints.Integer] {
      Retirement: T 
      Checking: T
      Total: T
    }
    
    struct Human[T: constraints.Integer] {
      export FullName: String
      export Age: Int
      BankAccount[T]
    }
    
    
    fun main(): Unit {
      let age = 28
      let firstName = "John"
      let lastName = "Doe"
      let fullName = firstName + " " + lastName
      let john = Human[Int]{FullName = fullName, Age = age, BankAccount = BankAccount[Int]{Retirement = 100000, Checking = 1000, Total = 100000 + 1000}}
      fmt.println("John's full name is:")
      fmt.println(john.FullName)
      fmt.println("In total, he has this much money:")
      fmt.println(john.BankAccount.Total)
    
    }
    package main
    
    import "fmt" as fmt
    
    alias Name = String
    
    fun getGreeting(name: Name): String {
      return "Hello, " + name + "!"
    }
    
    fun main(): Unit {
      let myGreeting = getGreeting("Bob")
      fmt.println(myGreeting)
    }
    package main
    
    import fmt "fmt"
    
    type name = string
    
    func getGreeting(name name) string {
    
    	return "Hello, " + name + "!"
    
    }
    
    func main() {
    	myGreeting := getGreeting("Bob")
    	fmt.Println(myGreeting)
    	// Eliminates any 'unused variable' errors
    	_ = myGreeting
    
    }
    
    Because it is true that I am a programmer, I am depressed
    import "<modulename>" as <aliasname>
    import "fmt" as fmt
    fmt.println("Hello World!")
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      fmt.println("Hello World!")
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	fmt.Println("Hello World!")
    }
    Hello World!
    package main
    
    import fmt "fmt"
    import strconv "strconv"
    
    type person struct {
    	happy     bool
    	money     int
    	lastName  string
    	firstName string
    }
    
    func (person person) getSummary() string {
    	fullName := person.firstName + " " + person.lastName
    
    	// Eliminates any 'unused variable' errors
    	_ = fullName
    	return fullName + " has $" + strconv.Itoa(person.money) + ". It is " + strconv.FormatBool(person.happy) + " that he is happy."
    }
    
    func main() {
    	person := person{firstName: "John", lastName: "Doe", money: 10000, happy: true}
    	fmt.Println(person.getSummary())
    	// Eliminates any 'unused variable' errors
    	_ = person
    
    }
    
    John Doe has $10000. It is true that he is happy.
    package main
    
    import fmt "fmt"
    import constraints "golang.org/x/exp/constraints"
    
    type bankAccount[T constraints.Integer] struct {
    	total      T
    	checking   T
    	retirement T
    }
    
    type human[T constraints.Integer] struct {
    	Age      int
    	FullName string
    
    	bankAccount[T]
    }
    
    func main() {
    	age := 28
    	firstName := "John"
    	lastName := "Doe"
    	fullName := firstName + " " + lastName
    	john := human[int]{FullName: fullName, Age: age, bankAccount: bankAccount[int]{retirement: 100000, checking: 1000, total: 100000 + 1000}}
    	fmt.Println("John's full name is:")
    	fmt.Println(john.FullName)
    	fmt.Println("In total, he has this much money:")
    	fmt.Println(john.bankAccount.total)
    	// Eliminates any 'unused variable' errors
    	_, _, _, _, _ = age, firstName, fullName, john, lastName
    
    }
    
    John's full name is:
    John Doe
    In total, he has this much money:
    101000
    Hello, Bob!
    alias <AliasName> = <Type>
    Working Example

    The def syntax creates a method. It is covered in a later section. In this context, it is used to implement the interface.

    package main
    
    import "fmt" as fmt
    import "strings" as strings
    
    interface AcceptableAgeType {
      | Int16 | Int32 | 
    }
    
    struct Person 
    
    Common placeholders throughout documentation
    package main
    
    import "fmt" as fmt
    
    
    fun main(): Unit {
      let myLambda = lambda (caps: Bool): String {
        if caps {
          return "HELLO"
    
    package main
    
    import fmt "fmt"
    
    func main() {
    	myLambda := func(caps bool) string {
    		if caps {
    
    			return "HELLO"
    

    Common placeholders throughout documentation
    case is
    required
  • New scopes cannot be used on the left side of the arrow. Only expressions can.

  • Working Example

    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let language = "Gauntlet"
      let reaction = when language @ String {
        is "Gauntlet" -> "smiled"
    
    package main
    
    import fmt "fmt"
    
    func main() {
    	language := "Gauntlet"
    	reaction := (func() string {
    		switch language {
    		case
    

    Tagged Unions

    Syntax

    Example

    package main
    
    import "fmt" as fmt
    import "strconv" as strconv
    
    enum Shapes {
        Circle(diameter: Int, color: String)
        Square(width
    

    Pipes

    Pipe Syntax

    expr |> someFunctionCall(<args with at least one underscore>)

    The pipe (|>) takes the expression on the left and "pipes" it into the function right, wherever there are underscores.

    For every underscore you use, a new instance of the left-hand expression will be made. For instance, myExpr |> someFunction(_, _) turns into someFunction(myExpr, myExpr). This many result in unwanted side-effects.

    Working Example

    Miscellaneous

    This page documents the part of the language that were not "big" enough to warrant an entire page.

    Line Comments

    Syntax

    Working Example

    At this time, block comments are not supported

    Array Literal

    You can use an array literal to construct an array.

    Syntax

    -OR-

    Working Example

    Slice Literal

    You can use a slice literal to construct a slice.

    Syntax

    Working Example

    Map Literal

    Map literals can be used to construct maps

    Syntax

    Working Example

    Indexing

    The indexing operator can be used on arrays, slices, strings, maps, and pointers to arrays

    Syntax

    Working Example

    Slicing

    Slicing can only be done on strings, slices, and arrays

    Syntax:

    Working Example

    Tuples

    Syntax

    Working Example

    Type Assertion

    Syntax

    Working Example

    Type Conversion

    Syntax

    Working Example

    Goroutines

    Syntax

    Working Example

    Defer

    Syntax

    Working Example

    Pointers & Dereferencing

    Pointer Syntax

    Dereferencing Syntax

    Working Example

    Sending and Receiving with Channels

    Sending Syntax

    Receiving Syntax

    Working Example

    Negated Expression

    Syntax

    Working Example

    Force-Statements

    Force-Statement Syntax

    A force-statement evaluates the expr between force and with. It must evaluate to (..., error).

    • If error != nil:

      • The program will panic with the expr to the right of with

    • If error == nil:

      • expression between try and with will be destructured into successVar and failureVar

    Working Example

    The below code will error, which is intended since force will call panic

    Pattern Matching

    Syntax

    <case expr> refers to any of the following:

    • An enum literal (e.g. Circle() in the below example)

      • Currently, you cannot pattern match on any field that is another enum literal. Support is currently being implemented for this.

    • A string (e.g. "hello")

    • An int (e.g. 30)

    • A decimal (e.g. 5.0)

    • A boolean (e.g. true)

    • A char (e.g. 'a')

    • [Support Coming Soon] Wildcard

    • [Support Coming Soon] Array literal (e.g. [2]string{"hello", "world"})

    • [Support Coming Soon] Slice literal (e.g. []string{"hello", "world"})

    Working Example

    Try-Statements

    Try-statement syntax

    --OR--

    The try-statement will evaluate the expression in-between try and with. Said expression must have a type of (..., error).

    • If error != nil: the expression to the right of with will be returned.

    • If error == nil:

      • If you're using the first syntax: Control flow will continue as normal

      • If you're using the second syntax: expression between try and with will be destructured into successVar and failureVar

    Working Example

    package main
    
    import fmt "fmt"
    import strings "strings"
    
    type acceptableAgeType interface {
    	int16 | int32
    }
    
    type person struct {
    	Age       int16
    	LastName  string
    	FirstName string
    }
    type greeter interface {
    	greet(punctuation string) string
    
    	person
    }
    type loudGreeter interface {
    	shout() string
    	greeter
    }
    
    func (name person) greet(punctuation string) {
    	fmt.Println("Greetings " + name.FirstName + " " + name.LastName + punctuation)
    }
    func (name person) shout() {
    	uppercaseFirstName := strings.ToUpper(name.FirstName)
    	uppercaseLastName := strings.ToUpper(name.LastName)
    	fmt.Println("GREETINGS " + uppercaseFirstName + " " + uppercaseLastName + "!!!!!!!")
    	// Eliminates any 'unused variable' errors
    	_, _ = uppercaseFirstName, uppercaseLastName
    }
    
    func addOneToAge[T acceptableAgeType](inputAge T) T {
    
    	return inputAge + 1
    
    }
    
    func greetBothWays(name person) {
    	fmt.Println("Normal greeting:")
    	name.greet(".")
    	fmt.Println("Shouting greeting:")
    	name.shout()
    
    }
    
    func main() {
    	person := person{FirstName: "John", LastName: "Doe", Age: 35}
    	greetBothWays(person)
    	fmt.Println("Next year, you'll be:")
    	fmt.Println(addOneToAge(person.Age))
    	// Eliminates any 'unused variable' errors
    	_ = person
    
    }
    
    Normal greeting:
    Greetings John Doe.
    Shouting greeting:
    GREETINGS JOHN DOE!!!!!!!
    Next year, you'll be:
    36
    interface <InterfaceName>[Generics] {
        [export] <methodName>(Arguments): <MethodReturnType> // Syntax of methods
        <EmbeddedInterface> // Syntax of embedded interfaces
        <EmbeddedStructs> // Syntax of embedded structs
        <| Type1 | Type2 | etc> // Syntax of type sets
        // NOTE: Type sets MUST start with `|` 
    }
    HELLO
    lambda <ReturnType> (Parameters) {
        <lambda body>
    }
    When I found out I was required to program in Gauntlet, I smiled!
    when <expr> @ <Return Type Of Below exprs> {
        is <expr> -> <expr>
        is <expr> -> <expr>
        is <expr> -> <expr>
        default -> <expr>
    }
    enum <TaggedUnionName> {
        case <case name>(<FieldName> : <FieldType>, ...) // case syntax
    }
    package main
    
    import fmt "fmt"
    import strconv "strconv"
    
    type Case343818345 struct {
    	diameter int
    	color    string
    }
    
    type Case421059818 struct {
    	width  int
    	height int
    	color  string
    }
    
    type Case499594069 struct {
    	base   int
    	width  int
    	height int
    	color  string
    }
    
    func main() {
    	fmt.Println("I only like red triangles. Let's see...")
    	myShape := map[int]any{499594069: Case499594069{base: 10, width: 5, height: 20, color: "red"}}
    	if _, exists := myShape[499594069]; exists {
    
    		if height, b := myShape[499594069].(Case499594069).height, myShape[499594069].(Case499594069).base; (func() bool {
    			return (myShape[499594069].(Case499594069).base == (b)) && (myShape[499594069].(Case499594069).height == (height)) && (myShape[499594069].(Case499594069).color == ("red"))
    		})() {
    			fmt.Println("It's a red triangle with a height of " + strconv.Itoa(height) + " and base length of " + strconv.Itoa(b) + "!")
    		}
    	}
    	if _, exists := myShape[421059818]; exists {
    
    		if width := myShape[421059818].(Case421059818).width; (func() bool {
    			return (myShape[421059818].(Case421059818).width == (width)) && (myShape[421059818].(Case421059818).color == ("red"))
    		})() {
    			fmt.Println("It's a red square with a width of " + strconv.Itoa(width))
    		}
    	}
    	if _, exists := myShape[343818345]; exists {
    
    		if diameter := myShape[343818345].(Case343818345).diameter; (func() bool {
    			return (myShape[343818345].(Case343818345).diameter == (diameter)) && (myShape[343818345].(Case343818345).color == ("red"))
    		})() {
    			fmt.Println("It's a red circle with a diameter of " + strconv.Itoa(diameter))
    		}
    	}
    	// Eliminates any 'unused variable' errors
    	_ = myShape
    
    }
    
    // Comment here
    let <successVar>, <failureVar> = force <expr> with <expr>
    match <expr> {
        case <case expr>: {
            <code block>
        }
    }
    try <expr> with <expr if error != nil>
    let <successVar, failureVar> = try <expr> with <expr>
    {
    export FirstName: String
    export LastName: String
    export Age: Int16
    }
    interface Greeter {
    Person
    greet(punctuation: String): String
    }
    interface LoudGreeter {
    Greeter
    shout(): String
    }
    def greet(name: Person, punctuation: String): Unit {
    fmt.println("Greetings " + name.FirstName + " " + name.LastName + punctuation)
    }
    def shout(name: Person): Unit {
    let uppercaseFirstName = strings.toUpper(name.FirstName)
    let uppercaseLastName = strings.toUpper(name.LastName)
    fmt.println("GREETINGS " + uppercaseFirstName + " " + uppercaseLastName + "!!!!!!!")
    }
    fun addOneToAge[T: AcceptableAgeType](inputAge: T): T {
    return inputAge + 1
    }
    fun greetBothWays(name: Person): Unit {
    fmt.println("Normal greeting:")
    name.greet(".")
    fmt.println("Shouting greeting:")
    name.shout()
    }
    fun main(): Unit {
    let person = Person{FirstName = "John", LastName = "Doe", Age = 35}
    greetBothWays(person)
    fmt.println("Next year, you'll be:")
    fmt.println(addOneToAge(person.Age))
    }
    }
    else {
    return "Hello"
    }
    }
    fmt.println(myLambda(true))
    }
    } else {
    return "Hello"
    }
    }
    fmt.Println(myLambda(true))
    // Eliminates any 'unused variable' errors
    _ = myLambda
    }
    is "Java" -> "threw up"
    is "C++" -> "ripped my hair out"
    is "PHP" -> "died"
    default -> "laughed"
    }
    fmt.println("When I found out I was required to program in " + language + ", I " + reaction + "!")
    }
    "PHP"
    :
    {
    return "died"
    }
    case "C++":
    {
    return "ripped my hair out"
    }
    case "Java":
    {
    return "threw up"
    }
    case "Gauntlet":
    {
    return "smiled"
    }
    default:
    {
    return "laughed"
    }
    }
    })()
    fmt.Println("When I found out I was required to program in " + language + ", I " + reaction + "!")
    // Eliminates any 'unused variable' errors
    _, _ = language, reaction
    }
    :
    Int
    ,
    height
    :
    Int
    ,
    color
    :
    String
    )
    Triangle(base: Int, width: Int, height: Int, color: String)
    }
    fun main(): Unit {
    fmt.println("I only like red triangles. Let's see...")
    let myShape = Triangle(base: 10, width : 5, height : 20, color : "red")
    match myShape {
    case Triangle(base: let b, height: let height, color : "red") : {
    fmt.println("It's a red triangle with a height of " + strconv.itoa(height) + " and base length of " + strconv.itoa(b) + "!")
    }
    case Square(width : let width, color : "red") : {
    fmt.println("It's a red square with a width of " + strconv.itoa(width))
    }
    case Circle(diameter: let diameter, color : "red") : {
    fmt.println("It's a red circle with a diameter of " + strconv.itoa(diameter))
    }
    }
    }
    package main
    
    import "fmt" as fmt
    
    fun add(num: Int, addend: Int): Int {
      return num + addend
    }
    
    fun subtract(num: Int, subtrahend: Int): Int {
      return num - subtrahend
    }
    
    fun multiply(num: Int, multiplier: Int): Int {
      return num * multiplier
    }
    
    fun divide(num: Int, divisor: Int): Int {
      return num / divisor
    }
    
    fun Unit main() {
      10
      |> add(_, 10)
      |> add(_, 30)
      |> divide(_, 2)
      |> subtract(_, 5)
      |> divide(_, 2)
      |> multiply(_, 10)
      |> fmt.println(_)
    }
    Hello world!
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      fmt.println("Hello world!") // This is a comment
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	fmt.Println("Hello world!")
    
    }
    
    package main
    
    import "fmt" as fmt
    import "errors" as errors
    
    fun divide(num1: Int, num2: Int): (Int, Error) {
      if num2 == 0 {
        return (0, errors.new("Cannot divide by 0"))
      }
      return (num1 / num2, null)
    }
    
    fun divideBy2(num: Int): (Int, Error) {
      return divide(num, 2)
    }
    
    fun divideBy0(num: Int): (Int, Error) {
      return divide(num, 0) 
    }
    
    fun getResults(num: Int): (Int, Error) {
      let dBy2Res, dBy2Err = force divideBy2(5) with "Error when dividing 5 by 2"
      let dBy0Res, dBy0Err = force divideBy0(10) with "Error when dividing 10 by 0"
      return (dBy2Res + dBy0Res, null)
    }
    
    fun main(): Unit {
      fmt.println("Let's see if there's an error:")
      let res, err = getResults(10)
      fmt.println(err != null)
    }
    package main
    
    import "fmt" as fmt
    import "errors" as errors
    
    fun divide(num1: Int, num2: Int): (Int, Error) {
      if num2 == 0 {
        return (0, errors.new("Cannot divide by 0"))
      }
      return (num1 / num2, null)
    }
    
    fun divideBy2(num: Int): (Int, Error) {
      return divide(num, 2)
    }
    
    fun divideBy0(num: Int): (Int, Error) {
      return divide(num, 0) 
    }
    
    fun getResults(num: Int): (Int, Error) {
      let dBy2Res, dBy2Err = try divideBy2(5) with (dBy2Res, dBy2Err)
      let dBy0Res, dBy0Err = try divideBy0(10) with (dBy0Res, dBy0Err)
      return (dBy2Res + dBy0Res, null)
    }
    
    fun main(): Unit {
      fmt.println("Let's see if there's an error:")
      let res, err = getResults(10)
      fmt.println(err != null)
    }
    I only like red shapes. Let's see if this shape is red...
    It's a red triangle with a height of 20 and base length of 10
    package main
    
    import fmt "fmt"
    
    func add(num int, addend int) int {
    
    	return num + addend
    
    }
    
    func subtract(num int, subtrahend int) int {
    
    	return num - subtrahend
    
    }
    
    func multiply(num int, multiplier int) int {
    
    	return num * multiplier
    
    }
    
    func divide(num int, divisor int) int {
    
    	return num / divisor
    
    }
    
    func main() {
    	fmt.Println(multiply(divide(subtract(divide(add(add(10, 10), 30), 2), 5), 2), 10))
    
    }
    
    100
    [<array length>]<Array Type>{<expr>, <expr>, ...}
    [...]<Array Type>{<key expr> : <value expr>, ...}
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let goodLanguages = [...]String{"Gauntlet", "Go", "F#"}
      let badLanguages = [3]String{"Java", "PHP", "C#"}
    
      fmt.println("Good languages:")
      fmt.println(goodLanguages)
      fmt.println("Bad languages:")
      fmt.println(badLanguages)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	goodLanguages :=
    		[...]string{"Gauntlet", "Go", "F#"}
    	badLanguages :=
    		[3]string{"Java", "PHP", "C#"}
    	fmt.Println("Good languages:")
    	fmt.Println(goodLanguages)
    	fmt.Println("Bad languages:")
    	fmt.Println(badLanguages)
    	// Eliminates any 'unused variable' errors
    	_, _ = badLanguages, goodLanguages
    
    }
    
    Good languages:
    [Gauntlet Go F#]
    Bad languages:
    [Java PHP C#]
    []<Slice type>{<expr1>, <expr2> ...}
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let first5Numbers = []Int{1, 2, 3, 4, 5} 
      fmt.println("The first 5 numbers are:")
      fmt.println(first5Numbers)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	first5Numbers := []int{1, 2, 3, 4, 5}
    	fmt.Println("The first 5 numbers are:")
    	fmt.Println(first5Numbers)
    	// Eliminates any 'unused variable' errors
    	_ = first5Numbers
    
    }
    
    The first 5 numbers are:
    [1 2 3 4 5]
    [<Key Type>]<Value Type>{<key expr> : <value expr>, ...]
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
    
      let grades = map[String]Int{
        "Bob" : 80
        "Joe" : 75
        "Josh" : 90
      }
    
      fmt.println("Bob's grade was: ")
      fmt.println(grades["Bob"])
    
    
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	grades := map[string]int{"Bob": 80, "Joe": 75, "Josh": 90}
    	fmt.Println("Bob's grade was: ")
    	fmt.Println(grades["Bob"])
    	// Eliminates any 'unused variable' errors
    	_ = grades
    
    }
    
    Bob's grade was: 
    80
    <expr>[expr>]
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let shoppingList = [...]String{"Bananna", "Orange", "Apples"}
      fmt.println("The first thing I want to buy when I get to the store is:")
      fmt.println(shoppingList[1])
    
      let streamingPasswords = map[String]String{
        "Netflix" : "net123",
        "Hulu" : "hulu5"
        "Disney+" : "Disney10"
      }
    
      fmt.println("The password to my Disney+ account is:")
      fmt.println(streamingPasswords["Disney+"])
    
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	shoppingList :=
    		[...]string{"Bananna", "Orange", "Apples"}
    	fmt.Println("The first thing I want to buy when I get to the store is:")
    	fmt.Println(shoppingList[1])
    	streamingPasswords := map[string]string{"Netflix": "net123", "Hulu": "hulu5", "Disney+": "Disney10"}
    	fmt.Println("The password to my Disney+ account is:")
    	fmt.Println(streamingPasswords["Disney+"])
    	// Eliminates any 'unused variable' errors
    	_, _ = shoppingList, streamingPasswords
    
    }
    
    The first thing I want to buy when I get to the store is:
    Orange
    The password to my Disney+ account is:
    Disney10
    <expr>[<start expr> : <end expr>]
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let statement = "I am a human being who is loved and cared for"
      let truePart = statement[0:18]
      fmt.println(truePart)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	statement := "I am a human being who is loved and cared for"
    	truePart := statement[0:18]
    	fmt.Println(truePart)
    	// Eliminates any 'unused variable' errors
    	_, _ = statement, truePart
    
    }
    
    I am a human being
    (<expr>, <expr>, <expr>, etc)
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let a, b, c, d = (1, 2, 3, 4)
      fmt.println("a is:")
      fmt.println(a)
      fmt.println("b is:")
      fmt.println(b)
      fmt.println("c is:")
      fmt.println(c)
      fmt.println("d is:")
      fmt.println(d)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	a, b, c, d := 1, 2, 3, 4
    	fmt.Println("a is:")
    	fmt.Println(a)
    	fmt.Println("b is:")
    	fmt.Println(b)
    	fmt.Println("c is:")
    	fmt.Println(c)
    	fmt.Println("d is:")
    	fmt.Println(d)
    	// Eliminates any 'unused variable' errors
    	_, _, _, _ = a, b, c, d
    
    }
    
    a is:
    1
    b is:
    2
    c is:
    3
    d is:
    4
    <identifier> typeassert <Type>
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let a: Any = 1
      let b = a typeassert Int
      fmt.println(b)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	var a any = 1
    	b := a.(int)
    	fmt.Println(b)
    	// Eliminates any 'unused variable' errors
    	_, _ = a, b
    
    }
    
    1
    (<Type>)(<expr>)
    package main
    
    import "fmt" as fmt
    
    wrapper Int Dollar
    
    fun main(): Unit {
      let dollars = Dollar(10)
      let intVersion = (Int)(dollars)
      fmt.println("I have this much money:")
      fmt.println(intVersion)
    }
    package main
    
    import fmt "fmt"
    
    type dollar int
    
    func main() {
    	dollars := dollar(10)
    	intVersion := int(dollars)
    	fmt.Println("I have this much money:")
    	fmt.Println(intVersion)
    	// Eliminates any 'unused variable' errors
    	_, _ = dollars, intVersion
    
    }
    
    I have this much money:
    10
    go {
        <scope content>
    }
    package main
    
    import "fmt" as fmt
    import "time" as time
    
    fun main(): Unit {
      go {
        fmt.println("Hello from Gauntlet!")
      }
      time.sleep(1 * time.second)
      fmt.println("Main function has ended")
    }
    package main
    
    import fmt "fmt"
    import time "time"
    
    func main() {
    	go (func() {
    		fmt.Println("Hello from Gauntlet!")
    
    	})()
    	time.Sleep(1 * time.Second)
    	fmt.Println("Main function has ended")
    
    }
    
    Hello from Gauntlet!
    Main function has ended
    defer {
        <scope content>
    }
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      defer {
        fmt.println("World!")
      }
      fmt.println("Hello")
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	defer (func() {
    		fmt.Println("World!")
    	})()
    	fmt.Println("Hello")
    
    }
    
    Hello
    World!
    &<expr>
    *<expr>
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let x = 10
      let ptr = &x 
      *ptr = 20
      fmt.println(x)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	x := 10
    	ptr := &x
    	*ptr = 20
    	fmt.Println(x)
    	// Eliminates any 'unused variable' errors
    	_, _ = ptr, x
    
    }
    
    20
    <channel name> <- <expr>
    <-<channel name>
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let ch = make(chan String)
    
      go {
    	ch <- "Hello from goroutine!"
       }
    
       let msg = <-ch
       fmt.println(msg)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	ch := make(chan string)
    	go (func() {
    		ch <- "Hello from goroutine!"
    
    	})()
    	msg := <-ch
    	fmt.Println(msg)
    	// Eliminates any 'unused variable' errors
    	_, _ = ch, msg
    
    }
    
    Hello from goroutine!
    !<expr>
    package main
    
    import "fmt" as fmt
    
    fun main(): Unit {
      let myValue = false
      let myNegatedValue = !myValue
      
      fmt.println("myValue:")
      fmt.println(myValue)
      fmt.println("myValue but negated:")
      fmt.println(myNegatedValue)
    }
    package main
    
    import fmt "fmt"
    
    func main() {
    	myValue := false
    	myNegatedValue := !myValue
    	fmt.Println("myValue:")
    	fmt.Println(myValue)
    	fmt.Println("myValue but negated:")
    	fmt.Println(myNegatedValue)
    	// Eliminates any 'unused variable' errors
    	_, _ = myNegatedValue, myValue
    
    }
    
    myValue:
    false
    myValue but negated:
    true
    package main
    
    import fmt "fmt"
    import errors "errors"
    
    func divide(num1 int, num2 int) (int, error) {
    	if num2 == 0 {
    
    		return 0, errors.New("Cannot divide by 0")
    	}
    
    	return num1 / num2, nil
    
    }
    
    func divideBy2(num int) (int, error) {
    
    	return divide(num, 2)
    
    }
    
    func divideBy0(num int) (int, error) {
    
    	return divide(num, 0)
    
    }
    
    func getResults(num int) (int, error) {
    	dBy2Res, dBy2Err := divideBy2(5)
    	if dBy2Err != nil {
    		panic("Error when dividing 5 by 2")
    	}
    	dBy0Res, dBy0Err := divideBy0(10)
    	if dBy0Err != nil {
    		panic("Error when dividing 10 by 0")
    	}
    
    	// Eliminates any 'unused variable' errors
    	_, _, _, _ = dBy0Err, dBy0Res, dBy2Err, dBy2Res
    	return dBy2Res + dBy0Res, nil
    
    }
    
    func main() {
    	fmt.Println("Let's see if there's an error:")
    	res, err := getResults(10)
    	fmt.Println(err != nil)
    	// Eliminates any 'unused variable' errors
    	_, _ = err, res
    
    }
    
    Let's see if there's an error:
    panic: Error when dividing 10 by 0
    
    goroutine 1 [running]:
    main.getResults(0x4bc5f8?)
            /home/user/projects/gauntlet-lang/GoTesting/sample.go:37 +0x25
    main.main()
            /home/user/projects/gauntlet-lang/GoTesting/sample.go:48 +0x5a
    exit status 2
    package main
    
    import "fmt" as fmt
    import "strconv" as strconv
    
    enum Shapes {
        Circle(diameter: Int, color: String)
        Square(width: Int, height: Int, color: String)
        Triangle(base: Int, width: Int, height: Int, color: String)
    }
    
    fun main(): Unit {
        fmt.println("I only like red triangles. Let's see...")
        
        let myShape = Triangle(base: 10, width : 5, height : 20, color : "red")
        
        match myShape {
            case Triangle(base: let b, height: let height, color : "red") : {
                fmt.println("It's a red triangle with a height of " + strconv.itoa(height) + " and base length of " + strconv.itoa(b) + "!")
            }
            case Square(width : let width, color : "red") : {
                fmt.println("It's a red square with a width of " + strconv.itoa(width))
            }
            case Circle(diameter: let diameter, color : "red") : {
                fmt.println("It's a red circle with a diameter of " + strconv.itoa(diameter))
            }
        }
    }
    package main
    
    import fmt "fmt"
    import strconv "strconv"
    
    type Case343818345 struct {
    diameter int
    color    string
    }
    
    type Case421059818 struct {
    width  int
    height int
    color  string
    }
    
    type Case499594069 struct {
    base   int
    width  int
    height int
    color  string
    }
    
    func main() {
    fmt.Println("I only like red triangles. Let's see...")
    myShape := map[int]any{499594069: Case499594069{base: 10, width: 5, height: 20, color: "red"}}
    if _, exists := myShape[499594069]; exists {
    
    	if height, b := myShape[499594069].(Case499594069).height, myShape[499594069].(Case499594069).base; (func() bool {
    		return (myShape[499594069].(Case499594069).base == (b)) && (myShape[499594069].(Case499594069).height == (height)) && (myShape[499594069].(Case499594069).color == ("red"))
    	})() {
    		fmt.Println("It's a red triangle with a height of " + strconv.Itoa(height) + " and base length of " + strconv.Itoa(b) + "!")
    	}
    }
    if _, exists := myShape[421059818]; exists {
    
    	if width := myShape[421059818].(Case421059818).width; (func() bool {
    		return (myShape[421059818].(Case421059818).width == (width)) && (myShape[421059818].(Case421059818).color == ("red"))
    	})() {
    		fmt.Println("It's a red square with a width of " + strconv.Itoa(width))
    	}
    }
    if _, exists := myShape[343818345]; exists {
    
    	if diameter := myShape[343818345].(Case343818345).diameter; (func() bool {
    		return (myShape[343818345].(Case343818345).diameter == (diameter)) && (myShape[343818345].(Case343818345).color == ("red"))
    	})() {
    		fmt.Println("It's a red circle with a diameter of " + strconv.Itoa(diameter))
    	}
    }
    // Eliminates any 'unused variable' errors
    _ = myShape
    
    }
    
    I only like red triangles. Let's see...
    It's a red triangle with a height of 20 and base length of 10!
    package main
    
    import fmt "fmt"
    import errors "errors"
    
    func divide(num1 int, num2 int) (int, error) {
    	if num2 == 0 {
    
    		return 0, errors.New("Cannot divide by 0")
    	}
    
    	return num1 / num2, nil
    
    }
    
    func divideBy2(num int) (int, error) {
    
    	return divide(num, 2)
    
    }
    
    func divideBy0(num int) (int, error) {
    
    	return divide(num, 0)
    
    }
    
    func getResults(num int) (int, error) {
    	dBy2Res, dBy2Err := divideBy2(5)
    	if dBy2Err != nil {
    		return dBy2Res, dBy2Err
    	}
    	dBy0Res, dBy0Err := divideBy0(10)
    	if dBy0Err != nil {
    		return dBy0Res, dBy0Err
    	}
    
    	// Eliminates any 'unused variable' errors
    	_, _, _, _ = dBy0Err, dBy0Res, dBy2Err, dBy2Res
    	return dBy2Res + dBy0Res, nil
    
    }
    
    func main() {
    	fmt.Println("Let's see if there's an error:")
    	res, err := getResults(10)
    	fmt.Println(err != nil)
    	// Eliminates any 'unused variable' errors
    	_, _ = err, res
    
    }
    
    Let's see if there's an error:
    true

    v0.2.0-alpha

    New Features

    Tagged Unions

    Hit the button below to read the documentation regarding tagged unions

    🚥Tagged Unions

    Pattern Matching

    Hit the button below to read the documentation regarding pattern matching

    Modifications

    New Syntax

    In the previous version of the language, the type would always come before the name. For example:

    in this new version, this aspect been reversed: the type will now always come after the name, seperated by a colon:

    New Pipe Operator

    The pipe operator has been changed from => to |>.

    Discord and GitHub

    Experince issues, or want to get involved? Please join the Discord server and/or create an issue on the GitHub page. Links can be found .

    Wrapper Types

    Wrapper types are equivalent to "Named Types" in Golang

    Wrapper Type Syntax

    wrapper <existing type to be wrapped> <Wrapper type name>

    Working Example

    🎚️Pattern Matching
    here
    package main
    
    import "fmt" as fmt
    
    wrapper Int Dollars
    
    fun addDollars(currentAmount: Dollars, amountToAdd: Int): Dollars {
      return Dollars(((Int)(currentAmount)) + amountToAdd)
    }
    
    fun printDollars(amount: Dollars): Unit {
      fmt.println(amount)
    }
    
    fun main(): Unit {
      let dollarsIHave = Dollars(100)
      let newAmount = addDollars(dollarsIHave, 900)
      printDollars(newAmount)
    }
    package main
    
    import fmt "fmt"
    
    type dollars int
    
    func addDollars(currentAmount dollars, amountToAdd int) dollars {
    
            return dollars((int(currentAmount)) + amountToAdd)
    
    }
    
    func printDollars(amount dollars) {
            fmt.Println(amount)
    
    }
    
    func main() {
            dollarsIHave := dollars(100)
            newAmount := addDollars(dollarsIHave, 900)
            printDollars(newAmount)
            // Eliminates any 'unused variable' errors
            _, _ = dollarsIHave, newAmount
    
    }
    
    // Old Syntax - <type> <name>
    fun getGreeting(String fullName)
    // New Syntax - <name>: <type>
    fun getGreeting(fullName: String)
    1000