Permalink
Browse files

Eradicate Promise.has_result in favor of .Bool

  • Loading branch information...
1 parent bfb393d commit 39ac0cab60097abfd5e72424ecc692928522a2da @lizmat lizmat committed Nov 15, 2013
Showing with 8 additions and 12 deletions.
  1. +8 −12 S17-concurrency.pod
View
@@ -13,8 +13,8 @@ RE-DRAFT: Synopsis 17: Concurrency
Created: 3 Nov 2013
- Last Modified: 13 Nov 2013
- Version: 5
+ Last Modified: 15 Nov 2013
+ Version: 6
This synopsis is based around the concurrency primitives and tools currently
being implemented in Rakudo on the JVM. It covers both things that are
@@ -261,12 +261,13 @@ which returns an element from the C<PromiseStatus> enumeration.
The result itself can be obtained by calling C<result>. If the C<Promise> was
already kept, the result is immediately returned. If the C<Promise> was broken
then the exception that it was broken with is thrown. If the C<Promise> is not
-yet kept or broken, then the caller will block until this happens. There is a
-C<has_result> method for checking if a C<Promise> is already kept or broken,
-and an C<excuse> method for extracting the exception from a C<Broken> C<Promise>
-rather than having it thrown.
+yet kept or broken, then the caller will block until this happens.
- if $promise.has_result {
+A C<Promise> will boolify to whether the C<Promise> is already kept or broken.
+There is also an C<excuse> method for extracting the exception from a C<Broken>
+C<Promise> rather than having it thrown.
+
+ if $promise {
if $promise.status == Kept {
say "Kept, result = " ~ $promise.result;
}
@@ -278,11 +279,6 @@ rather than having it thrown.
say "Still working!";
}
-A C<Promise> will boolify to C<has_result> also, for convenience.
-
-[Conjectural: we perhaps don't need has_result and the boolification. If the
-boolification is a good idea, maybe we drop .has_result.]
-
You can also simply use a switch:
given $promise.status {

0 comments on commit 39ac0ca

Please sign in to comment.