Nim
Overriding the built-in and:
proc `and`(x, y: bool): bool = false let a = true b = true if a: echo("a is true") if b: echo("b is true") if a and b: echo("a and b is true") Using a term-rewriting template:
template xand{`and`(x, y)}(x, y: bool): bool = false let a = true b = true if a: echo("a is true") if b: echo("b is true") if a and b: echo("a and b is true") Using a custom type:
type XandBool = enum xFalse xTrue converter toBool(x: XandBool): bool = case x of xFalse: false of xTrue: true proc `and`(x, y: XandBool): XandBool = xFalse let a = xTrue b = xTrue if a: echo("a is true") if b: echo("b is true") if a and b: echo("a and b is true")