diff --git a/lib/kc3/0.1/facts.kc3 b/lib/kc3/0.1/facts.kc3
index 2af460d..2098edc 100644
--- a/lib/kc3/0.1/facts.kc3
+++ b/lib/kc3/0.1/facts.kc3
@@ -46,7 +46,7 @@ defmodule Facts do
def with = cfn Tag "kc3_facts_with" (Facts, List, Fn, Result)
# with_macro(facts, [[?, ?, ?]], do result end) -> result
- def with_macro = cfn_macro Tag "kc3_facts_with_macro" (Facts, List, Block, Result)
+ def with_macro = cfn_macro Tag "kc3_facts_with_macro" (Tag, Tag, Tag, Result)
# with_tags(facts, subject, predicate, object,
# fn (fact) {result}) -> result
diff --git a/libkc3/env.c b/libkc3/env.c
index 713c0f3..27b351a 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -2312,21 +2312,33 @@ s_tag * env_facts_with (s_env *env, s_facts *facts, s_list **spec,
return NULL;
}
-s_tag * env_facts_with_macro (s_env *env, s_facts *facts, s_list **spec,
- s_block *block, s_tag *dest)
+s_tag * env_facts_with_macro (s_env *env, s_tag *facts_tag, s_tag *spec_tag,
+ s_tag *block_tag, s_tag *dest)
{
s_facts_with_cursor cursor = {0};
const s_fact *fact = NULL;
- s_tag spec_tag = {0};
+ s_facts *facts;
+ s_tag facts_eval;
+ s_list *spec = NULL;
+ s_tag spec_eval = {0};
s_tag tmp = {0};
- if (! env_eval_list(env, *spec, &spec_tag))
+ if (! env_eval_tag(env, facts_tag, &facts_eval))
return NULL;
- if (spec_tag.type != TAG_LIST) {
+ if (facts_eval.type != TAG_PTR) {
+ err_puts("env_facts_with_macro: facts is not a Ptr");
+ assert(! "env_facts_with_macro: facts is not a Ptr");
+ return NULL;
+ }
+ facts = facts_eval.data.ptr.p;
+ if (! env_eval_tag(env, spec_tag, &spec_eval))
+ return NULL;
+ if (spec_eval.type != TAG_LIST) {
err_puts("env_facts_with_macro: spec is not a List");
assert(! "env_facts_with_macro: spec is not a List");
return NULL;
}
- if (! facts_with_list(facts, &cursor, spec_tag.data.list))
+ spec = spec_eval.data.list;
+ if (! facts_with_list(facts, &cursor, spec))
return NULL;
while (1) {
if (! facts_with_cursor_next(&cursor, &fact))
@@ -2334,15 +2346,15 @@ s_tag * env_facts_with_macro (s_env *env, s_facts *facts, s_list **spec,
if (! fact)
break;
tag_clean(&tmp);
- if (! env_eval_block(env, block, &tmp)) {
+ if (! env_eval_tag(env, block_tag, &tmp)) {
goto clean;
}
}
*dest = tmp;
return dest;
clean:
- err_puts("env_facts_with: error");
- assert(! "env_facts_with: error");
+ err_puts("env_facts_with_macro: error");
+ assert(! "env_facts_with_macro: error");
tag_clean(&tmp);
return NULL;
}
diff --git a/libkc3/env.h b/libkc3/env.h
index 33d6e51..c96245b 100644
--- a/libkc3/env.h
+++ b/libkc3/env.h
@@ -78,8 +78,8 @@ s_tag * env_facts_first_with_tags (s_env *env, s_facts *facts,
s_tag * env_facts_with (s_env *env, s_facts *facts,
s_list **spec, s_fn *callback,
s_tag *dest);
-s_tag * env_facts_with_macro (s_env *env, s_facts *facts,
- s_list **spec, s_block *block,
+s_tag * env_facts_with_macro (s_env *env, s_tag *facts_tag,
+ s_tag *spec_tag, s_tag *block_tag,
s_tag *dest);
s_tag * env_facts_with_tags (s_env *env, s_facts *facts,
s_tag *subject, s_tag *predicate,
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index 9dad5b2..3615f3a 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -311,10 +311,10 @@ s_tag * kc3_facts_with (s_facts *facts, s_list **spec,
return env_facts_with(&g_kc3_env, facts, spec, callback, dest);
}
-s_tag * kc3_facts_with_macro (s_facts *facts, s_list **spec,
- s_block *block, s_tag *dest)
+s_tag * kc3_facts_with_macro (s_tag *facts_tag, s_tag *spec_tag,
+ s_tag *block_tag, s_tag *dest)
{
- return env_facts_with_macro(&g_kc3_env, facts, spec, block, dest);
+ return env_facts_with_macro(&g_kc3_env, facts_tag, spec_tag, block_tag, dest);
}
s_tag * kc3_facts_with_tags (s_facts *facts, s_tag *subject,
diff --git a/libkc3/kc3_main.h b/libkc3/kc3_main.h
index 60647be..2a962e4 100644
--- a/libkc3/kc3_main.h
+++ b/libkc3/kc3_main.h
@@ -100,8 +100,8 @@ bool * kc3_facts_replace_tags (s_facts *facts,
bool *dest);
s_tag * kc3_facts_with (s_facts *facts, s_list **spec,
s_fn *callback, s_tag *dest);
-s_tag * kc3_facts_with_macro (s_facts *facts, s_list **spec,
- s_block *block, s_tag *dest);
+s_tag * kc3_facts_with_macro (s_tag *facts_tag, s_tag *spec_tag,
+ s_tag *block_tag, s_tag *dest);
s_tag * kc3_facts_with_tags (s_facts *facts, s_tag *subject,
s_tag *predicate, s_tag *object,
s_fn *callback, s_tag *dest);