Home Explore Blog CI



neovim

60th chunk of `runtime/doc/luaref.txt`
c08209276a80830ab97d234c6911c7b70ccd90b21b3f748d0000000100000fac
 module system. Unlike `require`, it does not perform any path
        searching and does not automatically adds extensions. {libname} must
        be the complete file name of the C library, including if necessary a
        path and extension. {funcname} must be the exact name exported by the
        C library (which may depend on the C compiler and linker used).

        This function is not supported by ANSI C. As such, it is only
        available on some platforms (Windows, Linux, Mac OS X, Solaris, BSD,
        plus other Unix systems that support the `dlfcn` standard).

package.path                                                      *package.path*
        The path used by `require` to search for a Lua loader.

        At start-up, Lua initializes this variable with the value of the
        environment variable `LUA_PATH` or with a default path defined in
        `luaconf.h`, if the environment variable is not defined. Any `";;"` in
        the value of the environment variable is replaced by the default path.

        A path is a sequence of `templates` separated by semicolons. For each
        template, `require` will change each interrogation mark in the
        template by `filename`, which is `modname` with each dot replaced by a
        "directory separator" (such as `"/"`  in Unix); then it will try to
        load the resulting file name. So, for instance, if the Lua path is
>
               "./?.lua;./?.lc;/usr/local/?/init.lua"
<
        the search for a Lua loader for module `foo` will try to load the
        files `./foo.lua`, `./foo.lc`, and `/usr/local/foo/init.lua`, in that
        order.

package.preload                                              *package.preload()*
        A table to store loaders for specific modules (see |require()|).

package.seeall({module})                                      *package.seeall()*
        Sets a metatable for {module} with its `__index` field referring to
        the global environment, so that this module inherits values from the
        global environment. To be used as an option to function {module}.

==============================================================================
5.4 String Manipulation                                       *lua-lib-string*

This library provides generic functions for string manipulation, such as
finding and extracting substrings, and pattern matching. When indexing a
string in Lua, the first character is at position 1 (not at 0, as in C).
Indices are allowed to be negative and are interpreted as indexing backwards,
from the end of the string. Thus, the last character is at position -1, and
so on.

The string library provides all its functions inside the table `string`.
It also sets a metatable for strings where the `__index` field points to the
`string` table. Therefore, you can use the string functions in object-oriented
style. For instance, `string.byte(s, i)` can be written as `s:byte(i)`.

string.byte({s} [, {i} [, {j}]])                                 *string.byte()*
        Returns the internal numerical codes of the characters `s[i]`,
        `s[i+1]`,..., `s[j]`. The default value for {i} is 1; the default
        value for {j} is {i}.

        Note that numerical codes are not necessarily portable across
        platforms.

string.char({...})                                               *string.char()*
        Receives zero or more integers. Returns a string with length equal to
        the number of arguments, in which each character has the internal
        numerical code equal to its correspondent argument.

        Note that numerical codes are not necessarily portable across
        platforms.

string.dump({function})                                          *string.dump()*
        Returns a string containing a binary representation of the given
        function, so that a later |loadstring()| on this string returns a
        copy of the function. {function} must be a Lua function without
        upvalues.

string.find({s},

Title: Lua Package Variables and String Manipulation Library
Summary
This section describes Lua's `package.path` variable, its initialization, and how `require` uses it to search for Lua loaders using templates and file name replacements. It also covers `package.preload` for storing loaders and `package.seeall` for inheriting global environment values. The section then transitions to the string manipulation library (`string`), including string indexing, its metatable, and functions like `string.byte`, `string.char`, and `string.dump`.