From fe8d292bd722313402cfafa7ead8255127711344 Mon Sep 17 00:00:00 2001 From: sogaiu <983021772@users.noreply.github.com> Date: Sun, 15 Sep 2024 19:09:40 +0900 Subject: [PATCH] Mention signal in fiber overview --- content/docs/fibers/index.mdz | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/content/docs/fibers/index.mdz b/content/docs/fibers/index.mdz index 99bd41e..2b32b58 100644 --- a/content/docs/fibers/index.mdz +++ b/content/docs/fibers/index.mdz @@ -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 +```) +