Skip to content
FutureBlitz

    Install

    Import std.core.interfaces

    std.core.interfaces

    The Interfaces that the language's operators and strings work through. The built-in types implement the ones that fit them, and a Struct or Class implements one by listing it.

    std/core/interfaces.fb

    Types

    Equatable interface

    Public Interface Equatable

    What == says, and != is always its opposite. A Struct that lists Equatable without an Operator == of its own compares its fields, and a Class compares whether two are the same object.

    std/core/interfaces.fb, line 7

    • Operator ==(a: Self, b: Self): Bool operator #

      Whether a and b are equal.

    Comparable interface

    Public Interface Comparable Extends Equatable

    An order: what < says, which the other comparisons follow unless a type gives its own.

    std/core/interfaces.fb, line 13

    • Operator <(a: Self, b: Self): Bool operator #

      Whether a comes before b.

    • Operator >(a: Self, b: Self): Bool operator #

      Whether a comes after b.

    • Operator <=(a: Self, b: Self): Bool operator #

      Whether a comes before b or is equal to it.

    • Operator >=(a: Self, b: Self): Bool operator #

      Whether a comes after b or is equal to it.

    Hashable interface

    Public Interface Hashable Extends Equatable

    A number for Maps and Sets to find a value by, the same for values that are equal. A Struct that lists Hashable without a Hash of its own combines its fields', and a Class's comes from its object.

    std/core/interfaces.fb, line 28

    • Method Hash(): UInt64 method #

      Its hash, the same for values that are equal.

    Printable interface

    Public Interface Printable

    What a value shows in a string, like "{point}".

    std/core/interfaces.fb, line 34

    • Method ToString(): String method #

      Its text, as a string interpolation like "{value}" shows it.

    Formattable interface

    Public Interface Formattable Extends Printable

    A value that takes a format spec, the part after the ':' in "{price:.2}" or Format's "{0:>8}": Format gives its text for the spec, or Null when it doesn't take that spec. The numbers, Bool, String, and Enums are Formattable, by the specs the compiler checks.

    std/core/interfaces.fb, line 42

    • Method Format(spec: String): String? method #

      Its text for a format spec, like ".2" or ">8", or Null when it doesn't take that spec.

    Numeric interface

    Public Interface Numeric

    What arithmetic needs, so generic code like a Sum works on any number.

    std/core/interfaces.fb, line 48

    • Static Method Zero(): Self static method #

      The number that adding leaves alone: 0.

    • Static Method One(): Self static method #

      The number that multiplying leaves alone: 1.

    • Operator +(a: Self, b: Self): Self operator #

      a and b added up.

    • Operator -(a: Self, b: Self): Self operator #

      b taken away from a.

    • Operator *(a: Self, b: Self): Self operator #

      a and b multiplied together.

    • Operator /(a: Self, b: Self): Self operator #

      a divided by b.

    Cloneable interface

    Public Interface Cloneable

    What makes a copy of itself, which changing one doesn't change the other: arrays and std's collections are Cloneable.

    std/core/interfaces.fb, line 65

    • Method Clone(): Self method #

      A new value, equal to this one, that changing this one doesn't change.

    Defaultable interface

    Public Interface Defaultable

    What has a value to start from, for generic code that needs one: the numbers' is 0, Bool's False, String's "", an Enum's its zero, its first value or a @Flags Enum's no flags, and std's collections' is empty. It's DefaultValue, since Default is Select's keyword.

    std/core/interfaces.fb, line 73

    • Static Method DefaultValue(): Self static method #

      The value to start from, like 0 for a number, "" for a String, or an empty collection.

    Sendable interface

    Public Interface Sendable

    What can go to another thread, which the compiler decides: numbers, Bools, Strings, Enums, Callbacks, Channels, Mutexes, Atomics, and a Shared Class's objects and Weaks of them, and the Structs, tuples, and fixed arrays whose fields and elements all are, with a T? of any of them. A type can list it, or an Interface that extends it, to have that checked.

    std/core/interfaces.fb, line 82

    Report an issue with this page or with FutureBlitz on GitHub.