From 139400d981323f1d3da7cbbb09d30308f180edb6 Mon Sep 17 00:00:00 2001 From: DEntisT Date: Fri, 5 Jan 2024 19:53:51 +0100 Subject: [PATCH] document the thing. --- README.md | 2 +- doc/decorators.md | 4 ++++ doc/return.md | 24 ++++++++++++++++-------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 83678c3..9f97f68 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ - [Namespaces](doc/namespace.md) - [Passing arguments to user functions](doc/userargs.md) - [Persistent data management](doc/persistent.md) -- [`return` and `yield&return`](doc/return.md) +- [`return`](doc/return.md) - [System values](doc/sysval.md) - [Tasks](doc/tasks.md) - [Function structure types](doc/struct.md) diff --git a/doc/decorators.md b/doc/decorators.md index 3863b1f..0d8f096 100644 --- a/doc/decorators.md +++ b/doc/decorators.md @@ -38,6 +38,10 @@ void mytask() public } ``` +## `@yield` + +Check the return documentation. + # `this` keyword - This keyword is used for modifying decorator parameter values, without a specific order. diff --git a/doc/return.md b/doc/return.md index 1b66079..96e04a0 100644 --- a/doc/return.md +++ b/doc/return.md @@ -19,22 +19,30 @@ system.rem("Thing above will print 1") ``` -### `yield&return` +### `@yield` decorator -- `yield` return will do the same thing as a normal return, the difference is that the code block won't stop being executed until `};` or `return..,..;`. +- Using the `@yield` decorator before the return statement does not stop the code block from executing after returning a specific value. Example: ```cpp -int MyForm() public +str func() public { - console.println("Hello World") - yield&return,1 - console.println("This code will be executed too") + console.println("Print 1") + static*new.str,returnstr="Print 2" + @yield + return returnstr + if.notequ,1,1->return "Print OOPS" + console.println("Print 3") } -console.cout(MyForm); -system.rem("Thing above will print 1") +console.println(func) ``` +Output: +``` +Print 1 +Print 3 +Print 2 +``` ## Return types