Index: docs/book/ch04_pir_subroutines.pod =================================================================== --- docs/book/ch04_pir_subroutines.pod (revision 37614) +++ docs/book/ch04_pir_subroutines.pod (working copy) @@ -104,9 +104,9 @@ to the calling subroutine, and optionally returns result output values. Here's a complete code example that implements the factorial algorithm. -The subroutine C is a separate compilation unit, assembled and +The subroutine C is a separate compilation unit, assembled and processed after the C
function. Parrot resolves global symbols -like the C label between different units. +like the C label between different units. =begin PIR @@ -117,14 +117,14 @@ count = 5 product = 1 - \$I0 = fact(count, product) + \$I0 = factr(count, product) print \$I0 print "\n" end .end - .sub fact + .sub factr .param int c .param int p @@ -134,7 +134,7 @@ dec c branch loop fin: - .return p + .return (p) .end =end PIR @@ -171,8 +171,9 @@ .param int yrs :named("age") .param string call :named("name") \$S0 = "Hello " . call - \$S1 = "You are " . yrs - \$S1 = \$S1 . " years old + \$S1 = yrs + \$S1 = ", you are " . \$S1 + \$S1 = \$S1 . " years old\n" print \$S0 print \$S1 .end @@ -411,7 +412,7 @@ .sub add_two .param int value .local int val2 - val2 = add_one(value + val2 = add_one(value) .tailcall add_one(val2) .end @@ -419,7 +420,7 @@ .param int a .local int b b = a + 1 - return b + return (b) .end =end PIR @@ -536,7 +537,7 @@ in PIR that have their own scope besides subroutines. Fortunately, we can use these lexical subroutines to simulate this behavior that HLLs require: -=begin PIR +# =begin PIR # to be reinserted later when fixed TT#482 .sub 'MyOuter' .lex int x @@ -550,7 +551,7 @@ #x, y, and z are all "visible" here .end -=end PIR +# =end PIR In the example above we put the word C<"visible"> in quotes. This is because lexically-defined variables need to be accessed with the C and @@ -636,11 +637,11 @@ .sub main \$I1 = 5 # counter - call fact # same as "bsr fact" + bsr fact # call fact print \$I0 print "\n" \$I1 = 6 # counter - call fact + bsr fact print \$I0 print "\n" end @@ -867,7 +868,7 @@ You can also use the C<:invocant> flag to define a new name for the invocant object: -=begin PIR +# =begin PIR # to be reinserted later when fixed TT#482 .sub "MyMethod" :method \$S0 = self # Already defined as "self" @@ -880,7 +881,7 @@ say \$S0 .end -=end PIR +# =end PIR This example defines two methods in the C class. It calls one from the main body of the subroutine and the other from within the Index: docs/user/pir/pmcs.pod =================================================================== --- docs/user/pir/pmcs.pod (revision 37614) +++ docs/user/pir/pmcs.pod (working copy) @@ -335,7 +335,7 @@ =head3 Example 9: Setting a timer -=begin PIR +# =begin PIR # to be reinserted later when fixed TT#482 .include "timer.pasm" # for the timer constants @@ -362,7 +362,7 @@ goto loop .end -=end PIR +# =end PIR =head2 Author Index: docs/user/pir/intro.pod =================================================================== --- docs/user/pir/intro.pod (revision 37614) +++ docs/user/pir/intro.pod (working copy) @@ -256,7 +256,7 @@ .return (\$I2) .end -=cut +=end PIR This example also shows that PIR subroutines may be recursive just as in a high-level language. @@ -284,7 +284,7 @@ Note that with named arguments, you may rearrange the order of your parameters at will. -=begin PIR +# =begin PIR # to be reinserted later when fixed TT#482 .sub foo .param string "name" => a @@ -293,7 +293,7 @@ # ... .end -=end PIR +# =end PIR This subroutine may be called in any of the following ways: