jbee / panda

A early draft for a template rendering notation defined inside the template itself.
1 stars 0 forks source link

Nothing in a Boolean-Context #7

Open jbee opened 13 years ago

jbee commented 13 years ago

Nothing should always evaluate to false to not accidentally render a block just because a not existing reference has been made by mistake. That means not Nothing has to be still false not true in a boolean context like a case.

There is a special function to explicitly check for nothing that evaluates to true like: notexists <expr>.

Is it helpful to introduce a NothingNature sothat function can check this special case ?

jbee commented 13 years ago

Solution: A special function exists can change from nothing to false. The expression not exists x will evaluate to true when x is nothing. In addition the not operator will care about nothing and not evaluate not nothing to true. It stays nothing.

Through this no boolean expression should evaluate to an unexpected result. More complex expressions with & and | are not affected by the problem because nothing and not nothing will act like false when combined whereby the expression is not fulfilled accidentally. It will evaluate to false if nothing is one argument of &. The expression nothing | x is equal to x.

To allow not and exists to check for nothing they are defined by the same Functorizer that will know how to check it internally.