-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtao-s.lisp
3440 lines (2997 loc) · 116 KB
/
tao-s.lisp
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
(tao:common-lisp)
(in-package #:tao-internal)
(define
"sass"
(subr (pred item a-list func)
(cond ((assoc item a-list :test pred)) ;thenret
('T (funcall func))))
:documentation
"形式 : sass pred item a-list func
連想リスト a-list中に、第 1 要素が item と共に条件 pred を満足するペア
があれば、そのペアを返し、なければ func を評価し、その結果を返す。"
:example
"")
(define
"sassq"
(subr (item alist func)
(tao:sass #'eq item alist func))
:documentation
"形式 : sassq item a-list func
連想リスト a-list中に、第 1 要素が item と eq なペアがあれば、そのペア
を返し、なければ func を評価し、その結果を返す。"
:example
"(!xx '((a . 1) (b . 2) (c . 3) ((d e) . 4)))
(sassq 'a xx (lambda () (!z 5))) -> (a . 1)
(sassq 'e xx (lambda () (!z 5))) -> 5
(sassq '(d e) xx (lambda () (!z 5))) -> 5")
(define
"sassql"
(subr (item alist func)
(tao:sass #'eql item alist func))
:documentation
"形式 : sassql item a-list func
連想リスト a-list 中に、第 1 要素が item と eql なペアがあれば、その
ペアを返し、なければ func を評価し、その結果を返す。"
:example
"")
(define
"sassqu"
(subr (item alist func)
(tao:sass #'equal item alist func))
:documentation
"形式 : sassqu item a-list func
連想リスト a-list 中に、第 1 要素が item と equal なペアがあれば、その
ペアを返し、なければ func を評価し、その結果を返す。"
:example
"(!xx '((a . 1) (b . 2) (c . 3) ((d e) . 4)))
(sassqu 'a xx (lambda () (!z 5))) -> (a . 1)
(sassqu '(d e) xx (lambda () (!z 5))) -> ((d e) . 4)
(sassqu 'f xx (lambda () (!z 5))) -> 5")
(define
"save-sstatus"
(expr nil)
:documentation
"形式 : save-sstatus &opt terno
ターミナル terno の状態をセーブする。terno の既定値はこの関数が入力さ
れたターミナル。"
:example
"")
(define
"sbit"
#'sbit
:documentation
"形式 : sbit bit-array &rest subscripts
関数 bit と同じ働きをする。
ビット配列 bit-array の、添字 subscripts により指定されたビットを返す。
bit-array は単純ビット配列でなければならない。"
:example
"(!x (make-array 3))
-> {vector}77794(common:simple-general-vector . 3)
(sbit x 1) -> nil
(!y (make-array '(5 5) :element-type 'bit))
-> {applobj}70768(#!array . 10)
(sbit y 1 1) -> #0")
(define
"scale-float"
#'scale-float
:documentation
"形式 : scale-float number integer
number は、浮動小数点。(* number (expt (float b number) integer)) の
結果を返す。 b は number の内部表現に使われる基数。"
:example
"(scale-float 1.0 3) -> 8.0
(scale-float -1.0 3) -> -8.0
(scale-float 12.3 2) -> 49.2")
(define
"schar"
(subr (string index)
(if (< (cl:length string) index)
""
(coerce (list (char string index)) 'string)))
:documentation
"形式 : schar string index
string の index (0 から始まる数字) の位置の文字を返す。index は、
string の長さより小さくなければならない。"
:example
"(schar \"abcdefghij\" 0) -> \"a\"
(schar \"abcdefghij\" 3) -> \"d\"
(schar \"asd\" 5) -> \"\"")
(define
"sconc"
(subr (&rest strings)
(declare (optimize (safety 0) (speed 3))
(dynamic-extent strings))
(let ((len 0)
(pos 0))
(declare (fixnum len pos))
(dolist (s strings)
(declare (simple-string s))
(incf len (length s)))
(let ((result (make-string len)))
(declare (simple-string result))
(dolist (s strings)
(declare (simple-string s))
(loop :for c :across s
:do (setf (schar result pos) c) (incf pos)))
result)))
:documentation
"形式 : sconc &rest string1 string2 ... stringN
string1 string2 ... stringN を 1 つの文字列に結合し、その結果を返す。"
:example
"(sconc \"a\" \"b\") -> \"ab\"
(sconc \"123\" \"45\" \"6789\") -> \"123456789\"
(sconc \"abc\" nil) -> \"abc\"")
(define
"screen"
(expr nil)
:documentation
"形式 : screen &opt terno
ターミナル terno を screen モードにする。terno の既定値はこの関数が入力
されたターミナル。screen モードにおいて画面表示は、terminal ストリーム
に store される。入出力処理は多少遅くなるが、画面をファイルにしたり、
ハードコピーを取るというような、いくつかの関数を利用できる。"
:example
"")
(define
"search"
#'search
:documentation
"形式 : search seq1 seq2 &key :from-end :test :test-not :key :start1
:end1 :start2 :end2
シーケンス seq1 の :start1 から :end1 までの文字が、seq2 の :start2
から :end2 までに含まれているか探し、あれば seq2 の左端 (:from-end で
nil でない値が指定された場合は右端) の要素の添字番号を返し、なかった場
合はnil を返す。"
:example
"(search '(b c) '(a b c d e)) -> 1
(search '(a b c) '(a b c d e) :start1 2 :end1 3) -> 2
(serch '(a b c) '(a b c d e d c b a) :start1 2 end1 3
:start2 3 end2 7) -> 6")
(define
"second"
#'second
:documentation
"形式 : second list
list の 2 番目の要素の値を返す (最初の要素が 1 番目)。"
:example
"(second '(a b c)) -> b")
(define
"select"
(macro (item &body cases)
(let ((v (gensym)))
`(let ((,v ,item))
(cond
,@(mapcar (lambda (x)
(let ((case (car x))
(forms (cdr x)))
(cond ((consp case)
(if (and (eq 'quote (car case))
(eq 't (cadr case)))
`('T ,@forms)
`((member ,v (list ,@case) :test #'eq) ,@forms)))
((atom case)
(if (or (eq t case) (eq 'otherwize case))
`('T ,@forms)
`((eq ,v ,case) ,@forms)))
('T nil))))
cases)))))
:documentation
"形式 : select item (case1 form11 form12 ...)
(case2 form21 form22 ...)
...
順に case1 case2 ... が item と eq かどうか調べ、最初に eq になった
後のフォームを順に評価し、結果を返す。一番最後の caseK を t または
otherwise に指定し、それまでの全てが、eq でなかった時は、その後にくる
フォームを無条件に評価する。各 casei は item と比較される前に評価される。
casej がリストのときには eq のかわりに memq でテストを行なう。"
:example
"(select 3 ((3 4) 'abc) (t 'xyz)) -> abc
(select 'd ((a) \"a\") ((b) \"b\") ((c) \"c\"))
-> (unbound-variable a)")
(define
"selector"
(macro (item fn &body cases)
(let ((itm (gensym)))
(let ((ecases
(mapcar (lambda (xx)
(let ((key (car xx)))
(cond ((or (eq t key)
(equal '(quote t) key)
(eq 'otherwise key))
`('T ,@(cdr xx)))
((consp key)
`((member ,itm ',key :test ,fn) ,@(cdr xx)))
((atom key)
`((funcall ,fn ,itm ,key) ,@(cdr xx)))
('T nil))))
cases)))
`(let ((,itm ,item))
(cond ,@ecases)))))
:documentation
"形式 : selector item fn (case1 form11 form12 ...)
(case2 form21 form22 ...)
...
selector は selectq と同じ。ただし selector では、eq の代わりに equal
greaterp, string-lessp, などが利用できる。"
:example
"(selector 1 'greaterp
(1 \"1\")
(2 \"2\")
(t \"3\")) -> \"3\"")
(define
"selectq"
(macro (item &body cases)
(let ((v (gensym)))
`(let ((,v ,item))
(cond
,@(mapcar (lambda (x)
(let ((case (car x))
(forms (cdr x)))
(cond ((consp case)
(if (equal '(quote t) case)
`('T ,@forms)
`((member ,v ',case :test #'eq) ,@forms)))
((atom case)
(if (or (eq t case) (eq 'otherwize case))
`('T ,@forms)
`((eq ,v ',case) ,@forms)))
('T nil))))
cases)))))
:documentation
"形式 : selectq item (case1 form11 form12 ...)
(case2 form21 form22 ...)
...
順に case1 case2 ... が item と eq かどうか調べ、最初に eq になった
後のフォームを順に評価し、結果を返す。一番最後の caseK を t または
otherwise に指定し、それまでの全てが、eq でなかった時は、その後にくる
フォームを無条件に評価する。casej がリストのときには eq のかわりに
memq でテストを行なう。"
:example
"(selectq 'a (c (!x 1)) (b (!x 2)) (a (!x 3))) -> 3
(selectq 'a ((p q r) (!x 1)) ((a b c) (!x 2))) -> 2
(selectq (car x)
((end terminate) (do-closing-work))
(break (enter-break-mode))
(inq (reply-to-inquiry (cdr x)))
(update (update-data (cdr x)))
(otherwise (report-error)) )")
(define
"selectq-every"
(macro (item &body cases)
(let ((uqitem (cadr item)))
(let ((picked-cases
(remove-if-not (lambda (x)
(cond ((or (equal '(quote t) x) (eq t x)) 'T)
((consp x)
(member uqitem x :test #'eq))
((atom x)
(or (eq uqitem x) (eq 'otherwise x)))
('T nil)))
cases :key #'car)))
`(progn ,@(mapcan #'cdr picked-cases)))))
:documentation
"形式 : selectq-every item (case1 form11 form12 ... form1N)
(case2 form21 form22 ... form2N)
...
順に case1 case2 ... が item と eq かどうか調べ、eq になる全てを
選び、対応するフォームを評価し、最後のフォームの評価結果を返す。一番
最後の caseK を t または otherwise に指定し、それまでの全てが、eq で
なかった時は、その後のフォームを無条件に評価する。casej がリストのとき
には eq のかわりに memq でテストを行なう。"
:example
"(selectq-every 'a (a (!x 1))
(b (!x 2))
(c (!x 3))
(a (!y 4))) -> 4
x = 1, y = 4")
(define
"self-eval-form-p"
(expr (form)
(cond ((null form))
((numberp form))
((stringp form))
;; codnum
((keywordp form))
((vectorp form))
;; applobj
('T nil)))
:documentation
"形式 : self-eval-form-p arg
arg が self-eval 式ならば t 、そうでなければ nilを返す。self-eval 式と
は、nil、number, string, codnum, keyword, vector applobj で全てである。"
:example
"(self-eval-form-p 123) -> t
(self-eval-form-p \"hihihi\") -> t
(self-eval-form-p #expr) -> t
(self-eval-form-p 'a) -> nil
(self-eval-form-p '(1 2 3)) -> nil")
(define
"selfass-cons"
(expr (object1 object2)
(cons (intern (concatenate 'string "!!" (string object1)))
object2))
:documentation
"形式 : selfass-cons object1 object2
cons と同じだが自己投入式を作るのに用いられる。"
:example
"(selfass-cons 'func (list 'x (assignee-cons 'y)))
-> (!!func x !y)")
(define
"selfass-list"
(expr (&rest x)
(cons (intern (concatenate 'string "!!" (string (car x))))
(apply #'funcall #'list (cdr x))))
:documentation
"形式 : selfass-list &rest x
list と同じだが自己投入式を作るのに用いられる。"
:example
"(selfass-list 'func 'x '(assignee-cons 'y)) -> (!!func x !y)
(selfass-list 'hana (assign-cons 'sakura 'tsubaki))
-> (!!hana (!sakura . tsubaki))")
(define
"selfassp"
(subr (form)
(and (eq 'tao:selfass
(car form))
form))
:documentation
"形式 : salfassp arg
arg が自己投入式なら、それを返し、そうでなければ nil を返す。"
:example
"(selfassp '(!!cons 1234 !x)) -> (!!cons 1234 !x)")
(define
"semaphore"
(class T)
:documentation
"CPU が、ただ 1 つの入出力リソースを持っている場合に、2 つのプロセス
P と Q が、そのリソースを要求したとする。この場合 P と Q がそのリソース
を共有することは不可能。 P と Q は、排他的に自身だけでリソースを使わな
ければならない。セマフォは、このように、リソースの互いに排他的な使用の
ための最も基本的なツール。TAO では、セマフォは、クラス SEMAPHORE の
インスタンスとして提供され、3 つのインスタンス変数 :name
sys:semaphore-process-queue :process をとる。:name の値は、セマフォの
名前を表す。プロセスには複数のセマフォが存在する可能性もあるので、名前
が必要。:process の値は、セマフォを占有しているプロセスを表す。"
:example
"")
(define
"semi-globals"
(expr nil)
:documentation
"形式 : semi-globals &rest 'var
var が指定された時は、それらをセミグローバル変数として定義し、nil に
初期化する。指定されない時は、セミグローバル変数の名前と値を返す。"
:example
"(semi-globals a b c) ->
(+ - * / ** ++ // *** *prompt-function*
*history-command-over it that +++ ///
*screen-out-file* *ansi$caution-type* c b a)
a -> nil
b -> nil
c -> nil")
(define
"send"
(macro nil)
:documentation
"形式 : send receiver list-message-and-arg
メッセージをインスタンスに送る。receiver で、メッセージを受け取る
インスタンスを指定し、list-message-and-arg で、送られるメッセージの名前
と送られたメッセージにより呼び出されるメソッドで使われる引数のリストを
書く。"
:example
"(send 1 '(+ 10)) -> 11")
(define
"send-class-message"
(subr nil)
:documentation
"形式 : send-class-message 'class-name 'message &rest 'args
クラスメッセージ message を、クラス class-name へ送る。"
:example
"(defclass a (q) () ()) -> a
(defclass-method (a abc) () (!(cvar q) 10)) -> abc
(calss-variable q (class-of 'a)) -> nil
(send-calss-message a abc) -> 10
(class-variable 'q (class-of 'a)) -> 10")
(define
"send-mail"
(subr nil)
:documentation
"形式 : send-mail mailbox mail
メイル mail を、メイルボックス mailbox に送る。"
:example
"(!m-box (make-instance 'mailbox)) -> m-box
(send-mail m-box 12345) -> 12345")
(define
"seq"
(macro (&rest forms)
`(block nil
,@forms))
:documentation
"形式 : seq &resat form1 form2 ... formN
form1 form2 ... formN を順に実行し、最後のフォームの値を返す。"
:example
"x = \"enclosed\" ならば
(seq (prins \"[\") (prins x) (prins \"]\") x) -> \"enclosed\"
[enclosed] を出力。")
(define
"seqt"
(macro (&rest forms)
`(block nil
,@forms
t))
:documentation
"形式 : seqt &rest form1 form2 ... formN
form1 form2 ... formN を順に評価し、t を返す。ロジックプログラミング
の際、役立つ。"
:example
"(!x '(1 2 3)) -> (1 2 3)
(seqt (!y (cdr x) (!w (car y))) -> t
x = (1 2 3), y = (2 3), w = 2")
(define
"sequal"
(subr (string1 string2)
(cond ((some #'null (list string1 string2))
(error "nil?"))
((string-equal string1 string2)
(string-downcase string2))
('T nil)))
:documentation
"形式 : sequal string1 string2
stirng1 と string2 を比較し、一致した場合、string2 の値を返し、
そうでなければ nil を返す。大文字は小文字に変換する。"
:example
"(sequal \"abc\" \"abc\") -> \"abc\"
(sequal \"abc\" 'abc) -> \"abc\"
(sequal \"abc\" 'AbC) -> \"abc\"
(sequal nil nil) -> エラー
(sequal 123 123) -> エラー")
(define
"sequencep"
(expr (arg)
(typecase arg
(sequence t)
(otherwise nil)))
:documentation
"形式 : sequencep arg
arg がシーケンスなら arg を返し、それ以外なら nil を返す。"
:example
"")
(define
"set"
#'set
:documentation
"形式 : set x val
x に val を代入する。"
:example
"(!x 'a) -> a, ここで x = a
(set x '(p q r)) -> (p q r)
a -> (p q r)
(set (car x) 123) -> 123
p -> 123")
(define
"set-char-bit"
(expr nil)
:documentation
"形式 : set-char-bit char bit flag
文字 char のビット属性のうち、bit をクリアまたはセットした文字のデータ
を返す。flag が nilならクリアし、 nil 以外ならセットする。"
:example
"(set-char-bit #\\c :control t) -> #\\control-c
(set-char-bit #control-x :control t) -> #\\control-x
(set-char-bit #control-x :control nil) -> \"x\"
(set-char-bit #\\x :meta t) -> \"x\"")
(define
"set-date"
(expr nil)
:documentation
"西暦日付及び時間を設定する。"
:example
"(set-date)
System assumes today is 6-Apr-87.
Input [date and] time: dd-mmm-yy hh:mm 07-Apr-87 17:31")
(define
"set-default-keep-generation-count"
(expr nil)
:documentation
"形式 : set-default-keep-generation-count pathname &opt kgc
ディレクトリ pathname について、ファイルの世代をいくつにするかを決定
する。例えば、kgc が 3 のとき、最新バーションを含めてそれより古い 3 世
代のバージョンを保存する。kgc の既定値は 1 。"
:example
"(set-default-keep-generation-count \"cs:<dire>\" 3) -> 3
vdir \"test.tao\"
-> test.tao.5 最新ファイルを含めて 3 世代ファイルを保存
.4
.3
ここで test.tao を更新すると、
vdir \"test.tao\"
-> test.tao.6
.5
.4")
(define
"set-difference"
#'set-difference
:documentation
"形式 : set-difference list1 list2 &key :test :test-not :key
list1 と list2 を対比し、list1 には存在するが list2 には含まれていない
要素を抽出し、リストにして返す。nset-difference は破壊版。"
:example
"(set-difference '(1 2 3) '(2 4 6)) -> (1 3)
(set-difference '(1 2 3) '(1 2 3)) -> nil")
(define
"set-differenceq"
(subr (list1 &rest lists)
(do ((l list1 (cdr l))
result
(cmp (apply #'append lists)))
((endp l) (nreverse result))
(or (member (car l) (append result cmp) :test #'equal)
(push (car l) result))))
:documentation
"形式 : set-differenceq list1 &rest list2 ... listN
list1 には含まれているが、list2 ... listN には含まれていない要素を抽出
し、リストにして返す。ただし、返されるリストの中で重複した要素は、それ
が eq であれば、一方は削除される。list1 での要素の並び順序と返される
リストでの要素の並び順序は必ずしも一致しない。"
:example
"(set-differenceq '(1 2 3 4 5 6 4 2) '(5 3 1)) -> (2 4 6)
(set-differenceq '(1 2 3 4 5 6 7) '(1 2) '(3 4) '(2 5))
-> (6 7)")
(define
"set-dispatch-macro-character"
#'cl:set-dispatch-macro-character
:documentation
"形式 : set-dispatch-macro-character char1 char2 func &opt readtable
読み込み表 readtable にディスパッチ文字として登録されている char1 の
char2 に対する入力マクロ定義を関数 func で置き換える。char1 の表す文字
を X、char2 の表す文字を Y とするとき、read が \"XY\" で始まるデータを
読み込む際には、入力ストリームと char2、nil を引数として func が呼び
出される。\"XnY\" で始まるデータを読み込む際には,n の表す数値が func
への第 3 引数となる。ここで n はある非負整数の 10 表現である。
make-dispatch-macro-charactor、get-dispatch-macro-charactor 参照。"
:example
"")
(define
"set-error-function"
(expr nil)
:documentation
"形式 : set-error-function f-name &opt process
process において、f-name をエラー廃棄関数として定義する。
process が省略されるとカレントプロセスが使われる。f-name は、引数を
3 つとり、x, y, z とする。x はエラー名を表すストリング。 y は最初の補助
情報 (大抵の場合、エラーが起こった関数を表す)。 z は 2 番目の補助
情報(大抵の場合、エラーを起こした不正引数 (illegal argument) を表す)。"
:example
"")
(define
"set-exclusive-or"
#'set-exclusive-or
:documentation
"形式 : set-exclusive-or list1 list2 &key :test :test-not :key
list1 または list2 のいずれか一方に含まれている要素を抽出し、リストに
して返す。nset-exclusive-or は破壊版。"
:example
"(set-exclusive-or '(1 2 3) '(a b c)) -> (1 2 3 a b c)
(set-exclusive-or '(1 2 3) '()) -> (1 2 3)")
(define
"set-in-instance"
(macro nil)
:documentation
"set-in-instance 関数[#!macro]
説明
形式 : set-in-instance instance var-name value
instance のインスタンス変数 var-name に値 value を設定し、その値を返す。
<例>
(defclass a () (x y) () :gettable :settable) -> a
(!bb (make-instance 'a x 5 y 6)) -> {udo}43848a
[bb x] -> 5
[bb y] -> 6
(set-in-instance bb 'x 10) -> 10
[bb x] -> 10"
:example
"(defclass a () (x y) () :gettable :settable) -> a
(!bb (make-instance 'a x 5 y 6)) -> {udo}43848a
[bb x] -> 5
[bb y] -> 6
(set-in-instance bb 'x 10) -> 10
[bb x] -> 10")
(define
"set-job-name"
(expr nil)
:documentation
"形式 : set-job-name j-name &opt process
process に、ジョブ名 j-name を与える。process が省略されるとカレント
プロセスが使われる。"
:example
"")
(define
"set-keep-generation-count"
(expr (pathname &optional kgc)
(declare (ignore pathname kgc))
(values))
:documentation
"形式 : set-keep-generation-count pathname &opt kgc
ファイル pathname が、ファイルシステムで何世代保存されるかを決定する。
例えば、kgc が 3 のとき、pathname の最新バーションを含めてそれより古い
3 世代のバージョンを保存する。kgc の既定値は 1 。"
:example
"(set-keep-generation-count \"cs:<dire>test.tao\" 3) -> 3
vdir \"test.tao\"
-> test.tao.5 最新ファイルを含めて 3 世代ファイルを保存
.4
.3
ここで test.tao を更新すると、
vdir \"test.tao\"
-> test.tao.6
.5
.4")
(define
"set-loc-offset"
(subr (loc offset)
#+lispworks
(progn
(setf (fli::pointer-%offset loc) 0)
(fli:incf-pointer loc offset)))
:documentation
"形式 : set-loc-offset x y
ロックビット x のオフセット を、y (メモリブロック内の語アドレスを示す
0 から始まる数字) にセットする。ロックビットのオフセットへのアクセス
関数は、loc-ossset 。"
:example
"(!a (get-memblk #!8b-memblk 16)) ->
{memblk}489557(#!8b-memblk . {dnil}16)
(!b (locbit a 10)) ->
{locbit}{memblk}489557(#!8b-memblk . {dnil}16) . {dnil}10)
(loc-offset b) -> 10
(set-loc-offset b 1) ->
{locbit}{memblk}489557(#!8b-memblk . {dnil}16) . {dnil}1)
(loc-offset b) -> 1")
(define
"set-macro-character"
#'cl:set-macro-character
:documentation
"形式 : set-macro-character char func
&opt non-terminating-p readtable
char が read によって見つけられた時、func を呼び出すマクロ文字となる
ようにし、t を返す。non-terminating-p が 省略または nil が指定された
場合、char は非終端マクロ文字。すなわち、拡張されたトークンの中に組み
込まれることができる。get-macro-character 参照。"
:example
"")
(define
"set-priority"
(expr nil)
:documentation
"形式 : set-priority n &opt process
process に優先順位 n を与える。process が省略されるとカレントプロセス
が使われる。"
:example
"")
(define
"set-quantum"
(expr nil)
:documentation
"形式 : set-quantunm n &opt process
process に quantum 値 n を与える。process が省略されるとカレント
プロセスが使われる。"
:example
"")
(define
"set-syntax-from-char"
#'cl:set-syntax-from-char
:documentation
"形式 set-syntax-from-char to-char from-char
&opt to-readtable from-readtable
読み込み表 to-readtable 中の to-char を、読み込み表 from-readtable 中
の from-char と同一にする。to-readtable の既定値は現在の読み込み表
(変数 *readtable* の値) 。from-readtable の既定値は nil で、標準の
Lisp 読み込み表からの構文を用いることを意味している。"
:example
"")
(define
"set-sysmode"
(expr nil)
:documentation
"形式 : set-sysmode &key :car-nil-error :cdr-nil-error
:one-char-string :common-lisp :negation-as-failure
カレントプロセスの処理モードをセットする。
(1) :car-nil-error が nil 以外の値なら、フォーム (car nil) はエラー
になる。 nil なら、nil を返す。既定値は t 。
(2) :cdr-nil-error が nil 以外の値なら、フォーム (cdr nil) はエラー
になる。 nil なら、nil を返す。既定値は nil 。
(3) :one-char-string の値が nil 以外なら、キャラクタ \"a\" は \"a\" として
読まれる。nil なら、キャラクタ \"a\" は #\\a として読まれる。キャラクタ
#\\a は、この引数の値が nil であろうとなかろうと #\\a として読まれる。
既定値は nil 。
(4) :common-lisp の値が nil 以外なら、以下の 4 つのことが行われる。
① :car-nil-error の値は nil になる
② :cdr-nil-error の値は nil になる
③ :one-char-string の値は t になる
④ 入出力廃棄ルーチンやストリング廃棄ルーチン等の種々のスイッチ
は、TAO モードから Common Lisp モードに変わる。
既定値は nil 。
(5) :negation-as-failure が nil 以外の値なら、ロジックプログラミング
で、エラー \"unbound variable\" となると、バックトラックが起こる。つまり、
\"unbound variable\" は nil と同じであると見なされる。値が nil なら、
エラー \"unbound variable\" はエラーそのまま。既定値は nil 。"
:example
"(set-sysmode :common-lisp t) -> ok
(set-sysmode :car-nil-error t) -> ok")
(define
"tao.sys:set-tage"
(subr nil)
:documentation
"形式 : sys:set-tage x
tage ビットが on になり、x が返る。"
:example
"(sys:set-tage nil) -> ()
(sys:set-tage 100) -> #144 [8進の shortnum にする]")
(define
"set-terminal-type"
(expr nil)
:documentation
"形式 : set-terminal-type def-type
ユーザに terminal タイプを次の様に尋ねる。
Please input terminal type (default=def-type):
cit101e,vt100 の様な terminal タイプをタイプするとユーザのターミナル
が、その terminal タイプになる。crlf をタイプすると def-type がユーザ
のターミナルになる。login するとき使用される。"
:example
"")
(define
"setf"
(macro (&rest args)
`(setf ,@args))
:documentation
"形式 : setf &rest place datum
datum が place に格納される。datum を格納できる場所を示しうる関数に、
car,cdr, cadr,nth,first,symbol-value,nthv,array,shead,substring 等が
ある。これらの関数は setf の最初の引数として使用可能。
TAO では、setf の代わりにスペシャルシンボルマクロ ! を使う方が良い。"
:example
"(setf x 1 y 2) -> 2
x = 1, y = 2
(setf x '((a b) (c d) (e f))) -> ((a b) (c d) (e f))
(setf y \"qwertyu\") -> \"qwertyu\"
(setf (cadr x) '(1 2 3)) -> (1 2 3)
x -> ((a b) (1 2 3) (e f))
(setf (stail y 3) \"asdfg\") -> \"asdfg\"
y -> \"qweasdf\"")
(define
"setq"
(macro (&rest args)
`(setq ,@args))
:documentation
"形式 : setq &rest x1 val1 x2 val2 ...
まず val1 を評価しその結果を x1 に格納する。次に val2 を評価しその結果
を x2 に格納する。 ... そして、代入された最後の値を返す。
setq より ! のほうが速い。"
:example
"(setq x 1 y 2 z 3) -> 3
x = 1, y = 2 , z = 3
(setq x (+ y z) y (+ z x) z (+ x y)) -> 13
x = 5, y = 8 ,z = 13")
(define
"seventh"
#'seventh
:documentation
"形式 : seventh list
list の 7 番目の要素の値を返す (最初の要素が 1 番目)。"
:example
"(seventh '(0 1 2 3 4 5 6 7 8)) -> 6")
(define
"sg-value"
(subr nil)
:documentation
"形式 : sg-value var
セミグローバル変数 var の値を返す。"
:example
"(semi-globals abc) ->
(+ - * / ** \\++ // *** *prompt-function*
*history-command-overwrite* it that \\*** /// *screen-outfile*
*ansi$caution-type* abc)
(!abc '(a b c)) -> (a b c)
(sg-value 'abc) -> (a b c)")
(define
"shadow"
#'shadow
:documentation
"形式 : shadow symbol &opt package
symbol と同じ印字名のシンボルが package に存在しなければ新しいシンボル
をこの印字名で生成し、package に挿入し、t を返す。生成されたシンボルは
package がユースするパッケージにある同一印字名の外部シンボルをシャドウ
する。"
:example
"(shadow 'if) -> t
(de if (x)
(cond ((zerop x) i)
(t (* x (if (1- x)))))) -> if
(if 0) -> 1
(if 2) -> 2")
(define
"shadowing-import"
#'shadowing-import
:documentation
"形式 : shadowing-import symbol &opt package
import と同じ操作を行なうが symbol が package 中にすでにアクセス可能な
シンボルをシャドウするような場合であってもエラーを警告しない点が異なる。
symbol を package の内部シンボルとして登録し、t を返す。 symbol と同じ
印字名のシンボルが既にパッケージにあれば、そのシンボルを unintern する。
symbol は package がユースするパッケージに登録されている同一印字名の
外部シンボルをシャドウする。"
:example
"(!x 10)
(import sys:x) -> Name confilict! x
x -> エラー
(sys:with-privilege (!x 20)) -> 20
(sys:with-privilege (!window:x)) -> 30
(window:x) -> 30
(sys:x) -> 20
x -> 20
(shadowing-import window:x) -> t
x -> 30")
(define
"shead"
(subr (object &optional (n 1))
(let ((str (typecase object
(string object)
(atom (string-downcase (string object)))
(otherwise (error "~S is not type of ATOM." object)))))
(let ((len (cl:length str)))
(if (or (zerop n) (zerop len))
""
(let ((n (* (mod n len) (/ n (abs n)))))
(cond ((> n 0) (subseq str 0 n))
((< n 0) (subseq str (+ len n) len))
('T (subseq str 0 len))))))))
:documentation
"形式 : shead object &opt n
n >= 0 のときは、object の最初の n 文字から成る部分ストリングを作成し、
その結果を返す。
n < 0 のときは、object の最後の n 文字から成る部分ストリングを作成し、
その結果を返す。 n の既定値は 1。 object はストリングまたはアトム。"
:example
"(shead \"head\") -> \"h\"
(shead 'head 2) -> \"he\"
(shead 'string) -> \"s\"
(shead \"larger\" -3) -> \"ger\"
(shead \"short\" 10) -> \"short\"
(shead \"abc\" 0) -> \"\"
(shead \"\" 3) -> \"\"")
(define
"shift#"
;;(locative-operator nil)
(subr nil)
:documentation
"形式 : loc shift# n
loc について論理シフト操作を行う。 n で左へ何ビットシフトされるかが
指定される。"
:example
"(signed-integer-locatives p q r s) -> (p q r s)
(p <- #5252) -> 2730
(s <- (p shift# 1 )) -> 5461 (#12524)
(s <- (p shift# 2 )) -> 1365 (#2525)")
(define
"shiftf"
(cl-macro shiftf)
:documentation
"形式 : shiftf &rest x1 x2 ... xn value
x1 x2 x3 ... value を評価し、各値を右から左にシフトする。