42 lines
981 B
Markdown
42 lines
981 B
Markdown
# Logical and Comparison Expressions
|
|
|
|
Decodal supports boolean logic over concrete `Bool` values and comparison over concrete scalar values.
|
|
|
|
```dcdl
|
|
{
|
|
is_prod = env == "prod";
|
|
high_port = port > 9000;
|
|
enabled = is_prod && high_port;
|
|
disabled = !enabled;
|
|
}
|
|
```
|
|
|
|
## Logical operators
|
|
|
|
- `!expr` negates a concrete `Bool`.
|
|
- `lhs && rhs` returns boolean AND.
|
|
- `lhs || rhs` returns boolean OR.
|
|
|
|
`&&` and `||` short-circuit: the right-hand side is evaluated only when needed.
|
|
Logical operands must evaluate to concrete `Bool` values.
|
|
|
|
## Comparison operators
|
|
|
|
- `==`
|
|
- `!=`
|
|
- `<`
|
|
- `<=`
|
|
- `>`
|
|
- `>=`
|
|
|
|
`==` and `!=` compare concrete scalar values: `String`, `Bool`, `Int`, and `Float`.
|
|
`Int` and `Float` can be compared to each other numerically.
|
|
|
|
Ordering operators `<`, `<=`, `>`, and `>=` compare concrete numeric values only.
|
|
They are separate from prefix comparison constraints such as `> 443`.
|
|
|
|
```dcdl
|
|
port = Int & > 443 default 9443;
|
|
is_high = port > 9000;
|
|
```
|