{"id":"language--boolean-logic","name":"Boolean logic and short-circuiting","owner":"yeho","package":"language","kind":"language","signature":"!condition\nleft and right\nleft or right","description":"Use !, and, and or with bool values. and and or short-circuit, so the right side runs only when needed.","context":"Put cheap or safety-critical guards first so later expressions run only inside their valid domain.","parameters":[],"returns":"","members":[],"tags":["!","and","complete-program","cpu","false","language","logic","or","true","yeho"],"updated":"2026-09-09","source":{"repository":"yeho","path":"parser_expressions.cpp parseOr/parseAnd/parseUnary; conformance control.boolean-conditions"},"status":"stable","notes":["The canonical unary spelling is !, not the editor grammar's historical not token.","There are no truthy or falsy conversions."],"examples":[{"id":"complete","title":"Short circuit","description":"Put cheap or safety-critical guards first so later expressions run only inside their valid domain.","code":"list of int empty = []\nbool andResult = false and empty[0] == 1\nbool orResult = true or empty[0] == 1\n\nif !andResult and orResult\n{\n    Console.Log(\"short-circuit-ok\")\n}\nelse\n{\n    Console.Log(\"short-circuit-bad\")\n}\n","manifest":"package = \"tests.compiler.fastContract.shortCircuit\"\n","tags":["cpu","complete-program"],"verification":"type checked","run":"cpu-oracle","source":"tests/compiler/fast-contract/short-circuit/start.yh","sha256":"fd46f569be08898386e811ba9a008674510a5ee0fc950ea0c2b74cc2c94ba004","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=language--boolean-logic","json":"https://demonhunterlabs.com/reference/items/language--boolean-logic.json","markdown":"https://demonhunterlabs.com/reference/text/language--boolean-logic.md"}
