From d6a80e4961536a088ab12b468c4bffd818d335d2 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 16 Oct 2023 22:55:07 -0500 Subject: [PATCH] dummy.cl: Update to include while expressions --- dummy.cl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dummy.cl b/dummy.cl index 8d28727..963a333 100644 --- a/dummy.cl +++ b/dummy.cl @@ -13,12 +13,20 @@ fn main() { x }; - // A `for` expression is like the for-else construct in Python, but it returns a value via the `break` keyword - let z = for i in 0..y { + // A `while` expression is like the while-else construct in Python, + // but it returns a value via the `break` keyword + let z = while false { // do a thing repeatedly break true + // If `while` does not `break`, fall through to the `else` expression } else { false - }; + } + // The same is true of `for` expressions! + let w = for idx in 0..100 { + break idx + } else { + 12345 + } // TODO: decide how to do IO }