
g.dave
New User
Nov 11, 2011, 3:56 PM
Post #5 of 5
(2273 views)
|
|
Re: [FishMonger] require won't import at runtime?
[In reply to]
|
Can't Post
|
|
I've realized my answer. This works as does this Since in the last case the class methods were not imported at compile time, the compiler didn't know how to treat 'frobnicate' and 'munge' as bare words. Declaring them as functions explicitly gives the compiler the clue it needs to execute them as functions at runtime. syntactically it is akin to a simple lexical declaration of:
foo; # fails sub foo { print "foobar!\n" }; which does not work. reversing the order makes it work, or declaring 'foo' as a function also works:
sub foo { print "foobar!\n" }; foo; # works! or
foo(); # works! sub foo { print "foobar!\n" }; &bar; # also works! sub bar { print "barfoo!\n" }; The same principal is involved when using require and then import in a runtime manner. If I think about the timing of compile vs runtime evaluation it begins to make sense why my third example in the original post won't work. Thanks for the input.
(This post was edited by g.dave on Nov 11, 2011, 3:58 PM)
|