Commit 09cc3847be6e1ffc153fccf253d934d41019c8b6

Thomas de Grivel 2023-02-11T12:54:23

env_eval_ident

diff --git a/libc3/env.c b/libc3/env.c
index 3a783c7..493778d 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -312,7 +312,7 @@ bool env_eval_equal_tuple (s_env *env, const s_tuple *a,
   return true;
 }
 
-const s_tag * env_eval_ident (s_env *env, const s_ident *ident)
+s_tag * env_eval_ident (s_env *env, const s_ident *ident, s_tag *dest)
 {
   const s_tag *tag;
   assert(env);
@@ -321,7 +321,7 @@ const s_tag * env_eval_ident (s_env *env, const s_ident *ident)
     assert(! "env_eval_ident: unbound variable");
     errx(1, "env_eval_ident: unbound variable");
   }
-  return tag;
+  return tag_copy(tag, dest);
 }
 
 s_tag * env_eval_progn (s_env *env, const s_list *program, s_tag *dest)
@@ -353,7 +353,7 @@ s_tag * env_eval_tag (s_env *env, const s_tag *tag, s_tag *dest)
   case TAG_CALL_MACRO:
     return env_eval_call_macro(env, &tag->data.call, dest);
   case TAG_IDENT:
-    return tag_copy(env_eval_ident(env, &tag->data.ident), dest);
+    return env_eval_ident(env, &tag->data.ident, dest);
   case TAG_BOOL:
   case TAG_CHARACTER:
   case TAG_F32:
diff --git a/libc3/env.h b/libc3/env.h
index aa368b0..b4420da 100644
--- a/libc3/env.h
+++ b/libc3/env.h
@@ -23,23 +23,24 @@ void    env_clean (s_env *env);
 s_env * env_init (s_env *env);
 
 /* modifiers */
-s_tag *       env_eval_call_fn (s_env *env, const s_call *call,
+s_tag *    env_eval_call_fn (s_env *env, const s_call *call,
+                             s_tag *dest);
+s_tag *    env_eval_call_macro (s_env *env, const s_call *call,
                                 s_tag *dest);
-s_tag *       env_eval_call_macro (s_env *env, const s_call *call,
-                                   s_tag *dest);
-bool          env_eval_equal_list (s_env *env, const s_list *a,
-                                   const s_list *b, s_list **dest);
-bool          env_eval_equal_tag (s_env *env, const s_tag *a,
-                                  const s_tag *b, s_tag *dest);
-bool          env_eval_equal_tuple (s_env *env, const s_tuple *a,
-                                    const s_tuple *b, s_tuple *dest);
-s_tag *       env_eval_fn (s_env *env, const s_fn *fn, s_tag *dest);
-const s_tag * env_eval_ident (s_env *env, const s_ident *ident);
-s_tag *       env_eval_progn (s_env *env, const s_list *program,
-                              s_tag *dest);
-s_tag *       env_eval_tag (s_env *env, const s_tag *tag, s_tag *dest);
-s_module *    env_module_load (s_env *env, s_module *module,
-                               const s_sym *name, s_facts *facts);
+bool       env_eval_equal_list (s_env *env, const s_list *a,
+                                const s_list *b, s_list **dest);
+bool       env_eval_equal_tag (s_env *env, const s_tag *a,
+                               const s_tag *b, s_tag *dest);
+bool       env_eval_equal_tuple (s_env *env, const s_tuple *a,
+                                 const s_tuple *b, s_tuple *dest);
+s_tag *    env_eval_fn (s_env *env, const s_fn *fn, s_tag *dest);
+s_tag *    env_eval_ident (s_env *env, const s_ident *ident,
+                           s_tag *dest);
+s_tag *    env_eval_progn (s_env *env, const s_list *program,
+                           s_tag *dest);
+s_tag *    env_eval_tag (s_env *env, const s_tag *tag, s_tag *dest);
+s_module * env_module_load (s_env *env, s_module *module,
+                            const s_sym *name, s_facts *facts);
 
 /* control structures */
 void env_error_f (s_env *env, const char *fmt, ...);