You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This is a 'brand" capability to mark what can be mentioned in trusted code
@@ -806,7 +807,12 @@ Finally, analogously to type parameters, we can lower- and upper-bound capabilit
806
807
untrustedChannel.send("I can't be used") // error
807
808
```
808
809
The idea is that every capability derived from the marker capability `trusted` (and only those) are eligible to be used in the `block` closure
809
-
passed to `runSecure`. We can enforce this by an explicit capability parameter `C` constraining the possible captures of `block` to the interval `>: {trusted} <: {trusted}`
810
+
passed to `runSecure`. We can enforce this by an explicit capability parameter `C` constraining the possible captures of `block` to the interval `>: {trusted} <: {trusted}`.
811
+
812
+
Note that since capabilities of function types are covariant, we could have equivalently specified `runSecure`'s signature using implicit capture polymorphism to achieve the same behavior:
813
+
```scala
814
+
defrunSecure(block: () ->{trusted} Unit):Unit
815
+
```
810
816
811
817
## Capability Members
812
818
@@ -828,7 +834,8 @@ trait Thread:
828
834
traitGPUThreadextendsThread:
829
835
cap typeCap>: {cudaMalloc, cudaFree} <: {caps.cap}
830
836
```
831
-
837
+
Since `caps.cap` is the top element for subcapturing, we could have also left out the
838
+
upper bound: `cap type Cap >: {cudaMalloc, cudaFree}`.
832
839
833
840
We conclude with a more advanced example, showing how capability members and paths to these members can prevent leakage
834
841
of labels for lexically-delimited control operators:
0 commit comments