Skip to content

Instantly share code, notes, and snippets.

@nunorc
Created April 23, 2010 15:10
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 nunorc/376638 to your computer and use it in GitHub Desktop.
Save nunorc/376638 to your computer and use it in GitHub Desktop.
diff --git a/src/multi-dispatch.pod b/src/multi-dispatch.pod
index 67ce236..eb07595 100644
--- a/src/multi-dispatch.pod
+++ b/src/multi-dispatch.pod
@@ -144,12 +144,22 @@ this to count how often a type check occurs:
=end programlisting
-The first counter output is always C<0>, since the nominal types alone already
-determine which candidate matches best, so the where-block is never executed.
+This code defines three multis, one of which increases a counter whenever its
+C<where> clause executes. Any Perl 6 compiler is free to optimize away type
+checks it knows will succeed. In the current Rakudo implementation, the second
+line with C<say> will print a higher number than the first.
+
+The first C<$counter> output is always C<0>, since the nominal types
+alone already determine which candidate matches best, so the where-block
+is never executed.
The second output is at least C<1>. The compiler has to execute the
where-block at least once to check if the third candidate can be called, but
-the specification doesn not require the minimal possible number of runs.
+the specification does not require the minimal possible number of runs.
+This is illustrated in the second C<$counter> output. The specific
+implementation used to run this test actually executes the where-block twice.
+Keep in mind that the number of times the subtype checks blocks are
+executed is implementation specific.
=for author
@@ -157,11 +167,6 @@ Verify Rakudo * behavior at press time.
=end for
-This code defines three multis, one of which increases a counter whenever its
-C<where> clause executes. Any Perl 6 compiler is free to optimize away type
-checks it knows will succeed. In the current Rakudo implementation, the second
-line with C<say> will print a higher number than the first.
-
=begin sidebar
You I<can> do this, but you should avoid it in anything other than example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment