From c39c6e6b72c750180dd13c38db8c69a609dbf574 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 28 Oct 2015 06:08:23 -0700 Subject: Add obtain/yield macros interface to continuations. * lisplib.c (yield_set_entries, yield_instantiate): New static functions. (dlt_register): Registered new functions. * share/txr/stdlib/yield.tl: New file. * txr.1: Documented obtain, yield-from, obtain-block and yield. --- lisplib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lisplib.c') diff --git a/lisplib.c b/lisplib.c index 09e0386f..d4d71724 100644 --- a/lisplib.c +++ b/lisplib.c @@ -256,7 +256,22 @@ static val type_instantiate(val set_fun) return nil; } +static val yield_set_entries(val dlt, val fun) +{ + val name[] = { + lit("obtain"), lit("obtain-block"), lit("yield-from"), lit("yield"), + nil + }; + set_dlt_entries(dlt, name, fun); + return nil; +} +static val yield_instantiate(val set_fun) +{ + funcall1(set_fun, nil); + load(format(nil, lit("~a/yield.tl"), stdlib_path, nao)); + return nil; +} val dlt_register(val dlt, val (*instantiate)(val), @@ -280,6 +295,7 @@ void lisplib_init(void) dlt_register(dl_table, hash_instantiate, hash_set_entries); dlt_register(dl_table, except_instantiate, except_set_entries); dlt_register(dl_table, type_instantiate, type_set_entries); + dlt_register(dl_table, yield_instantiate, yield_set_entries); } val lisplib_try_load(val sym) -- cgit v1.2.3