x-engine-c v0.2.13
The C engine for x-lang
Loading...
Searching...
No Matches
closure.c File Reference

Syntax - Closure and Operative Creation (fn, op) More...

#include "x-prim.h"
#include "x-eval.h"
#include "x-type/operative.h"
#include "x-type/procedure.h"

Functions

static x_obj_tx_prim_closure (x_obj_t *p_base, x_obj_t *p_args)
 
static x_obj_tx_prim_operative (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_syntax_closure_register (x_obj_t *p_base, x_obj_t *p_args)
 

Detailed Description

Syntax - Closure and Operative Creation (fn, op)

Author
Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

Function Documentation

◆ x_prim_closure()

static x_obj_t * x_prim_closure ( x_obj_t p_base,
x_obj_t p_args 
)
static

Closure creation form. x-lang: (fn params body ...)

Creates a procedure (closure) that captures the current environment and BST index (fexpr – params and body are not evaluated). The resulting closure does NOT have X_OBJ_FLAG_WRAP; only wrap applicatives do.

Parameters
p_baseBase (execution context).
p_argsUnevaluated argument list; expects (caller params body ...).
Returns
A new procedure object.
See also
x_prim_operative
x_mkproc

◆ x_prim_operative()

static x_obj_t * x_prim_operative ( x_obj_t p_base,
x_obj_t p_args 
)
static

Operative creation form. x-lang: (op formals env-param body ...)

Creates a user-level fexpr (operative) that receives unevaluated arguments and an explicit environment parameter (fexpr – formals, env-param, and body are not evaluated).

Parameters
p_baseBase (execution context).
p_argsUnevaluated argument list; expects (caller formals env-param body ...).
Returns
A new operative object.
See also
x_prim_closure
x_mkop

◆ x_syntax_closure_register()

x_obj_t * x_syntax_closure_register ( x_obj_t p_base,
x_obj_t p_args 
)

Register closure and operative syntax primitives.

Binds: fn, op.

Parameters
p_baseBase (execution context).
p_argsUnused.
Returns
p_base.