Commit ec70b853b86191d183e2dca5669fceb190fc1a0a

Thomas de Grivel 2024-11-18T15:09:00

fix tests

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
diff --git a/.ikc3_history b/.ikc3_history
index dd1066c..f4faa5c 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,4 +1,3 @@
-1 + 100000000000000000000000000000000000000000000000000000000
 type(1 + 100000000000000000000000000000000000000000000000000000000)
 type(1 + 1)
 type(255)
@@ -97,3 +96,4 @@ Time.from_str("2024-10-31 23:00:00")
 Time.to_str(Time.from_str("2024-10-31 23:00:00"))
 List.map([1, 2, 3], fn (x) { x * 2 })
 Facts.collect_with(Facts.env_db(), [[op = ?, :is_a, :operator]], fn (fact) { op })
+1 + 1
diff --git a/lib/kc3/0.1/facts.kc3 b/lib/kc3/0.1/facts.kc3
index f25c2b7..6a7eb1c 100644
--- a/lib/kc3/0.1/facts.kc3
+++ b/lib/kc3/0.1/facts.kc3
@@ -21,7 +21,7 @@ defmodule Facts do
     Fn, Result)
 
   def collect_with_tags = cfn Tag "kc3_facts_collect_with_tags" (Facts,
-    Tag, Tag, Tag, Fn, Result)
+    Tag, Tag, Tag, Callable, Result)
 
   def database = cfn Ptr "facts_database" (Result)
 
@@ -30,12 +30,12 @@ defmodule Facts do
   # env_db() -> facts
   def env_db = cfn Ptr "kc3_env_db" (Result)
 
-  def first_with = cfn Tag "kc3_facts_first_with" (Facts, List, Fn, Result)
+  def first_with = cfn Tag "kc3_facts_first_with" (Facts, List, Callable, Result)
 
   # first_with_tags(facts, subject, predicate, object,
   #                 fn (fact) {result}) -> result
   def first_with_tags = cfn Tag "kc3_facts_first_with_tags" (Facts, Tag,
-    Tag, Tag, Fn, Result)
+    Tag, Tag, Callable, Result)
 
   def open = cfn Sw "facts_open_file" (Facts, Str)
 
@@ -46,7 +46,7 @@ defmodule Facts do
   def replace_tags = cfn Bool "kc3_facts_replace_tags" (Facts, Tag, Tag, Tag, Result)
 
   # with(facts, [[?, ?, ?]], fn (fact) {result}) -> result
-  def with = cfn Tag "kc3_facts_with" (Facts, List, Fn, Result)
+  def with = cfn Tag "kc3_facts_with" (Facts, List, Callable, Result)
 
   # with_macro(facts, [[?, ?, ?]], do result end) -> result
   def with_macro = cfn_macro Tag "kc3_facts_with_macro" (Tag, Tag, Tag, Result)
@@ -54,10 +54,10 @@ defmodule Facts do
   # with_tags(facts, subject, predicate, object,
   #           fn (fact) {result}) -> result
   def with_tags = cfn Tag "kc3_facts_with_tags" (Facts, Tag, Tag, Tag,
-    Fn, Result)
+    Callable, Result)
 
   # with_tuple(facts, tuple, fn (fact) {result}) -> result
-  def with_tuple = cfn Tag "kc3_facts_with_tuple" (Facts, Tuple, Fn,
+  def with_tuple = cfn Tag "kc3_facts_with_tuple" (Facts, Tuple, Callable,
     Result)
 
 end
diff --git a/lib/kc3/0.1/list.kc3 b/lib/kc3/0.1/list.kc3
index 38045c1..682c4dc 100644
--- a/lib/kc3/0.1/list.kc3
+++ b/lib/kc3/0.1/list.kc3
@@ -34,7 +34,7 @@ defmodule List do
     ([first], sep, acc) { str(reverse([first | acc])) }
   }
 
-  def map = cfn List "list_map" (List, Fn, Result)
+  def map = cfn List "list_map" (List, Callable, Result)
 
   def reverse = fn {
     (x) { reverse(x, []) }
@@ -44,6 +44,6 @@ defmodule List do
 
   def sort = cfn List "list_sort" (List, Result)
 
-  def sort_by = cfn List "list_sort_by" (List, Fn, Result)
+  def sort_by = cfn List "list_sort_by" (List, Callable, Result)
 
 end
diff --git a/libkc3/buf_parse.c b/libkc3/buf_parse.c
index 468d77f..479f424 100644
--- a/libkc3/buf_parse.c
+++ b/libkc3/buf_parse.c
@@ -1114,7 +1114,7 @@ sw buf_parse_call_paren (s_buf *buf, s_call *dest)
   return r;
 }
 
-sw buf_parse_callable (s_buf *buf, s_callable *dest)
+sw buf_parse_callable (s_buf *buf, p_callable *dest)
 {
   sw r;
   s_callable tmp = {0};
@@ -1123,12 +1123,14 @@ sw buf_parse_callable (s_buf *buf, s_callable *dest)
   if ((r = buf_parse_cfn(buf, &tmp.data.cfn)) > 0) {
     tmp.type = CALLABLE_CFN;
     tmp.reference_count = 1;
-    *dest = tmp;
+    *dest = alloc(sizeof(s_callable));
+    **dest = tmp;
   }
   else if ((r = buf_parse_fn(buf, &tmp.data.fn)) > 0) {
     tmp.type = CALLABLE_FN;
     tmp.reference_count = 1;
-    *dest = tmp;
+    *dest = alloc(sizeof(s_callable));
+    **dest = tmp;
   }
   return r;
 }
@@ -3857,7 +3859,7 @@ sw buf_parse_tag_callable (s_buf *buf, s_tag *dest)
   sw r;
   assert(buf);
   assert(dest);
-  if ((r = buf_parse_callable(buf, dest->data.callable)) > 0)
+  if ((r = buf_parse_callable(buf, &dest->data.callable)) > 0)
     dest->type = TAG_CALLABLE;
   return r;
 }
diff --git a/libkc3/buf_parse.h b/libkc3/buf_parse.h
index ee5b8db..190f80a 100644
--- a/libkc3/buf_parse.h
+++ b/libkc3/buf_parse.h
@@ -55,7 +55,7 @@ sw buf_parse_call_op (s_buf *buf, s_call *dest);
 sw buf_parse_call_op_rec (s_buf *buf, s_call *dest, sw min_precedence);
 sw buf_parse_call_op_unary (s_buf *buf, s_call *dest);
 sw buf_parse_call_paren (s_buf *buf, s_call *dest);
-sw buf_parse_callable (s_buf *buf, s_callable *dest);
+sw buf_parse_callable (s_buf *buf, p_callable *dest);
 sw buf_parse_cast (s_buf *buf, s_call *dest);
 sw buf_parse_cfn (s_buf *buf, s_cfn *dest);
 sw buf_parse_character (s_buf *buf, character *dest);
diff --git a/libkc3/env.c b/libkc3/env.c
index c8ddacd..3c91990 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -600,7 +600,7 @@ bool env_eval_call (s_env *env, s_call *call, s_tag *dest)
     err_write_1("\n");
     result = false;
   }
-  result = env_eval_callable(env, c.callable, dest);
+  result = env_eval_call_callable(env, &c, dest);
   call_clean(&c);
   return result;
 }
@@ -648,6 +648,28 @@ bool env_eval_call_callable (s_env *env, const s_call *call,
   return false;
 }
 
+bool env_eval_call_callable_args (s_env *env,
+                                  s_callable *callable,
+                                  s_list *arguments,
+                                  s_tag *dest)
+{
+  switch (callable->type) {
+  case CALLABLE_CFN:
+    return env_eval_call_cfn_args(env, &callable->data.cfn,
+                                  arguments, dest);
+  case CALLABLE_FN:
+    return env_eval_call_fn_args(env, &callable->data.fn,
+                                 arguments, dest);
+  case CALLABLE_VOID:
+    err_puts("env_eval_call_callable_args: CALLABLE_VOID");
+    assert(! "env_eval_call_callable_args: CALLABLE_VOID");
+    return false;
+  }
+  err_puts("env_eval_call_callable_args: unknown callable type");
+  assert(! "env_eval_call_callable_args: unknown callable type");
+  return false;
+}
+
 bool env_eval_call_cfn_args (s_env *env, s_cfn *cfn, s_list *arguments,
                              s_tag *dest)
 {
@@ -2197,7 +2219,7 @@ s_tag * env_facts_collect_with_tags (s_env *env, s_facts *facts,
                                      s_tag *subject,
                                      s_tag *predicate,
                                      s_tag *object,
-                                     s_fn *callback,
+                                     s_callable *callback,
                                      s_tag *dest)
 {
   s_list *arguments;
@@ -2226,9 +2248,9 @@ s_tag * env_facts_collect_with_tags (s_env *env, s_facts *facts,
     if (! fact_w_init_fact(fact_w, fact))
       goto clean;
     *l = list_new(NULL);
-    if (! env_eval_call_fn_args(env, callback, arguments, &(*l)->tag)) {
+    if (! env_eval_call_callable_args(env, callback, arguments,
+                                      &(*l)->tag))
       goto clean;
-    }
     l = &(*l)->next.data.list;
   }
  ok:
@@ -2247,7 +2269,7 @@ s_tag * env_facts_collect_with_tags (s_env *env, s_facts *facts,
 
 s_tag * env_facts_first_with (s_env *env, s_facts *facts,
                               s_list **spec,
-                              s_fn *callback, s_tag *dest)
+                              s_callable *callback, s_tag *dest)
 {
   s_list *arguments;
   s_facts_with_cursor cursor = {0};
@@ -2274,7 +2296,7 @@ s_tag * env_facts_first_with (s_env *env, s_facts *facts,
     goto ok;
   if (! fact_w_init_fact(fact_w, fact))
     goto clean;
-  if (! env_eval_call_fn_args(env, callback, arguments, &tmp)) {
+  if (! env_eval_call_callable_args(env, callback, arguments, &tmp)) {
     goto clean;
   }
  ok:
@@ -2295,7 +2317,7 @@ s_tag * env_facts_first_with (s_env *env, s_facts *facts,
 
 s_tag * env_facts_first_with_tags (s_env *env, s_facts *facts,
                                    s_tag *subject, s_tag *predicate,
-                                   s_tag *object, s_fn *callback,
+                                   s_tag *object, s_callable *callback,
                                    s_tag *dest)
 {
   s_list *arguments;
@@ -2325,7 +2347,7 @@ s_tag * env_facts_first_with_tags (s_env *env, s_facts *facts,
     goto ok;
   if (! fact_w_init_fact(fact_w, fact))
     goto clean;
-  if (! env_eval_call_fn_args(env, callback, arguments, &tmp)) {
+  if (! env_eval_call_callable_args(env, callback, arguments, &tmp)) {
     goto clean;
   }
  ok:
@@ -2340,7 +2362,7 @@ 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_callable *callback, s_tag *dest)
 {
   s_list *arguments;
   s_facts_with_cursor cursor = {0};
@@ -2361,7 +2383,7 @@ s_tag * env_facts_with (s_env *env, s_facts *facts, s_list **spec,
       break;
     tag_clean(&tmp);
     fact_w_init_fact(fact_w, fact);
-    if (! env_eval_call_fn_args(env, callback, arguments, &tmp)) {
+    if (! env_eval_call_callable_args(env, callback, arguments, &tmp)) {
       fact_w_clean(fact_w);
       goto clean;
     }
@@ -2429,7 +2451,7 @@ s_tag * env_facts_with_macro (s_env *env, s_tag *facts_tag, s_tag *spec_tag,
 
 s_tag * env_facts_with_tags (s_env *env, s_facts *facts, s_tag *subject,
                              s_tag *predicate, s_tag *object,
-                             s_fn *callback, s_tag *dest)
+                             s_callable *callback, s_tag *dest)
 {
   s_list *arguments;
   s_facts_cursor cursor = {0};
@@ -2453,7 +2475,7 @@ s_tag * env_facts_with_tags (s_env *env, s_facts *facts, s_tag *subject,
     fact_w_clean(fact_w);
     if (! fact_w_init_fact(fact_w, fact))
       goto clean;
-    if (! env_eval_call_fn_args(env, callback, arguments, &tmp)) {
+    if (! env_eval_call_callable_args(env, callback, arguments, &tmp)) {
       fact_w_clean(fact_w);
       goto clean;
     }
diff --git a/libkc3/env.h b/libkc3/env.h
index 9137218..8da02da 100644
--- a/libkc3/env.h
+++ b/libkc3/env.h
@@ -67,25 +67,27 @@ s_tag *        env_facts_collect_with_tags (s_env *env, s_facts *facts,
                                             s_tag *subject,
                                             s_tag *predicate,
                                             s_tag *object,
-                                            s_fn *callback,
+                                            s_callable *callback,
                                             s_tag *dest);
 s_tag *        env_facts_first_with (s_env *env, s_facts *facts,
-                                     s_list **spec, s_fn *callback,
+                                     s_list **spec,
+                                     s_callable *callback,
                                      s_tag *dest);
 s_tag *        env_facts_first_with_tags (s_env *env, s_facts *facts,
                                           s_tag *subject,
                                           s_tag *predicate,
                                           s_tag *object,
-                                          s_fn *callback, s_tag *dest);
+                                          s_callable *callback,
+                                          s_tag *dest);
 s_tag *        env_facts_with (s_env *env, s_facts *facts,
-                               s_list **spec, s_fn *callback,
+                               s_list **spec, s_callable *callback,
                                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_tag *        env_facts_with_tags (s_env *env, s_facts *facts,
                                     s_tag *subject, s_tag *predicate,
-                                    s_tag *object, s_fn *callback,
+                                    s_tag *object, s_callable *callback,
                                     s_tag *dest);
 s_tag *        env_ident_get (s_env *env, const s_ident *ident,
                               s_tag *dest);
@@ -155,8 +157,10 @@ bool env_eval_call (s_env *env, s_call *call,
                     s_tag *dest);
 bool env_eval_call_arguments (s_env *env, s_list *args,
                               s_list **dest);
+bool env_eval_call_callable (s_env *env, const s_call *call,
+                             s_tag *dest);
 bool env_eval_call_callable_args (s_env *env,
-                                  const s_callable *callable,
+                                  s_callable *callable,
                                   s_list *arguments,
                                   s_tag *dest);
 bool env_eval_call_cfn_args (s_env *env, s_cfn *cfn, s_list *arguments,
diff --git a/libkc3/hash.c b/libkc3/hash.c
index afae8ab..d69bade 100644
--- a/libkc3/hash.c
+++ b/libkc3/hash.c
@@ -26,7 +26,6 @@
   {                                                                    \
     const char t[] = #type;                                            \
     assert(hash);                                                      \
-    assert(x);                                                         \
     return hash_update(hash, t, sizeof(t)) &&                          \
       hash_update(hash, &x, sizeof(x));                                \
   }
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index 87446ee..7d6c4f4 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -258,25 +258,26 @@ s_tag * kc3_facts_collect_with_tags (s_facts *facts,
                                      s_tag *subject,
                                      s_tag *predicate,
                                      s_tag *object,
-                                     s_fn *callback,
+                                     p_callable *callback,
                                      s_tag *dest)
 {
   return env_facts_collect_with_tags(&g_kc3_env, facts, subject,
-                                     predicate, object, callback, dest);
+                                     predicate, object, *callback,
+                                     dest);
 }
 
 s_tag * kc3_facts_first_with (s_facts *facts, s_list **spec,
-                              s_fn *callback, s_tag *dest)
+                              p_callable *callback, s_tag *dest)
 {
-  return env_facts_first_with(&g_kc3_env, facts, spec, callback, dest);
+  return env_facts_first_with(&g_kc3_env, facts, spec, *callback, dest);
 }
 
 s_tag * kc3_facts_first_with_tags (s_facts *facts, s_tag *subject,
                                    s_tag *predicate, s_tag *object,
-                                   s_fn *callback, s_tag *dest)
+                                   p_callable *callback, s_tag *dest)
 {
   return env_facts_first_with_tags(&g_kc3_env, facts, subject,
-                                   predicate, object, callback, dest);
+                                   predicate, object, *callback, dest);
 }
 
 uw * kc3_facts_next_id (uw *dest)
@@ -312,9 +313,9 @@ bool * kc3_facts_replace_tags (s_facts *facts,
 }
 
 s_tag * kc3_facts_with (s_facts *facts, s_list **spec,
-                        s_fn *callback, s_tag *dest)
+                        p_callable *callback, s_tag *dest)
 {
-  return env_facts_with(&g_kc3_env, facts, spec, callback, dest);
+  return env_facts_with(&g_kc3_env, facts, spec, *callback, dest);
 }
 
 s_tag * kc3_facts_with_macro (s_tag *facts_tag, s_tag *spec_tag,
@@ -325,14 +326,14 @@ s_tag * kc3_facts_with_macro (s_tag *facts_tag, s_tag *spec_tag,
 
 s_tag * kc3_facts_with_tags (s_facts *facts, s_tag *subject,
                              s_tag *predicate, s_tag *object,
-                             s_fn *callback, s_tag *dest)
+                             p_callable *callback, s_tag *dest)
 {
   return env_facts_with_tags(&g_kc3_env, facts, subject, predicate,
-                             object, callback, dest);
+                             object, *callback, dest);
 }
 
 s_tag * kc3_facts_with_tuple (s_facts *facts, s_tuple *tuple,
-                              s_fn *callback, s_tag *dest)
+                              p_callable *callback, s_tag *dest)
 {
   assert(facts);
   assert(tuple);
@@ -344,8 +345,8 @@ s_tag * kc3_facts_with_tuple (s_facts *facts, s_tuple *tuple,
     return NULL;
   }
   return env_facts_with_tags(&g_kc3_env, facts, tuple->tag,
-                             tuple->tag + 1, tuple->tag + 2, callback,
-                             dest);
+                             tuple->tag + 1, tuple->tag + 2,
+                             *callback, dest);
 }
 
 s_tag * kc3_quote_cfn (const s_sym **sym, s_tag *dest)
diff --git a/libkc3/kc3_main.h b/libkc3/kc3_main.h
index e453cd5..9117df1 100644
--- a/libkc3/kc3_main.h
+++ b/libkc3/kc3_main.h
@@ -41,7 +41,8 @@ s_tag *        kc3_facts_first_with_tags (s_facts *facts,
                                           s_tag *subject,
                                           s_tag *predicate,
                                           s_tag *object,
-                                          s_fn *callback, s_tag *dest);
+                                          p_callable *callback,
+                                          s_tag *dest);
 uw *           kc3_facts_next_id (uw *dest);
 s_str *        kc3_getenv (const s_str *name, s_str *dest);
 void           kc3_license (void);
@@ -80,13 +81,14 @@ s_tag *      kc3_facts_collect_with_tags (s_facts *facts,
                                           s_tag *subject,
                                           s_tag *predicate,
                                           s_tag *object,
-                                          s_fn *callback,
+                                          p_callable *callback,
                                           s_tag *dest);
 s_tag *      kc3_facts_first_with (s_facts *facts, s_list **spec,
-                                   s_fn *callback, s_tag *dest);
+                                   p_callable *callback, s_tag *dest);
 s_tag *      kc3_facts_first_with_tags (s_facts *facts, s_tag *subject,
                                         s_tag *predicate, s_tag *object,
-                                        s_fn *callback, s_tag *dest);
+                                        p_callable *callback,
+                                        s_tag *dest);
 bool *       kc3_facts_remove_tags (s_facts *facts,
                                     s_tag *subject,
                                     s_tag *predicate,
@@ -98,12 +100,12 @@ bool *       kc3_facts_replace_tags (s_facts *facts,
                                      s_tag *object,
                                      bool *dest);
 s_tag *      kc3_facts_with (s_facts *facts, s_list **spec,
-                             s_fn *callback, s_tag *dest);
+                             p_callable *callback, 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);
+                                  p_callable *callback, s_tag *dest);
 s_tag *      kc3_identity (s_tag *tag, s_tag *dest);
 s_tag *      kc3_integer_reduce (s_tag *tag, s_tag *dest);
 s_tag *      kc3_let (s_tag *vars, s_tag *tag, s_tag *dest);
diff --git a/libkc3/list.c b/libkc3/list.c
index 2efae1f..869bd24 100644
--- a/libkc3/list.c
+++ b/libkc3/list.c
@@ -60,7 +60,7 @@ void list_f_clean (s_list **list)
     l = list_delete(l);
 }
 
-s_list ** list_filter (s_list **list, s_callable *function,
+s_list ** list_filter (s_list **list, p_callable *function,
                        s_list **dest)
 {
   s_list *arg;
@@ -76,7 +76,7 @@ s_list ** list_filter (s_list **list, s_callable *function,
     if (! tag_copy(&arg->tag, &l->tag))
       goto ko;
     *tail = list_new(NULL);
-    if (! eval_callable_call(function, arg, &(*tail)->tag))
+    if (! eval_callable_call(*function, arg, &(*tail)->tag))
       goto ko;
     if ((*tail)->tag.type == TAG_VOID)
       *tail = list_delete(*tail);
@@ -233,7 +233,7 @@ sw list_length (const s_list *list)
   return length;
 }
 
-s_list ** list_map (s_list **list, s_callable *function,
+s_list ** list_map (s_list **list, p_callable *function,
                     s_list **dest)
 {
   s_list *arg;
@@ -249,7 +249,7 @@ s_list ** list_map (s_list **list, s_callable *function,
     if (! tag_copy(&arg->tag, &l->tag))
       goto ko;
     *tail = list_new(NULL);
-    if (! eval_callable_call(function, arg, &(*tail)->tag))
+    if (! eval_callable_call(*function, arg, &(*tail)->tag))
       goto ko;
     tail = &(*tail)->next.data.list;
     l = list_next(l);
@@ -395,7 +395,7 @@ s_list ** list_sort (s_list **list, s_list **dest)
   return dest;
 }
 
-s_list ** list_sort_by (s_list **list, s_callable *compare,
+s_list ** list_sort_by (s_list **list, p_callable *compare,
                         s_list **dest)
 {
   s_list *arg1;
@@ -424,7 +424,7 @@ s_list ** list_sort_by (s_list **list, s_callable *compare,
         goto ko;
       if (! tag_init_copy(&arg2->tag, &l->tag))
         goto ko;
-      if (! eval_callable_call(compare, arg1, &tag))
+      if (! eval_callable_call(*compare, arg1, &tag))
         goto ko;
       tag_void(&arg1->tag);
       tag_void(&arg2->tag);
diff --git a/libkc3/list.h b/libkc3/list.h
index 47e0c5d..1893803 100644
--- a/libkc3/list.h
+++ b/libkc3/list.h
@@ -61,11 +61,11 @@ s_list ** list_tail (s_list **list);
 s_tuple * list_to_tuple_reverse (const s_list *list, s_tuple *dest);
 
 /* Operators */
-s_list ** list_filter (s_list **list, s_callable *function,
+s_list ** list_filter (s_list **list, p_callable *function,
                        s_list **dest);
-s_list ** list_map (s_list **list, s_callable *function, s_list **dest);
+s_list ** list_map (s_list **list, p_callable *function, s_list **dest);
 s_list ** list_remove_void (s_list **list);
-s_list ** list_sort_by (s_list **list, s_callable *compare,
+s_list ** list_sort_by (s_list **list, p_callable *compare,
                         s_list **dest);
 s_array * list_to_array (s_list *list, const s_sym *type,
                          s_array *dest);