العرضar

est

Translation status: العربية reader-locale proof. Code fences render through the ar pipeline; prose is canonical Latin.

Tests whether a value is or matches a type-like target.

Syntax: <expression> est <expression>

Category#

logic

  • non est

Examples#

radix/corpus/est/est.fab (canonical · keyword)#

Tests whether a value is or matches a type-like target.

# =============================================================================
# est — Tests whether a value is or matches a type-like target.
# =============================================================================
#
# What this teaches:
#   • Type checking — `<expr> est <type>` tests a valor's runtime variant tag without extraction.
#   • Null checking — `<expr> est nihil` checks for null values.
#   • Boolean checks — `<expr> est verum` / `<expr> est falsum` for exact boolean comparison.
#   • Negation — `<expr> non est <type>` negates the type check.
#   • Chaining — `est` composes with `et` and parenthesized expressions.
#
# Common mistakes:
#   • Using `est` for equality comparison — `est` checks variant tags and type-like targets, not structural equality; use `≡` for value comparison.
#
# See also: non est
# =============================================================================


# est — type, null, and boolean checks
#
# <expr> est nihil       — null check (legacy, lowers to == Valor::Nihil)
# <expr> est <type>      — variant tag check (lowers to matches!)
# <expr> non est <type>  — negated variant tag check
# <expr> est verum       — exact true check
# <expr> est falsum      — exact false check
#
# GRAMMAR:
#   typeCheckExpr :← expr 'est' type
#
# EXPECTED OUTPUT:
#   est.expected

fn explora(unknown x)  string {
    if x is null { return "nihil est" }
    return "aliud est"
}

fn explora_bivalens(bool x)  string {
    if x is true { return "verum est" }
    if x is false { return "falsum est" }
    return "aliud est"
}

main {
    # Null checking with est
    const int  null forsitan  null
    const _ nihil_est  forsitan is null
    print nihil_est

    # Boolean true check with est
    const _ enabled  true
    const _ verum_est  enabled is true
    print verum_est

    # Boolean false check with est
    const _ disabled  false
    const _ falsum_est  disabled is false
    print falsum_est

    # Chained with logical operators
    const string  null nomen  null
    const _ defectum_debet  nomen is null and enabled is true
    print defectum_debet

    # Parenthesized for clarity
    const _ utraque_nihil  (forsitan is null) and (nomen is null)
    print utraque_nihil

    # Dynamic ignotum dispatch for nihil and exact boolean checks on bivalens
    print explora(null)
    print explora_bivalens(true)
    print explora(42)

    # --- Variant checks against concrete types ---
    #
    # `est <type>` tests a valor's runtime variant tag directly, without
    # attempting extraction. The inner type parameters of lista/tabula are
    # not checked (width and element types are erased at Valor boxing time
    # by design — see docs/factory/est-variant-check/goal.md).

    const value name  "faber" ↦ value
    const value count  42 ↦ value
    const value tags  ["a", "b"] ↦ value
    const value active  true ↦ value
    const value ratio  1.5 ↦ value

    assert name is string
    assert count is int
    assert tags is list<value>
    assert active is bool
    assert ratio is float

    assert count not is string
    assert name not is int
}

Expected output:

verum
verum
verum
verum
verum
nihil est
verum est
aliud est