Skip to content

Decorators as Inert Data

Field decorators like @column("...") are not executed at runtime — they are stored as inert data in the type descriptor and readable through typeinfo(T).fields[i].decorators. A comptime loop can use them to map struct fields to database column names, forming the seed of a compile-time ORM.

Read the first @column decorator argument from an Account field via typeinfo in a comptime block, yielding the mapped column name "account_id".

03-decorators-orm.zolo
Playground
// Feature: field decorators are surfaced as inert data through `typeinfo`,

// so a comptime routine can map fields to DB columns (an ORM seed).


struct Account {
  @column("account_id")
  id: int,
  @column("display_name")
  name: str,
}

let col0 = comptime { typeinfo(Account).fields[0].decorators[0].args[0] }
print(col0)
// expected: account_id

enespt-br