Skip to content

Value

A value is an expression, in the context of a statement, that provides a value to that statement. Values, statements and conditions work together to express business logic at an appropriate level of abstraction — detailed enough to be meaningful, but not so specific as to constrain implementation.

RIDDL 2.0 replaced what had been a mostly-opaque quoted string with a real value-expression system. A literal string is still accepted everywhere, so pseudo-code remains available where structure would be false precision.

The Seven Forms

Form Syntax Meaning
Literal "some text" Opaque pseudo-code, or a literal constant
Value reference order.total A field, state field, function input, or let local
Constructor OrderPlaced(id, total = x) Builds a message or record
Get get from input SignupForm Reads a UI input or an entity state
Call call function Pricing.Total(a, b) Invokes a pure function for its result
Prompt prompt("compute the discount") A value computed by AI at generation time
Boolean a > b and not c A structured boolean expression

Value References

A value reference names something in scope. Four sources are consulted, in order:

  1. the on clause's message binding — bare ord is the whole message, ord.field reaches into it
  2. a field of the handled message, the entity state, or a function's requires input
  3. a definition reached by a qualified path, such as GState.active
  4. a named constant

A let local is also a value reference, but resolves lexically rather than through the symbol table: it is visible only after its declaration and is shadowed inside nested blocks.

Constructors

A constructor builds a message or record inline, rather than requiring it be assembled elsewhere first:

yield event OrderPlaced(orderId, total = cart.total, currency = "USD")
morph entity Order to state Done with record DoneData(note = "fulfilled")

Arguments are positional first, then named. Count, names, ordering and (best effort) types are all checked against the target's fields.

Get

get from reads a value from a UI input or an entity state:

let email   = get from input SignupForm
let current = get from state Active

Call

call invokes a function — and only a function, since functions are the only definitions guaranteed pure — and produces its result:

let total = call function Pricing.CalculateTotal(subtotal, taxRate = rate)

A call is value-producing rather than a bare statement, so it composes with let, set, return and constructor arguments. Calling something that declares no returns is an Error.

Prompt

prompt("...") denotes a value computed by AI at generation time:

set field recommendation to prompt("suggest a complementary product")

It is distinguished from the do statement by its parentheses. The statement describes an action for a human to implement; the value denotes something AI computes.

Boolean Expressions

Precedence runs or < and < not < comparison < atom, with parentheses to group:

when order.isPaid and not (order.isCancelled or order.isRefunded) then ??? end

and, or, not, true and false are context-sensitive: they are recognized only inside a boolean expression, so they remain legal identifiers everywhere else in the language.

Comparisons are type-safe and reference-only

Both operands of a comparison must be a typed reference — a value reference, a get from, or a named constant — never a literal. This is enforced at parse time, so count > 5, count > "5", count > true and count > R(1) all fail to parse.

To compare against a fixed value, name it. The constant is a definition, declared alongside the other definitions of its context:

constant MaxItems is Natural = "100"

and the comparison is a statement, written inside an on-clause:

when cart.itemCount > MaxItems then error "too many items" end

The point is to remove magic constants from models and to make every comparison check the types on both sides. == and != require operands of the same category; <, >, <= and >= require an ordered numeric type on both sides.

true and false remain valid boolean atoms — usable with and, or, not, and standalone — just not as comparison operands.

Where Values Are Used

Statement Operand
set the assigned value
let the bound expression
put the published value
return the returned value
send, tell, yield a message reference or constructor
morph a record reference or constructor
when, require, invariant a condition
match the subject, and each comparison pattern's comparand

Occurs In

Contains

Values may contain other values — a constructor's arguments, a call's arguments, and a boolean expression's operands are all themselves values.