Enum kailua_types::ty::Tag [] [src]

pub enum Tag {
    Require,
    Type,
    Assert,
    AssertNot,
    AssertType,
    GenericPairs,
    GlobalEnv,
    GlobalEval,
    BecomeModule,
    PackagePath,
    PackageCpath,
    StringMeta,
    MakeClass(ClassSystemId),
    KailuaGenTvar,
    KailuaAssertTvar,
    // some variants omitted
}

A type tag for giving a type special meanings.

Generally a type with a tag is equal to or a subtype of a specific form of types; it is safe to put a tag to an non-conforming type, but that won't work well in general.

Variants

function(string, ...) -> table

Also loads a code specified by the string literal (if any). Any exported types in that cdoe will be also brought to the current local scope.

function(any) -> string

Used by assertions but does nothing by its own. Has very limited return values.

function(any, ...) -> any

Also recognizes the following kinds of expressions:

  • <expr> asserts that the corresponding type is truthy.
  • not <expr> asserts that the corresponding type is falsy.
  • <type>(<expr>) == <string>, where <type> is a value with Type tag.

Expressions can be chained by and or or, subject to De Morgan's law. Any unrecognized expression or non-definitive conditions are ignored.

function(any, ...) -> any

Same to assert(not <expr>, ...).

function(any, string, ...) -> any

Basically same to assert(type(<expr>) == <string>, ...).

Also accepts additional string literals:

  • "integer" for an integer.

function(table, ...) -> (function(table, any) -> (any?, any), table, any, ...)

A hack for supporting generic pairs and ipairs functions. The first argument is exactly resolved first and the return values are updated to fit the following generic signature if possible (not yet directly supported):

({T => U}, ...) -> (function({T => U}, T) -> (T?, U), {T => U}, T, ...)

...except when the third return type is not any, in which case T is replaced with that parameter so that ipairs (which T should be integer) works for any table types.

table

A table mirroring the global environment.

function(...) -> (...)

Calling this function will alter the global environment in unspecified way, so it is no longer assumed to be known after the call.

function(string, ...) -> (...)

Calling this function will enable the "module" mode in Lua 5.1.

var string

Assigning to these variables will update the require paths (in the order). They are distinct to each other, but otherwise have the same syntax to Lua's.

table

The metatable for all strings. The method calls for string go through this table, and any modification to this table is immediately available to subsequent code.

Note that this table is linked to the current environment only by --# assume; there is no other valid way to get a table with such a type.

function(<class prototype type>?) -> <class prototype type>

A function that makes a class prototype. If the argument is given, it should be another existing prototype that acts as a parent of a newly created prototype.

The prototype is initially unnamed; the first assignment to a local or global variable will set its name, and the name cannot be changed thereafter.

There may be additional behaviors depending on the class system used.

function() -> any

Issues a fresh type variable for each use. The return type is ignored. This is strictly for testing.

function(any)

Fails when given type is not a type variable (no matter it is bounded or not). This is used for tests requiring a type variable to be resolved; By using this function we can ensure that we are indeed testing against a type variable.

Methods

impl Tag
[src]

Returns true if the effect of this tag is local to the current scope.

Non-scope-local tags have a limited ability inside non-global scopes.

Returns true if this tag needs the strict subtyping rule.

For example, it is NOT possible to update [type] function(any) -> string with a plain function(any) -> string, it has to be [type] function(any) -> string. Generally the tag working via assignment should have this false.

Trait Implementations

impl Copy for Tag
[src]

impl Clone for Tag
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Tag
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Tag
[src]

impl Debug for Tag
[src]

Formats the value using the given formatter.

impl Display for Tag
[src]