[svn:parrot] r39610 - trunk/docs/book/pir
allison at svn.parrot.org
allison at svn.parrot.org
Wed Jun 17 05:16:03 UTC 2009
Author: allison
Date: Wed Jun 17 05:16:02 2009
New Revision: 39610
URL: https://trac.parrot.org/parrot/changeset/39610
Log:
[book] Fixing example test failures in chapter 7.
Modified:
trunk/docs/book/pir/ch07_objects.pod
Modified: trunk/docs/book/pir/ch07_objects.pod
==============================================================================
--- trunk/docs/book/pir/ch07_objects.pod Wed Jun 17 05:09:53 2009 (r39609)
+++ trunk/docs/book/pir/ch07_objects.pod Wed Jun 17 05:16:02 2009 (r39610)
@@ -99,7 +99,7 @@
Methods in PIR are subroutines stored in the class object. Define a method with
the C<.sub> directive and the C<:method> modifier:
-=begin PIR_FRAGMENT
+=begin PIR
.sub half :method
$P0 = getattribute self, 'bar'
@@ -107,7 +107,7 @@
.return($P1)
.end
-=end PIR_FRAGMENT
+=end PIR
This method returns the integer value of the C<bar> attribute of the object
divided by two. Notice that the code never declares the named variable C<self>.
@@ -157,11 +157,11 @@
Methods can have multiple arguments and multiple return values just like
subroutine:
-=begin PIR_FRAGMENT
+=begin PIR_FRAGMENT_INVALID
- ($P0, $S1) = obj.'method'($I3, $P4)
+ ($P0, $S1) = $P2.'method'($I3, $P4)
-=end PIR_FRAGMENT
+=end PIR_FRAGMENT_INVALID
The C<can> opcode checks whether an object has a particular method. It
returns 0 (false) or 1 (true):
@@ -212,7 +212,7 @@
same name in the subclass. This example code overrides C<Bar>'s C<who_am_i>
method to return a more meaningful name:
-=begin PIR_FRAGMENT
+=begin PIR
.namespace [ 'Bar' ]
@@ -220,7 +220,7 @@
.return( 'I am proud to be a Bar' )
.end
-=end PIR_FRAGMENT
+=end PIR
Object creation for subclasses is the same as for ordinary classes:
@@ -260,7 +260,7 @@
with methods, Parrot stores vtable overrides in the class associated with the
currently selected namespace:
-=begin PIR_FRAGMENT
+=begin PIR
.sub 'init' :vtable
$P6 = new 'Integer'
@@ -268,18 +268,18 @@
.return()
.end
-=end PIR_FRAGMENT
+=end PIR
Subroutines acting as vtable overrides must either have the name of an actual
vtable function or include the vtable function name in the C<:vtable> modifier:
-=begin PIR_FRAGMENT
+=begin PIR
.sub foozle :vtable('init')
# ...
.end
-=end PIR_FRAGMENT
+=end PIR
You must call methods on objects explicitly, but Parrot calls vtable functions
implicitly in multiple contexts. For example, creating a new object with C<$P3
@@ -341,8 +341,8 @@
=begin PIR_FRAGMENT
- $P0 = inspect
- $P1 = $P0['attributes']
+ $P1 = inspect $P0
+ $P2 = $P1['attributes']
=end PIR_FRAGMENT
@@ -351,7 +351,7 @@
=begin PIR_FRAGMENT
- $P0 = inspect 'parents'
+ $P0 = inspect $P1, 'parents'
=end PIR_FRAGMENT
More information about the parrot-commits
mailing list