@@ -1017,8 +1017,8 @@ transform: func(blob) -> blob
1017
1017
```
1018
1018
1019
1019
As syntactic sugar, resource statements can also declare any number of
1020
- * methods* , which are functions that implicitly takes a ` self ` borrowed handle
1021
- parameter . A resource statement can also contain any number of * static
1020
+ * methods* , which are functions that implicitly take a ` self ` parameter that is
1021
+ a handle . A resource statement can also contain any number of * static
1022
1022
functions* , which do not have an implicit ` self ` parameter but are meant to be
1023
1023
lexically nested in the scope of the resource type. Lastly, a resource
1024
1024
statement can contain at most one * constructor* function, which is syntactic
@@ -1046,6 +1046,14 @@ bindings generators can generate idiomatic syntax for the target language or
1046
1046
(for languages like C) fall back to an appropriately-prefixed free function
1047
1047
name.
1048
1048
1049
+ When a resource type name is used directly (e.g. when ` blob ` is used as the
1050
+ return value of the constructor above), it stands for an "owning" handle
1051
+ that will call the resource's destructor when dropped. When a resource
1052
+ type name is wrapped with ` borrow<...> ` , it stands for a "borrowed" handle
1053
+ that will * not* call the destructor when dropped. As shown above, methods
1054
+ always desugar to a borrowed self parameter whereas constructors always
1055
+ desugar to an owned return value.
1056
+
1049
1057
Specifically, the syntax for a ` resource ` definition is:
1050
1058
``` ebnf
1051
1059
resource-item ::= 'resource' id resource-methods?
@@ -1055,6 +1063,8 @@ resource-method ::= func-item
1055
1063
| 'constructor' param-list
1056
1064
```
1057
1065
1066
+ The syntax for handle types is presented [ below] ( #handles ) .
1067
+
1058
1068
## Types
1059
1069
1060
1070
As mentioned previously the intention of ` wit ` is to allow defining types
0 commit comments