aboutsummaryrefslogtreecommitdiff
path: root/language_description.md
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-07 11:46:43 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-07 11:46:43 +0800
commitf08bc460b79260d7b5e7653faf3d30cb079cfed7 (patch)
treebdc8844a70d4125dbd4598adb28339b639a7c0a8 /language_description.md
parentAdd a README (diff)
downloade2-spec-f08bc460b79260d7b5e7653faf3d30cb079cfed7.tar.gz
e2-spec-f08bc460b79260d7b5e7653faf3d30cb079cfed7.tar.zst
e2-spec-f08bc460b79260d7b5e7653faf3d30cb079cfed7.zip
malloc: Return _, ESTACK instead of 0, ESTACKHEADmaster
Diffstat (limited to 'language_description.md')
-rw-r--r--language_description.md7
1 files changed, 3 insertions, 4 deletions
diff --git a/language_description.md b/language_description.md
index 63041d5..1e24066 100644
--- a/language_description.md
+++ b/language_description.md
@@ -41,15 +41,14 @@ func malloc(size_t s) (void*, error) {
/* What malloc is supposed to do */
return ptr, NIL;
} onfail {
- return 0, ESTACK;
+ return _, ESTACK;
}
```
If something causes `malloc` to be uncallable, e.g. if there is insufficient
stack space to hold its local variables, it simply returns a meaningless
-pointer and a non-nil error value. Note that although we return "`0`" in the
-example code above, the zero pointer is not guaranteed to be an invalid pointer
-in e².
+pointer and a non-nil error value. Returning the empty identifier `_` means
+that the return value is undefined and may be uninitialized.
Other functions may have different methods of failure. Some might return an
error, so it might be natural to set their error return value to something like