Skip to content

Commit

Permalink
Mention signal in fiber overview
Browse files Browse the repository at this point in the history
  • Loading branch information
sogaiu committed Sep 15, 2024
1 parent c88a558 commit fe8d292
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions content/docs/fibers/index.mdz
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,20 @@ an error clause is evaluated.
([err] (print "oops")))
# Evaluates to 6 - no error thrown
```)

The @code[signal] function can be used to raise a particular signal.
The function's first argument, @code[what], specifies the signal,
while the second argument, @code[x], is an arbitrary payload value.

@codeblock[janet](```
(try
(signal :error 1)
([err] (print "got error: " err)))
# evaluates to nil and prints "got error: 1"

(defer (pp :hey)
(signal :user4 :hello)
(pp :unreached))
# only prints :hey
```)

0 comments on commit fe8d292

Please sign in to comment.