Commit 5a7ad46db9ccf7ddf6daf077f6bfa508efc36e44

Thomas de Grivel 2024-11-16T22:02:40

wip deconstify much for ref counting everything.

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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
diff --git a/libkc3/facts.c b/libkc3/facts.c
index 365bcb4..e4b5a74 100644
--- a/libkc3/facts.c
+++ b/libkc3/facts.c
@@ -739,7 +739,7 @@ sw facts_open_log (s_facts *facts, s_buf *buf)
   return result;
 }
 
-s_tag * facts_ref_tag (s_facts *facts, const s_tag *tag)
+s_tag * facts_ref_tag (s_facts *facts, s_tag *tag)
 {
   s_set_item__tag *item;
   assert(facts);
diff --git a/libkc3/facts.h b/libkc3/facts.h
index 7c1fd8d..3bf0948 100644
--- a/libkc3/facts.h
+++ b/libkc3/facts.h
@@ -47,7 +47,7 @@ s_facts * facts_lock_unlock_w (s_facts *facts);
 s_facts * facts_lock_w (s_facts *facts);
 #endif
 sw        facts_open_file (s_facts *facts, const s_str *path);
-s_tag *   facts_ref_tag (s_facts *facts, const s_tag *tag);
+s_tag *   facts_ref_tag (s_facts *facts, s_tag *tag);
 bool *    facts_remove_fact (s_facts *facts, const s_fact *fact,
                              bool *dest);
 bool *    facts_remove_fact_tags (s_facts *facts,
@@ -59,15 +59,14 @@ s_facts * facts_remove_all (s_facts *facts);
 s_fact *  facts_replace_fact (s_facts *facts, s_fact *fact);
 s_fact *  facts_replace_tags (s_facts *facts, s_tag *subject,
                               s_tag *predicate, s_tag *object);
-sw             facts_save_file (s_facts *facts, const char *path);
-s_facts_transaction * facts_transaction_clean
-                 (s_facts_transaction *transaction);
-s_facts *      facts_transaction_rollback
-                 (s_facts *facts,
-                  const s_facts_transaction *transaction);
-void           facts_transaction_start
-                 (s_facts *facts, s_facts_transaction *transaction);
-bool           facts_unref_tag (s_facts *facts, const s_tag *tag);
+sw        facts_save_file (s_facts *facts, const char *path);
+s_facts_transaction *
+          facts_transaction_clean (s_facts_transaction *transaction);
+s_facts * facts_transaction_rollback
+(s_facts *facts, const s_facts_transaction *transaction);
+void      facts_transaction_start
+(s_facts *facts, s_facts_transaction *transaction);
+bool      facts_unref_tag (s_facts *facts, const s_tag *tag);
 
 /* Observers */
 sw        facts_dump (s_facts *facts, s_buf *buf);
diff --git a/libkc3/map.c b/libkc3/map.c
index 6f16f27..5d1e772 100644
--- a/libkc3/map.c
+++ b/libkc3/map.c
@@ -327,7 +327,7 @@ s_map * map_new_1 (const char *p)
   return map;
 }
 
-s_map * map_new_from_lists (const s_list *keys, const s_list *values)
+s_map * map_new_from_lists (s_list *keys, s_list *values)
 {
   s_map *map;
   map = alloc(sizeof(s_map));
@@ -341,8 +341,8 @@ s_map * map_new_from_lists (const s_list *keys, const s_list *values)
   
 }
 
-s_map * map_put (const s_map *map, const s_tag *key,
-                 const s_tag *value, s_map *dest)
+s_map * map_put (s_map *map, s_tag *key,
+                 s_tag *value, s_map *dest)
 {
   s_map tmp;
   uw i;
diff --git a/libkc3/map.h b/libkc3/map.h
index d70744f..261e900 100644
--- a/libkc3/map.h
+++ b/libkc3/map.h
@@ -28,7 +28,7 @@ s_map * map_init_from_alist (s_map *map, s_list *alist);
 void    map_delete (s_map *map);
 s_map * map_new (uw size);
 s_map * map_new_1 (const char *p);
-s_map * map_new_from_lists (const s_list *keys, const s_list *values);
+s_map * map_new_from_lists (s_list *keys, s_list *values);
 
 /* Operators. */
 s_map * map_sort (s_map *map);
@@ -44,8 +44,8 @@ const s_sym ** map_get_type (const s_map *map, const s_tag *key,
 const s_sym ** map_get_var_type (const s_map *map, const s_tag *key,
                                  const s_sym **dest);
 uw *           map_index (const s_map *map, const s_tag *key, uw *dest);
-s_map *        map_put (const s_map *map, const s_tag *key,
-                        const s_tag *value, s_map *dest);
+s_map *        map_put (s_map *map, s_tag *key,
+                        s_tag *value, s_map *dest);
 /*
 s_map *        map_put_list (const s_map *map, const s_list *alist,
                              s_map *dest);
diff --git a/libkc3/pcomplex.c b/libkc3/pcomplex.c
index 8b35928..7d1cb6e 100644
--- a/libkc3/pcomplex.c
+++ b/libkc3/pcomplex.c
@@ -33,7 +33,7 @@ s_complex ** pcomplex_init (s_complex **p)
 
 s_complex ** pcomplex_init_cast (s_complex **p,
                                  const s_sym * const *type,
-                                 const s_tag *src)
+                                 s_tag *src)
 {
   s_complex *tmp = NULL;
   assert(p);
@@ -47,7 +47,7 @@ s_complex ** pcomplex_init_cast (s_complex **p,
 }
 
 s_complex ** pcomplex_init_copy (s_complex **p,
-				 const s_complex * const *src)
+				 s_complex **src)
 {
   s_complex *tmp = NULL;
   assert(p);
diff --git a/libkc3/pcomplex.h b/libkc3/pcomplex.h
index 5a0bd79..10ab5b5 100644
--- a/libkc3/pcomplex.h
+++ b/libkc3/pcomplex.h
@@ -21,8 +21,8 @@ void         pcomplex_clean (s_complex **p);
 s_complex ** pcomplex_init (s_complex **p);
 s_complex ** pcomplex_init_cast (s_complex **p,
                                  const s_sym * const *type,
-                                 const s_tag *src);
+                                 s_tag *src);
 s_complex ** pcomplex_init_copy (s_complex **p,
-				 const s_complex * const *src);
+				 s_complex **src);
 
 #endif /* LIBKC3_PCOMPLEX_H */
diff --git a/libkc3/pcow.c b/libkc3/pcow.c
index e4bc7a4..4fffb73 100644
--- a/libkc3/pcow.c
+++ b/libkc3/pcow.c
@@ -15,8 +15,7 @@
 #include "pcow.h"
 #include "tag.h"
 
-s_tag * pcow_assign (s_cow * const *cow, const s_tag *value,
-                     s_tag *dest)
+s_tag * pcow_assign (s_cow **cow, s_tag *value, s_tag *dest)
 {
   assert(cow);
   assert(value);
@@ -52,7 +51,7 @@ s_cow ** pcow_init (s_cow **p, const s_sym *type)
 }
 
 s_cow ** pcow_init_cast (s_cow **p, const s_sym * const *type,
-                         const s_tag *src)
+                         s_tag *src)
 {
   s_cow *tmp = NULL;
   assert(p);
@@ -64,7 +63,7 @@ s_cow ** pcow_init_cast (s_cow **p, const s_sym * const *type,
   return p;
 }
 
-s_cow ** pcow_init_copy (s_cow **p, s_cow * const *src)
+s_cow ** pcow_init_copy (s_cow **p, s_cow **src)
 {
   assert(p);
   assert(src);
diff --git a/libkc3/pcow.h b/libkc3/pcow.h
index 4247e14..67401a8 100644
--- a/libkc3/pcow.h
+++ b/libkc3/pcow.h
@@ -19,11 +19,10 @@
 void     pcow_clean (s_cow **p);
 s_cow ** pcow_init (s_cow **p, const s_sym *type);
 s_cow ** pcow_init_cast (s_cow **p, const s_sym * const *type,
-                         const s_tag *src);
-s_cow ** pcow_init_copy (s_cow **p, s_cow * const *src);
+                         s_tag *src);
+s_cow ** pcow_init_copy (s_cow **p, s_cow **src);
 
 /* Operators. */
-s_tag * pcow_assign (s_cow * const *cow, const s_tag *value,
-                     s_tag *dest);
+s_tag * pcow_assign (s_cow **cow, s_tag *value, s_tag *dest);
 
 #endif /* LIBKC3_PCOW_H */
diff --git a/libkc3/quote.c b/libkc3/quote.c
index fd6c5d1..3b9b075 100644
--- a/libkc3/quote.c
+++ b/libkc3/quote.c
@@ -21,14 +21,14 @@ void quote_clean (s_quote *quote)
   tag_delete(quote->tag);
 }
 
-s_quote * quote_init (s_quote *quote, const s_tag *tag)
+s_quote * quote_init (s_quote *quote, s_tag *tag)
 {
   quote->tag = tag_new_copy(tag);
   return quote;
 }
 
 s_quote * quote_init_cast (s_quote *quote, const s_sym * const *type,
-                           const s_tag *tag)
+                           s_tag *tag)
 {
   assert(quote);
   assert(type);
@@ -52,7 +52,7 @@ s_quote * quote_init_cast (s_quote *quote, const s_sym * const *type,
   return NULL;
 }
 
-s_quote * quote_init_copy (s_quote *quote, const s_quote *src)
+s_quote * quote_init_copy (s_quote *quote, s_quote *src)
 {
   quote->tag = tag_new_copy(src->tag);
   return quote;
diff --git a/libkc3/quote.h b/libkc3/quote.h
index 1af4667..814ce35 100644
--- a/libkc3/quote.h
+++ b/libkc3/quote.h
@@ -17,10 +17,10 @@
 
 /* Stack-allocation compatible functions, call quote_clean after use. */
 void      quote_clean (s_quote *quote);
-s_quote * quote_init (s_quote *quote, const s_tag *tag);
+s_quote * quote_init (s_quote *quote, s_tag *tag);
 s_quote * quote_init_1 (s_quote *quote, const s8 *p);
 s_quote * quote_init_cast (s_quote *quote, const s_sym * const *type,
-                           const s_tag *src);
-s_quote * quote_init_copy (s_quote *quote, const s_quote *src);
+                           s_tag *src);
+s_quote * quote_init_copy (s_quote *quote, s_quote *src);
 
 #endif /* LIBKC3_QUOTE_H */
diff --git a/libkc3/s.c.in b/libkc3/s.c.in
index 7339c7f..9e13162 100644
--- a/libkc3/s.c.in
+++ b/libkc3/s.c.in
@@ -103,7 +103,7 @@ s_bits$ * s_bits$_init_cast
   }
   if (true) {
     err_puts("s_bits$_cast: stacktrace:");
-    err_inspect_list((const s_list * const *) &g_kc3_env.stacktrace);
+    err_inspect_list(g_kc3_env.stacktrace);
     err_write_1("\n");
   }
   assert(! "s_bits$_cast: cannot cast to S_bits$");
diff --git a/libkc3/s16.c b/libkc3/s16.c
index 341978c..d3339ca 100644
--- a/libkc3/s16.c
+++ b/libkc3/s16.c
@@ -103,7 +103,7 @@ s16 * s16_init_cast
   }
   if (true) {
     err_puts("s16_cast: stacktrace:");
-    err_inspect_list((const s_list * const *) &g_kc3_env.stacktrace);
+    err_inspect_list(g_kc3_env.stacktrace);
     err_write_1("\n");
   }
   assert(! "s16_cast: cannot cast to S16");
diff --git a/libkc3/s32.c b/libkc3/s32.c
index 4ceef97..ce50e80 100644
--- a/libkc3/s32.c
+++ b/libkc3/s32.c
@@ -103,7 +103,7 @@ s32 * s32_init_cast
   }
   if (true) {
     err_puts("s32_cast: stacktrace:");
-    err_inspect_list((const s_list * const *) &g_kc3_env.stacktrace);
+    err_inspect_list(g_kc3_env.stacktrace);
     err_write_1("\n");
   }
   assert(! "s32_cast: cannot cast to S32");
diff --git a/libkc3/s64.c b/libkc3/s64.c
index 7203a5a..24ac7d2 100644
--- a/libkc3/s64.c
+++ b/libkc3/s64.c
@@ -103,7 +103,7 @@ s64 * s64_init_cast
   }
   if (true) {
     err_puts("s64_cast: stacktrace:");
-    err_inspect_list((const s_list * const *) &g_kc3_env.stacktrace);
+    err_inspect_list(g_kc3_env.stacktrace);
     err_write_1("\n");
   }
   assert(! "s64_cast: cannot cast to S64");
diff --git a/libkc3/s8.c b/libkc3/s8.c
index 92c9bee..29e7fad 100644
--- a/libkc3/s8.c
+++ b/libkc3/s8.c
@@ -103,7 +103,7 @@ s8 * s8_init_cast
   }
   if (true) {
     err_puts("s8_cast: stacktrace:");
-    err_inspect_list((const s_list * const *) &g_kc3_env.stacktrace);
+    err_inspect_list(g_kc3_env.stacktrace);
     err_write_1("\n");
   }
   assert(! "s8_cast: cannot cast to S8");
diff --git a/libkc3/set.c.in b/libkc3/set.c.in
index 5e84647..9ffb5ac 100644
--- a/libkc3/set.c.in
+++ b/libkc3/set.c.in
@@ -19,7 +19,7 @@
 #include "set_item___NAME$.h"
 
 s_set_item___NAME$ *
-set_add___NAME$ (s_set___NAME$ *set, const _TYPE$ *data)
+set_add___NAME$ (s_set___NAME$ *set, _TYPE$ *data)
 {
   uw hash;
   assert(set);
@@ -33,7 +33,7 @@ set_add___NAME$ (s_set___NAME$ *set, const _TYPE$ *data)
 }
 
 s_set_item___NAME$ *
-set_add_collision___NAME$ (s_set___NAME$ *set, const _TYPE$ *data, uw hash, s_set_item___NAME$ *item)
+set_add_collision___NAME$ (s_set___NAME$ *set, _TYPE$ *data, uw hash, s_set_item___NAME$ *item)
 {
   s_set_item___NAME$ *new_item;
   new_item = set_item_new___NAME$(data, hash, item->next);
@@ -44,7 +44,7 @@ set_add_collision___NAME$ (s_set___NAME$ *set, const _TYPE$ *data, uw hash, s_se
 }
 
 s_set_item___NAME$ *
-set_add_h___NAME$ (s_set___NAME$ *set, const _TYPE$ *data, uw hash)
+set_add_h___NAME$ (s_set___NAME$ *set, _TYPE$ *data, uw hash)
 {
   uw h;
   s_set_item___NAME$ *i;
diff --git a/libkc3/set.h.in b/libkc3/set.h.in
index ee98ddf..4f09f19 100644
--- a/libkc3/set.h.in
+++ b/libkc3/set.h.in
@@ -16,18 +16,17 @@
 
 #include "types.h"
 
-s_set_item___NAME$ *
-set_add___NAME$ (s_set___NAME$ *set, const _TYPE$ *data);
-
-s_set_item___NAME$ *
-set_add_collision___NAME$ (s_set___NAME$ *set, const _TYPE$ *data, uw hash, s_set_item___NAME$ *item);
-
-s_set_item___NAME$ *
-set_add_h___NAME$ (s_set___NAME$ *set, const _TYPE$ *data, uw hash);
+/* Stack-allocation compatible functions, call set_clean___NAME$
+   after use. */
 
 void
 set_clean___NAME$ (s_set___NAME$ *set);
 
+s_set___NAME$ *
+set_init___NAME$ (s_set___NAME$ *set, uw max);
+
+/* Observers. */
+
 s_set_item___NAME$ *
 set_get___NAME$ (const s_set___NAME$ *set, const _TYPE$ *data);
 
@@ -40,8 +39,16 @@ set_get_hash___NAME$ (const s_set___NAME$ *set, uw hash);
 s_set_item___NAME$ *
 set_get_hash_next___NAME$ (const s_set_item___NAME$ *item);
 
-s_set___NAME$ *
-set_init___NAME$ (s_set___NAME$ *set, uw max);
+/* Operators. */
+
+s_set_item___NAME$ *
+set_add___NAME$ (s_set___NAME$ *set, _TYPE$ *data);
+
+s_set_item___NAME$ *
+set_add_collision___NAME$ (s_set___NAME$ *set, _TYPE$ *data, uw hash, s_set_item___NAME$ *item);
+
+s_set_item___NAME$ *
+set_add_h___NAME$ (s_set___NAME$ *set, _TYPE$ *data, uw hash);
 
 bool
 set_remove___NAME$ (s_set___NAME$ *set, const _TYPE$ *data);
diff --git a/libkc3/set__fact.c b/libkc3/set__fact.c
index 3136ff4..b8de22b 100644
--- a/libkc3/set__fact.c
+++ b/libkc3/set__fact.c
@@ -19,7 +19,7 @@
 #include "set_item__fact.h"
 
 s_set_item__fact *
-set_add__fact (s_set__fact *set, const s_fact *data)
+set_add__fact (s_set__fact *set, s_fact *data)
 {
   uw hash;
   assert(set);
@@ -33,7 +33,7 @@ set_add__fact (s_set__fact *set, const s_fact *data)
 }
 
 s_set_item__fact *
-set_add_collision__fact (s_set__fact *set, const s_fact *data, uw hash, s_set_item__fact *item)
+set_add_collision__fact (s_set__fact *set, s_fact *data, uw hash, s_set_item__fact *item)
 {
   s_set_item__fact *new_item;
   new_item = set_item_new__fact(data, hash, item->next);
@@ -44,7 +44,7 @@ set_add_collision__fact (s_set__fact *set, const s_fact *data, uw hash, s_set_it
 }
 
 s_set_item__fact *
-set_add_h__fact (s_set__fact *set, const s_fact *data, uw hash)
+set_add_h__fact (s_set__fact *set, s_fact *data, uw hash)
 {
   uw h;
   s_set_item__fact *i;
diff --git a/libkc3/set__fact.h b/libkc3/set__fact.h
index b034b45..6cdac62 100644
--- a/libkc3/set__fact.h
+++ b/libkc3/set__fact.h
@@ -16,18 +16,17 @@
 
 #include "types.h"
 
-s_set_item__fact *
-set_add__fact (s_set__fact *set, const s_fact *data);
-
-s_set_item__fact *
-set_add_collision__fact (s_set__fact *set, const s_fact *data, uw hash, s_set_item__fact *item);
-
-s_set_item__fact *
-set_add_h__fact (s_set__fact *set, const s_fact *data, uw hash);
+/* Stack-allocation compatible functions, call set_clean__fact
+   after use. */
 
 void
 set_clean__fact (s_set__fact *set);
 
+s_set__fact *
+set_init__fact (s_set__fact *set, uw max);
+
+/* Observers. */
+
 s_set_item__fact *
 set_get__fact (const s_set__fact *set, const s_fact *data);
 
@@ -40,8 +39,16 @@ set_get_hash__fact (const s_set__fact *set, uw hash);
 s_set_item__fact *
 set_get_hash_next__fact (const s_set_item__fact *item);
 
-s_set__fact *
-set_init__fact (s_set__fact *set, uw max);
+/* Operators. */
+
+s_set_item__fact *
+set_add__fact (s_set__fact *set, s_fact *data);
+
+s_set_item__fact *
+set_add_collision__fact (s_set__fact *set, s_fact *data, uw hash, s_set_item__fact *item);
+
+s_set_item__fact *
+set_add_h__fact (s_set__fact *set, s_fact *data, uw hash);
 
 bool
 set_remove__fact (s_set__fact *set, const s_fact *data);
diff --git a/libkc3/set__tag.c b/libkc3/set__tag.c
index 7bc5de4..7f515ab 100644
--- a/libkc3/set__tag.c
+++ b/libkc3/set__tag.c
@@ -19,7 +19,7 @@
 #include "set_item__tag.h"
 
 s_set_item__tag *
-set_add__tag (s_set__tag *set, const s_tag *data)
+set_add__tag (s_set__tag *set, s_tag *data)
 {
   uw hash;
   assert(set);
@@ -33,7 +33,7 @@ set_add__tag (s_set__tag *set, const s_tag *data)
 }
 
 s_set_item__tag *
-set_add_collision__tag (s_set__tag *set, const s_tag *data, uw hash, s_set_item__tag *item)
+set_add_collision__tag (s_set__tag *set, s_tag *data, uw hash, s_set_item__tag *item)
 {
   s_set_item__tag *new_item;
   new_item = set_item_new__tag(data, hash, item->next);
@@ -44,7 +44,7 @@ set_add_collision__tag (s_set__tag *set, const s_tag *data, uw hash, s_set_item_
 }
 
 s_set_item__tag *
-set_add_h__tag (s_set__tag *set, const s_tag *data, uw hash)
+set_add_h__tag (s_set__tag *set, s_tag *data, uw hash)
 {
   uw h;
   s_set_item__tag *i;
diff --git a/libkc3/set__tag.h b/libkc3/set__tag.h
index 93ae7ba..a901d7d 100644
--- a/libkc3/set__tag.h
+++ b/libkc3/set__tag.h
@@ -16,18 +16,17 @@
 
 #include "types.h"
 
-s_set_item__tag *
-set_add__tag (s_set__tag *set, const s_tag *data);
-
-s_set_item__tag *
-set_add_collision__tag (s_set__tag *set, const s_tag *data, uw hash, s_set_item__tag *item);
-
-s_set_item__tag *
-set_add_h__tag (s_set__tag *set, const s_tag *data, uw hash);
+/* Stack-allocation compatible functions, call set_clean__tag
+   after use. */
 
 void
 set_clean__tag (s_set__tag *set);
 
+s_set__tag *
+set_init__tag (s_set__tag *set, uw max);
+
+/* Observers. */
+
 s_set_item__tag *
 set_get__tag (const s_set__tag *set, const s_tag *data);
 
@@ -40,8 +39,16 @@ set_get_hash__tag (const s_set__tag *set, uw hash);
 s_set_item__tag *
 set_get_hash_next__tag (const s_set_item__tag *item);
 
-s_set__tag *
-set_init__tag (s_set__tag *set, uw max);
+/* Operators. */
+
+s_set_item__tag *
+set_add__tag (s_set__tag *set, s_tag *data);
+
+s_set_item__tag *
+set_add_collision__tag (s_set__tag *set, s_tag *data, uw hash, s_set_item__tag *item);
+
+s_set_item__tag *
+set_add_h__tag (s_set__tag *set, s_tag *data, uw hash);
 
 bool
 set_remove__tag (s_set__tag *set, const s_tag *data);
diff --git a/libkc3/set_item.c.in b/libkc3/set_item.c.in
index e5f35c1..643b786 100644
--- a/libkc3/set_item.c.in
+++ b/libkc3/set_item.c.in
@@ -17,7 +17,7 @@
 #include "_NAME$.h"
 
 s_set_item___NAME$ *
-set_item_new___NAME$ (const _TYPE$ *data, uw hash, s_set_item___NAME$ *next)
+set_item_new___NAME$ (_TYPE$ *data, uw hash, s_set_item___NAME$ *next)
 {
   s_set_item___NAME$ *item;
   item = alloc(sizeof(s_set_item___NAME$));
diff --git a/libkc3/set_item.h.in b/libkc3/set_item.h.in
index 0003c1a..93201d3 100644
--- a/libkc3/set_item.h.in
+++ b/libkc3/set_item.h.in
@@ -23,7 +23,7 @@
 #include "types.h"
 
 s_set_item___NAME$ *
-set_item_new___NAME$ (const _TYPE$ *data, uw hash, s_set_item___NAME$ *next);
+set_item_new___NAME$ (_TYPE$ *data, uw hash, s_set_item___NAME$ *next);
 
 void
 set_item_delete___NAME$ (s_set_item___NAME$ *x);
diff --git a/libkc3/set_item__fact.c b/libkc3/set_item__fact.c
index f8f4be2..11246f7 100644
--- a/libkc3/set_item__fact.c
+++ b/libkc3/set_item__fact.c
@@ -17,7 +17,7 @@
 #include "fact.h"
 
 s_set_item__fact *
-set_item_new__fact (const s_fact *data, uw hash, s_set_item__fact *next)
+set_item_new__fact (s_fact *data, uw hash, s_set_item__fact *next)
 {
   s_set_item__fact *item;
   item = alloc(sizeof(s_set_item__fact));
diff --git a/libkc3/set_item__fact.h b/libkc3/set_item__fact.h
index 13c2fa2..9008aa6 100644
--- a/libkc3/set_item__fact.h
+++ b/libkc3/set_item__fact.h
@@ -23,7 +23,7 @@
 #include "types.h"
 
 s_set_item__fact *
-set_item_new__fact (const s_fact *data, uw hash, s_set_item__fact *next);
+set_item_new__fact (s_fact *data, uw hash, s_set_item__fact *next);
 
 void
 set_item_delete__fact (s_set_item__fact *x);
diff --git a/libkc3/set_item__tag.c b/libkc3/set_item__tag.c
index a1effcf..3da0cdc 100644
--- a/libkc3/set_item__tag.c
+++ b/libkc3/set_item__tag.c
@@ -17,7 +17,7 @@
 #include "tag.h"
 
 s_set_item__tag *
-set_item_new__tag (const s_tag *data, uw hash, s_set_item__tag *next)
+set_item_new__tag (s_tag *data, uw hash, s_set_item__tag *next)
 {
   s_set_item__tag *item;
   item = alloc(sizeof(s_set_item__tag));
diff --git a/libkc3/set_item__tag.h b/libkc3/set_item__tag.h
index 7fed27b..d440682 100644
--- a/libkc3/set_item__tag.h
+++ b/libkc3/set_item__tag.h
@@ -23,7 +23,7 @@
 #include "types.h"
 
 s_set_item__tag *
-set_item_new__tag (const s_tag *data, uw hash, s_set_item__tag *next);
+set_item_new__tag (s_tag *data, uw hash, s_set_item__tag *next);
 
 void
 set_item_delete__tag (s_set_item__tag *x);
diff --git a/libkc3/sw.c b/libkc3/sw.c
index e19e439..38ba225 100644
--- a/libkc3/sw.c
+++ b/libkc3/sw.c
@@ -103,7 +103,7 @@ sw * sw_init_cast
   }
   if (true) {
     err_puts("sw_cast: stacktrace:");
-    err_inspect_list((const s_list * const *) &g_kc3_env.stacktrace);
+    err_inspect_list(g_kc3_env.stacktrace);
     err_write_1("\n");
   }
   assert(! "sw_cast: cannot cast to Sw");