-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
242 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.5.2 | ||
2.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,4 +95,4 @@ user@hostname:~/git/abs$ cwd = cd() | |
user@hostname:~$ `ls .absrc` | ||
.absrc | ||
user@hostname:~$ | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ Returns the name of the runtime: | |
|
||
```py | ||
runtime.name # "abs" | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ Though you can comment after a statement: | |
|
||
```bash | ||
x = 1 # Now, this is a cool assignment! | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
permalink: /syntax/defer | ||
--- | ||
|
||
# Defer <Badge text="experimental" type="warning"/> | ||
|
||
Sometimes it is very helpful to guarantee a certain function is executed | ||
regardless of what code path we take: you can use the `defer` keyword for | ||
this. | ||
|
||
```py | ||
echo(1) | ||
defer echo(3) | ||
echo(2) | ||
# 1 | ||
# 2 | ||
# 3 | ||
``` | ||
|
||
When you schedule a function to be deferred, it will executed right at | ||
the end of the current scope. A `defer` inside a function will then | ||
execute at the end of that function itself: | ||
|
||
```py | ||
echo(1) | ||
f fn() { | ||
defer echo(3) | ||
echo(2) | ||
} | ||
fn() | ||
echo(4) | ||
# 1 | ||
# 2 | ||
# 3 | ||
# 4 | ||
``` | ||
|
||
You can `defer` any callable: a function call, a method or even a system | ||
command. This can be very helpful if you need to run a cleanup function | ||
right before wrapping up with your code: | ||
|
||
```sh | ||
defer `rm my-file.txt` | ||
"some text" > "my-file.txt" | ||
|
||
... | ||
... | ||
"some other text" >> "my-file.txt" | ||
``` | ||
|
||
In this case, you will be guaranteed to execute the command that removes | ||
`my-file.txt` before the program closes. | ||
|
||
Be aware that code that is deferred does not have access to the return value | ||
of its scope, and will supress errors -- if a `defer` block messes up you're | ||
not going to see any error. This behavior is experimental, but we would most | ||
likely like to give this kind of control through [try...catch...finally](https://github.com/abs-lang/abs/issues/118). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,4 +403,4 @@ Bitwise left shift: | |
```bash | ||
1 << 1 # 2 | ||
1 << "hello" # ERROR: type mismatch: NUMBER << STRING | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,4 +136,4 @@ Returns a string containing the number: | |
|
||
```bash | ||
99.str() # "99" | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.