Some parts of the code are documented here.

Overview

Introduction to Agate code source

Agate is a kind of fork of Wren, the basic implementation comes from Wren with functions and types that have been renamed and/or refactored. If you want to understand some parts of Agate source code, you should look in Wren source code and its excellent comments.

Agate is implemented with three files:

  • agate.h is the public C interface of the Agate language.

  • agate.c is the main file that implements the C interface of the Agate language.

  • core.inc is the basic implementation of the core library, it is generated from core.agate with core.sh.

In addition, the following files are provided:

  • debug.inc.c contains additional functions that are necessary for debugging (for developpers only), this file may be included from agate.c.

  • agate-run.c is a driver for standalone bare Agate, it can execute an Agate script from the command line.

  • agate.l, agate.y are the Flex file and the Bison file for checking Agate syntax

  • syntax.c is the driver for the Flex/Bison parser.

  • tests.inc is the list of all tests, it is generated with tests.sh.

  • tests.c is the driver for running all the tests.

  • agate-support.h, agate-support.c are files that implement some functions needed in the Agate configuration, they can be used as is.

Differences with Wren

Agate is largely based on Wren. Here are the main differences:

  • Variables are declared with def, not var.

  • Agate has Int, Float and Char as primitive types instead of Num.

  • Wren List is Agate Array.

  • Functions can be declared with def (but also with Fn.new()).

  • Functions can be called directly with f() without .call. Classes can implement a () method to be callable.

  • Math functions are in the Math class, not methods of Num.

  • Agate Map can take as key any object that implements a hash method (and core types do implement hash).

  • Wren module is Agate unit.

  • Calling a method on this is done with .method, method refers to a variable (local or global).

  • Agate has assert as a keyword and the behaviour of assert can be defined at runtime.

  • Agate has no concurrency (and do not plan to introduce concurrency), so no Fiber.

  • Agate has no annotations (and do not plan to introduce annotations).

  • Agate is reentrant!

  • Coding conventions are different: Agate methods, functions and variables are in snake case rather than camel case.

Why "Agate"?

Agate is a gemstone less precious than Ruby or Perl.

Implementation notes

Conventions for core library

  • Classes or methods starting with __ are considered private and may change.

  • When possible, implement methods with native functions, especially for String