GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ant-src/ant: The Ant programming language

BranchesTags
Open more actions menu

Latest commit

 

History

733 Commits
733 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
ast
ast
 
 
cmd/ant
cmd/ant
 
 
docs
docs
 
 
examples
examples
 
 
internal
internal
 
 
parser
parser
 
 
scripts
scripts
 
 
testdata/fuzz/FuzzCheck
testdata/fuzz/FuzzCheck
 
 
tests
tests
 
 
value
value
 
 
wasm
wasm
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
TODO.md
TODO.md
 
 
ant.go
ant.go
 
 
errors.go
errors.go
 
 
example_test.go
example_test.go
 
 
fuzz_test.go
fuzz_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
host.go
host.go
 
 
host_test.go
host_test.go
 
 
reflect_test.go
reflect_test.go
 
 
session.go
session.go
 
 
session_decls_test.go
session_decls_test.go
 
 
session_test.go
session_test.go
 
 
test.go
test.go
 
 

Repository files navigation

Ant

Ant is a typed language with errors as values, pipes for data, and goroutines.

Examples

var result = [5, 2, 8, 1]
  | Array.filter({ x > 2 })
  | Array.map({ x * 10 })
  | Array.sort()
println(result) // [50, 80]
type Ready = { url: string }
type Pending = {}
func status(job: Ready | Pending): string {
  if job is Ready { job.url } else { "pending" }
}
func firstLine(path: string): Result[string | null, Error] {
  var file = try File.open(path)
  defer { File.close(file) }
  File.readLine(file)
}
var messages: Channel[string] = Channel.new()
select {
  var message = Channel.receive(messages) { println(message) }
  Time.sleep(Time.duration(seconds: 1)) { println("Timeout") }
}
var date = Time.plainDate(2024, 8, 31)
var next = Time.add(date, Time.duration(months: 1))
println(next) // 2024-09-30

Install

go install github.com/ant-src/ant/cmd/ant@latest

Type-check and run:

ant check main.ant
ant run main.ant

Try things out in the REPL, which highlights the code as it is typed, completes names, members, and arguments with Tab, and suggests the first completion after the cursor:

ant

Format, or check the layout in CI:

ant fmt .
ant fmt --check .

Read the docs of the standard library, or of a module's exports:

ant doc Array.map
ant doc Time
ant doc geometry.ant distance

Complete commands, flags, and files in the shell:

source <(ant --comp zsh)   # in ~/.zshrc, after compinit
source <(ant --comp bash)  # in ~/.bashrc
ant --comp fish | source   # in ~/.config/fish/config.fish

Editor Support

Ant provides code completion, diagnostics, and navigation through the Language Server Protocol (LSP), and debugging through the Debug Adapter Protocol (DAP).

  • Visual Studio Code
  • IntelliJ IDEA
  • Neovim

Go API

Ant can be embedded in Go applications for executing scripts, calling Ant functions, and exposing Go functions to Ant.

Load, check, and run a program:

prog, err := ant.Load("main.ant")
diags := prog.Check()
err = prog.Run(ctx, ant.WithArgs(args))

Call Ant functions from Go:

in, err := prog.Start(ctx)
defer in.Close()

scale, _ := in.Func("scale")
result, err := scale.Call(point, 2.0)

Expose Go functions to Ant using namespaces and Ant type signatures:

prog, err := ant.Load("main.ant", ant.WithNamespace(ant.Namespace{
    Name:       "Kv",
    Signatures: "func Kv.get(key: string): string | null",
    Funcs:      map[string]ant.HostFunc{"get": get},
}), ant.WithoutNamespaces("File", "Http"))

Evaluate code interactively with persistent state, using the same API as the Ant REPL:

s, err := ant.NewSession(ctx, ant.WithStdout(os.Stdout))
v, err := s.Eval("var x = 2")
v, err = s.Eval("x * 21")

License

MIT

About

The Ant programming language

ant-lang.org

Topics

ant-lang

Resources

Readme
MIT license
Activity
Custom properties

Stars

14 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.