Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: 'use subs' causes method to vanish

by zwon (Monsignor)
on Feb 05, 2009 at 20:43 UTC ( #741687=note: print w/ replies, xml ) Need Help??


in reply to 'use subs' causes method to vanish

use subs rewrites existing symbols. Place use subs before init_gui definition. There's no sense to use subs after function is declared.

Update: BTW, I don't think you should use subs at all in this application.


Comment on Re: 'use subs' causes method to vanish
Select or Download Code
Replies are listed 'Best First'.
Re^2: 'use subs' causes method to vanish
by gnosti (Friar) on Feb 05, 2009 at 20:55 UTC
    You're right, I don't need (and from this result won't be using) use subs for an object method. I only encountered this because I used a script to use subs for all subs, to be able to begin to get rid of parentheses for non-object subs.

    I can sort out the methods from the subs and solve the problem, and I'd like to understand perl internals better, too. Hence this posting.

      I only encountered this because I used a script to use subs for all subs, to be able to begin to get rid of parentheses for non-object subs.

      As you've seen, that's a bad idea. If you're rigorous about the order in which Perl compiles your code, you can get away with it... but I like to avoid code which relies on a well-defined order of appearance in the compilation process, as it seems fragile.

        Hi chromatic,

        I'm honored. I agree that it's not a good idea to code using fragile features. In this case, I can't get my updated test case to break whereever I place my 'use subs' statement. I'm curious, because I expect use subs to be part of the extremely beaten-on core of the core of perl. I'm also curious, because I've found such suprising behavior in my bugs that I wondered if it might be worth exploring them more, rather than just fixing or working around them and moving on.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2015-07-28 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls