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,12 +1,12 @@
|
||||
# 7. Errors and nil
|
||||
|
||||
Dino has no exceptions. A function that can fail says so in its result, and you handle it.
|
||||
Rex has no exceptions. A function that can fail says so in its result, and you handle it.
|
||||
|
||||
## error
|
||||
|
||||
`error` is a type that is either `nil` (all fine) or holds a message.
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func parse_age(s: string): (int, error) {
|
||||
var n, err = s.to_int()
|
||||
if err != nil {
|
||||
@@ -40,7 +40,7 @@ func main() {
|
||||
Writing `?` after a call means "if this failed, return the error from *my* function too".
|
||||
Otherwise you get the value.
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func half(n: int): (int, error) {
|
||||
if n % 2 != 0 { return 0, error("{n} is odd") }
|
||||
return n / 2, nil
|
||||
@@ -69,9 +69,9 @@ if it returns an error, the program prints `error: message` and exits with code
|
||||
|
||||
## Optional values: `T?`
|
||||
|
||||
A `T?` is either a `T` or `nil`. It is how Dino says "this might be missing".
|
||||
A `T?` is either a `T` or `nil`. It is how Rex says "this might be missing".
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func find(names: []string, wanted: string): int? {
|
||||
for i, n in names {
|
||||
if n == wanted { return i }
|
||||
@@ -105,7 +105,7 @@ program with a message instead of misbehaving.)
|
||||
|
||||
Maps give you optionals too:
|
||||
|
||||
```dino
|
||||
```rex
|
||||
func main() {
|
||||
var ports = {"http": 80}
|
||||
var p = ports.get("https")
|
||||
|
||||
Reference in new issue
Block a user