Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active September 10, 2016 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/d35362c10ad8b54a13c4c13b63dc1b08 to your computer and use it in GitHub Desktop.
Save dogbert17/d35362c10ad8b54a13c4c13b63dc1b08 to your computer and use it in GitHub Desktop.
Attempt to correct erroneous description of eqv in operators.pod6. See http://irclog.perlgeek.de/perl6/2016-09-09#i_13180195
index 387813c..0531234 100644
--- a/doc/Language/operators.pod6
+++ b/doc/Language/operators.pod6
@@ -1480,16 +1480,17 @@ the same, i.e. from the same type and (recursively) contain the same values.
say 1 eqv 2; # False
say 1 eqv 1.0; # False
-For arbitrary objects this is not possible with the default C<eqv> operator.
-E.g., C<eqv> will not consider two instances of the same object as being
-structurally equivalent:
+The default C<eqv> operator even works with arbitrary objects. E.g., C<eqv>
+will consider two instances of the same object as being structurally
+equivalent:
my class A {
has $.a;
}
- say A.new(a => 5) eqv A.new(a => 5); #=> False
+ say A.new(a => 5) eqv A.new(a => 5); #=> True
-To get C<eqv> semantics for objects of this class, one would need to
+Although the above example works as intended the C<eqv> code has to fall back
+to a slower code path in in order to do its job. One way to avoid this is to
implement an appropriate infix C<eqv> operator:
my class A {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment