|
x-engine-c v0.2.13
The C engine for x-lang
|
The raised-error type: a structured error value the language owns. More...
#include "x-type.h"Go to the source code of this file.
Macros | |
| #define | X_TYPE_ERR_NAME "ERR" |
| #define | x_obj_type_iserr(B, X) x_obj_is_type((B), (X), X_TYPE_ERR_NAME) |
| #define | x_err_code(X) x_firstobj((X)) |
| #define | x_err_subject(X) x_restobj((X)) |
Functions | |
| x_obj_t * | x_type_err_register (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_err_struct (x_obj_t *p_base, x_obj_t *p_obj) |
The raised-error type: a structured error value the language owns.
| #define x_err_code | ( | X | ) | x_firstobj((X)) |
An ERR is a PAIR-shaped typed object: (code . obj).
The error's CODE: a static-string atom naming what went wrong.
The string is the C message literal from the raise site ("Unbound SYMBOL", "type: no + for"), repointed in place on each raise – the literals have static storage, so no copy and no allocation is needed to make one reachable from x-lang. The language maps the code to whatever tag vocabulary it likes; the engine does not name tags.
| #define x_err_subject | ( | X | ) | x_restobj((X)) |
The error's SUBJECT: what the raise site was complaining about – the unbound symbol's name, the offending operand – as a static-string atom, repointed in place like the code. Empty string when the raise named no subject.
A STRING and not the object itself, deliberately. Raise sites build their subject on the C STACK (x-type/symbol.c:366 fills a local array and passes its address), and the longjmp out of x_eval_error destroys that frame – so retaining the pointer hands the language a dangling one. What IS stable is the string it points at: an interned symbol's name outlives any frame. The engine has always trusted exactly that much (x_eval_error extracts x_atomstr(p_obj) and keeps nothing else), and this slot is that same trust made reachable instead of flattened into a sentence.
| #define x_obj_type_iserr | ( | B, | |
| X | |||
| ) | x_obj_is_type((B), (X), X_TYPE_ERR_NAME) |
Test whether object X is a raised error on base B.
| #define X_TYPE_ERR_NAME "ERR" |
Type-system symbol name
Register or retrieve the ERR type on the base context.
Register or retrieve the ERR type on the base context.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – Unused |
Build the ERR type descriptor.
Build the ERR type descriptor.
Name only. No make handler: an ERR is not constructed from x-lang – the base owns the single instance and the raise path fills it. No write or display handler either: those stacks are the language's extension point and boot empty on purpose, so an ERR renders as the bounded #<obj:ERR> form until x-lang's err-io.x pushes the prose.
| p_base | x_obj_t* – Base (execution context) |
| p_obj | x_obj_t* – Unused |