Matthew Sacks wrote: > > Greetings: > > When you invoke a method, the first argument to the method equal to the > method's invocant is automatically inserted. >
Correct. > i) Is this essentially the same as a C++ "this" pointer? > Yes, the Perl idiom generally looks like: sub method { my $self = shift; my @args = @_; ... } Where the first line, $self = shift, removes the first argument and stores it to $self for future access. Then the rest of the passed argumetns show up in the rest of @_, storing them to another location is by choice. perldoc -f shift > ii) Apparently, the first argument can be a reference to its object, or the > object. > In Perl those are really the same. An object is really just a blessed reference, perldoc -f bless Though there can be the distinction of a class method vs. an object method, where the first argument won't be a reference/object, but instead the name of the class. This is basically how a constructor is written, though any other class method would do the same. > iii) There is an example in the Camel book, in the > Object-Oriented-Programming Chapter (ch. 12), where accessor methods are > being generated automatically; in this example, it seems that the invocant is > explicity placed into the first argument. If you put in the this pointer, > does PERL know not to put in another one? > My camel is still packed so I can't address this specific issue. Perl automatically adds the first argument whenever a subroutine is called in method format. It won't check the other arguments to see if they are references/class names, so for sure it can't tell. Having said that depending on the method used for accessor generation it might need this for some reason. You might also be interested in the OOP docs that come with Perl, perldoc perl For a list of those. http://danconia.org p.s. Perl is the language, perl is the interpreter, PERL does not compute ;-).... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>