From: Ricardo SIGNES Date: Tue, 20 Jan 2009 23:21:34 +0000 (-0500) Subject: remove some indirect method calls, add a caveat X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=797f796a9610b63f252016d76732152c8ff9fb39;p=p5sagit%2Fp5-mst-13.2.git remove some indirect method calls, add a caveat --- diff --git a/pod/perlcall.pod b/pod/perlcall.pod index 08173d2..06f3aa3 100644 --- a/pod/perlcall.pod +++ b/pod/perlcall.pod @@ -1218,9 +1218,9 @@ virtual. The static method, C, prints out simply the class name and a version number. The virtual method, C, prints out a single element of the array. Here is an all Perl example of using it. - $a = new Mine ('red', 'green', 'blue'); + $a = Mine->new('red', 'green', 'blue'); $a->Display(1); - PrintID Mine; + Mine->PrintID; will print @@ -1277,7 +1277,7 @@ the C and C methods from C. So the methods C and C can be invoked like this - $a = new Mine ('red', 'green', 'blue'); + $a = Mine->new('red', 'green', 'blue'); call_Method($a, 'Display', 1); call_PrintID('Mine', 'PrintID'); diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 4814ac7..f8d2282 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -4675,7 +4675,7 @@ into package C
.) Here is a typical code layout: } # In the main program - push @INC, new Foo(...); + push @INC, Foo->new(...); Note that these hooks are also permitted to set the %INC entry corresponding to the files they have loaded. See L. diff --git a/pod/perlglossary.pod b/pod/perlglossary.pod index d22e2ac..f0240b0 100644 --- a/pod/perlglossary.pod +++ b/pod/perlglossary.pod @@ -1457,6 +1457,9 @@ invocant between the method and its arguments: give $gollum "Fisssssh!"; give $gollum "Precious!"; +In modern Perl, calling methods this way is often considered bad practice and +to be avoided. + =item indirect object slot The syntactic position falling between a method call and its arguments diff --git a/pod/perlothrtut.pod b/pod/perlothrtut.pod index 3253097..e0d69c5 100644 --- a/pod/perlothrtut.pod +++ b/pod/perlothrtut.pod @@ -607,10 +607,10 @@ this: sleep 10; $DataQueue->enqueue(undef); -You create the queue with new Thread::Queue. Then you can add lists of -scalars onto the end with enqueue(), and pop scalars off the front of -it with dequeue(). A queue has no fixed size, and can grow as needed -to hold everything pushed on to it. +You create the queue with C<< Thread::Queue->new >>. Then you can add +lists of scalars onto the end with enqueue(), and pop scalars off the +front of it with dequeue(). A queue has no fixed size, and can grow as +needed to hold everything pushed on to it. If a queue is empty, dequeue() blocks until another thread enqueues something. This makes queues ideal for event loops and other @@ -740,10 +740,10 @@ it. A more elaborate example looks like this: use Thread qw(yield); - new Thread \&thread_sub, 1; - new Thread \&thread_sub, 2; - new Thread \&thread_sub, 3; - new Thread \&thread_sub, 4; + Thread->new(\&thread_sub, 1); + Thread->new(\&thread_sub, 2); + Thread->new(\&thread_sub, 3); + Thread->new(\&thread_sub, 4); sub sync_sub :locked { my $CallingThread = shift @_; @@ -790,7 +790,7 @@ method attribute indicates whether the subroutine is really a method. } foreach my $thrnum (1..10) { - new Thread \&tester, $thrnum; + Thread->new(\&tester, $thrnum); } package Foo;