home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _669f82e441657666f0bd18d1ea71fe17 < prev    next >
Text File  |  2000-03-23  |  4KB  |  110 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>autouse - postpone load of modules until a function is used</TITLE>
  5. <LINK REL="stylesheet" HREF="../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> autouse - postpone load of modules until a function is used</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  25.     <LI><A HREF="#warning">WARNING</A></LI>
  26.     <LI><A HREF="#author">AUTHOR</A></LI>
  27.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  28. </UL>
  29. <!-- INDEX END -->
  30.  
  31. <HR>
  32. <P>
  33. <H1><A NAME="name">NAME</A></H1>
  34. <P>autouse - postpone load of modules until a function is used</P>
  35. <P>
  36. <HR>
  37. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  38. <UL>
  39. <LI>Linux</LI>
  40. <LI>Solaris</LI>
  41. <LI>Windows</LI>
  42. </UL>
  43. <HR>
  44. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  45. <PRE>
  46.   use autouse 'Carp' => qw(carp croak);
  47.   carp "this carp was predeclared and autoused ";</PRE>
  48. <P>
  49. <HR>
  50. <H1><A NAME="description">DESCRIPTION</A></H1>
  51. <P>If the module <CODE>Module</CODE> is already loaded, then the declaration</P>
  52. <PRE>
  53.   use autouse 'Module' => qw(func1 func2($;$) Module::func3);</PRE>
  54. <P>is equivalent to</P>
  55. <PRE>
  56.   use Module qw(func1 func2);</PRE>
  57. <P>if <CODE>Module</CODE> defines <CODE>func2()</CODE> with prototype <CODE>($;$)</CODE>, and <CODE>func1()</CODE> and
  58. <CODE>func3()</CODE> have no prototypes.  (At least if <CODE>Module</CODE> uses <CODE>Exporter</CODE>'s
  59. <A HREF="../lib/Pod/perlfunc.html#item_import"><CODE>import</CODE></A>, otherwise it is a fatal error.)</P>
  60. <P>If the module <CODE>Module</CODE> is not loaded yet, then the above declaration
  61. declares functions <CODE>func1()</CODE> and <CODE>func2()</CODE> in the current package, and
  62. declares a function Module::func3().  When these functions are called,
  63. they load the package <CODE>Module</CODE> if needed, and substitute themselves
  64. with the correct definitions.</P>
  65. <P>
  66. <HR>
  67. <H1><A NAME="warning">WARNING</A></H1>
  68. <P>Using <CODE>autouse</CODE> will move important steps of your program's execution
  69. from compile time to runtime.  This can</P>
  70. <UL>
  71. <LI>
  72. Break the execution of your program if the module you <CODE>autouse</CODE>d has
  73. some initialization which it expects to be done early.
  74. <P></P>
  75. <LI>
  76. hide bugs in your code since important checks (like correctness of
  77. prototypes) is moved from compile time to runtime.  In particular, if
  78. the prototype you specified on <CODE>autouse</CODE> line is wrong, you will not
  79. find it out until the corresponding function is executed.  This will be
  80. very unfortunate for functions which are not always called (note that
  81. for such functions <CODE>autouse</CODE>ing gives biggest win, for a workaround
  82. see below).
  83. <P></P></UL>
  84. <P>To alleviate the second problem (partially) it is advised to write
  85. your scripts like this:</P>
  86. <PRE>
  87.   use Module;
  88.   use autouse Module => qw(carp($) croak(&$));
  89.   carp "this carp was predeclared and autoused ";</PRE>
  90. <P>The first line ensures that the errors in your argument specification
  91. are found early.  When you ship your application you should comment
  92. out the first line, since it makes the second one useless.</P>
  93. <P>
  94. <HR>
  95. <H1><A NAME="author">AUTHOR</A></H1>
  96. <P>Ilya Zakharevich (<A HREF="mailto:ilya@math.ohio-state.edu">ilya@math.ohio-state.edu</A>)</P>
  97. <P>
  98. <HR>
  99. <H1><A NAME="see also">SEE ALSO</A></H1>
  100. <P>perl(1).</P>
  101. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  102. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  103. <STRONG><P CLASS=block> autouse - postpone load of modules until a function is used</P></STRONG>
  104. </TD></TR>
  105. </TABLE>
  106.  
  107. </BODY>
  108.  
  109. </HTML>
  110.