Skip to main content

Specialisation

Struct Specialisation 

Source
pub struct Specialisation {
    pub of: Subject,
    pub key: Vec<Type>,
    pub declaration: Declaration,
}
Expand description

A constrained declaration, or a member of an instance with a context, at one assignment of ground types to its constrained variables: an ordinary declaration of the module that uses it.

specialise makes these. The body is a copy of the declaring module’s code with the assignment applied to every type in it, and with each reference that carried obligations resolved at the types they are now at, so nothing in it asks which instance is meant and nothing is passed at run time to say (DEC-2 decision 7). It is placed in the module that uses it and not in the module that declares the function, because the instance a copy calls may be declared by a module that imports the declaring one: emitted beside min, a copy that called the compare of an App that imports Basics would make Basics import App.

Two uses at one key in one module are one specialisation, and two modules that use one key each hold a copy. For a function that is code written twice and nothing a program can observe. For a binding with no parameters it is one evaluation for each module that uses it where the chapter says “once”, and a Zelkova value has no identity, so what differs is the work done and never an answer.

Fields§

§of: Subject

What this is a copy of.

§key: Vec<Type>

The ground type each constrained variable of the declaration is at, in the order the variables first occur in its context.

Only the variables a constraint is on are in it: nothing a JavaScript module emits depends on any other, so a variable with no constraint needs no copy. A target whose code does depend on one reads its type off the nodes of declaration, where it is left a variable.

§declaration: Declaration

The copy: the declaring declaration’s name and parameters, its type and every type in its body with the key applied, an empty context, and Declaration::arity and Declaration::span as it was written.

Trait Implementations§

Source§

impl Debug for Specialisation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.