Files
sakurac/core/traits/signature.sakura
T

32 lines
1.2 KiB
Plaintext
Raw Normal View History

2026-10-26 10:14:11 -05:00
#! @file signature.sakura
#! @author John Christman (sorakatadzuma@gmail.com)
#! @copyright Malunal Studios, LLC.
#! @license MIT
#!
#! Contains the signature trait, which the compiler gives every function type,
#! and which names what a function takes and what it gives.
module core;
#! A function type, as `def(i64, bool): u8`, a variadic one, as `def(i64...):
#! i64`, or the address of a C function, as `cfn<def(i32): void>`.
#!
#! Generic code bounded by it names the parts of the type it is given: `F::result`
#! is what a function of it gives, and `F::params` the types it takes, as a pack,
#! so `args: F::params...` takes the arguments it does. A variadic function's
#! pack ends in the type of the values its last parameter takes, so a parameter
#! of the pack is variadic too.
#!
#! A pattern parameter, as `def(Ts...): R` of `invokable`, is given a signature
#! whole: `invokable<F>` where `F: signature` names `F::params` and `F::result`
#! as `Ts` and `R`.
#!
#! The compiler decides what is a signature, so no type implements it.
pub trait signature {
#! What a function of the type gives.
type result;
#! The types a function of the type takes, as a pack, which only the compiler
#! gives.
type params...;
}