From a2b0e0813bc2b322f0ba77d0361172b78d0e4c72 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Thu, 7 Apr 2022 23:56:03 -0400 Subject: [PATCH] Have `?` fall back to stringObj. Note that ->forward is not used once an Object is in the environment. --- src/env.c | 8 ++++++++ src/object.h | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/env.c b/src/env.c index a74d1e4..5265d65 100644 --- a/src/env.c +++ b/src/env.c @@ -410,6 +410,14 @@ Object help(Object* params, int length, struct Environment* env) return text; } } + Object* object = fetch(symbol, env); + if (object) { + size_t len; + char* string = stringObj(object, &len); + Object text = stringFromSlice(string, len); + free(string); + return text; + } return nullTerminated("Help not found!"); } diff --git a/src/object.h b/src/object.h index 83e615d..5a2ce86 100644 --- a/src/object.h +++ b/src/object.h @@ -106,7 +106,10 @@ struct Object { #endif }; - Object* forward; + union { + Object* forward; + char* docString; + }; }; struct StructDef {