From WikiChip
Difference between revisions of "Lua Standard Libraries"

m (Package Library)
 
Line 3: Line 3:
 
== Basic Library ==
 
== Basic Library ==
 
{{main|Basic Library - Lua}}
 
{{main|Basic Library - Lua}}
 +
 
The Basic Library is composed of a set of core functions for the Lua language.
 
The Basic Library is composed of a set of core functions for the Lua language.
  
 
=== coroutine Library ===
 
=== coroutine Library ===
 
{{main|Coroutine Library - Lua}}
 
{{main|Coroutine Library - Lua}}
 +
 
The Coroutine Library is a sub-library of the Basic Library that provides a set of functions for manipulating coroutines. All coroutines functions are exported inside the table ''coroutine''.
 
The Coroutine Library is a sub-library of the Basic Library that provides a set of functions for manipulating coroutines. All coroutines functions are exported inside the table ''coroutine''.
  
 
== Package Library ==
 
== Package Library ==
 
{{main|Package Library - Lua}}
 
{{main|Package Library - Lua}}
 +
 
The Package Library provides the facilities for loading and building modules. With the exception of [[require - Lua|require]] and [[module - Lua|module]], all package library functions are in the table ''package''.
 
The Package Library provides the facilities for loading and building modules. With the exception of [[require - Lua|require]] and [[module - Lua|module]], all package library functions are in the table ''package''.
  
 
== Mathematical Library ==
 
== Mathematical Library ==
 
{{main|Mathematical Library - Lua}}
 
{{main|Mathematical Library - Lua}}
 +
 
The Mathematical Library provides a set of common mathematical functions such as trigonometric functions, exponentiation and logarithms, rounding functions, and various other math auxiliary functions such as maximum, minimum and pseudo-random generators. All mathematical functions resides inside the table ''math''.
 
The Mathematical Library provides a set of common mathematical functions such as trigonometric functions, exponentiation and logarithms, rounding functions, and various other math auxiliary functions such as maximum, minimum and pseudo-random generators. All mathematical functions resides inside the table ''math''.
  
 
== String Library ==
 
== String Library ==
 
{{main|String Library - Lua}}
 
{{main|String Library - Lua}}
 +
 
The String Library provides a set of functions for manipulating strings, searching and extracting substrings, as well as pattern matching. String indexes are 1-based. Negative indices are interpreted as indexing backwards, from the end of the string. All string manipulating functions reside inside the table ''string''. The string library assumes the strings are encoded using a one-byte encoding schemes.
 
The String Library provides a set of functions for manipulating strings, searching and extracting substrings, as well as pattern matching. String indexes are 1-based. Negative indices are interpreted as indexing backwards, from the end of the string. All string manipulating functions reside inside the table ''string''. The string library assumes the strings are encoded using a one-byte encoding schemes.
  
 
== Table Library ==
 
== Table Library ==
 
{{main|Table Library - Lua}}
 
{{main|Table Library - Lua}}
 +
 
The Table Library provides generic functions for manipulating tables. Most of the functions assume that the table represents a list or an array. All table manipulation functions are inside the table ''table''.
 
The Table Library provides generic functions for manipulating tables. Most of the functions assume that the table represents a list or an array. All table manipulation functions are inside the table ''table''.
  
 
== I/O Library ==
 
== I/O Library ==
 
{{main|I/O Library - Lua}}
 
{{main|I/O Library - Lua}}
 +
 
The I/O Library provides a set of file manipulation functions in two styles: using implicit file descriptors and using explicit file descriptors. Table ''io'' also provides three predefined file descriptors: io.stdin, io.stdout, and io.stderr as the standard input, out and error streams.
 
The I/O Library provides a set of file manipulation functions in two styles: using implicit file descriptors and using explicit file descriptors. Table ''io'' also provides three predefined file descriptors: io.stdin, io.stdout, and io.stderr as the standard input, out and error streams.
  
 
== OS Library ==
 
== OS Library ==
 
{{main|OS Library - Lua}}
 
{{main|OS Library - Lua}}
 +
 
The OS Library provides a set of miscellaneous functions for various OS services such as time and date manipulation, temporary file, environment variable, and file renaming and removing.
 
The OS Library provides a set of miscellaneous functions for various OS services such as time and date manipulation, temporary file, environment variable, and file renaming and removing.
  
 
== Debug Library ==
 
== Debug Library ==
 
{{main|Debug Library - Lua}}
 
{{main|Debug Library - Lua}}
 +
 
The Debug Library provides facilities for debugging and profiling Lua programs. All debug functions are provided inside the ''debug'' table.
 
The Debug Library provides facilities for debugging and profiling Lua programs. All debug functions are provided inside the ''debug'' table.
  

Latest revision as of 23:30, 1 March 2014

The Lua Standard Libraries are a small collection of modules for performing common tasks such as manipulating strings, working with tables, input/out processing, and various other facilities for performing operating system services. The standard libraries functions are implemented directly through the C API.

Basic Library[edit]

Main article: Basic Library - Lua


The Basic Library is composed of a set of core functions for the Lua language.

coroutine Library[edit]

Main article: Coroutine Library - Lua


The Coroutine Library is a sub-library of the Basic Library that provides a set of functions for manipulating coroutines. All coroutines functions are exported inside the table coroutine.

Package Library[edit]

Main article: Package Library - Lua


The Package Library provides the facilities for loading and building modules. With the exception of require and module, all package library functions are in the table package.

Mathematical Library[edit]

Main article: Mathematical Library - Lua


The Mathematical Library provides a set of common mathematical functions such as trigonometric functions, exponentiation and logarithms, rounding functions, and various other math auxiliary functions such as maximum, minimum and pseudo-random generators. All mathematical functions resides inside the table math.

String Library[edit]

Main article: String Library - Lua


The String Library provides a set of functions for manipulating strings, searching and extracting substrings, as well as pattern matching. String indexes are 1-based. Negative indices are interpreted as indexing backwards, from the end of the string. All string manipulating functions reside inside the table string. The string library assumes the strings are encoded using a one-byte encoding schemes.

Table Library[edit]

Main article: Table Library - Lua


The Table Library provides generic functions for manipulating tables. Most of the functions assume that the table represents a list or an array. All table manipulation functions are inside the table table.

I/O Library[edit]

Main article: I/O Library - Lua


The I/O Library provides a set of file manipulation functions in two styles: using implicit file descriptors and using explicit file descriptors. Table io also provides three predefined file descriptors: io.stdin, io.stdout, and io.stderr as the standard input, out and error streams.

OS Library[edit]

Main article: OS Library - Lua


The OS Library provides a set of miscellaneous functions for various OS services such as time and date manipulation, temporary file, environment variable, and file renaming and removing.

Debug Library[edit]

Main article: Debug Library - Lua


The Debug Library provides facilities for debugging and profiling Lua programs. All debug functions are provided inside the debug table.