Reference
A sheet to look things up at a glance. Each section points to the page that covers it in full.
Reserved words
They can't be the names of variables, functions, classes or parameters:
and | break | case | catch | class | const |
continue | def | default | div | do | elfor |
else | elsif | end | enum | exit | false |
fn | for | foreach | func | if | import |
in | mod | nil | not | off | on |
operator | or | private | ref | repeat | return |
struct | super | switch | then | this | true |
try | type | until | use | var | while |
do, repeat and ref are reserved, but in 0.9.7 they aren't used for anything: while and until don't take do, and ref gives an error when compiling.
| Words | What for | Where |
|---|---|---|
var, const, enum | Variables, constants and enumerations | Variables and constants |
if, then, elsif, else, switch, case, default | Choosing what runs | Control structures |
for, elfor, foreach, in, while, until, break, continue | Loops | Control structures |
end | Closing a block | Basic syntax |
func, return, fn | Functions and lambdas | Functions |
class, def, this, super, private, operator | Classes and objects | Classes and objects |
struct | Data structures | Structs |
try, catch, exit | Errors and leaving the program | Errors and exceptions |
use, import | Modules and other files | Programs in several files |
and, or, not, div, mod | Operators | Operators |
true, false, on, off, nil | Values | Data types |
type | The type of a value | type |
Operators
| Operators | What they do |
|---|---|
+, -, *, / | Addition, subtraction, multiplication and division. / always gives a decimal: 5 / 2 is 2.5. |
div, mod, % | Integer division and remainder: 5 div 2 is 2, and 5 mod 2 and 5 % 2 are 1. |
++, -- | Add or subtract one to a variable: x++. |
==, !=, <, <=, >, >= | Compare two values. |
and, or, not, ! | Logical. ! is the same as not. |
&, |, ^, ~, <<, >> | Bitwise. With two booleans, ^ is the exclusive or: true ^ false is true. |
? : | Conditional: a > b ? a : b. |
=, +=, -=, *=, /=, %= | Assignment. |
In JARU, and and or have the same precedence, and not is worked out before comparisons: use parentheses when you mix them. The order of all of them is in Operator precedence, and each one, with examples, in Operators.
Types
| Type | Written as | type() gives |
|---|---|---|
| Boolean | true, false, on, off | tBool |
| No value | nil | tNil |
| Integer, 32-bit signed | 42, -7, 0x1F | tInteger |
| Decimal, 64-bit | 3.14, .5, 1e3 | tFloat |
| String | "hello", 'hello' | tString |
| List | [1, 2, 3] | tList |
| Map | {"x": 1, "y": 2} | tMap |
| Array | {1, 2, 3} | tArray |
| Function and lambda | func, fn | tFunction |
| Class and instance | class, Player() | tClass, tInstance |
The details are in Data types. String methods are in Strings, and those of lists, maps and arrays in Lists, maps and arrays.
Standard library
Functions that don't need use:
| For | Functions |
|---|---|
| The console | print, println, readLine, cls, ink, paper |
| Time | pause, clock, time |
| Converting and knowing the type | chr, int, float, type |
| Random numbers | randomize, random |
| Arithmetic | abs, round, sqrt, vlenght |
| How long something is | len |
| Colors | rgb |
| The system and memory | memUse, memFree, platform, vmerror |
| Base64 | encode64, decode64 |
Constants
The compiler knows them without use:
| Constants | What for |
|---|---|
HW_ESP32, HW_ESP32S3, HW_WIN32, HW_WEB, HW_ESP32P4, HW_ESP32S31 | What platform() returns |
tBool, tInteger, tFloat, tString, tList, tMap… | What type() returns |
ERR_UNKNOWN … ERR_TIME_OUT | The errors: see Errors and exceptions |
LOW, HIGH | The levels of a pin: see GPIO |
PI, SQRT2 | π and √2: see Math |
The full list, with their values, is in Constants.
Modules
They're brought in with use, as in use Display. How they're used, in Modules.
| Module | What for |
|---|---|
| Display | Opening the screen or the window, its size and its background, and the game's pace |
| Draw | Drawing points, lines, rectangles, circles, text, images and tilemaps |
| Bitmap | Loading BMP images and working with them |
| Sprite | Sprites with animation, collisions and physics |
| GridMap | 2D grids: tilemaps, collisions with the map and pathfinding |
| Scene | The scene: its sprites, the camera, the physics and the map |
| Sound | Synthesised sounds, PCM samples and music |
| Input | The keyboard, the buttons and the gamepad, as game actions |
| GPIO | Input and output pins, PWM and interrupts |
| I2C | Sensors and other devices connected over I2C |
| LED | Strips and matrices of WS2812 colour LEDs |
| Power | Putting the board to sleep to save power, and waking it up |
| MQTT | Publishing and receiving MQTT messages |
| Http | HTTP requests to APIs and web services |
| File | Files and folders, in the flash, on the SD card or on the PC |
| Bytes | Byte blocks for binary data |
| JSON | Reading and writing JSON |
| Timer | Calling a function after some time, once or every so often |
| Math | Mathematical functions and constants |
| GC | The garbage collector, which frees the memory that's no longer used |
Resources
- The JARU website
- GitHub
- Contact: info@jarulang.com