diff options
| author | LLLL Colonq <llll@colonq> | 2025-09-24 17:18:54 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-09-24 17:18:54 -0400 |
| commit | d5bb1abc0e3b945e01e1fbb5991537ad33de83c0 (patch) | |
| tree | d2039d9cdd5f7b1e08297ccdd989a9e5db36f9ec /src/runtime.h | |
| parent | f5dd8de68e70d6948005aa8bdcde1a9c80a6c0ea (diff) | |
Add lambda
Diffstat (limited to 'src/runtime.h')
| -rw-r--r-- | src/runtime.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime.h b/src/runtime.h index 2db4ee8..539c8a9 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -46,12 +46,14 @@ typedef struct { // "heavy" values, the targets of refs PIT_VALUE_HEAVY_SORT_CONS=0, PIT_VALUE_HEAVY_SORT_ARRAY, PIT_VALUE_HEAVY_SORT_BYTES, + PIT_VALUE_HEAVY_SORT_FUNC, PIT_VALUE_HEAVY_SORT_NATIVEFUNC, } hsort; union { struct { pit_value car, cdr; } cons; struct { pit_value *data; i64 len; } array; struct { u8 *data; i64 len; } bytes; + struct { pit_value env; pit_value args; pit_value body; } func; pit_nativefunc nativefunc; }; } pit_value_heavy; @@ -73,7 +75,7 @@ typedef struct { } sort; union { pit_value literal; - struct { i64 arity; pit_value func; } apply; + i64 apply; // arity of application pit_value bind; // symbol to bind pit_value unbind; // symbol to unbind }; @@ -161,12 +163,18 @@ pit_value pit_cons(pit_runtime *rt, pit_value car, pit_value cdr); pit_value pit_list(pit_runtime *rt, i64 num, ...); pit_value pit_car(pit_runtime *rt, pit_value v); pit_value pit_cdr(pit_runtime *rt, pit_value v); +pit_value pit_append(pit_runtime *rt, pit_value xs, pit_value ys); +pit_value pit_reverse(pit_runtime *rt, pit_value xs); +pit_value pit_contains_eq(pit_runtime *rt, pit_value needle, pit_value haystack); // working with functions +pit_value pit_free_vars(pit_runtime *rt, pit_value args, pit_value body); +pit_value pit_lambda(pit_runtime *rt, pit_value args, pit_value body); pit_value pit_nativefunc_new(pit_runtime *rt, pit_nativefunc f); pit_value pit_apply(pit_runtime *rt, pit_value f, pit_value args); // evaluation! +pit_value pit_expand_macros(pit_runtime *rt, pit_value top); pit_value pit_eval(pit_runtime *rt, pit_value e); #endif |
