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
@@ -1,6 +1,6 @@
|
||||
# 4. Functions
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func add(a: int, b: int): int {
|
||||
return a + b
|
||||
}
|
||||
@@ -25,7 +25,7 @@ Names in a row can share a type: `func area(w, h: float): float`.
|
||||
|
||||
A function can return more than one value. The most common use is a value and an `error`.
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func divide(a, b: int): (int, error) {
|
||||
if b == 0 {
|
||||
return 0, error("cannot divide by zero")
|
||||
@@ -53,7 +53,7 @@ A parameter is a copy as far as you can tell: changing it inside never changes t
|
||||
variable. (When a function only *reads* a parameter, the compiler passes it without copying,
|
||||
so big lists are free to pass around.)
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func grow(xs: []int): []int {
|
||||
xs.push(99)
|
||||
return xs
|
||||
@@ -73,7 +73,7 @@ func main() {
|
||||
|
||||
A function has a type like `func(int): int`. You can store it, pass it and return it.
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func double(x: int): int { return x * 2 }
|
||||
|
||||
func apply(f: func(int): int, x: int): int {
|
||||
@@ -96,7 +96,7 @@ func main() {
|
||||
### Short lambdas
|
||||
|
||||
`x => x * 2` and `(a, b) => a + b` are shorthand for a one-expression function. The types
|
||||
come from where it is used, so it works where Dino already knows what function is expected
|
||||
come from where it is used, so it works where Rex already knows what function is expected
|
||||
(a parameter, a typed variable, a struct field, or another argument of a generic function).
|
||||
The short form is one expression; for several statements use the long `func(x: int): int { }`.
|
||||
|
||||
@@ -105,7 +105,7 @@ The short form is one expression; for several statements use the long `func(x: i
|
||||
A function written inside another can use the variables around it. It **copies** them when
|
||||
it is created and keeps its own copy from then on.
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func make_counter(): func(): int {
|
||||
var n = 0
|
||||
return func(): int {
|
||||
|
||||
Reference in new issue
Block a user