summaryrefslogtreecommitdiff
path: root/pod/perlobj.pod
diff options
context:
space:
mode:
authorOvid <publiustemp-p5p@yahoo.com>2004-04-03 10:59:22 -0800
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-04-05 15:24:49 +0000
commiteac7fe86f47901babc387c242e8dc65d73838746 (patch)
tree7c25ef6bdd95bad7571d4b38f79eee6b90ac56d1 /pod/perlobj.pod
parent46ec2f140c7050c2c6553ebf8e07a3f368560ff0 (diff)
downloadperl-eac7fe86f47901babc387c242e8dc65d73838746.tar.gz
ref ($proto) || $proto patch
Message-ID: <406F7A0A.50702@yahoo.com> (with minor reformatting) p4raw-id: //depot/perl@22654
Diffstat (limited to 'pod/perlobj.pod')
-rw-r--r--pod/perlobj.pod13
1 files changed, 7 insertions, 6 deletions
diff --git a/pod/perlobj.pod b/pod/perlobj.pod
index 7d7beaf477..891ebe37f2 100644
--- a/pod/perlobj.pod
+++ b/pod/perlobj.pod
@@ -97,9 +97,11 @@ so that your constructors may be inherited:
}
Or if you expect people to call not just C<< CLASS->new() >> but also
-C<< $obj->new() >>, then use something like this. The initialize()
-method used will be of whatever $class we blessed the
-object into:
+C<< $obj->new() >>, then use something like the following. (Note that using
+this to call new() on an instance does not automatically perform any
+copying. If you want a shallow or deep copy of an object, you'll have to
+specifically allow for that.) The initialize() method used will be of
+whatever $class we blessed the object into:
sub new {
my $this = shift;
@@ -485,9 +487,8 @@ if you don't care to leak. For example, here's a self-referential
node such as one might use in a sophisticated tree structure:
sub new_node {
- my $self = shift;
- my $class = ref($self) || $self;
- my $node = {};
+ my $class = shift;
+ my $node = {};
$node->{LEFT} = $node->{RIGHT} = $node;
$node->{DATA} = [ @_ ];
return bless $node => $class;