diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-10-01 06:58:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-10-01 06:58:23 -0700 |
commit | ca0ca229837e344df05bfa79333b1ed4993f9719 (patch) | |
tree | af070c8742122f7be39972d7c660813c92985b8d | |
parent | 6e3ee573178e8860bb79f68153bfa7ed7ac949c7 (diff) | |
download | txr-ca0ca229837e344df05bfa79333b1ed4993f9719.tar.gz txr-ca0ca229837e344df05bfa79333b1ed4993f9719.tar.bz2 txr-ca0ca229837e344df05bfa79333b1ed4993f9719.zip |
Allow super to take an instance as an argument.
* struct.c (super): Detect structure instance
and resolve it to its type. Recursion eliminated in favor of
imperative approach that eliminates redundant checks.
* txr.1: Description of super updated.
-rw-r--r-- | struct.c | 8 | ||||
-rw-r--r-- | txr.1 | 5 |
2 files changed, 9 insertions, 4 deletions
@@ -263,8 +263,12 @@ val super(val type) val stype = find_struct_type(type); if (!stype) no_such_struct(lit("super"), type); - return super(stype); - } else { + type = stype; + } else if (structp(type)) { + type = struct_type(type); + } + + { struct struct_type *st = coerce(struct struct_type *, cobj_handle(type, struct_type_s)); return st->super; @@ -18388,8 +18388,9 @@ has no supertype. The .meta type -must be either a struct type object, or else -a symbol which names a struct type. +argument must be either a struct type object, a +a symbol which names a struct type (which is resolved to that type), +or else a structure instance (which is resolved to its structure type). .coNP Function @ make-struct .synb |