Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Would someone mind helping me understand this Perl OO code?

by romandas (Pilgrim)
on Dec 22, 2009 at 16:11 UTC ( #813916=note: print w/replies, xml ) Need Help??


in reply to Re^3: Would someone mind helping me understand this Perl OO code?
in thread Would someone mind helping me understand this Perl OO code?

I'm sure this behavior is documented somewhere, but didn't see it. Do you know where it can be found?

Since new isn't a reserved word, how does perl know to pass the package name implicitly into that method in the first place? I could have just as badlyeasily named the constructor 'bargle'. Is the package name passed implicitly on every method call? Or just the one where the object is blessed?
  • Comment on Re^4: Would someone mind helping me understand this Perl OO code?

Replies are listed 'Best First'.
Re^5: Would someone mind helping me understand this Perl OO code?
by almut (Canon) on Dec 22, 2009 at 16:16 UTC
    Do you know where it can be found?

    ...for example in perltoot (search for "Method Call" (case-sensitively)).

Re^5: Would someone mind helping me understand this Perl OO code?
by kennethk (Abbot) on Dec 22, 2009 at 16:18 UTC
    In perlboot, an intro to OO in Perl, it is discussed in The extra parameter of method invocation.

    Update: To answer your updated question, the package name or blessed object are passed in a method invocation whenever you use the The Arrow Operator to invoke a package method. So Node->new() will pass "Node" and new(), Node::new() or $code_ref->() would not.

Re^5: Would someone mind helping me understand this Perl OO code?
by ikegami (Pope) on Dec 22, 2009 at 16:18 UTC

    It's the first thing perlobj says about methods

    A Method is Simply a Subroutine

    Unlike say C++, Perl doesn't provide any special syntax for method definition. (It does provide a little syntax for method invocation though. More on that later.) A method expects its first argument to be the object (reference) or package (string) it is being invoked on.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://813916]
help
Chatterbox?
[Corion]: Talking about it, the top should be fairly visible in the situations I've experienced at least. The top is uncomfortable for people in the first three rows, but that's life ;)
[ambrus]: The pillars are there because this is in the 6th floor of building R of BME, which is an attic that was built in after the original building, which is also why the elevator doesn't go that high and the windows are tiny.
[Corion]: ambrus: Hehe ;) Yeah - such real life stuff is far more inconveniencing than wasting display area due to screen ratio problems :)
[ambrus]: Corion: yes, it's a bit tricky. you can try to adjust the slides live to cover only a part of the screen, but it's still hard.
[ambrus]: Corion: two very hard things about presentations I should try to work on if I have twenty times as much free time as in real life are:
[Corion]: That's why I like HTML - it makes it relatively easy to resize stuff. Resizing with Powerpoint is much harder, or at least, I remember it being that way
[ambrus]: (a) good sans serif fonts optimized for slides in a projector with coverage of the symbols needed for mathematical formulas in a sans serif font matching the text font well, and
[ambrus]: (b) a good presentation system that lets the presenter quickly interactively edit the slides live during a presentation, to combine the advantages of blackboard and overhead slide styles in modern tech
[Corion]: Heh - in university, I cheated on (a) by doing blackboard presentations using chalk. But those were 2 hour presentations, not quick/essential/ reduced presentations where you want to show something quick
[ambrus]: (either on just one screen or two screens). this is necessary because

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2017-09-26 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?