Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make == eq eqv DWIM on Promises
With the emphasis on "I" :-)   Inspired by the first Promises slide in
jnthn++ last presentation:
  http://jnthn.net/papers/2015-yapcasia-concurrency.pdf

It occurred to me that the whole slide could be reduced to:

  sub MAIN($file1, $file2) {
      say (start from-json(slurp($file1)) eqv (start from-json(slurp($file2)))
        ?? 'Files contain identical JSON'
        !! 'Files contain different JSON';
  }

with these changes.
  • Loading branch information
lizmat committed Aug 23, 2015
1 parent edffe05 commit ac34880
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/Promise.pm
Expand Up @@ -212,6 +212,14 @@ my class Promise {
});
$s
}

# experimental
method Str(Promise:D:) { self.result.Str }
method Numeric(Promise:D:) { self.result.Numeric }
}

multi sub infix:<eqv>(Promise:D $a, Promise:D $b) {
infix:<eqv>($a.result, $b.result);
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit ac34880

Please sign in to comment.