diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-01 04:08:59 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-01 04:08:59 -0500 |
| commit | d471a41369690a9d2d9b8862ea5ff0ae9cbe40fc (patch) | |
| tree | 9399d12700c3d975a95b0946833dc419b3268419 /examples/defer.cup | |
| parent | Testing: Add support for testing stdout results, check builtins (diff) | |
| download | cup-d471a41369690a9d2d9b8862ea5ff0ae9cbe40fc.tar.xz cup-d471a41369690a9d2d9b8862ea5ff0ae9cbe40fc.zip | |
Add basic `defer` implementation.
We don't have any closures yet, so it's essentially the same as just
moving the statement after the `defer` keyword to the end of the block/
right before returning from the function.
Diffstat (limited to 'examples/defer.cup')
| -rw-r--r-- | examples/defer.cup | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/defer.cup b/examples/defer.cup new file mode 100644 index 0000000..e8e4778 --- /dev/null +++ b/examples/defer.cup @@ -0,0 +1,13 @@ +fn main() { + defer print(1); + { + defer print(2); + { + defer print(3); + print(4); + } + print(5); + return 0; + } + print(10); +}
\ No newline at end of file |