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

Re^4: perl inheritance

by Anonymous Monk
on Mar 23, 2012 at 20:21 UTC ( #961307=note: print w/replies, xml ) Need Help??


in reply to Re^3: perl inheritance
in thread perl inheritance

This smells like a good place for an import method.. What do you think? thanks!

Replies are listed 'Best First'.
Re^5: perl inheritance
by tobyink (Abbot) on Mar 23, 2012 at 23:06 UTC

    No, I wouldn't put it in an import module. A BEGIN block would be better. If you put it in import, you have no guarantee that the import method will ever actually be called. It's quite easy to load a module without ever calling the import method. Conversely, it's very easy for the import method to get called multiple times.

    I actually do something pretty similar to the technique being discussed in XML::LibXML::Augment.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      What's the advantage of using a BEGIN block for that? Do you really think there's something to gain putting those methods in place, before the other methods are compiled?

        Very little advantage in this case. It just so happens that in the same loop I'm also playing around with @ISA and past experience has taught me to alter @ISA as early as possible. Modern versions of Perl are pretty smart when it comes to invalidating method resolution caches, but force of habit makes me put any @ISA alteration in a BEGIN block unless there's a good reason not to.

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re^5: perl inheritance
by JavaFan (Canon) on Mar 23, 2012 at 20:27 UTC
    Sounds like a bad idea to me. Why do you think that's a good idea?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://961307]
help
Chatterbox?
[ambrus]: But either of these is a big problem in practice, so I'd need to spend like thirty years of my life to solve (a) and five more years to solve (b)
[ambrus]: Corion: yes, CURRENTLY the blackboard is more convenient
[ambrus]: and it's not like I want to ban blackboards anyway
[ambrus]: you already have blackboards and a canvas for projector or overhead transparencies (or positive film slide projector, not used for maths) canvas in the same lecture halls today, and switch in a few minutes between presentations,
[ambrus]: they're only difficult to use together.
[ambrus]: overhead transparencies are a nice convenience by the way that mix the two slides, because you can write them in advance and edit them during the presentation easily. but they're not very much in fasion these days.
[ambrus]: you can even print them.
[Discipulus]: ambrus i'm trying out MremoteNG which wrap putty and rdp and many other things..
[Corion]: ambrus: Yes, ideally you would have the ease of overhead projection transparencies and pens drawing on them, combined with the computer generated slide text...
[Corion]: Maybe the solution would be a tablet (with pens), like the Wacom tablets, but you still need good software and need to know how to operate it well in an interactive setting ;)

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









    Results (293 votes). Check out past polls.

    Notices?