 |
|
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
|

05-29-2009
, 10:05
Re: DEATHS ZOMG
|
#8
|
From Pawn Language Guide (which I suggest you download)
Stock Functions
A “stock” function is a function that the pawn parser must “plug into” the program
when it is used, and that it may simply “remove” from the program (without warning)
when it is not used. Stock functions allow a compiler or interpreter to optimize the
memory footprint and the file size of a (compiled) pawn program: any stock function
that is not referred to, is completely skipped —as if it were lacking from the source
file. A typical use of stock functions, hence, is in the creation of a set of “library”
functions. A collection of general purpose functions, all marked as “stock”may be put
in a separate include file, which is then included in any pawn script. Only the library
functions that are actually used get “linked” in.
To declare a stock function, prefix the function name with the keyword stock. Public
functions and native functions cannot be declared "stock".
When a stock function calls other functions, it is usually a good practice to
declare those other functions as “stock” too —with the exception of native
functions. Similarly, any global variables that are used by a stock function
should in most cases also be defined “stock”. The removal of unused (stock)
functions can cause a chain reaction in which other functions and global
variables are not longer accessed either. Those functions are then removed
as well, thereby continuing the chain reaction until only the functions that
are used, directly or indirectly, remain.
Stock Variables
A global variable may be declared as “stock”. A stock declaration is one that the parser
may remove or ignore if the variable turns out not to be used in the program.
__________________
|
|
|
|