रेंडरिंगhi

है

Tests whether a value's runtime type is a given type.

Translation status: हिन्दी reader-locale proof. Term names and code fences follow the hi pack; supporting prose may still be English.

Tests whether a value's runtime type is a given type.

Syntax: <expression> est <type>

Category#

logic

Examples#

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

Tests whether a value's runtime type is a given type.

# =============================================================================
# est — Tests whether a value's runtime type is a given type.
# =============================================================================
#
# What this teaches:
#   • Type checking — `<expr> est <type>` tests a मान's runtime variant tag without extraction.
#   • Null checking — `<expr> est null` tests the null type (the null value is `null`).
#   • Negation — `<expr> नहीं est <type>` negates the type check.
#   • Chaining — `है` composes with `et` and parenthesized expressions.
#
# Common mistakes:
#   • Using `है` to compare values — its right-hand side is always a type; use `≡` (or `≠`) for value comparison: `<expr> ≡ सत्य`, `<expr> ≡ असत्य`.
#
# See also: नहीं est, ≡
# =============================================================================


# est — type and null checks
#
# <expr> est null       — null-type check (lowers to is_nil)
# <expr> est <type>      — variant tag check (lowers to matches!)
# <expr> नहीं est <type>  — negated variant tag check
#
# Value comparison is the equality family's job:
# <expr> ≡ सत्य         — exact true comparison
# <expr> ≡ असत्य        — exact false comparison
#
# GRAMMAR:
#   typeCheckExpr :← expr 'est' type
#
# EXPECTED OUTPUT:
#   est.expected

fn explora(any x) → string {
    if x is none then return "nihil est"
    return "aliud est"
}

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

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

    # Boolean true comparison with ≡
    const _ enabled ← true
    const _ verum_est ← enabled ≡ true
    print verum_est

    # Boolean false comparison with ≡
    const _ disabled ← false
    const _ falsum_est ← disabled ≡ false
    print falsum_est

    # Chained with logical operators
    const string ∪ none नाम ← null
    const _ defectum_debet ← नाम is none and enabled ≡ true
    print defectum_debet

    # Parenthesized for clarity
    const _ utraque_nihil ← forsitan is none and नाम is none
    print utraque_nihil

    # Dynamic अज्ञात dispatch for शून्य_मान and exact boolean checks on तार्किक
    print explora(null)
    print explora_bivalens(true)
    print explora(42)

    # --- Variant checks against concrete types ---
    #
    # `est <type>` tests a मान's runtime variant tag directly, without
    # attempting extraction. The inner type parameters of सूची/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 quantitas ← 42 ↦ value
    const value notae ← ["a", "b"] ↦ value
    const value active ← true ↦ value
    const value proportio ← 1.5 ↦ value
    assert name is string
    assert quantitas is int
    assert notae is list<value>
    assert active is bool
    assert proportio is float
    assert quantitas not is string
    assert name not is int
}

Expected output:

verum
verum
verum
verum
verum
nihil est
verum est
aliud est