是
Tests whether a value's runtime type is a given type.
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.
Tests whether a value's runtime type is a given type.
Syntax: <expression> est <type>
Category#
logic
Related#
- non est
- ≡
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