File: xleval.c

package info (click to toggle)
xlispstat 3.52.14-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,560 kB
  • ctags: 12,676
  • sloc: ansic: 91,357; lisp: 21,759; sh: 1,525; makefile: 521; csh: 1
file content (1442 lines) | stat: -rw-r--r-- 34,637 bytes parent folder | download | duplicates (2)
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
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
/* xleval - xlisp evaluator */
/* Copyright (c) 1989, by David Michael Betz.                            */
/* You may give out copies of this software; for conditions see the file */
/* COPYING included with this distribution.                              */

#include "xlisp.h"

/* macro to check for lambda list keywords */
#define iskey(s) ((s) == lk_optional \
               || (s) == lk_rest \
               || (s) == lk_key \
               || (s) == lk_aux \
               || (s) == lk_allow_other_keys \
               || (s) == lk_whole \
               || (s) == lk_body \
               || (s) == lk_environment)

/* macros to handle tracing */
#define trenter(sym,argc,argv) {if (!null(sym)) doenter(sym,argc,argv);}
#define trexit(sym,val) {if (!null(sym)) doexit(sym,val);}

/* local forward declarations */
LOCAL LVAL xlbadfunction P1H(LVAL);
LOCAL VOID badarglist(V);
/*LOCAL*/ VOID doenter P3H(LVAL, int, FRAMEP);
/*LOCAL*/ VOID doexit P2H(LVAL, LVAL);
LOCAL LVAL evalhook P1H(LVAL);
LOCAL LVAL evform P1H(LVAL);
LOCAL LVAL evfun P3H(LVAL, int, FRAMEP);
LOCAL int  evpushargs P2H(LVAL, LVAL);
LOCAL int  member P2H(LVAL, LVAL);
#ifndef XLISP_STAT
LOCAL LVAL member2 P3H(LVAL, LVAL, LVAL);
#endif /* XLISP_STAT */
#ifdef APPLYHOOK
LOCAL LVAL applyhook P2H(LVAL, LVAL);
#endif
#ifdef CONDITIONS
LOCAL VOID xlcondunbound P2H(LVAL, LVAL);
#endif /* CONDITIONS */

LOCAL LVAL xlbadfunction P1C(LVAL, arg)
{
  return xlerror("bad function",arg);
}

/* xleval - evaluate an xlisp expression (checking for *evalhook*) */
LVAL xleval P1C(LVAL, expr)
{
    /* check for control codes */
    if (--xlsample <= 0) {
	xlsample = SAMPLE;
	oscheck();
    }

    /* check for *evalhook* */
    if (!null(getvalue(s_evalhook)))
	return (evalhook(expr));

    /* dispatch on the node type */
    switch (ntype(expr)) {
    case CONS:
	return (evform(expr));
#ifdef BYTECODE
    case BCODE:
	return (BC_evform(expr));
#endif /* BYTECODE */
    case SYMBOL:
#ifdef MULVALS
	xlnumresults = 1;
	return (xlresults[0] = xlgetvalue(expr));
#else
	return (xlgetvalue(expr));
#endif /* MULVALS */
    default:
#ifdef MULVALS
	xlnumresults = 1;
	return (xlresults[0] = expr);
#else
	return (expr);
#endif /* MULVALS */
    }
}

/* xlxeval - evaluate an xlisp expression (bypassing *evalhook*) */
LVAL xlxeval P1C(LVAL, expr)
{
    /* dispatch on node type */
    switch (ntype(expr)) {
    case CONS:
	return (evform(expr));
#ifdef BYTECODE
    case BCODE:
	return (BC_evform(expr));
#endif /* BYTECODE */
    case SYMBOL:
#ifdef MULVALS
	xlnumresults = 1;
	return (xlresults[0] = xlgetvalue(expr));
#else
	return (xlgetvalue(expr));
#endif /* MULVALS */
    default:
#ifdef MULVALS
	xlnumresults = 1;
	return (xlresults[0] = expr);
#else
	return (expr);
#endif /* MULVALS */
    }
}

/* xlapply - apply a function to arguments (already on the stack) */
LVAL xlapply P1C(int, argc)
{
    LVAL fun,val;

    /* get the function */
    fun = xlfp[1];

    /* get the functional value of symbols */
    if (symbolp(fun)) {
	while ((val = getfunction(fun)) == s_unbound)
	    xlfunbound(fun);
	fun = xlfp[1] = val;
    }

    /* check for nil */
    if (null(fun))
	xlbadfunction(fun);

    /* dispatch on node type */
    switch (ntype(fun)) {
    case SUBR: {
        FRAMEP oldargv;
        int oldargc;
	oldargc = xlargc;
	oldargv = xlargv;
	xlargc = argc;
	xlargv = xlfp + 3;
	val = (*getsubr(fun))();
#ifdef MULVALS
	if (! mulvalp(fun)) {
	  xlnumresults = 1;
	  xlresults[0] = val;
	}
#endif /* MULVALS */
	xlargc = oldargc;
	xlargv = oldargv;
	break;
        }
    case CONS:
	if (!consp(cdr(fun)))
	    xlbadfunction(fun);
	if (car(fun) == s_lambda)
	    fun = xlfp[1]         /* TAA fix (vanNiekerk) */
		= xlclose(NIL,
	                  s_lambda,
	                  car(cdr(fun)),
	                  cdr(cdr(fun)),
	                  xlenv,xlfenv);
	else
	    xlbadfunction(fun);
	/**** fall through into the next case ****/
    case CLOSURE:
	if (gettype(fun) != s_lambda)
	    xlbadfunction(fun);
	val = evfun(fun,argc,xlfp+3);
	break;
#ifdef BYTECODE
    case BCCLOSURE:
	if (getbcctype(fun) != s_lambda)
	    xlbadfunction(fun);
        val = BC_evfun(fun,argc,xlfp+3);
	break;
#endif /* BYTECODE */
    default:
	xlbadfunction(fun);
	val = NIL; /* to keep compiler happy */
    }

    /* remove the call frame */
    xlsp = xlfp;
    xlfp = xlfp - (int)getfixnum(*xlfp);

    /* return the function value */
    return (val);
}

/* evform - evaluate a form */
LOCAL LVAL evform P1C(LVAL, form)
{
    LVAL fun,args,val;
    LVAL tracing=NIL;
    FRAMEP argv;
    int argc;
LVAL **oldst = xlstack, oform = form; /**** remove after debugging */

#ifdef STSZ
/* Debugging -- print system and eval stack remaining at each invocation */
/*  fprintf(stderr, "%d/%d  ",STACKREPORT(argc), xlstack-xlstkbase); */
    /* check the stack */
    stchck();
#endif

    /* protect some pointers */
    xlstkcheck(2);
    xlsave(fun);
    xlsave(args);

    /* get the function and the argument list */
    fun = car(form);
    args = cdr(form);

    /* get the functional value of symbols */
    if (symbolp(fun)) {
	if (!null(getvalue(s_tracelist)) && member(fun,getvalue(s_tracelist)))
	    tracing = fun;
	fun = xlgetfunction(fun);
    }

    /* check for nil */
    if (null(fun))
	xlbadfunction(NIL);

    /* dispatch on node type */
    switch (ntype(fun)) {
    case SUBR:
#ifdef APPLYHOOK
        /* check for *applyhook* */
        if (!null(getvalue(s_applyhook))) {
            val = (applyhook(fun,args));
            break;
        }
#endif
	argv = xlargv;
	argc = xlargc;
	xlargc = evpushargs(fun,args);
	xlargv = xlfp + 3;
	trenter(tracing,xlargc,xlargv);
	val = (*getsubr(fun))();
#ifdef MULVALS
	if (! mulvalp(fun)) {
	  xlnumresults = 1;
	  xlresults[0] = val;
	}
#endif /* MULVALS */
	trexit(tracing,val);
	xlsp = xlfp;
	xlfp = xlfp - (int)getfixnum(*xlfp);
	xlargv = argv;
	xlargc = argc;
	break;
    case FSUBR:
	argv = xlargv;
	argc = xlargc;
	xlargc = pushargs(fun,args);
	xlargv = xlfp + 3;
	val = (*getsubr(fun))();
#ifdef MULVALS
	if (! mulvalp(fun)) {
	  xlnumresults = 1;
	  xlresults[0] = val;
	}
#endif /* MULVALS */
	xlsp = xlfp;
	xlfp = xlfp - (int)getfixnum(*xlfp);
	xlargv = argv;
	xlargc = argc;
	break;
    case CONS:
	if (!consp(cdr(fun)))
	    xlbadfunction(fun);
	if ((/* type = */ car(fun)) == s_lambda)
	    fun = xlclose(NIL,
	                  s_lambda,
	                  car(cdr(fun)),
	                  cdr(cdr(fun)),
	                  xlenv,xlfenv);
	else
	    xlbadfunction(fun);
	/**** fall through into the next case ****/
    case CLOSURE:
	if (gettype(fun) == s_lambda) {
#ifdef APPLYHOOK
            /* check for *applyhook* */
            if (!null(getvalue(s_applyhook))) {
                val = (applyhook(fun,args));
                break;
            }
#endif
	    argc = evpushargs(fun,args);
	    argv = xlfp + 3;
	    trenter(tracing,argc,argv);
	    val = evfun(fun,argc,argv);
	    trexit(tracing,val);
	    xlsp = xlfp;
	    xlfp = xlfp - (int)getfixnum(*xlfp);
	}
	else {
	    LVAL tmp = form;
	    macroexpand(fun,args,&tmp);
	    fun = tmp;
	    if (!null(getvalue(s_dispmacros)) && consp(fun)) {
		/* substitute back into original fcn */
		rplaca(form, car(fun));
		rplacd(form, cdr(fun));
	    }
	    val = xleval(fun);
	}
	break;
#ifdef BYTECODE
    case BCCLOSURE:
	if (getbcctype(fun) == s_lambda) {
#ifdef APPLYHOOK
            /* check for *applyhook* */
            if (!null(getvalue(s_applyhook))) {
                val = (applyhook(fun,args));
                break;
            }
#endif
	    argc = evpushargs(fun,args);
	    argv = xlfp + 3;
	    trenter(tracing,argc,argv);
	    val = BC_evfun(fun,argc,argv);
	    trexit(tracing,val);
	    xlsp = xlfp;
	    xlfp = xlfp - (int)getfixnum(*xlfp);
	}
	else {
	    LVAL tmp = form;
	    macroexpand(fun,args,&tmp);
	    fun = tmp;
	    if (!null(getvalue(s_dispmacros)) && consp(fun)) {
		/* substitute back into original fcn */
		rplaca(form, car(fun));
		rplacd(form, cdr(fun));
	    }
	    val = xleval(fun);
	}
	break;
#endif /* BYTECODE */
    default:
	xlbadfunction(fun);
	val = NIL; /* to keep compiler happy */
    }

    /* restore the stack */
    xlpopn(2);

if (oldst != xlstack) { /**** remove after debugging */
  stdputstr("stack messup - ");
  stdprint(oform);
}
    
    /* return the result value */
    return (val);
}

/* xlexpandmacros - expand macros in a form */
LVAL xlexpandmacros P1C(LVAL, form)
{
    LVAL fun,args;

    /* protect some pointers */
    xlstkcheck(3);
    xlprotect(form);
    xlsave(fun);
    xlsave(args);

    /* expand until the form isn't a macro call */
    while (consp(form)) {
	fun = car(form);		/* get the macro name */
	args = cdr(form);		/* get the arguments */
	if (! symbolp(fun) || (fun = xlxgetfunction(fun)) == s_unbound)
	    break;
	if (!macroexpand(fun,args,&form))
	    break;
    }

    /* restore the stack and return the expansion */
    xlpopn(3);
    return (form);
}

/* macroexpand - expand a macro call */
/* assumes form is passed as *pval */
int macroexpand P3C(LVAL, fun, LVAL, args, LVAL *, pval)
{
    FRAMEP argv;
    int argc;
    LVAL tmp1, tmp2;

    /* make sure it's really a macro call */
#ifdef BYTECODE
    if (! (bcclosurep(fun) && getbcctype(fun) == s_macro)
	&& ! (closurep(fun) && gettype(fun) == s_macro))
      return (FALSE);
#else
    if (! (closurep(fun) && gettype(fun) == s_macro))
      return (FALSE);
#endif

    /* call the expansion function */
    /* modified for CL-compliant form of expansion function */
    xlstkcheck(2);
    xlsave(tmp1);
    xlsave(tmp2);
#ifdef OLDMACROS
    tmp1 = cons(xlenv,xlfenv);
    tmp2 = copylist(*pval);
    tmp2 = cons(tmp2,args);
#else
    tmp1 = copylist(*pval);
    tmp2 = cons(xlenv,xlfenv);
    tmp2 = consa(tmp2);
#endif /* OLDMACROS */
    argc = pushargs(fun,cons(tmp1, tmp2));
    xlpopn(2);
    argv = xlfp + 3;
#ifdef BYTECODE
    if (bcclosurep(fun))
      *pval = BC_evfun(fun,argc,argv);
    else
      *pval = evfun(fun,argc,argv);
#else
    *pval = evfun(fun,argc,argv);
#endif /* BYTECODE */
    xlsp = xlfp;
    xlfp = xlfp - (int)getfixnum(*xlfp);
    return (TRUE);
}

/* evalhook - call the evalhook function */
LOCAL LVAL evalhook P1C(LVAL, expr)
{
    FRAMEP newfp;
    LVAL olddenv,val;

    /* create the new call frame */
    newfp = xlsp;
    pusharg(cvfixnum((FIXTYPE)(newfp - xlfp)));
    pusharg(getvalue(s_evalhook));
    pusharg(cvfixnum((FIXTYPE)2));
    pusharg(expr);
    pusharg(cons(xlenv,xlfenv));
    xlfp = newfp;

    /* rebind the hook functions to nil */
    olddenv = xldenv;
    xldbind(s_evalhook,NIL);
    xldbind(s_applyhook,NIL);

    /* call the hook function */
    val = xlapply(2);

    /* unbind the symbols */
    xlunbind(olddenv);

    /* return the value */
    return (val);
}

#ifdef APPLYHOOK
/* applyhook - call the applyhook function */
LOCAL LVAL applyhook P2C(LVAL, fun, LVAL, args)
{
    FRAMEP newfp;
    LVAL olddenv,val,last,next;

    xlsave1(val);   /* protect against GC */

    if (consp(args)) { /* build argument list -- if there are any */
        /* we will pass evaluated arguments, with hooks enabled */
        /* so argument evaluation will be hooked too */
        val = last = consa(xleval(car(args)));
        args = cdr(args);
        while (consp(args)) { /* handle any more in loop */
            next = consa(xleval(car(args)));
            rplacd(last,next);
            last = next;
            args = cdr(args);
        }
    }

    /* create the new call frame */
    newfp = xlsp;
    pusharg(cvfixnum((FIXTYPE)(newfp - xlfp)));
    pusharg(getvalue(s_applyhook));
    pusharg(cvfixnum((FIXTYPE)2));
    pusharg(fun);
    pusharg(val);
    xlfp = newfp;

    /* rebind hook functions to NIL */

    olddenv = xldenv;
    xldbind(s_evalhook,NIL);
    xldbind(s_applyhook,NIL);


    /* call the hook function */
    val = xlapply(2);

    /* unbind the symbols */
    xlunbind(olddenv);

    /* return the value */
    return (val);
}
#endif

/* evpushargs - evaluate and push a list of arguments */
LOCAL int evpushargs P2C(LVAL, fun, LVAL, args)
{
    FRAMEP newfp;
    int argc;

    /* protect the argument list */
    xlprot1(args);

    /* build a new argument stack frame */
    newfp = xlsp;
    pusharg(cvfixnum((FIXTYPE)(newfp - xlfp)));
    pusharg(fun);
    pusharg(NIL); /* will be argc */

    /* evaluate and push each argument */
    for (argc = 0; consp(args); args = cdr(args), ++argc)
	pusharg(xleval(car(args)));

    /* establish the new stack frame */
    newfp[2] = cvfixnum((FIXTYPE)argc);
    xlfp = newfp;

    /* restore the stack */
    xlpop();

    /* return the number of arguments */
    return (argc);
}

/* pushargs - push a list of arguments */
int pushargs P2C(LVAL, fun, LVAL, args)
{
    FRAMEP newfp;
    int argc;

    /* build a new argument stack frame */
    newfp = xlsp;
    pusharg(cvfixnum((FIXTYPE)(newfp - xlfp)));
    pusharg(fun);
    pusharg(NIL); /* will be argc */

    /* push each argument */
    for (argc = 0; consp(args); args = cdr(args), ++argc)
	pusharg(car(args));

    /* establish the new stack frame */
    newfp[2] = cvfixnum((FIXTYPE)argc);
    xlfp = newfp;

    /* return the number of arguments */
    return (argc);
}

/* makearglist - make a list of the remaining arguments */
LVAL makearglist P2C(int, argc, LVAL *, argv)
{
    LVAL list,this,last;
    xlsave1(list);
    for (last = NIL; --argc >= 0; last = this) {
	this = cons(*argv++,NIL);
	if (!null(last)) rplacd(last,this);
	else list = this;
	last = this;
    }
    xlpop();
    return (list);
}

/* evfun - evaluate a function */
LOCAL LVAL evfun P3C(LVAL, fun, int, argc, FRAMEP, argv)
{
    LVAL oldenv,oldfenv,cptr,val;
    LVAL olddenv=xldenv;
    CONTEXT cntxt;

    /* protect some pointers */
    xlstkcheck(3);
    xlsave(oldenv);
    xlsave(oldfenv);
    xlsave(cptr);

    /* create a new environment frame */
    oldenv = xlenv;
    oldfenv = xlfenv;
    xlenv = xlframe(getenvi(fun));
    xlfenv = getfenv(fun);

    /* bind the formal parameters */
    xlabind(fun,argc,argv);

    /* setup the implicit block */
    if (!null(getname(fun)))
	xlbegin(&cntxt,CF_RETURN,getname(fun));

    /* execute the block */
#ifdef CRAYCC
    if (null(getname(fun))) goto noname;
    if (setjmp(cntxt.c_jmpbuf))
        val = xlvalue;
    else {
    noname:
#else
    if (!null(getname(fun)) && setjmp(cntxt.c_jmpbuf))
	val = xlvalue;
    else {
#endif /* CRAYCC */
#ifdef LEXBIND
        if (!null(getname(fun)))
	  xlbindtag(&cntxt,getname(fun),xlenv);
#endif
#ifdef MULVALS
        xlnumresults = 1;
	xlresults[0] = NIL;
#endif /* MULVALS */
	for (val = NIL, cptr = getbody(fun); consp(cptr); cptr = cdr(cptr)) {

	  /* check for control codes */
	  if (--xlsample <= 0) {
	    xlsample = SAMPLE;
	    oscheck();
	  }

	  val = car(cptr);

	  /* check for *evalhook* */
	  if (!null(getvalue(s_evalhook))) {
	    val = evalhook(val);
	    continue;
	  }

	  /* dispatch on the node type */
	  switch (ntype(val)) {
	  case CONS:
	    val = evform(val);
	    break;
#ifdef MULVALS
	  case SYMBOL:
	    val = xlgetvalue(val);
	    /* fall through */
	  default:
	    xlnumresults = 1;
	    xlresults[0] = val;
	    break;
#else
	  case SYMBOL:
	    val = xlgetvalue(val);
	    break;
	  default: /* nothing */
	    break;
#endif /* MULVALS */
	  }
        }
    }

    /* finish the block context */
    if (!null(getname(fun)))
	xlend(&cntxt);

    /* restore the environment */
    xlenv = oldenv;
    xlfenv = oldfenv;
    xlunbind(olddenv);

    /* restore the stack */
    xlpopn(3);

    /* return the result value */
    return (val);
}

/* xlclose - create a function closure */
LVAL xlclose P6C(LVAL, name, LVAL, type, LVAL, fargs, LVAL, body, LVAL, env, LVAL, fenv)
{
    LVAL closure,key=NULL,arg,def,svar,new,last;
#ifndef PACKAGES
    char keyname[STRMAX+2];
#endif /* PACKAGES */
    LVAL wholesym=NULL,envsym=NULL;
    int destruct = FALSE;

    /* protect some pointers */
    xlsave1(closure);
    xlprot1(fargs);

    /* create the closure object */
    closure = newclosure(name,type,env,fenv);
    setlambda(closure,fargs);
    setbody(closure,body);

    /* check for &whole and &environment in macros */
    if (type == s_macro) {
      LVAL next, last;

      fargs = copylist(fargs);
      envsym = s_unbound;

      /* check for &whole argument */
      if (consp(fargs) && car(fargs) == lk_whole) {
	fargs = cdr(fargs);
	if (consp(fargs) && (!null(arg = car(fargs))) &&
	    symbolp(arg) && !iskey(arg))
	  wholesym = arg;
	else
	  badarglist();
	fargs = cdr(fargs);
      }
      else {
	wholesym = s_unbound;
	envsym = s_unbound;
      }

      /* check for &environment argument */
      for (next = fargs, last = NIL;
	   consp(next);
	   last = next, next = cdr(next)) {
	if (car(next) == lk_environment) {
	  if (consp(cdr(next)) && (!null(arg = car(cdr(next)))) &&
	      symbolp(arg) && !iskey(arg))
	    envsym = arg;
	  else
	    badarglist();
	  if (null(last))
	    fargs = cdr(cdr(fargs));
	  else
	    rplacd(last, cdr(cdr(next)));
	  break;
	}
      }

      /* replace &body by &rest */
      for (next = fargs; consp(next); next = cdr(next))
	if (car(next) == lk_body)
	  rplaca(next, lk_rest);

      /* replace dotted list by &rest */
      for (next = fargs, last = NIL;
	   consp(next);
	   last = next, next = cdr(next));
      if (consp(last) && ! null(arg = cdr(last))) {
	if (symbolp(arg) && !iskey(arg))
	  rplacd(last, cons(lk_rest, cons(arg, NIL)));
	else
	  badarglist();
      }

      /* check for destructuring */
      for (next = fargs; consp(next) && !iskey(car(next)); next = cdr(next))
	 if (consp(car(next))) {
	   if (fboundp(s_destructbind)) {
	     destruct = TRUE;
	     break;
	   }
	   else
	     xlfail("destructuring macro arglists not supported yet");
	 }

      if (destruct) {
	LVAL sym;
	xlsave1(sym);
	sym = xlmakesym("R");
	setbody(closure,
		consa(cons(s_destructbind, cons(fargs, cons(sym, body)))));
	fargs = cons(lk_rest, consa(sym));
	xlpop();
      }
      setlambda(closure, fargs);
    }

    /* handle each required argument */
    last = NIL;
    while (consp(fargs) && (!null(arg = car(fargs))) && !iskey(arg)) {

	/* make sure the argument is a symbol */
	if (!symbolp(arg))
	    badarglist();

	/* create a new argument list entry */
	new = cons(arg,NIL);

	/* link it into the required argument list */
	if (!null(last))
	    rplacd(last,new);
	else
	    setargs(closure,new);
	last = new;

	/* move the formal argument list pointer ahead */
	fargs = cdr(fargs);
    }
    if (type == s_macro)
      setargs(closure,cons(envsym,cons(wholesym,getargs(closure))));

    /* check for the '&optional' keyword */
    if (consp(fargs) && car(fargs) == lk_optional) {
	fargs = cdr(fargs);

	/* handle each optional argument */
	last = NIL;
	while (consp(fargs) && (!null(arg = car(fargs))) && !iskey(arg)) {

	    /* get the default expression and specified-p variable */
	    def = svar = NIL;
	    if (consp(arg)) {
		if (!null(def = cdr(arg)))
		    if (consp(def)) {
			if (!null(svar = cdr(def)))
			    if (consp(svar)) {
				svar = car(svar);
				if (!symbolp(svar))
				    badarglist();
			    }
			    else
				badarglist();
			def = car(def);
		    }
		    else
			badarglist();
		arg = car(arg);
	    }

	    /* make sure the argument is a symbol */
	    if (!symbolp(arg))
		badarglist();

	    /* create a fully expanded optional expression */
	    new = cons(cons(arg,cons(def,cons(svar,NIL))),NIL);

	    /* link it into the optional argument list */
	    if (!null(last))
		rplacd(last,new);
	    else
		setoargs(closure,new);
	    last = new;

	    /* move the formal argument list pointer ahead */
	    fargs = cdr(fargs);
	}
    }

    /* check for the '&rest' keyword */
    if (consp(fargs)
	&& (car(fargs) == lk_rest
	    || (type == s_macro && car(fargs) == lk_body))) {
        fargs = cdr(fargs);

	/* get the &rest argument */
	if (consp(fargs) && (!null((arg = car(fargs)))) && !iskey(arg) && symbolp(arg))
	    setrest(closure,arg);
	else
	    badarglist();

	/* move the formal argument list pointer ahead */
	fargs = cdr(fargs);
    }

    /* check for the '&key' keyword */
    if (consp(fargs) && car(fargs) == lk_key) {
	fargs = cdr(fargs);

	/* handle each key argument */
	last = NIL;
	while (consp(fargs) && (!null(arg = car(fargs))) && !iskey(arg)) {

	    /* get the default expression and specified-p variable */
	    def = svar = NIL;
	    if (consp(arg)) {
		if (!null(def = cdr(arg)))
		    if (consp(def)) {
			if (!null(svar = cdr(def)))
			    if (consp(svar)) {
				svar = car(svar);
				if (!symbolp(svar))
				    badarglist();
			    }
			    else
				badarglist();
			def = car(def);
		    }
		    else
			badarglist();
		arg = car(arg);
	    }

	    /* get the keyword and the variable */
	    if (consp(arg)) {
		key = car(arg);
		if (!symbolp(key))
		    badarglist();
		if (!null(arg = cdr(arg)))
		    if (consp(arg))
			arg = car(arg);
		    else
			badarglist();
	    }
	    else if (symbolp(arg)) {
#ifdef PACKAGES
		key = xlintern(getstring(getpname(arg)), xlkeypack);
#else
		strcpy(keyname,":");
		STRCAT(keyname,getstring(getpname(arg)));
		key = xlenter(keyname);
#endif /* PACKAGES */
	    }

	    /* make sure the argument is a symbol */
	    if (!symbolp(arg))
		badarglist();

	    /* create a fully expanded key expression */
	    new = cons(cons(key,cons(arg,cons(def,cons(svar,NIL)))),NIL);

	    /* link it into the optional argument list */
	    if (!null(last))
		rplacd(last,new);
	    else
		setkargs(closure,new);
	    last = new;

	    /* move the formal argument list pointer ahead */
	    fargs = cdr(fargs);
	}
    }

    /* check for the '&allow-other-keys' keyword */
    if (consp(fargs) && car(fargs) == lk_allow_other_keys)  {
        /* save marker that other keys are allowed */
        setkargs(closure,cons(lk_allow_other_keys,getkargs(closure)));
	fargs = cdr(fargs);
    }

    /* check for the '&aux' keyword */
    if (consp(fargs) && car(fargs) == lk_aux) {
	fargs = cdr(fargs);

	/* handle each aux argument */
	last = NIL;
	while (consp(fargs) && (!null(arg = car(fargs))) && !iskey(arg)) {

	    /* get the initial value */
	    def = NIL;
	    if (consp(arg)) {
		if (!null(def = cdr(arg)))
		    if (consp(def))
			def = car(def);
		    else
			badarglist();
		arg = car(arg);
	    }

	    /* make sure the argument is a symbol */
	    if (!symbolp(arg))
		badarglist();

	    /* create a fully expanded aux expression */
	    new = cons(cons(arg,cons(def,NIL)),NIL);

	    /* link it into the aux argument list */
	    if (!null(last))
		rplacd(last,new);
	    else
		setaargs(closure,new);
	    last = new;

	    /* move the formal argument list pointer ahead */
	    fargs = cdr(fargs);
	}
    }

    /* make sure this is the end of the formal argument list */
    if (!null(fargs))
      badarglist();

    /* restore the stack */
    xlpopn(2);

#ifndef OLDMACROS
    /* now if it is a macro fix it up to be CL-compliant */
    if (type == s_macro) {
      LVAL wsym, esym, fun, tmp;
      xlstkcheck(5);
      xlprotect(closure);
      xlsave(wsym);
      xlsave(esym);
      xlsave(fun);
      xlsave(tmp);
      esym = car(getargs(closure));
      wsym = car(cdr(getargs(closure)));
      if (esym == s_unbound) esym = xlmakesym("E");
      if (wsym == s_unbound) wsym = xlmakesym("W");
      if (destruct) {
	tmp = cdr(cdr(car(getbody(closure))));
	rplaca(tmp, cons(s_cdr, consa(wsym)));
      }
      else {
	fun = cons(s_lambda, cons(getlambda(closure), getbody(closure)));
	fun = cons(s_function, consa(fun));
	tmp = cons(s_apply, cons(fun, consa(cons(s_cdr, consa(wsym)))));
	setbody(closure, consa(tmp));
      }
      setargs(closure, cons(wsym, consa(esym)));
      setlambda(closure, cons(wsym, consa(esym)));
      setoargs(closure, NIL);
      setrest(closure, NIL);
      setkargs(closure, NIL);
      setaargs(closure, NIL);
      xlpopn(5);
    }
#endif /* OLDMACROS */
      
    /* return the new closure */
    return (closure);
}

/* xlabind - bind the arguments for a function */
VOID xlabind P3C(LVAL, fun, int, argc, LVAL *, argv)
{
    LVAL *kargv,fargs,key,arg,def,svar,p;
    int keycount=0;
    int rargc,kargc;

    /* protect some pointers */
    xlsave1(def);

    /* bind each required argument */
    for (fargs = getargs(fun); consp(fargs); fargs = cdr(fargs)) {

	/* make sure there is an actual argument */
	if (--argc < 0)
	    xltoofew();

        if (constantp(car(fargs))) xlnoassign(car(fargs));

	/* bind the formal variable to the argument value */
	xlbind(car(fargs),*argv++);
    }

    /* bind each optional argument */
    for (fargs = getoargs(fun); consp(fargs); fargs = cdr(fargs)) {

	/* get argument, default and specified-p variable */
	p = car(fargs);
	arg = car(p); p = cdr(p);
	def = car(p); p = cdr(p);
	svar = car(p);

        if (constantp(arg)) xlnoassign(arg);
        if ((!null(svar)) && constantp(svar)) xlnoassign(svar);

	/* bind the formal variable to the argument value */
	if (argc > 0) {
	    argc--;
	    xlbind(arg,*argv++);
	    if (!null(svar)) xlbind(svar, s_true);
	}

	/* bind the formal variable to the default value */
	else {
	    if (!null(def)) def = xleval(def);
	    xlbind(arg,def);
	    if (!null(svar)) xlbind(svar,NIL);
	}
    }

    /* save the count of the &rest of the argument list */
    rargc = argc;

    /* handle '&rest' argument */
    if (!null(arg = getrest(fun))) {
	if (constantp(arg)) xlnoassign(arg);
	def = makearglist(argc,argv);
	xlbind(arg,def);
	argc = 0;
    }

    /* handle '&key' arguments */
    if (!null(fargs = getkargs(fun))) {
	if (rargc & 1)  /* TAA Mod added check -- 9/93 */
	    xlfail( "keyword value missing");
	if (car(fargs) == lk_allow_other_keys)
	    fargs = cdr(fargs);     /* toss marker */
        else
            keycount = (rargc+1)/2; /* number of keyword arguments */

	for (; consp(fargs); fargs = cdr(fargs)) {

	    /* get keyword, argument, default and specified-p variable */
	    p = car(fargs);
	    key = car(p); p = cdr(p);
	    arg = car(p); p = cdr(p);
	    def = car(p); p = cdr(p);
	    svar = car(p);

            if (constantp(arg)) xlnoassign(arg);
            if (!null(svar) && constantp(svar)) xlnoassign(svar);

	    /* look for the keyword in the actual argument list */
	    for (kargv = argv, kargc = rargc; (kargc -= 2) >= 0; kargv += 2)
		if (*kargv == key)
		    break;

	    /* bind the formal variable to the argument value */
	    if (kargc >= 0) {
	        keycount--;
		xlbind(arg,*++kargv);
		if (!null(svar)) xlbind(svar, s_true);
	        /* "delete" any duplicate arguments  TAA Added 9/93 */
                for (;(kargc -= 2) >= 0 ; kargv++)
                    if (*++kargv == key) keycount--;

            }

	    /* bind the formal variable to the default value */
	    else {
		if (!null(def)) def = xleval(def);
		xlbind(arg,def);
		if (!null(svar)) xlbind(svar,NIL);
	    }
	}

        if (keycount > 0 && !null(getvalue(s_strict_keywords))) {
	  /* some keyword args were left over, and ! &allow-other-keys */
	  for (kargv = argv, kargc = rargc; kargc > 0; kargc -= 2, kargv += 2)
	    if (kargv[0] == k_allow_other_keys && !null(kargv[1]))
	      break;

	  if (kargc == 0)
	    xlfail("too many or invalid keyword arguments");
	}
	argc = 0;
    }

    /* check for the '&aux' keyword */
    for (fargs = getaargs(fun); consp(fargs); fargs = cdr(fargs)) {

	/* get argument and default */
	p = car(fargs);
	arg = car(p); p = cdr(p);
	def = car(p);

        if (constantp(arg)) xlnoassign(arg);

	/* bind the auxiliary variable to the initial value */
	if (!null(def)) def = xleval(def);
	xlbind(arg,def);
    }

    /* make sure there aren't too many arguments */
    if (argc > 0)
	xltoomany();

    /* restore the stack */
    xlpop();
}

#ifndef XLISP_STAT
/* evmethod - evaluate a method */
LVAL evmethod(obj,msgcls,message)
  LVAL obj,msgcls,message;
{
    LVAL oldenv,oldfenv,cptr,name,val;
    LVAL olddenv=xldenv;
    LVAL tracing = NIL;
    CONTEXT cntxt;

    /* protect some pointers */
    xlstkcheck(3);
    xlsave(oldenv);
    xlsave(oldfenv);
    xlsave(cptr);

    /* create an 'object' stack entry and a new environment frame */
    oldenv = xlenv;
    oldfenv = xlfenv;
    xlenv = cons(cons(obj,msgcls),getenvi(cdr(message)));
    xlenv = xlframe(xlenv);
    xlfenv = getfenv(cdr(message));

    /* bind the formal parameters */
    xlabind(cdr(message),xlargc,xlargv);

    /* check for and start tracing  TAA 9/1/96 */
    if (!null(getvalue(s_tracelist)) &&
        (tracing = member2(msgcls, car(message), getvalue(s_tracelist))) != NIL) {
        trenter(tracing,xlargc,xlargv);
    }

    /* setup the implicit block */
    if (!null(name = getname(cdr(message))))
        xlbegin(&cntxt,CF_RETURN,name);

    /* execute the block */
    if (!null(name) && setjmp(cntxt.c_jmpbuf))
        val = xlvalue;
    else {
#ifdef LEXBIND
        if (!null(name))
          xlbindtag(&cntxt,name,xlenv);
#endif
#ifdef MULVALS
        xlnumresults = 1;
        xlresults[0] = NIL;
#endif /* MULVALS */
        for (val = NIL, cptr = getbody(cdr(message)); consp(cptr); cptr = cdr(cptr))
            val = xleval(car(cptr));
    }

    /* finish the block context */
    if (!null(name))
        xlend(&cntxt);

    /* end tracing */
    trexit(tracing, val);

    /* restore the environment */
    xlenv = oldenv;
    xlfenv = oldfenv;
    xlunbind(olddenv);

    /* restore the stack */
    xlpopn(3);

    /* return the result value */
    return (val);
}
#endif /* XLISP_STAT */

/* doenter - print trace information on function entry */
/* LOCAL VOID doenter(sym,argc,argv) *//* made global for method tracing */
VOID doenter P3C(LVAL, sym, int, argc, FRAMEP, argv)
{
    int i;
    LVAL olddenv;

    /* indent to the current trace level */
    for (i = 0; i < xltrcindent; ++i)
	trcputstr(" ");
    ++xltrcindent;

    /* rebind tracelist during printing - L. Tierney */
    olddenv = xldenv;
    xldbind(s_tracelist,NIL);
	
    /* display the function call */
    if (consp(sym)) {
        sprintf(buf,"Entering: %s,%s, Argument list: (",
                getstring(getivar(car(sym), PNAME)),
                getstring(getpname(car(cdr(sym)))));
    }
    else 
        sprintf(buf,"Entering: %s, Argument list: (",
                getstring(getpname(sym)));
    trcputstr(buf);
    while (--argc >= 0) {
	trcprin1(*argv++);
	if (argc) trcputstr(" ");
    }
    trcputstr(")\n");

    /* unbind the symbols - L. Tierney */
    xlunbind(olddenv);
}

/* doexit - print trace information for function/macro exit */
/* LOCAL VOID doexit(sym,val) *//* made global for method tracing */
VOID doexit P2C(LVAL, sym, LVAL, val)
{
#ifdef MULVALS
    extern int xltrcindent;
    int i, n;
    LVAL olddenv, *oldsp;
    
    /* indent to the current trace level */
    --xltrcindent;
    for (i = 0; i < xltrcindent; ++i)
	trcputstr(" ");
    
    /* rebind tracelist during printing - L. Tierney */
    olddenv = xldenv;
    xldbind(s_tracelist,NIL);
	
    /* save the results on the stack */
    oldsp = xlsp;
    n = xlnumresults;
    for (i = 0; i < n; i++)
      pusharg(xlresults[i]);

    /* display the function values */
    switch (n) {
    case 0:
      sprintf(buf,"Exiting: %s, No values. ",
	      getstring(getpname(consp(sym)?car(cdr(sym)):sym)));
      break;
    case 1:
      sprintf(buf,"Exiting: %s, Value: ",
	      getstring(getpname(consp(sym)?car(cdr(sym)):sym)));
      break;
    default:
      sprintf(buf,"Exiting: %s, Values: ",
	      getstring(getpname(consp(sym)?car(cdr(sym)):sym)));
    }
    trcputstr(buf);
    for (i = 0; i < n; i++) {
      trcprin1(oldsp[i]);
      if (i < n - 1) trcputstr(" ");
    }
    trcputstr("\n");

    /* restore the results and the stack */
    for (i = 0; i < n; i++)
      xlresults[i] = oldsp[i];
    xlnumresults = n;
    xlsp = oldsp;

    /* unbind the symbols - L. Tierney */
    xlunbind(olddenv);
#else
    int i;
    LVAL olddenv;

    /* indent to the current trace level */
    --xltrcindent;
    for (i = 0; i < xltrcindent; ++i)
	trcputstr(" ");

    /* rebind tracelist during printing - L. Tierney */
    olddenv = xldenv;
    xldbind(s_tracelist,NIL);
	
    /* display the function value */
    sprintf(buf,"Exiting: %s, Value: ",
            getstring(getpname(consp(sym)?car(cdr(sym)):sym)));
    trcputstr(buf);
    trcprin1(val);
    trcputstr("\n");

    /* unbind the symbols - L. Tierney */
    xlunbind(olddenv);
#endif /* MULVALS */
}

/* member - is 'x' a member of 'list'? */
LOCAL int member P2C(LVAL, x, LVAL, list)
{
    for (; consp(list); list = cdr(list))
	if (x == car(list))
	    return (TRUE);
    return (FALSE);
}

#ifndef XLISP_STAT
/* member2 - is '(x y)' a member of 'list'? */
LOCAL LVAL member2(x, y,list)
  LVAL x, y, list;
{
    LVAL cl;
    for (; consp(list); list = cdr(list)) 
        if (consp((cl=car(list))) && x == car(cl) && y == car(cdr(cl)))
            return (cl);

    return (NIL);
}
#endif /* XLISP_STAT */

/* xlunbound - signal an unbound variable error */
VOID xlunbound P1C(LVAL, sym)
{
#ifdef CONDITIONS
  if (! null(getvalue(s_condition_hook)))
    xlcondunbound(s_unboundvar, sym);
  else
#endif /* CONDITIONS */
    xlcerror("try evaluating symbol again","unbound variable",sym);
}

/* xlfunbound - signal an unbound function error */
VOID xlfunbound P1C(LVAL, sym)
{
#ifdef CONDITIONS
  if (! null(getvalue(s_condition_hook)))
    xlcondunbound(s_unboundfun, sym);
  else
#endif /* CONDITIONS */
    xlcerror("try evaluating symbol again","unbound function",sym);
}

/* xlstkoverflow - signal a stack overflow error */
VOID xlstkoverflow(V)
{
    xlabort("evaluation stack overflow");
}

/* xlargstkoverflow - signal an argument stack overflow error */
VOID xlargstkoverflow(V)
{
    xlabort("argument stack overflow");
}

/* badarglist - report a bad argument list error */
LOCAL VOID badarglist(V)
{
    xlfail("bad formal argument list");
}

#ifdef CONDITIONS
LOCAL VOID xlcondunbound P2C(LVAL, type, LVAL, sym)
{
  FRAMEP newfp, fp;

  /* build a new argument stack frame */
  newfp = xlsp;
  pusharg(cvfixnum((FIXTYPE)(newfp - xlfp)));
  pusharg(getvalue(s_condition_hook));
  pusharg(cvfixnum((FIXTYPE) 7));
  pusharg(s_cerror);
  fp = null(xlfp[0]) ? xlfp : xlfp - getfixnum(*xlfp);
  pusharg(null(fp[0]) ? NIL : cvfixnum((FIXTYPE) (fp - xlargstkbase)));
  pusharg(cons(xlenv,xlfenv));
  pusharg(cvstring("Try evaluating the symbol ~*~s again."));
  pusharg(type);
  pusharg(k_name);
  pusharg(sym);

  /* establish the new stack frame */
  xlfp = newfp;

  /* apply the function */
  xlapply(7);
}
#endif /* CONDITIONS */