Skip to content

truthiness

Pannous edited this page Sep 18, 2021 · 5 revisions

Truthiness in angle

Angle stays close to python truthiness:

Falsey values are:

''==false
0==false
0.0==false
nil==false
()==false
{}==false
[]==false
x==false  // if x in unbound/unset reference
{x}==false  // if x in unbound/unset reference
otherwise created empty objects == false e.g.
b'' - an empty bytes
set() - an empty set
cat{} == false  // empty objects are falsey even if they are of known type
    objects for which
        obj.bool() returns False
        obj.len() returns 0

Pretty much everything else is truthy, including

{x:1}
[1]

Todo:

{x:0}
[0]

A "truthy" value will satisfy the check performed by if or while statements. We use "truthy" and "falsy" to differentiate from the bool values True and False.

This allows general natural usage of logic for ternary conditional operators: a and b or c is similar to if a then b else c or/else ARE NOT IDENTICAL: if 1 then 0 else 2 == 0 1 and 0 or 2 == 2 !!!

If statements could thus be realized without any special internal logic. Only because we want to capture all different ways of writing if expression is some special handling necessary. Search testIf function to see all variants.

Home

Philosophy

data & code blocks

features

inventions

evaluation

keywords

iteration

tasks

examples

todo : bad ideas and open questions

⚠️ specification and progress are out of sync

Clone this wiki locally