@@ -103,6 +103,102 @@ BexProgramSource source = BexProgramSource.withDefinition(
103103);
104104` ` `
105105
106+ # # Function Arguments And Blue Patterns
107+
108+ BEX function arguments may declare Blue type or shape patterns. BEX does not
109+ have a separate type enum or type system; declared argument patterns are Blue
110+ nodes and runtime values are checked with Blue's node/type matcher.
111+
112+ ` ` ` yaml
113+ functions:
114+ capture:
115+ args:
116+ amount:
117+ type: Integer
118+ hotelOrder:
119+ blueId: HotelOrderBlueId
120+ request:
121+ customerName:
122+ type: Text
123+ schema:
124+ required: true
125+ nights:
126+ type: Integer
127+ schema:
128+ required: true
129+ expr:
130+ amount:
131+ $var: amount
132+ order:
133+ $var: hotelOrder
134+ ` ` `
135+
136+ All declared function arguments are required by the function call ABI for now.
137+ Unknown functions, extra argument names, and missing declared arguments fail at
138+ compile time. Typed arguments are checked after their call expressions are
139+ evaluated; a runtime mismatch throws `BexException`.
140+
141+ Text `"400"` does not match the Blue `Integer` pattern. Use an explicit
142+ conversion when conversion is intended :
143+
144+ ` ` ` yaml
145+ $call:
146+ function: capture
147+ args:
148+ amount:
149+ $integer:
150+ $event: /message/request/amount
151+ ` ` `
152+
153+ Untyped required arguments remain supported by declaring an empty pattern :
154+
155+ ` ` ` yaml
156+ args:
157+ input: {}
158+ ` ` `
159+
160+ When BEX converts computed values back to Blue nodes for `$is`, function
161+ argument checks, or output conversion, Blue language keys keep their Blue
162+ meaning. For example, this computed value is a node with a `type` field and a
163+ `status` property, not an object with an ordinary property named `type` :
164+
165+ ` ` ` yaml
166+ type:
167+ blueId: HotelOrderType
168+ status: confirmed
169+ ` ` `
170+
171+ A bare `blueId` object is a Blue reference pattern :
172+
173+ ` ` ` yaml
174+ blueId: HotelOrderType
175+ ` ` `
176+
177+ Do not combine `blueId` with sibling fields to describe a typed instance. Use
178+ `type : { blueId: ... }` for typed values.
179+
180+ BEX programs are Blue documents, so BEX syntax must use valid Blue authoring
181+ forms. For user-defined name containers such as `functions`, `constants`,
182+ ` args` , and `$call.args`, do not use Blue language keys as names. This includes
183+ ` value` , `items`, `blueId`, `type`, `schema`, `name`, `description`,
184+ ` itemType` , `keyType`, `valueType`, `mergePolicy`, `constraints`, `contracts`,
185+ ` properties` , `$previous`, and `$pos`.
186+
187+ For operator bodies, payload/reference/control keys such as `value`, `items`,
188+ ` blueId` , `properties`, `$previous`, and `$pos` cannot be used as ordinary
189+ multi-field operands. Use BEX operand names such as `node`, `list`, `input`,
190+ ` pattern` , `object`, `key`, `path`, `val`, `cond`, `then`, and `else`.
191+
192+ Metadata keys such as `name`, `description`, `type`, `schema`, `itemType`,
193+ ` keyType` , and `valueType` are legal Blue language fields, but they are not
194+ ordinary object properties. An operator may use one of them only when the BEX
195+ compiler explicitly supports that field.
196+
197+ Function argument patterns and `$is.pattern` are static Blue patterns. BEX does
198+ not evaluate expressions inside those patterns, and it does not emulate Blue
199+ authoring sugar such as inline `type : Integer` preprocessing for computed type
200+ fields.
201+
106202# # Document Views
107203
108204` BexDocumentView` owns document pointer resolution, canonical reads, resolved
@@ -188,13 +284,24 @@ BEX operators are Blue objects whose single key starts with `$`.
188284| Operator | Purpose |
189285|---|---|
190286| `$unwrap` | Unwrap Blue scalar wrapper values. |
287+ | `$is` | Return whether a value matches a Blue pattern. |
191288| `$text` | Convert to text. |
192289| `$integer` | Convert to exact integer. |
193290| `$number` | Convert to exact decimal/number. |
194291| `$boolean` | Convert to boolean. |
195292| `$object` | Require an object, or default undefined to an empty object. |
196293| `$list` | Require a list, or default undefined to an empty list. |
197294
295+ `$is.pattern` is static Blue pattern data, not a BEX expression :
296+
297+ ` ` ` yaml
298+ $is:
299+ node:
300+ $event: /message/request/amount
301+ pattern:
302+ type: Integer
303+ ` ` `
304+
198305# ## Strings
199306
200307| Operator | Purpose |
@@ -205,6 +312,14 @@ BEX operators are Blue objects whose single key starts with `$`.
205312| `$startsWith` | Check a prefix. |
206313| `$sliceAfter` | Return text after a prefix. |
207314
315+ ` ` ` yaml
316+ $join:
317+ list:
318+ - a
319+ - b
320+ separator: ":"
321+ ` ` `
322+
208323# ## Logic And Comparison
209324
210325| Operator | Purpose |
@@ -254,6 +369,10 @@ BEX operators are Blue objects whose single key starts with `$`.
254369| `$call` | Call a local function. |
255370| `$literal` | Return payload without compiling nested operators. |
256371
372+ ` $literal` prevents normal expression compilation, but BEX still rejects
373+ BEX-looking operators inside Blue type-definition fields such as `type`,
374+ ` itemType` , `keyType`, `valueType`, `blue`, and `schema`.
375+
257376# # Statement Operators
258377
259378| Statement | Purpose |
0 commit comments