You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/language/control-flow.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,20 @@ Recursive lambdas use `self` to refer to the enclosing function:
79
79
80
80
If no error is raised, `try` returns the result of the body expression normally. Works inside lambdas compiled to bytecode.
81
81
82
+
### Fallback value
83
+
84
+
If the second argument is **not** a function, it is returned as-is as the fallback value on error (evaluated only when the body fails). Because lambdas do not capture closures, this is the only way to surface an outer binding from the failure branch:
85
+
86
+
```lisp
87
+
‣ (try (raise "boom") 0)
88
+
0
89
+
90
+
‣ ((fn [data] (try (raise "boom") data)) 123)
91
+
123
92
+
```
93
+
94
+
A handler must accept the single error argument, so only a lambda or a unary builtin is *called* with the error; any other value (including a multi-argument builtin) is treated as a fallback value.
95
+
82
96
## Early Return: return
83
97
84
98
`return` exits the innermost enclosing compiled lambda early with the given value:
Copy file name to clipboardExpand all lines: docs/docs/namespaces/ipc.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,22 +12,25 @@ Connect to a Rayforce server (`./rayforce -p <port>`) and exchange messages over
12
12
13
13
| Function | Arity | Flags | Description |
14
14
|---|---|---|---|
15
-
|[`.ipc.open`](#ipc-open)|unary| restricted | Open a TCP connection; return an i64 handle. |
15
+
|[`.ipc.open`](#ipc-open)|variadic| restricted | Open a TCP connection (optional connect timeout); return an i64 handle. |
16
16
|[`.ipc.send`](#ipc-send)| binary | restricted | Send a message synchronously; return the server's result. |
17
17
|[`.ipc.post`](#ipc-post)| binary | restricted | Send a message asynchronously (fire-and-forget); return the null object. |
18
18
|[`.ipc.close`](#ipc-close)| unary | restricted | Close a connection handle. |
19
19
|[`.ipc.handle`](#ipc-handle)| variadic | — | The current connection's handle inside a server-side hook; `-1` otherwise. |
20
20
21
21
## `.ipc.open` { #ipc-open }
22
22
23
-
Signature: `(.ipc.open "host:port")` or `(.ipc.open "host:port:user:password")`.
23
+
Signature: `(.ipc.open "host:port")` or `(.ipc.open "host:port:user:password")`, with an optional trailing connect timeout in milliseconds: `(.ipc.open "host:port" 2000)`.
24
24
25
25
Returns: an `i64` handle. Negative handles never escape — errors are surfaced as Rayfall error objects:
26
26
27
-
-`type` — argument is not a string.
28
-
-`domain` — malformed address (missing port, port out of `(0, 65535]`, oversized host/user/password).
27
+
-`type` — address argument is not a string, or the timeout argument is not an integer.
28
+
-`rank` — called with fewer than 1 or more than 2 arguments.
29
+
-`domain` — malformed address (missing port, port out of `(0, 65535]`, oversized host/user/password), or a negative timeout.
29
30
-`access` — server requires auth and you didn't supply credentials, **or** the password is wrong.
30
-
-`io` — connection refused / network error.
31
+
-`io` — connection refused / network error, or `connection timed out` when the connect did not complete within the timeout.
32
+
33
+
The optional timeout bounds **both** the TCP connect and the handshake I/O. A blocking `connect()` ignores socket send/receive timeouts, so without an explicit bound a dead or packet-filtered peer would otherwise hang for the operating-system default (often minutes). When omitted, a default budget of 5 seconds applies.
31
34
32
35
The handshake exchanges a 2-byte `{wire_version, auth_flag}` greeting. A wire-version mismatch closes the connection before any payload is exchanged.
33
36
@@ -37,6 +40,9 @@ The handshake exchanges a 2-byte `{wire_version, auth_flag}` greeting. A wire-ve
37
40
38
41
;; With credentials (server started with -u or -U)
39
42
(set h (.ipc.open "127.0.0.1:5000:admin:secret123"))
43
+
44
+
;; Fail fast if the peer doesn't answer within 2 seconds
0 commit comments