diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-10-01 06:47:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-10-01 06:47:21 -0700 |
commit | 6e3ee573178e8860bb79f68153bfa7ed7ac949c7 (patch) | |
tree | e38006b4b8269ac947bf04be46a9c56b1ca2bf2b /struct.c | |
parent | 4f2f121684a68f0bd43c113d5b07436430692601 (diff) | |
download | txr-6e3ee573178e8860bb79f68153bfa7ed7ac949c7.tar.gz txr-6e3ee573178e8860bb79f68153bfa7ed7ac949c7.tar.bz2 txr-6e3ee573178e8860bb79f68153bfa7ed7ac949c7.zip |
New super-method function.
* struct.c (struct_init): Register super-method.
(super_method): New function.
* struct.h (super_method): Declared.
* txr.1: Documented.
Diffstat (limited to 'struct.c')
-rw-r--r-- | struct.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -125,6 +125,7 @@ void struct_init(void) reg_fun(intern(lit("structp"), user_package), func_n1(structp)); reg_fun(intern(lit("struct-type"), user_package), func_n1(struct_type)); reg_fun(intern(lit("method"), user_package), func_n2(method)); + reg_fun(intern(lit("super-method"), user_package), func_n2(super_method)); } static noreturn void no_such_struct(val ctx, val sym) @@ -679,6 +680,12 @@ val method(val strct, val slotsym) return func_f0v(cons(slot(strct, slotsym), strct), method_fun); } +val super_method(val strct, val slotsym) +{ + val super_slot = static_slot(super(struct_type(strct)), slotsym); + return func_f0v(cons(super_slot, strct), method_fun); +} + static void struct_inst_print(val obj, val out, val pretty) { struct struct_inst *si = coerce(struct struct_inst *, obj->co.handle); |