Rename the language from Dino to Rex
Files use .rex, the command is rex, and the crate, runtime prefixes, docs, editor files and examples all use the new name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f44f09b6a
commit
7cf9727bcd
94 files changed
+858
-858
No files matched your search
+16
-16
@@ -1,7 +1,7 @@
|
||||
# 11. Cheatsheet
|
||||
|
||||
## Basics
|
||||
```dino
|
||||
```rex
|
||||
var x = 1 // changeable; type inferred
|
||||
var y: float = 2 // with a type
|
||||
const MAX = 100 // fixed
|
||||
@@ -15,7 +15,7 @@ print("x is {x}", y) // interpolation with { }
|
||||
Convert numbers with `float(x)`, `int(x)`, `u8(x)`.
|
||||
|
||||
## Control flow
|
||||
```dino
|
||||
```rex
|
||||
if a > b { } else if a == b { } else { }
|
||||
for i in 0..10 { } // 0..9
|
||||
for i in 0..10 step 2 { }
|
||||
@@ -28,7 +28,7 @@ match v { 1 => a, _ => b }
|
||||
```
|
||||
|
||||
## Functions
|
||||
```dino
|
||||
```rex
|
||||
func add(a, b: int): int { return a + b }
|
||||
func f(): (int, error) { return 1, nil }
|
||||
var n, err = f()
|
||||
@@ -38,14 +38,14 @@ var h = x => x * 2 // where the type is known
|
||||
```
|
||||
|
||||
## Lists
|
||||
```dino
|
||||
```rex
|
||||
var xs = [1, 2, 3] var e: []int
|
||||
xs.push(4) xs.pop() xs.len()
|
||||
xs[0] xs[0] = 9 xs[1..3]
|
||||
```
|
||||
|
||||
## Maps
|
||||
```dino
|
||||
```rex
|
||||
var m = {"a": 1} var e: map[string, int] = {}
|
||||
var e2 = map[string, int]{}
|
||||
m["b"] = 2 // add or replace
|
||||
@@ -56,7 +56,7 @@ m.get_or("z", 0) m.len() m.keys() m.values() m.remove("a")
|
||||
```
|
||||
|
||||
## Strings
|
||||
```dino
|
||||
```rex
|
||||
s.len() s.upper() s.lower() s.trim() s.split(",") s.lines() s.fields()
|
||||
s.replace(a, b) s.repeat(n) s.contains(x) s.starts_with(x) s.ends_with(x)
|
||||
s.index_of(x) s.to_int() s.to_float() s[1..4] s[2..] s[..3]
|
||||
@@ -64,7 +64,7 @@ s.index_of(x) s.to_int() s.to_float() s[1..4] s[2..] s[..3]
|
||||
```
|
||||
|
||||
## Characters
|
||||
```dino
|
||||
```rex
|
||||
var c = 'a' '\n' 'é' // one character, single quotes
|
||||
c == 'a' c < 'z' // compare
|
||||
c.is_digit() c.is_letter() c.is_alnum() c.is_space() c.is_upper() c.is_lower()
|
||||
@@ -75,7 +75,7 @@ s[i] // the char starting at byte i
|
||||
```
|
||||
|
||||
## Structs and enums
|
||||
```dino
|
||||
```rex
|
||||
struct P {
|
||||
name: string
|
||||
x, y: float
|
||||
@@ -91,19 +91,19 @@ E.B(3) match e { A => 1, B(n) => n }
|
||||
```
|
||||
|
||||
## Errors and nil
|
||||
```dino
|
||||
```rex
|
||||
error("message {x}") err != nil return 0, nil
|
||||
var v: int? = nil if v != nil { v } if v == nil { return }
|
||||
```
|
||||
|
||||
## Sharing
|
||||
```dino
|
||||
```rex
|
||||
var a = shared T{...} var b = a // same value, two owners
|
||||
var w = weak a w.upgrade() // shared T? (nil if gone)
|
||||
```
|
||||
|
||||
## Generics and interfaces
|
||||
```dino
|
||||
```rex
|
||||
func first[T](xs: []T): T { return xs[0] }
|
||||
func big[T: Ordered](a, b: T): T { ... } // Ordered, Number, or an interface
|
||||
struct Stack[T] { items: []T } Stack[int]{}
|
||||
@@ -112,15 +112,15 @@ var s: Shape = Circle{1.0}
|
||||
```
|
||||
|
||||
## Files
|
||||
```dino
|
||||
import utils // utils.dino next to this file
|
||||
import tools.fs // tools/fs.dino, used as fs.name
|
||||
```rex
|
||||
import utils // utils.rex next to this file
|
||||
import tools.fs // tools/fs.rex, used as fs.name
|
||||
import os // built-in: os math time
|
||||
pub func f() {} // visible to other files
|
||||
```
|
||||
|
||||
## C libraries
|
||||
```dino
|
||||
```rex
|
||||
import "zlib.h" // zlib.crc32(...), zlib.Z_OK, types like zlib.gzFile
|
||||
import "raylib.h" { InitWindow } // only these names, used bare
|
||||
import "foo.h" link "foo" // when pkg-config doesn't know it (libfoo.so)
|
||||
@@ -129,7 +129,7 @@ lib.fill(buf, n) // T* parameters take a variable or a list
|
||||
```
|
||||
|
||||
## Commands
|
||||
`dino run f.dino args…` · `dino build f.dino -o out` · `dino check f.dino` · `dino emit-c f.dino` · `dino fmt path` (`--check` to only report) · `dino lsp` (editor server) · `dino header x.h [word]` (what a C header offers)
|
||||
`rex run f.rex args…` · `rex build f.rex -o out` · `rex check f.rex` · `rex emit-c f.rex` · `rex fmt path` (`--check` to only report) · `rex lsp` (editor server) · `rex header x.h [word]` (what a C header offers)
|
||||
|
||||
## Things that stop the program (exit code 2)
|
||||
Divide by zero · list index/slice out of range · `pop` on an empty list · reading a missing
|
||||
|
||||
Reference in new issue
Block a user