File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ str: {
352352 export: :suppress }
353353identity(v): v
354354
355- ` { doc: "`constantly (k)` - return single arg function that always returns k."
355+ ` { doc: "`const (k)` - return single arg function that always returns k."
356356 export: :suppress }
357357const(k, _): k
358358
@@ -415,17 +415,30 @@ with-meta: __WITHMETA
415415 export: :suppress }
416416meta: __META
417417
418+ ` :suppress
419+ assertions: {
420+ # In debug mode maybe the machine checks every return value against
421+ # metadata, but for performance reasons we only check for explicit
422+ # assertions.
423+
424+ ` { doc: "`validator(v)` - find the validator for a value `v` in its metadata" }
425+ validator(v): lookup-or(:assert, const(true), meta(v))
426+
427+ ` { doc: "`check(v)` - panic if value doesn't satisfy its validator" }
428+ check(v): if(v validator(v), v, panic("assertion failed"))
429+ }
430+
418431` { doc: "`e //=> v` - add metadata to assert expression `e` evaluates to `v` and return value of `e`."
419432 export: :suppress
420433 associates: :left
421434 precedence: :meta }
422- (e //=> v): e with-meta({ assert: __EQ(v)})
435+ (e //=> v): e with-meta({ assert: __EQ(v)}) assertions.check
423436
424437` { doc: "`e //=? f` - add metadata to assert expression `e` satisfies function `f` and return value of `e`."
425438 export: :suppress
426439 associates: :left
427440 precedence: :meta }
428- (e //=? f): e with-meta({ assert: f})
441+ (e //=? f): e with-meta({ assert: f}) assertions.check
429442
430443
431444#
You can’t perform that action at this time.
0 commit comments