pub struct Context {
    pub name: Str,
    pub kind: ContextKind,
    /* private fields */
}
Expand description

Represents the context of the current scope

Recursive functions/methods are highlighted with the prefix rec_, as performance may be significantly degraded.

Fields§

§name: Str§kind: ContextKind

Implementations§

Perform types linearization. TODO: Current implementation may be very inefficient.

C3 linearization requires prior knowledge of inter-type dependencies, and cannot be used for Erg structural subtype linearization

Algorithm:

[Int, Str, Nat, Never, Obj, Str!, Module]
=> [], [Int, Str, Nat, Never, Obj, Str!, Module]
=> [[Int]], [Str, Nat, Never, Obj, Str!, Module]
# 1. If related, put them in the same array; if not, put them in different arrays.
=> [[Int], [Str]], [Nat, Never, Obj, Str!, Module]
=> ...
=> [[Int, Nat, Never, Obj]], [Str, Str!], [Module]]
# 2. Then, perform sorting on the arrays
=> [[Never, Nat, Int, Obj], [Str!, Str], [Module]]
# 3. Concatenate the arrays
=> [Never, Nat, Int, Obj, Str!, Str, Module]
# 4. From the left, "slide" types as far as it can.
=> [Never, Nat, Int, Str!, Str, Module, Obj]

Int.meta_type() == ClassType (<: Type) Show.meta_type() == TraitType (<: Type) [Int; 3].meta_type() == [ClassType; 3] (<: Type)

This method is intended to be called only in the top-level module. .cfg is not initialized and is used around.

unlike pop, outer must be None.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.