Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: compile or run-time inheritance

by ioannis (Abbot)
on Jun 17, 2006 at 15:10 UTC ( #555977=note: print w/replies, xml ) Need Help??


in reply to compile or run-time inheritance

You cannot have binding of methods before INIT because the type of invocant is determined at runtime. For example, when we bless a reference with bless {}, $string, this executes at runtime to assign the class type, which tells us which @ISA to examine.

Replies are listed 'Best First'.
Re^2: compile or run-time inheritance
by adrianh (Chancellor) on Jun 18, 2006 at 09:13 UTC
    You cannot have binding of methods before INIT because the type of invocant is determined at runtime

    I beg to differ :-)

    #! /usr/bin/perl use strict; use warnings; INIT { print "in INIT\n"; print "out INIT\n"; } BEGIN { print "in BEGIN\n"; { package Foo; sub new { bless {}, shift }; sub foo { print "I'm a ", shift, "\n"}; } Foo->new->foo; print "out BEGIN\n"; } __END__ in BEGIN I'm a Foo=HASH(0x181af90) out BEGIN in INIT out INIT
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://555977]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2020-06-02 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (19 votes). Check out past polls.

    Notices?