Renderingen-US

Bindings

Binding a name to a value. is the bind glyph: the value on the right goes into the name on the left.

Constant or variable#

const binds once. var binds a name you intend to change.

reader locale
faber format --locale en — English reader surface
main {
    const int limit  10
    var int count  0
    count  count + 1
    print limit, count
}
faber format --locale la — canonical Faber
incipit {
    fixum numerus limit  10
    varia numerus count  0
    count  count + 1
    nota limit, count
}
faber format --locale th-TH — Thai
เริ่ม {
    คงที่ จำนวน limit  10
    แปร จำนวน count  0
    count  count + 1
    บันทึก limit, count
}
faber format --locale zh-Hans — Simplified Chinese
入口 {
    常量 整数 limit  10
    变量 整数 count  0
    count  count + 1
    显示 limit, count
}
faber format --locale zh-Hant — Traditional Chinese
入口 {
    定值 整數 limit  10
    變值 整數 count  0
    count  count + 1
    註記 limit, count
}
faber format --locale vi — Vietnamese
bắt_đầu {
    hằng số limit  10
    biến số count  0
    count  count + 1
    ghi_chú limit, count
}
faber format --locale ar — Arabic
بداية {
    ثابت عدد limit  10
    متغير عدد count  0
    count  count + 1
    اعرض limit, count
}
faber format --locale hi — Hindi
आरंभ {
    स्थिर संख्या limit  10
    चर संख्या count  0
    count  count + 1
    दिखाओ limit, count
}

Reassigning a const is a compile error, not a convention. Reach for const first and widen to var only where the value genuinely moves.

Type holes#

_ is a type hole: the compiler infers one concrete type for the binding.

reader locale
faber format --locale en — English reader surface
main {
    const string nomen  "Marcus"
    const list<int> numeri  [1, 2, 3]
    print nomen, numeri
}
faber format --locale la — canonical Faber
incipit {
    fixum textus nomen  "Marcus"
    fixum lista<numerus> numeri  [1, 2, 3]
    nota nomen, numeri
}
faber format --locale th-TH — Thai
เริ่ม {
    คงที่ ข้อความ nomen  "Marcus"
    คงที่ รายการ<จำนวน> numeri  [1, 2, 3]
    บันทึก nomen, numeri
}
faber format --locale zh-Hans — Simplified Chinese
入口 {
    常量 文本 nomen  "Marcus"
    常量 列表<整数> numeri  [1, 2, 3]
    显示 nomen, numeri
}
faber format --locale zh-Hant — Traditional Chinese
入口 {
    定值 文字 nomen  "Marcus"
    定值 列表<整數> numeri  [1, 2, 3]
    註記 nomen, numeri
}
faber format --locale vi — Vietnamese
bắt_đầu {
    hằng văn_bản nomen  "Marcus"
    hằng danh_sách<số> numeri  [1, 2, 3]
    ghi_chú nomen, numeri
}
faber format --locale ar — Arabic
بداية {
    ثابت نص nomen  "Marcus"
    ثابت قائمة<عدد> numeri  [1, 2, 3]
    اعرض nomen, numeri
}
faber format --locale hi — Hindi
आरंभ {
    स्थिर पाठ nomen  "Marcus"
    स्थिर सूची<संख्या> numeri  [1, 2, 3]
    दिखाओ nomen, numeri
}

The hole infers a type; it does not make the binding dynamic. nomen is string from this point on.

Union holes#

in type position is a union hole — the binding admits a finite set of types rather than one.

reader locale
faber format --locale en — English reader surface
main {
    const string  int mixed  7
    const list<string  int> both  [1, "two", 3]
    print mixed, both
}
faber format --locale la — canonical Faber
incipit {
    fixum textus  numerus mixed  7
    fixum lista<textus  numerus> both  [1, "two", 3]
    nota mixed, both
}
faber format --locale th-TH — Thai
เริ่ม {
    คงที่ ข้อความ  จำนวน mixed  7
    คงที่ รายการ<ข้อความ  จำนวน> both  [1, "two", 3]
    บันทึก mixed, both
}
faber format --locale zh-Hans — Simplified Chinese
入口 {
    常量 文本  整数 mixed  7
    常量 列表<文本  整数> both  [1, "two", 3]
    显示 mixed, both
}
faber format --locale zh-Hant — Traditional Chinese
入口 {
    定值 文字  整數 mixed  7
    定值 列表<文字  整數> both  [1, "two", 3]
    註記 mixed, both
}
faber format --locale vi — Vietnamese
bắt_đầu {
    hằng văn_bản  số mixed  7
    hằng danh_sách<văn_bản  số> both  [1, "two", 3]
    ghi_chú mixed, both
}
faber format --locale ar — Arabic
بداية {
    ثابت نص  عدد mixed  7
    ثابت قائمة<نص  عدد> both  [1, "two", 3]
    اعرض mixed, both
}
faber format --locale hi — Hindi
आरंभ {
    स्थिर पाठ  संख्या mixed  7
    स्थिर सूची<पाठ  संख्या> both  [1, "two", 3]
    दिखाओ mixed, both
}

Read a union out with match, which forces every arm to be handled.

Optional values#

T ∪ nihil is the optional shape. It is an ordinary union whose other member is nothing — Faber has no separate nullable syntax.

reader locale
faber format --locale en — English reader surface
fn primum(list<int> res)  int  null {
    if res.longitudo()  0 then return null
    return res[0]
}

main {
    print primum([1, 2, 3])
}
faber format --locale la — canonical Faber
functio primum(lista<numerus> res)  numerus  nihil {
    si res.longitudo()  0 ergo redde nihil
    redde res[0]
}

incipit {
    nota primum([1, 2, 3])
}
faber format --locale th-TH — Thai
ฟังก์ชัน primum(รายการ<จำนวน> res)  จำนวน  ว่าง {
    ถ้า res.longitudo()  0 ดังนั้น คืน ว่าง
    คืน res[0]
}

เริ่ม {
    บันทึก primum([1, 2, 3])
}
faber format --locale zh-Hans — Simplified Chinese
函数 primum(列表<整数> res)  整数   {
    如果 res.longitudo()  0  返回 
    返回 res[0]
}

入口 {
    显示 primum([1, 2, 3])
}
faber format --locale zh-Hant — Traditional Chinese
函式 primum(列表<整數> res)  整數   {
     res.longitudo()  0  傳回 
    傳回 res[0]
}

入口 {
    註記 primum([1, 2, 3])
}
faber format --locale vi — Vietnamese
hàm primum(danh_sách<số> res)  số  rỗng {
    nếu res.longitudo()  0 do_đó trả rỗng
    trả res[0]
}

bắt_đầu {
    ghi_chú primum([1, 2, 3])
}
faber format --locale ar — Arabic
دالة primum(قائمة<عدد> res)  عدد  لاشيء {
    إذا res.longitudo()  0 إذن أعد لاشيء
    أعد res[0]
}

بداية {
    اعرض primum([1, 2, 3])
}
faber format --locale hi — Hindi
फलन primum(सूची<संख्या> res)  संख्या  शून्य {
    यदि res.longitudo()  0 अतः लौटाओ शून्य
    लौटाओ res[0]
}

आरंभ {
    दिखाओ primum([1, 2, 3])
}

Destructuring#

from pulls named fields out of a record in one statement.

reader locale
faber format --locale en — English reader surface
class Punctum {
    int x
    int y
}

main {
    const Punctum p  Punctum {x = 1, y = 2}
    const int x  p.x
    const int y  p.y
    print x, y
}
faber format --locale la — canonical Faber
genus Punctum {
    numerus x
    numerus y
}

incipit {
    fixum Punctum p  Punctum {x = 1, y = 2}
    fixum numerus x  p.x
    fixum numerus y  p.y
    nota x, y
}
faber format --locale th-TH — Thai
ชนิด Punctum {
    จำนวน x
    จำนวน y
}

เริ่ม {
    คงที่ Punctum p  Punctum {x = 1, y = 2}
    คงที่ จำนวน x  p.x
    คงที่ จำนวน y  p.y
    บันทึก x, y
}
faber format --locale zh-Hans — Simplified Chinese
 Punctum {
    整数 x
    整数 y
}

入口 {
    常量 Punctum p  Punctum {x = 1, y = 2}
    常量 整数 x  p.x
    常量 整数 y  p.y
    显示 x, y
}
faber format --locale zh-Hant — Traditional Chinese
類型 Punctum {
    整數 x
    整數 y
}

入口 {
    定值 Punctum p  Punctum {x = 1, y = 2}
    定值 整數 x  p.x
    定值 整數 y  p.y
    註記 x, y
}
faber format --locale vi — Vietnamese
kiểu Punctum {
    số x
    số y
}

bắt_đầu {
    hằng Punctum p  Punctum {x = 1, y = 2}
    hằng số x  p.x
    hằng số y  p.y
    ghi_chú x, y
}
faber format --locale ar — Arabic
صنف Punctum {
    عدد x
    عدد y
}

بداية {
    ثابت Punctum p  Punctum {x = 1, y = 2}
    ثابت عدد x  p.x
    ثابت عدد y  p.y
    اعرض x, y
}
faber format --locale hi — Hindi
वर्ग Punctum {
    संख्या x
    संख्या y
}

आरंभ {
    स्थिर Punctum p  Punctum {x = 1, y = 2}
    स्थिर संख्या x  p.x
    स्थिर संख्या y  p.y
    दिखाओ x, y
}

Records are built with named fields in braces, not positional arguments — so adding a field never silently reorders an existing call site.

Related: Types and widths · Control flow