Instantly share code, notes, and snippets.
Created
June 10, 2010 21:23
-
Save prakashk/433654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/bin/book-to-latex b/bin/book-to-latex | |
index a909a46..35434d9 100644 | |
--- a/bin/book-to-latex | |
+++ b/bin/book-to-latex | |
@@ -12,6 +12,7 @@ print <<'HEADER'; | |
\usepackage[utf8]{inputenc} | |
\usepackage{makeidx} | |
\usepackage[colorlinks=true,pagebackref]{hyperref} | |
+\usepackage{wrapfig} | |
\makeindex | |
@@ -38,3 +39,38 @@ print <<'FOOTER'; | |
\end{document} | |
FOOTER | |
+ | |
+package Pod::PseudoPod::LaTeX; | |
+ | |
+sub start_sidebar | |
+{ | |
+ my ( $self, $flags ) = @_; | |
+ | |
+ $self->{scratch} .= "\n\\begin{wrapfigure}{o}{0.6\\textwidth}\n" | |
+ . "\\framebox{\n" | |
+ . "\\begin{minipage}{0.57\\textwidth}\n" | |
+ . "\\vspace{3pt}\n\n" | |
+ . "\\small{\n"; | |
+ | |
+ if ( $flags->{title} ) | |
+ { | |
+ my $title = $self->encode_text( $flags->{title} ); | |
+ $self->{scratch} .= "\\begin{center}\n" | |
+ . "\\large{\\bfseries{" . $title . "}}\n" | |
+ . "\\end{center}\n\n"; | |
+ } | |
+} | |
+ | |
+sub end_sidebar | |
+{ | |
+ my $self = shift; | |
+ | |
+ $self->{scratch} .= "}\n" # end \small | |
+ . "\\vspace{3pt}\n" | |
+ . "\\end{minipage}\n" | |
+ # end framebox | |
+ . "}\n" | |
+ . "\\end{wrapfigure}\n\n"; | |
+} | |
+ | |
+1; | |
diff --git a/src/multi-dispatch.pod b/src/multi-dispatch.pod | |
index 86292a0..3040106 100644 | |
--- a/src/multi-dispatch.pod | |
+++ b/src/multi-dispatch.pod | |
@@ -153,6 +153,13 @@ 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. | |
+=begin sidebar | |
+ | |
+You I<can> do this, but you should avoid it in anything other than example | |
+code. Relying on the side effects of type checks produces unreliable code. | |
+ | |
+=end sidebar | |
+ | |
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 does not require the minimal possible number of runs. | |
@@ -167,13 +174,6 @@ Verify Rakudo * behavior at press time. | |
=end for | |
-=begin sidebar | |
- | |
-You I<can> do this, but you should avoid it in anything other than example | |
-code. Relying on the side effects of type checks produces unreliable code. | |
- | |
-=end sidebar | |
- | |
=head1 Narrowness | |
There's one candidate not yet explained from the JSON example: | |
@@ -497,11 +497,6 @@ latter by installing a I<proto> routine: | |
=end programlisting | |
-Nearly all Perl 6 built-in functions and operators export a proto definition, | |
-which prevents accidental overriding of built-insN<One of the very rare | |
-exceptions is the smart match operator C<< infix:<~~> >> which is not easily | |
-overloadable. Instead it redispatches to overloadable multi methods.>. | |
- | |
=begin sidebar | |
To hide all candidates of a multi and replace them by another sub, you can | |
@@ -510,6 +505,11 @@ supports this. | |
=end sidebar | |
+Nearly all Perl 6 built-in functions and operators export a proto definition, | |
+which prevents accidental overriding of built-insN<One of the very rare | |
+exceptions is the smart match operator C<< infix:<~~> >> which is not easily | |
+overloadable. Instead it redispatches to overloadable multi methods.>. | |
+ | |
=head1 Multi Methods | |
X<multimethods> | |
diff --git a/src/operators.pod b/src/operators.pod | |
index 8fea7d4..619229b 100644 | |
--- a/src/operators.pod | |
+++ b/src/operators.pod | |
@@ -501,14 +501,6 @@ It's C<~~>, the smart match operator. | |
=end programlisting | |
-The smart match operator always decides what kind of comparision to do based | |
-upon the type of the value on the right hand side. In the three examples above, | |
-it would do a numeric, a string and a range comparision respectively. While | |
-we've already seen operators to do numeric and string comparisons -- C<==> and | |
-C<eq> -- there is no operator for comparing ranges. This is part of the power | |
-of smart matching: more complex types can define interesting and useful ways to | |
-compare themselves to other things. | |
- | |
=begin sidebar | |
Smart match works by calling the C<ACCEPTS> method on the operand on the right | |
@@ -520,4 +512,12 @@ just by implementing an C<ACCEPTS> method to do the right thing. | |
=end sidebar | |
+The smart match operator always decides what kind of comparision to do based | |
+upon the type of the value on the right hand side. In the three examples above, | |
+it would do a numeric, a string and a range comparision respectively. While | |
+we've already seen operators to do numeric and string comparisons -- C<==> and | |
+C<eq> -- there is no operator for comparing ranges. This is part of the power | |
+of smart matching: more complex types can define interesting and useful ways to | |
+compare themselves to other things. | |
+ | |
=for vim: spell | |
diff --git a/src/subs-n-sigs.pod b/src/subs-n-sigs.pod | |
index 024e9c6..afd015d 100644 | |
--- a/src/subs-n-sigs.pod | |
+++ b/src/subs-n-sigs.pod | |
@@ -819,14 +819,6 @@ signature on the callee side. It is also possible to write a signature that | |
binds the capture itself into a variable. This is especially useful for writing | |
routines that delegate to other routines with the same arguments. | |
-=begin sidebar | |
- | |
-An optimizing Perl 6 compiler may, of course, be able to optimize away building | |
-the capture data structure every call if it statically knows what is going to | |
-be called. | |
- | |
-=end sidebar | |
- | |
=begin programlisting | |
sub visit-czechoslovakia(|$plan) { | |
@@ -837,6 +829,14 @@ be called. | |
=end programlisting | |
+=begin sidebar | |
+ | |
+An optimizing Perl 6 compiler may, of course, be able to optimize away building | |
+the capture data structure every call if it statically knows what is going to | |
+be called. | |
+ | |
+=end sidebar | |
+ | |
The benefit of using this over a signature like C<:(*@pos, *%named)> is that | |
these both enforce some context on the arguments, which may be premature. For | |
example, if the caller passes two arrays, they would flatten into C<@pos>. This |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment