Commit 0c94de125075e4fdaf7c3a70018a6bd10c24f0ca

Thomas de Grivel 2024-01-03T12:09:10

wip struct_type

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
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index f6e8c3c..b03fb82 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -1858,7 +1858,7 @@ sw buf_inspect_tag (s_buf *buf, const s_tag *tag)
   case TAG_STR:     return buf_inspect_str(buf, &tag->data.str);
   case TAG_STRUCT:  return buf_inspect_struct(buf, &tag->data.struct_);
   case TAG_STRUCT_TYPE:
-    return buf_inspect_struct_type(buf, tag->data.struct_type);
+    return buf_inspect_struct_type(buf, &tag->data.struct_type);
   case TAG_SYM:     return buf_inspect_sym(buf, &tag->data.sym);
   case TAG_TUPLE:   return buf_inspect_tuple(buf, &tag->data.tuple);
   case TAG_U8:      return buf_inspect_u8(buf, &tag->data.u8);
@@ -1907,7 +1907,7 @@ sw buf_inspect_tag_size (const s_tag *tag)
   case TAG_STR:      return buf_inspect_str_size(&tag->data.str);
   case TAG_STRUCT:   return buf_inspect_struct_size(&tag->data.struct_);
   case TAG_STRUCT_TYPE:
-    return buf_inspect_struct_type_size(tag->data.struct_type);
+    return buf_inspect_struct_type_size(&tag->data.struct_type);
   case TAG_SYM:      return buf_inspect_sym_size(&tag->data.sym);
   case TAG_TUPLE:    return buf_inspect_tuple_size(&tag->data.tuple);
   case TAG_U8:       return buf_inspect_u8_size(&tag->data.u8);
diff --git a/libc3/env.c b/libc3/env.c
index 5d52e7e..6c55dd4 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -1216,7 +1216,7 @@ s_struct_type * env_struct_type_find (s_env *env, const s_sym *module)
     assert(! "env_struct_type_find: invalid struct_type");
     return NULL;
   }
-  result = tag_var.data.struct_type;
+  result = &tag_var.data.struct_type;
   facts_cursor_clean(&cursor);
   return result;
 }
diff --git a/libc3/hash.c b/libc3/hash.c
index c09fb68..cc16942 100644
--- a/libc3/hash.c
+++ b/libc3/hash.c
@@ -420,7 +420,7 @@ bool hash_update_tag (t_hash *hash, const s_tag *tag)
   case TAG_STRUCT:
     return hash_update_struct(hash, &tag->data.struct_);
   case TAG_STRUCT_TYPE:
-    return hash_update_struct_type(hash, tag->data.struct_type);
+    return hash_update_struct_type(hash, &tag->data.struct_type);
   case TAG_SYM:   return hash_update_sym(hash, &tag->data.sym);
   case TAG_TUPLE: return hash_update_tuple(hash, &tag->data.tuple);
   case TAG_U8:    return hash_update_u8(hash, &tag->data.u8);
diff --git a/libc3/tag.c b/libc3/tag.c
index d0429b7..65346c3 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -36,6 +36,7 @@
 #include "quote.h"
 #include "str.h"
 #include "struct.h"
+#include "struct_type.h"
 #include "tag.h"
 #include "tag_type.h"
 #include "time.h"
@@ -185,7 +186,8 @@ void tag_clean (s_tag *tag)
   case TAG_QUOTE:       quote_clean(&tag->data.quote);            break;
   case TAG_STR:         str_clean(&tag->data.str);                break;
   case TAG_STRUCT:      struct_clean(&tag->data.struct_);         break;
-  case TAG_STRUCT_TYPE: struct_type_clean(tag->data.struct_type); break;
+  case TAG_STRUCT_TYPE:
+    struct_type_clean(&tag->data.struct_type);                    break;
   case TAG_TUPLE:       tuple_clean(&tag->data.tuple);            break;
   case TAG_BOOL:
   case TAG_CHARACTER:
@@ -289,6 +291,7 @@ s_tag * tag_init_copy (s_tag *tag, const s_tag *src)
   case TAG_S16:
   case TAG_S32:
   case TAG_S64:
+  case TAG_STRUCT_TYPE:
   case TAG_SW:
   case TAG_SYM:
   case TAG_U8:
@@ -660,39 +663,40 @@ bool tag_to_const_pointer (const s_tag *tag, const s_sym *type,
     return false;
   }
   switch (tag_type) {
-  case TAG_ARRAY:     *dest = &tag->data.array;      return true;
-  case TAG_BOOL:      *dest = &tag->data.bool;       return true;
-  case TAG_CALL:      *dest = &tag->data.call;       return true;
-  case TAG_CFN:       *dest = &tag->data.cfn;        return true;
-  case TAG_CHARACTER: *dest = &tag->data.character;  return true;
-  case TAG_F32:       *dest = &tag->data.f32;        return true;
-  case TAG_F64:       *dest = &tag->data.f64;        return true;
-  case TAG_FACT:      *dest = &tag->data.fact;       return true;
-  case TAG_FN:        *dest = &tag->data.fn;         return true;
-  case TAG_IDENT:     *dest = &tag->data.ident;      return true;
-  case TAG_INTEGER:   *dest = &tag->data.integer;    return true;
-  case TAG_SW:        *dest = &tag->data.sw;         return true;
-  case TAG_S64:       *dest = &tag->data.s64;        return true;
-  case TAG_S32:       *dest = &tag->data.s32;        return true;
-  case TAG_S16:       *dest = &tag->data.s16;        return true;
-  case TAG_S8:        *dest = &tag->data.s8;         return true;
-  case TAG_U8:        *dest = &tag->data.u8;         return true;
-  case TAG_U16:       *dest = &tag->data.u16;        return true;
-  case TAG_U32:       *dest = &tag->data.u32;        return true;
-  case TAG_U64:       *dest = &tag->data.u64;        return true;
-  case TAG_UW:        *dest = &tag->data.uw;         return true;
-  case TAG_LIST:      *dest = &tag->data.list;       return true;
-  case TAG_MAP:       *dest = &tag->data.map;        return true;
-  case TAG_PTAG:      *dest = &tag->data.ptag;       return true;
-  case TAG_PTR:       *dest = &tag->data.ptr.p;      return true;
-  case TAG_PTR_FREE:  *dest = &tag->data.ptr_free.p; return true;
-  case TAG_QUOTE:     *dest = &tag->data.quote;      return true;
-  case TAG_STR:       *dest = &tag->data.str;        return true;
-  case TAG_STRUCT:    *dest = &tag->data.struct_;    return true;
-  case TAG_SYM:       *dest = &tag->data.sym;        return true;
-  case TAG_TUPLE:     *dest = &tag->data.tuple;      return true;
-  case TAG_VAR:       *dest = NULL;                  return true;
-  case TAG_VOID:      *dest = NULL;                  return true;
+  case TAG_ARRAY:       *dest = &tag->data.array;       return true;
+  case TAG_BOOL:        *dest = &tag->data.bool;        return true;
+  case TAG_CALL:        *dest = &tag->data.call;        return true;
+  case TAG_CFN:         *dest = &tag->data.cfn;         return true;
+  case TAG_CHARACTER:   *dest = &tag->data.character;   return true;
+  case TAG_F32:         *dest = &tag->data.f32;         return true;
+  case TAG_F64:         *dest = &tag->data.f64;         return true;
+  case TAG_FACT:        *dest = &tag->data.fact;        return true;
+  case TAG_FN:          *dest = &tag->data.fn;          return true;
+  case TAG_IDENT:       *dest = &tag->data.ident;       return true;
+  case TAG_INTEGER:     *dest = &tag->data.integer;     return true;
+  case TAG_SW:          *dest = &tag->data.sw;          return true;
+  case TAG_S64:         *dest = &tag->data.s64;         return true;
+  case TAG_S32:         *dest = &tag->data.s32;         return true;
+  case TAG_S16:         *dest = &tag->data.s16;         return true;
+  case TAG_S8:          *dest = &tag->data.s8;          return true;
+  case TAG_U8:          *dest = &tag->data.u8;          return true;
+  case TAG_U16:         *dest = &tag->data.u16;         return true;
+  case TAG_U32:         *dest = &tag->data.u32;         return true;
+  case TAG_U64:         *dest = &tag->data.u64;         return true;
+  case TAG_UW:          *dest = &tag->data.uw;          return true;
+  case TAG_LIST:        *dest = &tag->data.list;        return true;
+  case TAG_MAP:         *dest = &tag->data.map;         return true;
+  case TAG_PTAG:        *dest = &tag->data.ptag;        return true;
+  case TAG_PTR:         *dest = &tag->data.ptr.p;       return true;
+  case TAG_PTR_FREE:    *dest = &tag->data.ptr_free.p;  return true;
+  case TAG_QUOTE:       *dest = &tag->data.quote;       return true;
+  case TAG_STR:         *dest = &tag->data.str;         return true;
+  case TAG_STRUCT:      *dest = &tag->data.struct_;     return true;
+  case TAG_STRUCT_TYPE: *dest = &tag->data.struct_type; return true;
+  case TAG_SYM:         *dest = &tag->data.sym;         return true;
+  case TAG_TUPLE:       *dest = &tag->data.tuple;       return true;
+  case TAG_VAR:         *dest = NULL;                   return true;
+  case TAG_VOID:        *dest = NULL;                   return true;
   }
   warnx("tag_to_const_pointer: invalid tag type: %s",
         tag_type_to_string(tag_type));
@@ -891,11 +895,17 @@ bool tag_to_ffi_pointer (s_tag *tag, const s_sym *type, void **dest)
       *dest = &tag->data.struct_;
       return true;
     }
-    if (type == tag->data.struct_.type.module) {
+    if (type == tag->data.struct_.type->module) {
       *dest = tag->data.struct_.data;
       return true;
     }
     goto invalid_cast;
+  case TAG_STRUCT_TYPE:
+    if (type == sym_1("StructType")) {
+      *dest = &tag->data.struct_type;
+      return true;
+    }
+    goto invalid_cast;
   case TAG_SYM:
     if (type == sym_1("Sym")) {
       *dest = (void *) &tag->data.sym;
@@ -942,39 +952,40 @@ bool tag_to_pointer (s_tag *tag, const s_sym *type, void **dest)
     return false;
   }
   switch (tag_type) {
-  case TAG_VOID:      *dest = NULL;                  return true;
-  case TAG_ARRAY:     *dest = &tag->data.array;      return true;
-  case TAG_BOOL:      *dest = &tag->data.bool;       return true;
-  case TAG_CALL:      *dest = &tag->data.call;       return true;
-  case TAG_CFN:       *dest = &tag->data.cfn;        return true;
-  case TAG_CHARACTER: *dest = &tag->data.character;  return true;
-  case TAG_F32:       *dest = &tag->data.f32;        return true;
-  case TAG_F64:       *dest = &tag->data.f64;        return true;
-  case TAG_FACT:      *dest = &tag->data.fact;       return true;
-  case TAG_FN:        *dest = &tag->data.fn;         return true;
-  case TAG_IDENT:     *dest = &tag->data.ident;      return true;
-  case TAG_INTEGER:   *dest = &tag->data.integer;    return true;
-  case TAG_SW:        *dest = &tag->data.sw;         return true;
-  case TAG_S64:       *dest = &tag->data.s64;        return true;
-  case TAG_S32:       *dest = &tag->data.s32;        return true;
-  case TAG_S16:       *dest = &tag->data.s16;        return true;
-  case TAG_S8:        *dest = &tag->data.s8;         return true;
-  case TAG_U8:        *dest = &tag->data.u8;         return true;
-  case TAG_U16:       *dest = &tag->data.u16;        return true;
-  case TAG_U32:       *dest = &tag->data.u32;        return true;
-  case TAG_U64:       *dest = &tag->data.u64;        return true;
-  case TAG_UW:        *dest = &tag->data.uw;         return true;
-  case TAG_LIST:      *dest = &tag->data.list;       return true;
-  case TAG_MAP:       *dest = &tag->data.map;        return true;
-  case TAG_PTAG:      *dest = &tag->data.ptag;       return true;
-  case TAG_PTR:       *dest = &tag->data.ptr.p;      return true;
-  case TAG_PTR_FREE:  *dest = &tag->data.ptr_free.p; return true;
-  case TAG_QUOTE:     *dest = &tag->data.quote;      return true;
-  case TAG_STR:       *dest = &tag->data.str;        return true;
-  case TAG_STRUCT:    *dest = &tag->data.struct_;    return true;
-  case TAG_SYM:       *dest = &tag->data.sym;        return true;
-  case TAG_TUPLE:     *dest = &tag->data.tuple;      return true;
-  case TAG_VAR:       *dest = NULL;                  return true;
+  case TAG_VOID:        *dest = NULL;                   return true;
+  case TAG_ARRAY:       *dest = &tag->data.array;       return true;
+  case TAG_BOOL:        *dest = &tag->data.bool;        return true;
+  case TAG_CALL:        *dest = &tag->data.call;        return true;
+  case TAG_CFN:         *dest = &tag->data.cfn;         return true;
+  case TAG_CHARACTER:   *dest = &tag->data.character;   return true;
+  case TAG_F32:         *dest = &tag->data.f32;         return true;
+  case TAG_F64:         *dest = &tag->data.f64;         return true;
+  case TAG_FACT:        *dest = &tag->data.fact;        return true;
+  case TAG_FN:          *dest = &tag->data.fn;          return true;
+  case TAG_IDENT:       *dest = &tag->data.ident;       return true;
+  case TAG_INTEGER:     *dest = &tag->data.integer;     return true;
+  case TAG_SW:          *dest = &tag->data.sw;          return true;
+  case TAG_S64:         *dest = &tag->data.s64;         return true;
+  case TAG_S32:         *dest = &tag->data.s32;         return true;
+  case TAG_S16:         *dest = &tag->data.s16;         return true;
+  case TAG_S8:          *dest = &tag->data.s8;          return true;
+  case TAG_U8:          *dest = &tag->data.u8;          return true;
+  case TAG_U16:         *dest = &tag->data.u16;         return true;
+  case TAG_U32:         *dest = &tag->data.u32;         return true;
+  case TAG_U64:         *dest = &tag->data.u64;         return true;
+  case TAG_UW:          *dest = &tag->data.uw;          return true;
+  case TAG_LIST:        *dest = &tag->data.list;        return true;
+  case TAG_MAP:         *dest = &tag->data.map;         return true;
+  case TAG_PTAG:        *dest = &tag->data.ptag;        return true;
+  case TAG_PTR:         *dest = &tag->data.ptr.p;       return true;
+  case TAG_PTR_FREE:    *dest = &tag->data.ptr_free.p;  return true;
+  case TAG_QUOTE:       *dest = &tag->data.quote;       return true;
+  case TAG_STR:         *dest = &tag->data.str;         return true;
+  case TAG_STRUCT:      *dest = &tag->data.struct_;     return true;
+  case TAG_STRUCT_TYPE: *dest = &tag->data.struct_type; return true;
+  case TAG_SYM:         *dest = &tag->data.sym;         return true;
+  case TAG_TUPLE:       *dest = &tag->data.tuple;       return true;
+  case TAG_VAR:         *dest = NULL;                   return true;
   }
   warnx("tag_to_pointer: invalid tag type: %d", tag_type);
   assert(! "tag_to_pointer: invalid tag type");
@@ -986,40 +997,41 @@ const s_sym ** tag_type (const s_tag *tag, const s_sym **dest)
   assert(tag);
   assert(dest);
   switch (tag->type) {
-  case TAG_VOID:       *dest = sym_1("Void");      return dest;
-  case TAG_ARRAY:      *dest = sym_1("Array");     return dest;
-  case TAG_BOOL:       *dest = sym_1("Bool");      return dest;
-  case TAG_CALL:       *dest = sym_1("Call");      return dest;
-  case TAG_CFN:        *dest = sym_1("Cfn");       return dest;
-  case TAG_CHARACTER:  *dest = sym_1("Character"); return dest;
-  case TAG_F32:        *dest = sym_1("F32");       return dest;
-  case TAG_F64:        *dest = sym_1("F64");       return dest;
-  case TAG_FACT:       *dest = sym_1("Fact");      return dest;
-  case TAG_FN:         *dest = sym_1("Fn");        return dest;
-  case TAG_IDENT:      *dest = sym_1("Ident");     return dest;
-  case TAG_INTEGER:    *dest = sym_1("Integer");   return dest;
-  case TAG_SW:         *dest = sym_1("Sw");        return dest;
-  case TAG_S64:        *dest = sym_1("S64");       return dest;
-  case TAG_S32:        *dest = sym_1("S32");       return dest;
-  case TAG_S16:        *dest = sym_1("S16");       return dest;
-  case TAG_S8:         *dest = sym_1("S8");        return dest;
-  case TAG_U8:         *dest = sym_1("U8");        return dest;
-  case TAG_U16:        *dest = sym_1("U16");       return dest;
-  case TAG_U32:        *dest = sym_1("U32");       return dest;
-  case TAG_U64:        *dest = sym_1("U64");       return dest;
-  case TAG_UW:         *dest = sym_1("Uw");        return dest;
-  case TAG_LIST:       *dest = sym_1("List");      return dest;
-  case TAG_MAP:        *dest = sym_1("Map");       return dest;
-  case TAG_PTAG:       *dest = sym_1("Ptag");      return dest;
-  case TAG_PTR:        *dest = sym_1("Ptr");       return dest;
-  case TAG_PTR_FREE:   *dest = sym_1("PtrFree");   return dest;
-  case TAG_QUOTE:      *dest = sym_1("Quote");     return dest;
-  case TAG_STR:        *dest = sym_1("Str");       return dest;
-  case TAG_STRUCT:     *dest = tag->data.struct_.type.module;
-                                                   return dest;
-  case TAG_SYM:        *dest = sym_1("Sym");       return dest;
-  case TAG_TUPLE:      *dest = sym_1("Tuple");     return dest;
-  case TAG_VAR:        *dest = sym_1("Var");       return dest;
+  case TAG_VOID:        *dest = sym_1("Void");       return dest;
+  case TAG_ARRAY:       *dest = sym_1("Array");      return dest;
+  case TAG_BOOL:        *dest = sym_1("Bool");       return dest;
+  case TAG_CALL:        *dest = sym_1("Call");       return dest;
+  case TAG_CFN:         *dest = sym_1("Cfn");        return dest;
+  case TAG_CHARACTER:   *dest = sym_1("Character");  return dest;
+  case TAG_F32:         *dest = sym_1("F32");        return dest;
+  case TAG_F64:         *dest = sym_1("F64");        return dest;
+  case TAG_FACT:        *dest = sym_1("Fact");       return dest;
+  case TAG_FN:          *dest = sym_1("Fn");         return dest;
+  case TAG_IDENT:       *dest = sym_1("Ident");      return dest;
+  case TAG_INTEGER:     *dest = sym_1("Integer");    return dest;
+  case TAG_SW:          *dest = sym_1("Sw");         return dest;
+  case TAG_S64:         *dest = sym_1("S64");        return dest;
+  case TAG_S32:         *dest = sym_1("S32");        return dest;
+  case TAG_S16:         *dest = sym_1("S16");        return dest;
+  case TAG_S8:          *dest = sym_1("S8");         return dest;
+  case TAG_U8:          *dest = sym_1("U8");         return dest;
+  case TAG_U16:         *dest = sym_1("U16");        return dest;
+  case TAG_U32:         *dest = sym_1("U32");        return dest;
+  case TAG_U64:         *dest = sym_1("U64");        return dest;
+  case TAG_UW:          *dest = sym_1("Uw");         return dest;
+  case TAG_LIST:        *dest = sym_1("List");       return dest;
+  case TAG_MAP:         *dest = sym_1("Map");        return dest;
+  case TAG_PTAG:        *dest = sym_1("Ptag");       return dest;
+  case TAG_PTR:         *dest = sym_1("Ptr");        return dest;
+  case TAG_PTR_FREE:    *dest = sym_1("PtrFree");    return dest;
+  case TAG_QUOTE:       *dest = sym_1("Quote");      return dest;
+  case TAG_STR:         *dest = sym_1("Str");        return dest;
+  case TAG_STRUCT:      *dest = tag->data.struct_.type->module;
+                                                     return dest;
+  case TAG_STRUCT_TYPE: *dest = sym_1("StructType"); return dest;
+  case TAG_SYM:         *dest = sym_1("Sym");        return dest;
+  case TAG_TUPLE:       *dest = sym_1("Tuple");      return dest;
+  case TAG_VAR:         *dest = sym_1("Var");        return dest;
   }
   warnx("tag_type: unknown tag type: %d", tag->type);
   assert(! "tag_type: unknown tag type");
diff --git a/libc3/tag_type.c b/libc3/tag_type.c
index 852ca47..c1545e2 100644
--- a/libc3/tag_type.c
+++ b/libc3/tag_type.c
@@ -16,538 +16,128 @@
 bool tag_type_size (e_tag_type type, uw *dest)
 {
   switch (type) {
-  case TAG_VOID:      *dest = 0;                 return true;
-  case TAG_ARRAY:     *dest = sizeof(s_array);   return true;
-  case TAG_BOOL:      *dest = sizeof(bool);      return true;
-  case TAG_CALL:      *dest = sizeof(s_call);    return true;
-  case TAG_CFN:       *dest = sizeof(s_cfn);     return true;
-  case TAG_CHARACTER: *dest = sizeof(character); return true;
-  case TAG_F32:       *dest = sizeof(f32);       return true;
-  case TAG_F64:       *dest = sizeof(f64);       return true;
-  case TAG_FACT:      *dest = sizeof(s_fact);    return true;
-  case TAG_FN:        *dest = sizeof(s_fn);      return true;
-  case TAG_IDENT:     *dest = sizeof(s_ident);   return true;
-  case TAG_INTEGER:   *dest = sizeof(s_integer); return true;
-  case TAG_SW:        *dest = sizeof(sw);        return true;
-  case TAG_S64:       *dest = sizeof(s64);       return true;
-  case TAG_S32:       *dest = sizeof(s32);       return true;
-  case TAG_S16:       *dest = sizeof(s16);       return true;
-  case TAG_S8:        *dest = sizeof(s8);        return true;
-  case TAG_U8:        *dest = sizeof(u8);        return true;
-  case TAG_U16:       *dest = sizeof(u16);       return true;
-  case TAG_U32:       *dest = sizeof(u32);       return true;
-  case TAG_U64:       *dest = sizeof(u64);       return true;
-  case TAG_UW:        *dest = sizeof(uw);        return true;
-  case TAG_LIST:      *dest = sizeof(s_list *);  return true;
-  case TAG_MAP:       *dest = sizeof(s_map);     return true;
-  case TAG_PTAG:      *dest = sizeof(p_tag);     return true;
+  case TAG_VOID:        *dest = 0;                     return true;
+  case TAG_ARRAY:       *dest = sizeof(s_array);       return true;
+  case TAG_BOOL:        *dest = sizeof(bool);          return true;
+  case TAG_CALL:        *dest = sizeof(s_call);        return true;
+  case TAG_CFN:         *dest = sizeof(s_cfn);         return true;
+  case TAG_CHARACTER:   *dest = sizeof(character);     return true;
+  case TAG_F32:         *dest = sizeof(f32);           return true;
+  case TAG_F64:         *dest = sizeof(f64);           return true;
+  case TAG_FACT:        *dest = sizeof(s_fact);        return true;
+  case TAG_FN:          *dest = sizeof(s_fn);          return true;
+  case TAG_IDENT:       *dest = sizeof(s_ident);       return true;
+  case TAG_INTEGER:     *dest = sizeof(s_integer);     return true;
+  case TAG_SW:          *dest = sizeof(sw);            return true;
+  case TAG_S64:         *dest = sizeof(s64);           return true;
+  case TAG_S32:         *dest = sizeof(s32);           return true;
+  case TAG_S16:         *dest = sizeof(s16);           return true;
+  case TAG_S8:          *dest = sizeof(s8);            return true;
+  case TAG_U8:          *dest = sizeof(u8);            return true;
+  case TAG_U16:         *dest = sizeof(u16);           return true;
+  case TAG_U32:         *dest = sizeof(u32);           return true;
+  case TAG_U64:         *dest = sizeof(u64);           return true;
+  case TAG_UW:          *dest = sizeof(uw);            return true;
+  case TAG_LIST:        *dest = sizeof(s_list *);      return true;
+  case TAG_MAP:         *dest = sizeof(s_map);         return true;
+  case TAG_PTAG:        *dest = sizeof(p_tag);         return true;
   case TAG_PTR:
-  case TAG_PTR_FREE:  *dest = sizeof(void *);    return true;
-  case TAG_QUOTE:     *dest = sizeof(s_quote);   return true;
-  case TAG_STR:       *dest = sizeof(s_str);     return true;
-  case TAG_STRUCT:    *dest = sizeof(s_struct);  return true;
-  case TAG_SYM:       *dest = sizeof(s_sym *);   return true;
-  case TAG_TUPLE:     *dest = sizeof(s_tuple);   return true;
-  case TAG_VAR:       *dest = 0;                 return true;
+  case TAG_PTR_FREE:    *dest = sizeof(void *);        return true;
+  case TAG_QUOTE:       *dest = sizeof(s_quote);       return true;
+  case TAG_STR:         *dest = sizeof(s_str);         return true;
+  case TAG_STRUCT:      *dest = sizeof(s_struct);      return true;
+  case TAG_STRUCT_TYPE: *dest = sizeof(s_struct_type); return true;
+  case TAG_SYM:         *dest = sizeof(s_sym *);       return true;
+  case TAG_TUPLE:       *dest = sizeof(s_tuple);       return true;
+  case TAG_VAR:         *dest = 0;                     return true;
   }
   warnx("tag_type_size: invalid tag type: %d", type);
   assert(! "tag_type_size: invalid tag type");
   return false;
 }
 
-/*
-bool tag_type_to_buf_inspect (e_tag_type type, f_buf_inspect *dest)
-{
-  switch (type) {
-  case TAG_VOID:
-    *dest = (f_buf_inspect) buf_inspect_void;      return true;
-  case TAG_ARRAY:
-    *dest = (f_buf_inspect) buf_inspect_array;     return true;
-  case TAG_BOOL:
-    *dest = (f_buf_inspect) buf_inspect_bool;      return true;
-  case TAG_CALL:
-    *dest = (f_buf_inspect) buf_inspect_call;      return true;
-  case TAG_CFN:
-    *dest = (f_buf_inspect) buf_inspect_cfn;       return true;
-  case TAG_CHARACTER:
-    *dest = (f_buf_inspect) buf_inspect_character; return true;
-  case TAG_F32:
-    *dest = (f_buf_inspect) buf_inspect_f32;       return true;
-  case TAG_F64:
-    *dest = (f_buf_inspect) buf_inspect_f64;       return true;
-  case TAG_FACT:
-    *dest = (f_buf_inspect) buf_inspect_fact;      return true;
-  case TAG_FN:
-    *dest = (f_buf_inspect) buf_inspect_fn;        return true;
-  case TAG_IDENT:
-    *dest = (f_buf_inspect) buf_inspect_ident;     return true;
-  case TAG_INTEGER:
-    *dest = (f_buf_inspect) buf_inspect_integer;   return true;
-  case TAG_SW:
-    *dest = (f_buf_inspect) buf_inspect_sw;        return true;
-  case TAG_S64:
-    *dest = (f_buf_inspect) buf_inspect_s64;       return true;
-  case TAG_S32:
-    *dest = (f_buf_inspect) buf_inspect_s32;       return true;
-  case TAG_S16:
-    *dest = (f_buf_inspect) buf_inspect_s16;       return true;
-  case TAG_S8:
-    *dest = (f_buf_inspect) buf_inspect_s8;        return true;
-  case TAG_U8:
-    *dest = (f_buf_inspect) buf_inspect_u8;        return true;
-  case TAG_U16:
-    *dest = (f_buf_inspect) buf_inspect_u16;       return true;
-  case TAG_U32:
-    *dest = (f_buf_inspect) buf_inspect_u32;       return true;
-  case TAG_U64:
-    *dest = (f_buf_inspect) buf_inspect_u64;       return true;
-  case TAG_UW:
-    *dest = (f_buf_inspect) buf_inspect_uw;        return true;
-  case TAG_LIST:
-    *dest = (f_buf_inspect) buf_inspect_list;      return true;
-  case TAG_MAP:
-    *dest = (f_buf_inspect) buf_inspect_map;       return true;
-  case TAG_PTAG:
-    *dest = (f_buf_inspect) buf_inspect_ptag;      return true;
-  case TAG_PTR:
-    *dest = (f_buf_inspect) buf_inspect_ptr;       return true;
-  case TAG_PTR_FREE:
-    *dest = (f_buf_inspect) buf_inspect_ptr_free;  return true;
-  case TAG_QUOTE:
-    *dest = (f_buf_inspect) buf_inspect_quote;     return true;
-  case TAG_STR:
-    *dest = (f_buf_inspect) buf_inspect_str;       return true;
-  case TAG_STRUCT:
-    *dest = (f_buf_inspect) buf_inspect_struct;    return true;
-  case TAG_SYM:
-    *dest = (f_buf_inspect) buf_inspect_sym;       return true;
-  case TAG_TUPLE:
-    *dest = (f_buf_inspect) buf_inspect_tuple;     return true;
-  case TAG_VAR:
-    *dest = (f_buf_inspect) buf_inspect_var;       return true;
-  }
-  warnx("buf_inspect: unknown tag type: %d", type);
-  assert(! "buf_inspect: unknown tag type");
-  return false;
-}
-
-bool tag_type_to_buf_inspect_size (e_tag_type type,
-                                   f_buf_inspect_size *p)
-{
-  switch (type) {
-  case TAG_VOID:
-    *p = (f_buf_inspect_size) buf_inspect_void_size;        return true;
-  case TAG_ARRAY:
-    *p = (f_buf_inspect_size) buf_inspect_array_size;       return true;
-  case TAG_BOOL:
-    *p = (f_buf_inspect_size) buf_inspect_bool_size;        return true;
-  case TAG_CALL:
-    *p = (f_buf_inspect_size) buf_inspect_call_size;        return true;
-  case TAG_CFN:
-     *p = (f_buf_inspect_size) buf_inspect_cfn_size;        return true;
-  case TAG_CHARACTER:
-    *p = (f_buf_inspect_size) buf_inspect_character_size;   return true;
-  case TAG_F32:
-     *p = (f_buf_inspect_size) buf_inspect_f32_size;        return true;
-  case TAG_F64:
-     *p = (f_buf_inspect_size) buf_inspect_f64_size;        return true;
-  case TAG_FACT:
-    *p = (f_buf_inspect_size) buf_inspect_fact_size;        return true;
-  case TAG_FN:
-      *p = (f_buf_inspect_size) buf_inspect_fn_size;        return true;
-  case TAG_IDENT:
-   *p = (f_buf_inspect_size) buf_inspect_ident_size;        return true;
-  case TAG_INTEGER:
-    *p = (f_buf_inspect_size) buf_inspect_integer_size;     return true;
-  case TAG_SW:
-      *p = (f_buf_inspect_size) buf_inspect_sw_size;        return true;
-  case TAG_S64:
-     *p = (f_buf_inspect_size) buf_inspect_s64_size;        return true;
-  case TAG_S32:
-    *p = (f_buf_inspect_size) buf_inspect_s32_size;         return true;
-  case TAG_S16:
-    *p = (f_buf_inspect_size) buf_inspect_s16_size;         return true;
-  case TAG_S8:
-    *p = (f_buf_inspect_size) buf_inspect_s8_size;          return true;
-  case TAG_U8:
-    *p = (f_buf_inspect_size) buf_inspect_u8_size;          return true;
-  case TAG_U16:
-    *p = (f_buf_inspect_size) buf_inspect_u16_size;         return true;
-  case TAG_U32:
-    *p = (f_buf_inspect_size) buf_inspect_u32_size;         return true;
-  case TAG_U64:
-    *p = (f_buf_inspect_size) buf_inspect_u64_size;         return true;
-  case TAG_UW:
-    *p = (f_buf_inspect_size) buf_inspect_uw_size;          return true;
-  case TAG_LIST:
-    *p = (f_buf_inspect_size) buf_inspect_list_size;        return true;
-  case TAG_MAP:
-    *p = (f_buf_inspect_size) buf_inspect_map_size;         return true;
-  case TAG_PTAG:
-    *p = (f_buf_inspect_size) buf_inspect_ptag_size;        return true;
-  case TAG_PTR:
-    *p = (f_buf_inspect_size) buf_inspect_ptr_size;         return true;
-  case TAG_PTR_FREE:
-    *p = (f_buf_inspect_size) buf_inspect_ptr_free_size;    return true;
-  case TAG_QUOTE:
-    *p = (f_buf_inspect_size) buf_inspect_quote_size;       return true;
-  case TAG_STR:
-    *p = (f_buf_inspect_size) buf_inspect_str_size;         return true;
-  case TAG_STRUCT:
-    *p = (f_buf_inspect_size) buf_inspect_struct_size;      return true;
-  case TAG_SYM:
-    *p = (f_buf_inspect_size) buf_inspect_sym_size;         return true;
-  case TAG_TUPLE:
-    *p = (f_buf_inspect_size) buf_inspect_tuple_size;       return true;
-  case TAG_VAR:
-    *p = (f_buf_inspect_size) buf_inspect_var_size;         return true;
-  }
-  warnx("tag_type_to_buf_inspect_size: unknown tag type: %d", type);
-  assert(! "tag_type_to_buf_inspect_size: unknown tag type");
-  return false;
-}
-
-bool tag_type_to_buf_parse (e_tag_type type, f_buf_parse *p)
-{
-  switch (type) {
-  case TAG_VOID:      *p = (f_buf_parse) buf_parse_void;    return true;
-  case TAG_ARRAY:     *p = (f_buf_parse) buf_parse_array;   return true;
-  case TAG_BOOL:      *p = (f_buf_parse) buf_parse_bool;    return true;
-  case TAG_CALL:      *p = (f_buf_parse) buf_parse_call;    return true;
-  case TAG_CFN:       *p = (f_buf_parse) buf_parse_cfn;     return true;
-  case TAG_CHARACTER: *p = (f_buf_parse) buf_parse_character;  return 1;
-  case TAG_F32:       *p = (f_buf_parse) buf_parse_f32;     return true;
-  case TAG_F64:       *p = (f_buf_parse) buf_parse_f64;     return true;
-  case TAG_FACT:      *p = (f_buf_parse) buf_parse_fact;    return true;
-  case TAG_FN:        *p = (f_buf_parse) buf_parse_fn;      return true;
-  case TAG_IDENT:     *p = (f_buf_parse) buf_parse_ident;   return true;
-  case TAG_INTEGER:   *p = (f_buf_parse) buf_parse_integer; return true;
-  case TAG_SW:        *p = (f_buf_parse) buf_parse_sw;      return true;
-  case TAG_S64:       *p = (f_buf_parse) buf_parse_s64;     return true;
-  case TAG_S32:       *p = (f_buf_parse) buf_parse_s32;     return true;
-  case TAG_S16:       *p = (f_buf_parse) buf_parse_s16;     return true;
-  case TAG_S8:        *p = (f_buf_parse) buf_parse_s8;      return true;
-  case TAG_U8:        *p = (f_buf_parse) buf_parse_u8;      return true;
-  case TAG_U16:       *p = (f_buf_parse) buf_parse_u16;     return true;
-  case TAG_U32:       *p = (f_buf_parse) buf_parse_u32;     return true;
-  case TAG_U64:       *p = (f_buf_parse) buf_parse_u64;     return true;
-  case TAG_UW:        *p = (f_buf_parse) buf_parse_uw;      return true;
-  case TAG_LIST:      *p = (f_buf_parse) buf_parse_list;    return true;
-  case TAG_MAP:       *p = (f_buf_parse) buf_parse_map;     return true;
-  case TAG_PTAG:      *p = (f_buf_parse) buf_parse_ptag;    return true;
-  case TAG_PTR:       *p = (f_buf_parse) buf_parse_ptr;     return true;
-  case TAG_PTR_FREE:  *p = (f_buf_parse) buf_parse_ptr_free;   return 1;
-  case TAG_QUOTE:     *p = (f_buf_parse) buf_parse_quote;   return true;
-  case TAG_STR:       *p = (f_buf_parse) buf_parse_str;     return true;
-  case TAG_STRUCT:    *p = (f_buf_parse) buf_parse_struct;  return true;
-  case TAG_SYM:       *p = (f_buf_parse) buf_parse_sym;     return true;
-  case TAG_TUPLE:     *p = (f_buf_parse) buf_parse_tuple;   return true;
-  case TAG_VAR:       *p = (f_buf_parse) buf_parse_var;     return true;
-  }
-  warnx("tag_type_to_buf_parse: invalid tag type: %d", type);
-  assert(! "tag_type_to_buf_parse: invalid tag type");
-  return false;
-}
-
-bool tag_type_to_env_eval (e_tag_type type, f_env_eval *dest)
-{
-  switch (type) {
-  case TAG_VOID:   *dest = (f_env_eval) env_eval_void;      return true;
-  case TAG_ARRAY:  *dest = (f_env_eval) env_eval_array_tag; return true;
-  case TAG_CALL:   *dest = (f_env_eval) env_eval_call;      return true;
-  case TAG_IDENT:  *dest = (f_env_eval) env_eval_ident;     return true;
-  case TAG_LIST:   *dest = (f_env_eval) env_eval_list;      return true;
-  case TAG_MAP:    *dest = (f_env_eval) env_eval_map;       return true;
-  case TAG_QUOTE:  *dest = (f_env_eval) env_eval_quote;     return true;
-  case TAG_STRUCT: *dest = (f_env_eval) env_eval_struct;    return true;
-  case TAG_TUPLE:  *dest = (f_env_eval) env_eval_tuple;     return true;
-  case TAG_BOOL:
-  case TAG_CFN:
-  case TAG_CHARACTER:
-  case TAG_F32:
-  case TAG_F64:
-  case TAG_FACT:
-  case TAG_FN:
-  case TAG_INTEGER:
-  case TAG_PTAG:
-  case TAG_PTR:
-  case TAG_PTR_FREE:
-  case TAG_S8:
-  case TAG_S16:
-  case TAG_S32:
-  case TAG_S64:
-  case TAG_SW:
-  case TAG_STR:
-  case TAG_SYM:
-  case TAG_U8:
-  case TAG_U16:
-  case TAG_U32:
-  case TAG_U64:
-  case TAG_UW:
-  case TAG_VAR:    *dest = NULL;                            return true;
-  }
-  warnx("tag_type_to_env_eval: unknown tag type: %d", type);
-  assert(! "tag_type_to_env_eval: unknown tag type");
-  return false;
-}
-*/
-
 bool tag_type_to_ffi_type (e_tag_type type, ffi_type **dest)
 {
   switch (type) {
-  case TAG_ARRAY:     *dest = &ffi_type_pointer; return true;
-  case TAG_BOOL:      *dest = &ffi_type_uint8;   return true;
-  case TAG_CALL:      *dest = &ffi_type_pointer; return true;
-  case TAG_CFN:       *dest = &ffi_type_pointer; return true;
-  case TAG_CHARACTER: *dest = &ffi_type_schar;   return true;
-  case TAG_F32:       *dest = &ffi_type_float;   return true;
-  case TAG_F64:       *dest = &ffi_type_double;  return true;
-  case TAG_FACT:      *dest = &ffi_type_pointer; return true;
-  case TAG_FN:        *dest = &ffi_type_pointer; return true;
-  case TAG_IDENT:     *dest = &ffi_type_pointer; return true;
-  case TAG_INTEGER:   *dest = &ffi_type_sint;    return true;
-  case TAG_LIST:      *dest = &ffi_type_pointer; return true;
-  case TAG_MAP:       *dest = &ffi_type_pointer; return true;
-  case TAG_PTAG:      *dest = &ffi_type_pointer; return true;
-  case TAG_PTR:       *dest = &ffi_type_pointer; return true;
-  case TAG_PTR_FREE:  *dest = &ffi_type_pointer; return true;
-  case TAG_QUOTE:     *dest = &ffi_type_pointer; return true;
-  case TAG_S8:        *dest = &ffi_type_sint8;   return true;
-  case TAG_S16:       *dest = &ffi_type_sint16;  return true;
-  case TAG_S32:       *dest = &ffi_type_sint32;  return true;
-  case TAG_S64:       *dest = &ffi_type_sint64;  return true;
-  case TAG_SW:        *dest = &ffi_type_slong;   return true;
-  case TAG_STR:       *dest = &ffi_type_pointer; return true;
-  case TAG_STRUCT:    *dest = &ffi_type_pointer; return true;
-  case TAG_SYM:       *dest = &ffi_type_pointer; return true;
-  case TAG_TUPLE:     *dest = &ffi_type_pointer; return true;
-  case TAG_U8:        *dest = &ffi_type_uint8;   return true;
-  case TAG_U16:       *dest = &ffi_type_uint16;  return true;
-  case TAG_U32:       *dest = &ffi_type_uint32;  return true;
-  case TAG_U64:       *dest = &ffi_type_uint64;  return true;
-  case TAG_UW:        *dest = &ffi_type_ulong;   return true;
-  case TAG_VAR:       *dest = &ffi_type_pointer; return true;
-  case TAG_VOID:      *dest = &ffi_type_void;    return true;
+  case TAG_ARRAY:       *dest = &ffi_type_pointer; return true;
+  case TAG_BOOL:        *dest = &ffi_type_uint8;   return true;
+  case TAG_CALL:        *dest = &ffi_type_pointer; return true;
+  case TAG_CFN:         *dest = &ffi_type_pointer; return true;
+  case TAG_CHARACTER:   *dest = &ffi_type_schar;   return true;
+  case TAG_F32:         *dest = &ffi_type_float;   return true;
+  case TAG_F64:         *dest = &ffi_type_double;  return true;
+  case TAG_FACT:        *dest = &ffi_type_pointer; return true;
+  case TAG_FN:          *dest = &ffi_type_pointer; return true;
+  case TAG_IDENT:       *dest = &ffi_type_pointer; return true;
+  case TAG_INTEGER:     *dest = &ffi_type_sint;    return true;
+  case TAG_LIST:        *dest = &ffi_type_pointer; return true;
+  case TAG_MAP:         *dest = &ffi_type_pointer; return true;
+  case TAG_PTAG:        *dest = &ffi_type_pointer; return true;
+  case TAG_PTR:         *dest = &ffi_type_pointer; return true;
+  case TAG_PTR_FREE:    *dest = &ffi_type_pointer; return true;
+  case TAG_QUOTE:       *dest = &ffi_type_pointer; return true;
+  case TAG_S8:          *dest = &ffi_type_sint8;   return true;
+  case TAG_S16:         *dest = &ffi_type_sint16;  return true;
+  case TAG_S32:         *dest = &ffi_type_sint32;  return true;
+  case TAG_S64:         *dest = &ffi_type_sint64;  return true;
+  case TAG_SW:          *dest = &ffi_type_slong;   return true;
+  case TAG_STR:         *dest = &ffi_type_pointer; return true;
+  case TAG_STRUCT:      *dest = &ffi_type_pointer; return true;
+  case TAG_STRUCT_TYPE: *dest = &ffi_type_pointer; return true;
+  case TAG_SYM:         *dest = &ffi_type_pointer; return true;
+  case TAG_TUPLE:       *dest = &ffi_type_pointer; return true;
+  case TAG_U8:          *dest = &ffi_type_uint8;   return true;
+  case TAG_U16:         *dest = &ffi_type_uint16;  return true;
+  case TAG_U32:         *dest = &ffi_type_uint32;  return true;
+  case TAG_U64:         *dest = &ffi_type_uint64;  return true;
+  case TAG_UW:          *dest = &ffi_type_ulong;   return true;
+  case TAG_VAR:         *dest = &ffi_type_pointer; return true;
+  case TAG_VOID:        *dest = &ffi_type_void;    return true;
   }
   warnx("tag_type_to_ffi_type: unknown tag type: %d", type);
   assert(! "tag_type_to_ffi_type: unknown tag type");
   return false;
 }
 
-/*
-bool tag_type_to_hash_update (e_tag_type type, f_hash_update *p)
-{
-  switch (type) {
-  case TAG_VOID:   *p = (f_hash_update) hash_update_void;   return true;
-  case TAG_ARRAY:  *p = (f_hash_update) hash_update_array;  return true;
-  case TAG_BOOL:   *p = (f_hash_update) hash_update_bool;   return true;
-  case TAG_CALL:   *p = (f_hash_update) hash_update_call;   return true;
-  case TAG_CFN:    *p = (f_hash_update) hash_update_cfn;    return true;
-  case TAG_CHARACTER:
-    *p = (f_hash_update) hash_update_character;             return true;
-  case TAG_F32:    *p = (f_hash_update) hash_update_f32;    return true;
-  case TAG_F64:    *p = (f_hash_update) hash_update_f64;    return true;
-  case TAG_FACT:   *p = (f_hash_update) hash_update_fact;   return true;
-  case TAG_FN:     *p = (f_hash_update) hash_update_fn;     return true;
-  case TAG_IDENT:  *p = (f_hash_update) hash_update_ident;  return true;
-  case TAG_INTEGER:
-    *p = (f_hash_update) hash_update_integer;               return true;
-  case TAG_SW:     *p = (f_hash_update) hash_update_sw;     return true;
-  case TAG_S64:    *p = (f_hash_update) hash_update_s64;    return true;
-  case TAG_S32:    *p = (f_hash_update) hash_update_s32;    return true;
-  case TAG_S16:    *p = (f_hash_update) hash_update_s16;    return true;
-  case TAG_S8:     *p = (f_hash_update) hash_update_s8;     return true;
-  case TAG_U8:     *p = (f_hash_update) hash_update_u8;     return true;
-  case TAG_U16:    *p = (f_hash_update) hash_update_u16;    return true;
-  case TAG_U32:    *p = (f_hash_update) hash_update_u32;    return true;
-  case TAG_U64:    *p = (f_hash_update) hash_update_u64;    return true;
-  case TAG_UW:     *p = (f_hash_update) hash_update_uw;     return true;
-  case TAG_LIST:   *p = (f_hash_update) hash_update_list;   return true;
-  case TAG_MAP:    *p = (f_hash_update) hash_update_map;    return true;
-  case TAG_PTAG:   *p = (f_hash_update) hash_update_ptag;   return true;
-  case TAG_PTR:    *p = (f_hash_update) hash_update_ptr;    return true;
-  case TAG_PTR_FREE:
-    *p = (f_hash_update) hash_update_ptr_free;              return true;
-  case TAG_QUOTE:  *p = (f_hash_update) hash_update_quote;  return true;
-  case TAG_STR:    *p = (f_hash_update) hash_update_str;    return true;
-  case TAG_STRUCT: *p = (f_hash_update) hash_update_struct; return true;
-  case TAG_SYM:    *p = (f_hash_update) hash_update_sym;    return true;
-  case TAG_TUPLE:  *p = (f_hash_update) hash_update_tuple;  return true;
-  case TAG_VAR:    *p = (f_hash_update) hash_update_var;    return true;
-  }
-  warnx("tag_type_to_hash_update: unknown tag type: %d", type);
-  assert(! "tag_type_to_hash_update: unknown tag type");
-  return false;
-}
-
-bool tag_type_to_init_cast (e_tag_type type, f_init_cast *p)
-{
-  switch (type) {
-  case TAG_VOID:     *p = NULL;                             return true;
-  case TAG_ARRAY:    *p = (f_init_cast) array_init_cast;    return true;
-  case TAG_BOOL:     *p = (f_init_cast) bool_init_cast;     return true;
-  case TAG_CALL:     *p = (f_init_cast) call_init_cast;     return true;
-  case TAG_CFN:      *p = (f_init_cast) cfn_init_cast;      return true;
-  case TAG_CHARACTER:
-    *p = (f_init_cast) character_init_cast;                 return true;
-  case TAG_F32:      *p = (f_init_cast) f32_init_cast;      return true;
-  case TAG_F64:      *p = (f_init_cast) f64_init_cast;      return true;
-  case TAG_FACT:     *p = (f_init_cast) fact_init_cast;     return true;
-  case TAG_FN:       *p = (f_init_cast) fn_init_cast;       return true;
-  case TAG_IDENT:    *p = (f_init_cast) ident_init_cast;    return true;
-  case TAG_INTEGER:  *p = (f_init_cast) integer_init_cast;  return true;
-  case TAG_SW:       *p = (f_init_cast) sw_init_cast;       return true;
-  case TAG_S64:      *p = (f_init_cast) s64_init_cast;      return true;
-  case TAG_S32:      *p = (f_init_cast) s32_init_cast;      return true;
-  case TAG_S16:      *p = (f_init_cast) s16_init_cast;      return true;
-  case TAG_S8:       *p = (f_init_cast) s8_init_cast;       return true;
-  case TAG_U8:       *p = (f_init_cast) u8_init_cast;       return true;
-  case TAG_U16:      *p = (f_init_cast) u16_init_cast;      return true;
-  case TAG_U32:      *p = (f_init_cast) u32_init_cast;      return true;
-  case TAG_U64:      *p = (f_init_cast) u64_init_cast;      return true;
-  case TAG_UW:       *p = (f_init_cast) uw_init_cast;       return true;
-  case TAG_LIST:     *p = (f_init_cast) list_init_cast;     return true;
-  case TAG_MAP:      *p = (f_init_cast) map_init_cast;      return true;
-  case TAG_PTAG:     *p = (f_init_cast) ptag_init_cast;     return true;
-  case TAG_PTR:      *p = (f_init_cast) ptr_init_cast;      return true;
-  case TAG_PTR_FREE: *p = (f_init_cast) ptr_free_init_cast; return true;
-  case TAG_QUOTE:    *p = (f_init_cast) quote_init_cast;    return true;
-  case TAG_STR:      *p = (f_init_cast) str_init_cast;      return true;
-  case TAG_STRUCT:   *p = (f_init_cast) struct_init_cast;   return true;
-  case TAG_SYM:      *p = (f_init_cast) sym_init_cast;      return true;
-  case TAG_TUPLE:    *p = (f_init_cast) tuple_init_cast;    return true;
-  case TAG_VAR:      *p = NULL;                             return true;
-  }
-  warnx("tag_type_to_init_cast: invalid tag type: %d", type);
-  assert(! "tag_type_to_init_cast: invalid tag type");
-  return false;
-}
-
-bool tag_type_to_init_copy (e_tag_type type, f_init_copy *p)
-{
-  switch (type) {
-  case TAG_ARRAY:     *p = (f_init_copy) array_init_copy;   return true;
-  case TAG_BOOL:      *p = (f_init_copy) bool_init_copy;    return true;
-  case TAG_CALL:      *p = (f_init_copy) call_init_copy;    return true;
-  case TAG_CFN:       *p = (f_init_copy) cfn_init_copy;     return true;
-  case TAG_CHARACTER: *p = (f_init_copy) character_init_copy;  return 1;
-  case TAG_F32:       *p = (f_init_copy) f32_init_copy;     return true;
-  case TAG_F64:       *p = (f_init_copy) f64_init_copy;     return true;
-  case TAG_FACT:      *p = (f_init_copy) fact_init_copy;    return true;
-  case TAG_FN:        *p = (f_init_copy) fn_init_copy;      return true;
-  case TAG_IDENT:     *p = (f_init_copy) ident_init_copy;   return true;
-  case TAG_INTEGER:   *p = (f_init_copy) integer_init_copy; return true;
-  case TAG_SW:        *p = (f_init_copy) sw_init_copy;      return true;
-  case TAG_S64:       *p = (f_init_copy) s64_init_copy;     return true;
-  case TAG_S32:       *p = (f_init_copy) s32_init_copy;     return true;
-  case TAG_S16:       *p = (f_init_copy) s16_init_copy;     return true;
-  case TAG_S8:        *p = (f_init_copy) s8_init_copy;      return true;
-  case TAG_U8:        *p = (f_init_copy) u8_init_copy;      return true;
-  case TAG_U16:       *p = (f_init_copy) u16_init_copy;     return true;
-  case TAG_U32:       *p = (f_init_copy) u32_init_copy;     return true;
-  case TAG_U64:       *p = (f_init_copy) u64_init_copy;     return true;
-  case TAG_UW:        *p = (f_init_copy) uw_init_copy;      return true;
-  case TAG_LIST:      *p = (f_init_copy) list_init_copy;    return true;
-  case TAG_MAP:       *p = (f_init_copy) map_init_copy;     return true;
-  case TAG_PTAG:      *p = (f_init_copy) ptag_init_copy;    return true;
-  case TAG_PTR:       *p = (f_init_copy) ptr_init_copy;     return true;
-  case TAG_PTR_FREE:  *p = (f_init_copy) ptr_free_init_copy;   return 1;
-  case TAG_QUOTE:     *p = (f_init_copy) quote_init_copy;   return true;
-  case TAG_STR:       *p = (f_init_copy) str_init_copy;     return true;
-  case TAG_STRUCT:    *p = (f_init_copy) struct_init_copy;  return true;
-  case TAG_SYM:       *p = (f_init_copy) sym_init_copy;     return true;
-  case TAG_TUPLE:     *p = (f_init_copy) tuple_init_copy;   return true;
-  case TAG_VAR:       *p = NULL;                            return true;
-  case TAG_VOID:      *p = NULL;                            return true;
-  }
-  warnx("tag_type_to_init_copy: invalid tag type: %d", type);
-  assert(! "tag_type_to_init_copy: invalid tag type");
-  return false;
-}
-*/
-
 const s8 * tag_type_to_string (e_tag_type tag_type)
 {
   switch (tag_type) {
-  case TAG_VOID:      return "Void";
-  case TAG_ARRAY:     return "Array";
-  case TAG_BOOL:      return "Bool";
-  case TAG_CALL:      return "Call";
-  case TAG_CFN:       return "Cfn";
-  case TAG_CHARACTER: return "Character";
-  case TAG_F32:       return "F32";
-  case TAG_F64:       return "F64";
-  case TAG_FACT:      return "Fact";
-  case TAG_FN:        return "Fn";
-  case TAG_IDENT:     return "Ident";
-  case TAG_INTEGER:   return "Integer";
-  case TAG_SW:        return "Sw";
-  case TAG_S64:       return "S64";
-  case TAG_S32:       return "S32";
-  case TAG_S16:       return "S16";
-  case TAG_S8:        return "S8";
-  case TAG_U8:        return "U8";
-  case TAG_U16:       return "U16";
-  case TAG_U32:       return "U32";
-  case TAG_U64:       return "U64";
-  case TAG_UW:        return "Uw";
-  case TAG_LIST:      return "List";
-  case TAG_MAP:       return "Map";
-  case TAG_PTAG:      return "Ptag";
-  case TAG_PTR:       return "Ptr";
-  case TAG_PTR_FREE:  return "PtrFree";
-  case TAG_QUOTE:     return "Quote";
-  case TAG_STR:       return "Str";
-  case TAG_STRUCT:    return "Struct";
-  case TAG_SYM:       return "Sym";
-  case TAG_TUPLE:     return "Tuple";
-  case TAG_VAR:       return "Var";
+  case TAG_VOID:        return "Void";
+  case TAG_ARRAY:       return "Array";
+  case TAG_BOOL:        return "Bool";
+  case TAG_CALL:        return "Call";
+  case TAG_CFN:         return "Cfn";
+  case TAG_CHARACTER:   return "Character";
+  case TAG_F32:         return "F32";
+  case TAG_F64:         return "F64";
+  case TAG_FACT:        return "Fact";
+  case TAG_FN:          return "Fn";
+  case TAG_IDENT:       return "Ident";
+  case TAG_INTEGER:     return "Integer";
+  case TAG_SW:          return "Sw";
+  case TAG_S64:         return "S64";
+  case TAG_S32:         return "S32";
+  case TAG_S16:         return "S16";
+  case TAG_S8:          return "S8";
+  case TAG_U8:          return "U8";
+  case TAG_U16:         return "U16";
+  case TAG_U32:         return "U32";
+  case TAG_U64:         return "U64";
+  case TAG_UW:          return "Uw";
+  case TAG_LIST:        return "List";
+  case TAG_MAP:         return "Map";
+  case TAG_PTAG:        return "Ptag";
+  case TAG_PTR:         return "Ptr";
+  case TAG_PTR_FREE:    return "PtrFree";
+  case TAG_QUOTE:       return "Quote";
+  case TAG_STR:         return "Str";
+  case TAG_STRUCT:      return "Struct";
+  case TAG_STRUCT_TYPE: return "StructType";
+  case TAG_SYM:         return "Sym";
+  case TAG_TUPLE:       return "Tuple";
+  case TAG_VAR:         return "Var";
   }
   warnx("tag_type_to_string: unknown tag type: %d", tag_type);
   assert(! "tag_type_to_string: unknown tag type");
   return NULL;
 }
-
-/*
-const s_sym * tag_type_to_sym (e_tag_type tag_type)
-{
-  switch (tag_type) {
-  case TAG_VOID:       return sym_1("Void");
-  case TAG_ARRAY:      return sym_1("Array");
-  case TAG_BOOL:       return sym_1("Bool");
-  case TAG_CALL:       return sym_1("Call");
-  case TAG_CFN:        return sym_1("Cfn");
-  case TAG_CHARACTER:  return sym_1("Character");
-  case TAG_F32:        return sym_1("F32");
-  case TAG_F64:        return sym_1("F64");
-  case TAG_FACT:       return sym_1("Fact");
-  case TAG_FN:         return sym_1("Fn");
-  case TAG_IDENT:      return sym_1("Ident");
-  case TAG_INTEGER:    return sym_1("Integer");
-  case TAG_SW:         return sym_1("Sw");
-  case TAG_S64:        return sym_1("S64");
-  case TAG_S32:        return sym_1("S32");
-  case TAG_S16:        return sym_1("S16");
-  case TAG_S8:         return sym_1("S8");
-  case TAG_U8:         return sym_1("U8");
-  case TAG_U16:        return sym_1("U16");
-  case TAG_U32:        return sym_1("U32");
-  case TAG_U64:        return sym_1("U64");
-  case TAG_UW:         return sym_1("Uw");
-  case TAG_LIST:       return sym_1("List");
-  case TAG_MAP:        return sym_1("Map");
-  case TAG_PTAG:       return sym_1("Ptag");
-  case TAG_PTR:        return sym_1("Ptr");
-  case TAG_PTR_FREE:   return sym_1("PtrFree");
-  case TAG_QUOTE:      return sym_1("Quote");
-  case TAG_STR:        return sym_1("Str");
-  case TAG_STRUCT:     return sym_1("Struct");
-  case TAG_SYM:        return sym_1("Sym");
-  case TAG_TUPLE:      return sym_1("Tuple");
-  case TAG_VAR:        return sym_1("Var");
-  }
-  assert(! "tag_type_to_sym: invalid tag type");
-  errx(1, "tag_type_to_sym: invalid tag type: %d", tag_type);
-  return NULL;
-}
-*/
diff --git a/libc3/types.h b/libc3/types.h
index cf67e5c..659d875 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -387,38 +387,38 @@ struct float_s {
 
 /* 5 */
 union tag_data {
-  s_array        array;
-  bool           bool;
-  s_call         call;
-  s_cfn          cfn;
-  character      character;
-  f32            f32;
-  f64            f64;
-  s_fact         fact;
-  s_fn           fn;
-  s_ident        ident;
-  s_integer      integer;
-  s_list        *list;
-  s_map          map;
-  p_tag          ptag;
-  u_ptr_w        ptr;
-  u_ptr_w        ptr_free;
-  s_quote        quote;
-  s_str          str;
-  s_struct       struct_;
-  s_struct_type *struct_type;
-  const s_sym   *sym;
-  s8             s8;
-  s16            s16;
-  s32            s32;
-  s64            s64;
-  sw             sw;
-  s_tuple        tuple;
-  u8             u8;
-  u16            u16;
-  u32            u32;
-  u64            u64;
-  uw             uw;
+  s_array       array;
+  bool          bool;
+  s_call        call;
+  s_cfn         cfn;
+  character     character;
+  f32           f32;
+  f64           f64;
+  s_fact        fact;
+  s_fn          fn;
+  s_ident       ident;
+  s_integer     integer;
+  s_list       *list;
+  s_map         map;
+  p_tag         ptag;
+  u_ptr_w       ptr;
+  u_ptr_w       ptr_free;
+  s_quote       quote;
+  s_str         str;
+  s_struct      struct_;
+  s_struct_type struct_type;
+  const s_sym  *sym;
+  s8            s8;
+  s16           s16;
+  s32           s32;
+  s64           s64;
+  sw            sw;
+  s_tuple       tuple;
+  u8            u8;
+  u16           u16;
+  u32           u32;
+  u64           u64;
+  uw            uw;
 };
 
 /* 6 */