Perl-Sensitive Sunglasses | |
PerlMonks |
Re^4: Beware of POSIX constants (sorta)by tye (Sage) |
on Oct 04, 2005 at 02:19 UTC ( [id://497113]=note: print w/replies, xml ) | Need Help?? |
Yes, I don't think Perl Mouse was suggesting it would get a prototype. But so what? Would adding a prototype solve any problems? Usually, the entire program has been compiled at that point already, so adding a prototype doesn't gain anything. Yes, I don't think tye was suggesting that just adding a prototype would be enough to solve any problem. But so what? Would defining the function earlier solve any problems? The function doesn't have a prototype so defining it early doesn't gain anything. (: But, in fact, you don't have to define the function earlier. You can still use "POSIX's autoloading behaviour" to delay the defining of the function's body, you just have to fix the exporting of the function to export a prototype (by declaring the function that you haven't defined yet). Here's an example of how to do that making the bold assumption that all POSIX exported items with ALL_CAPS names are supposed to be constants (and mostly ignoring POSIX's current implementation for the sake of making a quick demonstration):
which outputs:
Which shows that Perl was forced to autoload the function after the line that prints the prototype and yet the problem is fixed. - tye
In Section
Meditations
|
|