From 84877900aa8fc5ce5d12ebe3a2dcbfd04f9e1a5f Mon Sep 17 00:00:00 2001 From: sogaiu <983021772@users.noreply.github.com> Date: Sat, 18 Jan 2025 13:03:12 +0900 Subject: [PATCH] Mention new scopes for if and while --- content/docs/specials.mdz | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content/docs/specials.mdz b/content/docs/specials.mdz index fd2de9b..19abb83 100644 --- a/content/docs/specials.mdz +++ b/content/docs/specials.mdz @@ -155,6 +155,9 @@ macro. The condition is considered false only if it evaluates to @code`nil` or @code`false` - all other values are considered @code`true`. +If when-true or when-false is evaluated, this is done in the context +of a newly introduced lexical scope. + @codeblock[janet]``` (if true 10) # evaluates to 10 (if false 10) # evaluates to nil @@ -211,6 +214,8 @@ or @code`nil`. Therefore, it is expected that the body will contain some side effects or the loop will go on forever. The @code`while` loop always evaluates to @code`nil`. +Note that the @code`while` special form introduces a new lexical scope. + @codeblock[janet]``` (var i 0) (while (< i 10)