-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtao-p.lisp
1425 lines (1246 loc) · 47.1 KB
/
tao-p.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
"p-sem"
(subr nil)
:documentation
"形式 : p-sem semaphore
semaphore をチェックする p-オペレーションを実行する。
semaphore により示された使用可能なリソースの数を返す。
その値が 0 なら、この関数を呼び出したプロセスは、値が増えるまで待たな
ければならない。semaphore の値が 1 ならば、値を 1 減じる。"
:example
"(!abc (make-instance 'semaphore :name 'abc))
(de test1 (semaphore name)
(loop (&aux count)
(:init (!count 0))
(:until (= count 5))
(p-sem semaphore)
(print \"test-1\")
(print-time)
(sleep 5)
(v-sem semaphore)
(inc count)))
(de test2 (semaphore name)
(loop (&aux count)
(:init (!count 0))
(:until (= count 5))
(p-sem semaphore)
(print \"test-2\")
(print-time)
(!!cons name !queue)
(sleep 2)
(v-sem semaphore)
(inc count)))
(!process1
(process-fork 'def-1 'test1 (list abc 'def-1)
:standard-output *standard-output*))
(!process2
(process-fork 'def-2 'test2 (list abc 'def-2)
:standrd-output *standard-output*))
->
\"test-1\" 8 Apr-87 13:02:39
\"test-1\" 8-Apr-87 13:02:44
\"test-2\" 8-Apr-87 13:02:45
\"test-2\" 8-Apr-87 13:02:47
\"test-2\" 8-Apr-87 13:02:49
\"test-1\" 8-Apr-87 13:02:50
\"test-2\" 8-Apr-87 13:02:51
\"test-2\" 8-Apr-87 13:02:53
Fork process completed! def-2 with: 5
\"test-1\" 8-Apr-87 13:02:55
\"test-1\" 8-Apr-87 13:03:00
Fork process completed! def-1 with: 5")
(define
"p-sem-with-timeout"
(subr nil)
:documentation
"形式 : p-sem-with-timeout tick semaphore
時間切れを設定できることを除いては、関数 p-sem と同じ。
semaphore をチェックする p-オペレーションを実行する。
semaphore の値が 0 なら、この関数を呼び出したプロセスは、値が増えるか、
時間切れとなるまで待たなければならない。時間切れは、tick で指定。
セマフォをひとつも得ることなく時間切れになれば nil を返す。
うまくセマフォを占有できた時は t を返す。"
:example
"")
(define
"package-name"
#'package-name
:documentation
"形式 : package-name package
package のパッケージ名を文字列として返す。
パッケージとは {vector}34567(package . 10) などであり、
パッケージ名とは make-package の中で指定された文字列名である。"
:example
"(package-name (list-all-global-packages)) ->
(\"apropos\" \"net\" \"step\" \"bas\" \"sys\" \"key\")
いまここでTAOのシステムパッケージ名が見える。
(package-name (list-all-packages))
-> (\"dbg\" \"zetalisp\" \"maclisp\")")
(define
"package-nicknames"
#'package-nicknames
:documentation
"形式 : package-nicknames package
package のニックネームを文字列のリストで返す。"
:example
"(package-nicknames (list-all-global-packages)) -> nil
(!a (make-package \"hiro\" :nickname '(\"s\")) ->
{vector}1312994(package . 12)
(package-nickname a) -> (\"s\")
(make-package) で nicknameを付ける時、nicknameは 1文字。")
(define
"package-shadowing-symbols"
#'package-shadowing-symbols
:documentation
"形式 : package-shadowing-symbols &opt package
package (既定値、カレントパッケージ) 内のシンボルのうち関数 shadow
または shadow-import によって他のシンボルをシャドウしているものを
リストにして返す。"
:example
"(package-shadowing-symbols) -> nil
(shadow 'car) -> t
(package-shadowing-symbols) -> (car)
(car '(1 2 3)) -> エラー")
(define
"package-use-list"
#'package-use-list
:documentation
"形式 : package-use-list &opt package
package (既定値、カレントパッケージ) がユースしている全てのパッケージ
名をリストで返す。"
:example
"(package-name (package-use-list)) -> nil
(use \"net\")
(package-name (package-use-list)) -> (\"net\")")
(define
"package-used-by-list"
#'package-used-by-list
:documentation
"形式 : package-used-by-list package
package をユースしている全てのパッケージ名をリストで返す。"
:example
"(package-name (package-used-by-list (find-package \"dbg\"))) ->
(\"abc\" \"window\")
(package-name (package-used-by-list (find-package \"bas\"))) ->
(\"dbg\" \"zetalisp\" \"maclisp\")")
(define
"packagep"
#'cl:packagep
:documentation
"形式 : packagep pkg
pkg が パッケージなら t を返し、それ以外なら nil を返す。"
:example
"(!gg (make-package 'gonta)) -> {vector}61567(package . 10)
(packagep gg) -> t
(packagep 'gonta) -> nil
(packagep (global-package \"bas\")) -> t")
(define
"pairlis"
#'pairlis
:documentation
"形式 : pairlis car-list cdr-list
リスト car-list の各要素と cdr-list の各要素を対にした連想リストを作
り、それを返す。"
:example
"(pairlis '(okuno ohsato hibino) '(3323 3668 3589))
-> ((okuno . 3323) (ohsato . 3668) (hibino . 3589))")
(define
"parent-package"
(expr nil)
:documentation
"形式 : parent-package &opt package
package (既定値はカレントパッケージ) の親パッケージを返す。"
:example
"(package-name (parent-package)) -> \"bas\"")
(define
"parent-package-chain"
(expr nil)
:documentation
"形式 : parent-package-chain &opt package
package (既定値はカレントパッケージ) から根パッケージ
(sys:univ-package) へとつながる親リンクチェーンにあるすべての
パッケージをリストにして返す。"
:example
"(package-name (parent-package-chain)) -> (\"bas\" \"univ\")")
(define
"parse-integer"
#'parse-integer
:documentation
"形式 : parse-integer string &opt start end radix junk-allowed
string から整数を 1 つ読み込んで、それを返す。junk-allowed が nil
(既定値) であれば string のstart と end の範囲(省略時、全体)を、基数
radix により読み込む。string が整数を全く含まなければエラーを警告する。
junk-allowed が nil 以外なら整数の前後に空白文字があっても無視し、う
まく整数が読み込めなくてもエラーを出さずに nil を返す。"
:example
"")
(define
"parse-namestring"
#'parse-namestring
:documentation
"形式 : parse-namestring thing &opt host defaults
thing を対応する パス名 に変換し、それを返す。"
:example
"(!u (parse-string \"Ho::bs:<tan>abc.tao\"))
-> !({udo}1798330pathname 20)")
(define
"parse-universal-time"
(expr nil)
:documentation
"形式 : parse-universal-time universal-string
時刻を表す文字列 universal-string をユニバーサルタイム形式の時刻に
変換し、それを返す。関数 get-universal-time を参照。"
:example
"(parse-universal-time (pname-of-time (get-universal-time)))
-> 2698274161
(parse-universal-time \" 1-Jan-85 00:00:00\") -> 2682406800")
(define
"pathname"
#'pathname
:documentation
"形式 : pathname path
ファイル指定 path をパス名の udo に変換して返す。
path は、文字列、シンボル、パス名の udo、またはストリームの udo 。"
:example
"(pathname \"abc.tao\") -> !({udo}1827722pathname 7)
(namestring (pathname \"abc.tao\")) -> \"abc.tao\"")
(define
"pathname-device"
#'pathname-device
:documentation
"形式 : pathname-device pathname
ファイル pathname のデバイス名を返す。
pathname は、文字列、シンボル、パス名の udo、ストリームの udo の
いずれでもよい。"
:example
"(pathname-device *default-pathname-defaults*) -> \"bs\"
(pathname-device \"Al::cs:<user>test.tao.5\") -> \"cs\"")
(define
"pathname-directory"
#'pathname-directory
:documentation
"形式 : pathname-directory pathname
ファイル pathname のディレクトリ名を返す。
pathname は、文字列、シンボル、パス名の udo、ストリームの udo の
いずれかでよい。"
:example
"(pathname-directory *default-pathname-defaults*) -> \"dire\"
(pathname-device \"Al::cs:<user>test.tao.5\") -> \"user\"")
(define
"pathname-host"
#'pathname-host
:documentation
"形式 : pathname-host pathname
ファイル pathname のホスト名を返す。
pathname は、文字列、シンボル、パス名の udo、ストリームの udo の
いずれかでよい。"
:example
"(pathname-host *default-pathname-defaults*) -> \"Ho\"
(pathname-device \"Al::cs:<user>test.tao.5\") -> \"Al\"")
(define
"pathname-name"
#'pathname-name
:documentation
"形式 : pathname-name pathname
ファイル pathname のファイル名を返す。
pathname は、文字列、シンボル、パス名の udo、ストリームの udo の
いずれかでよい。"
:example
"(pathname-name *default-pathname-defaults*) -> \"foo\"
(pathname-name \"Al::cs:<user>test.tao.5\") -> \"test\"")
(define
"pathname-type"
#'pathname-type
:documentation
"形式 : pathname-type pathname
ファイル pathname のタイプを返す。
pathname は、文字列、シンボル、パス名の udo、ストリームの udo の
いずれかでよい。"
:example
"(pathname-type *default-pathname-defaults*) -> \"tao\"
(pathname-type \"Al::cs:<user>test.tao.5\") -> \"tao\"")
(define
"pathname-version"
#'pathname-version
:documentation
"形式 : pathname-version pathname
ファイル pathname のバージョン番号を返す。
pathname は、文字列、シンボル、パス名の udo、ストリームの udo の
いずれかでよい。"
:example
"(pathname-version *default-pathname-defaults*) -> :newest
(pathname-version \"Al::cs:<user>test.tao.5\") -> 5")
(define
"pathnamep"
#'cl:pathnamep
:documentation
"形式 : pathnamep object
object がパス名の udo なら t 、そうでなければ nil を返す。"
:example
"(pathnamep \"cs\") -> nil
(pathnamep (make-pathname :host \"asd\")) -> t
(pathnamep *default-pathname-defaults*) -> t")
(define
"pc98k-terminal"
(class T)
:documentation
"ターミナルのクラス。インスタンスは pc98k。"
:example
"")
(define
"peek-char"
#'peek-char
:documentation
"形式 : peek-char &opt peek-type input-stream
peek-type が、t の時、空白文字はスキップして、その次に読まれるべき
1 文字を返す。peek-type が nil の時、ストリーム input-stream から次
に読まれるべき 1 文字を返す。peek-type の既定値は、nil 。
input-stream の既定値は *standard-input* の値。"
:example
"\"asd.tao\" の内容が D aN......とする。
(!aa (open \"asd.tao\")) -> {udo}1172343file-stream
(peek-char t aa) -> \"D\"
(read-char aa) -> \"D\"
(peek-char nil aa) -> #\\space
(peek-char t aa) -> \"a\" スペ-スはスキップする。
(read-char aa) -> \"a\"
(peek-char t aa) -> \"N\"
(read-char aa) -> \"N\"")
(define
"peelinv"
(subr (object)
(typecase object
(GL (car (gl.cons object)))
(T object)))
:documentation
"形式 : peelinv object
object の潜在ポインタを順に取り去っていき、最初の顕在ポインタ、
つまり通常のポインタに行き当たったらそこで止まる。"
:example
"(peelinv '(a b c)) ->(a b c)
(peelinv 'd) -> d")
(define
"phase"
#'phase
:documentation
"形式 : phase complex
複素数 complex を極座標表現での偏角を表現するためのラジアン値に変更
して返す。"
:example
"(phase #c(2 3)) -> 0.98279972324799f0
(phase #c(4 -1)) -> -0.244978663126964f0")
(define
"pi"
(constant pi)
:documentation
"円周率(π)を表す値が格納されているシステム定数 (大域定数)。
本システムでは 3.1415926535898f0。"
:example
"")
(define
"pipe-stream"
(class two-way-stream)
:documentation
"インスタンスが パイプストリーム であるクラス。
入出力両方向に動作する。入出力時に、2 つ以上のプロセスがこの
ストリームを分割し、データはこのストリームを通してあるプロセスからも
う一方のプロセスにパスされる。"
:example
"")
#-(or allegro lispworks ccl)
(defsynonym (setf tao:plist) (setf cl:symbol-plist))
#+lispworks
(defun (setf tao:plist) (var sym)
(system::set-symbol-plist sym var))
#+ccl
(defun (setf tao:plist) (var sym)
(ccl::set-symbol-plist sym var))
#+allegro
(defun (setf tao:plist) (var sym)
(setf (excl::sy_plist sym) var))
(define
"plist"
#'cl:symbol-plist
:documentation
"形式 : plist symbol
symbol の属性リストを返す。
symbol の属性リストを作るためにも用いられる。"
:example
"(plist 'aa) aa の属性リストを返す。
(!(plist 'aa) new-plst)
aa の属性リスト全部を new-plst で置き換える。
(!(plist 'xxx) '(a 1 b 2 c 3 d 4)) -> (a 1 b 2 c 3 d 4)
xxx は (a 1 b 2 c 3 d 4) になる。")
(define
"plus"
#'+
:documentation
"形式 : plus &rest number1 number2 ... numberN
number1, number2, ... numberN の値の和を返す。
(+ number1 number2 ... numberN) と同じ。"
:example
"(plus 1 2 3) -> 6
(plus) -> 0")
(define
"plusp"
#'plusp
:documentation
"形式 : plusp number
number が正の数なら、その値を返し、それ以外なら nil を返す。"
:example
"(plusp 543654) -> 543654
(plusp -123) -> nil
(plusp 0) -> nil")
(define
"pname"
(subr (object)
(typecase object
(string object)
(symbol (string object))
(otherwise (write-to-string object))))
:documentation
"形式 : pname object
object の値を文字列として返す。symbol-name 参照。
(pname x) は、x が string である点を除けば (write-to-string x) と同じ。"
:example
"(pname 'uvwxyz) -> \"uvwxyz\"
(pname \"abcdefg\") -> \"abcdefg\" ( \"\"abcdefg\"\"ではない)
(pname '(a . b)) -> \"(a . b)\"")
(define
"pname-of-time"
(expr (universal-time)
(multiple-value-bind (ss mm hh d m y) (decode-universal-time universal-time)
(format nil "~2,,D-~
~[Jan~;Feb~;Mar~;Apr~;May~;Jun~;Jul~;Aug~;Sep~;Oct~;Nov~;Dec~]-~
~2,'0D ~
~2,'0D:~
~2,'0D:~
~2,'0D" d (1- m) (if (> y 1999) (- y 2000) (- y 1900)) hh mm ss)))
:documentation
"形式 : pname-of-time universal-time
ユニバーサルタイム形式の時刻を、文字列に変換し、返す。
関数 get-universal-time を参照。"
:example
"(pname-of-time (get-universal-time)) -> \" 3-Jul-85 13:50:35\"")
(define
"pop"
(cl-macro pop)
:documentation
"形式 : pop 'var
リスト変数 var の内容の car 部 (リストの第 1 要素) を返す。
副作用として、var の内容の cdr 部が、var の内容の新しい値となる。
(pop x) = (progi ^(car x) (cdr! x))。
ただし、(pop x) の x は一度しか評価されない。"
:example
"x = (1 2 3 4) の場合
(pop x) -> 1 であり、同時に x = (2 3 4) となる。さらに続けると、
(pop x) -> 2 であり、同時に x = (3 4) となる。
y = ((1 2) 3 (4 5) 6) の場合
(pop y) -> (1 2)であり、同時に y = (3 (4 5) 6) となる。さらに
(pop y) -> 3 であり、同時に y = ((4 5) 6) となる。さらに
(pop y) -> (4 5) であり、同時に y = (6) である。")
(define
"position"
#'position
:documentation
"形式 : position item seq &key :from-end :test :test-not
:start :end :key
:from-end が nil (既定値) ならシーケンス seq の :start から :end まで
の範囲で、item が、条件 :test または :test-not を満たす最初の要素
(:from-end が nil 以外なら最後の要素) の添字の値を返す。
(該当する要素が見つからなければ、nil を返す)。:from-ed と :test-not
を同時に指定してはいけない。"
:example
"(position 'a '(1 2 a b c )) -> 2
(position 'a '(1 2 a b c d) :start 3 :end 5) -> nil
(position '3 '(1 2 3 4 5) :test #'<) -> 3
(position '3 '(1 2 3 4 5) :test-not #'< :from-end t) -> 2")
(define
"position-if"
#'position-if
:documentation
"形式 : position-if test seq &key :from-end :start :end :key
シーケンス seq の :start から :end までの範囲で、条件 test を満足する
要素を検索し、最初の要素 (:from-end が nil 以外なら最後の要素) の添字
の値を返す。(満足する要素が見つからなければ、nil を返す)。"
:example
"(position-if #'evenp '(1 2 3 4 5)) -> 1
(position-if #'evenp '(1 2 3 4 5) :from-end t) -> 3
(position-if #'oddp '(1 2 3 4 5) :start 3 :end 5) -> 4")
(define
"position-if-not"
#'cl:position-if-not
:documentation
"形式 : position-if-not test seq &key :from-end :start :end :key
シーケンス seq の :start から :end までの範囲で、条件 test を満足し
ない要素を検索し、最初の要素 (:from-end が nil以外なら最後の要素) の
添字の値を返す。(満足しない要素が見つからなければ、nil を返す)。"
:example
"(position-if-not #'evenp '(1 2 3 4 5)) -> 0
(position-if-not #'evenp '(1 2 3 4 5) :from-end t) -> 4
(position-if-not #'oddp '(1 2 3 4 5) :start 3 :end 5) -> 3")
(define
"pprint"
#'pprint
:documentation
"形式 : pprint object &opt stream
object の印字表現を、変数 *pretty-print* の値に従って、その前に改行を
付けて、stream へ出力する。この関数は、値を返さない。
stream の既定値は、変数 *standard-output* の値。"
:example
"(!print-pretty* t) -> t
(pprint '((a b) c d)) ->
((a b)
c d)
t
(!*print-pretty* nil) -> nil
(pprint '((a b) c d)) ->
((a b)
c d)")
(define
"prin1"
#'prin1
:documentation
"形式 : prin1 object &opt stream
object の印字表現を、stream に出力し、object の値を返す。
object の中に、escape 文字があってもかまわない。
stream の既定値は、変数 *standard-output* の値。
(prin1 x y) = (common:write x :stream y :escape t)
関数 read に対応している基本的な出力関数。"
:example
"(prin1 'a) -> aa")
(define
"prin1-to-string"
#'prin1-to-string
:documentation
"形式 : prin1-to-string object
object を文字列にして返す。object の中に、escape 文字があってもよい。
関数 write-to-string,princ-to-string,prin1 参照。"
:example
"(prin1to-string 'asdfg) -> \"asdfg\"")
(define
"princ"
#'princ
:documentation
"形式 : princ object &opt stream
object の印字表現を、stream に出力し、object の値と出力文字数を返す。
出力は escape 文字を持たない。
stream の既定値は、変数 *standard-output* の値。
(princ object output-stream) = (write object :stream ouput-stream
:escape nil)"
:example
"(princ 'a) -> a!(a 1)
(princ 'abcdef) -> abcdef!(abcdef 6)")
(define
"princ-to-string"
#'princ-to-string
:documentation
"形式 : princ-to-string object
object を文字列にして返す。出力は escape 文字を持たない。
関数 write-to-string,prin1-to-string,princ 参照。"
:example
"(princ-to-string 'qwert) -> \"qwert\"")
(define
"prins"
(subr (object &optional stream)
(princ object stream))
:documentation
"形式 : prins object &opt stream
stream に object をプリントし、object の値を返す。
stream の既定値は、変数 *standard-output* の値。
object が数なら、prins は、関数 tyo と同じ。
object がシンボルなら、その印字名をプリントする。
object が文字列なら、ダブルクォートなしに、プリントする。"
:example
"(prins 70) -> F70
(prins 'abc) -> abcabc
(prins \"abc def\") -> abc def\"abc def\"")
(define
"print"
#'print
:documentation
"形式 : print object &opt stream
改行文字、object、1 文字の空白を、stream に出力し、object の値を返
す。stream の既定値は、変数 *standard-output* の値。"
:example
"(print 'abc) ->
abc abc
(print \"abc def\") ->
\"abc def\" \"abc def\"")
(define
"print-methods-of-class"
(exprdyn nil)
:documentation
"形式 : print-methods-of-class class-vect
クラス class-vect のメソッドを表示する。"
:example
"(defmethod (abc tashizan) (x y &aux z) (!z (+ x y)))
-> tashizan
(defmethod (abc hikizan) (x y &aux z) (!z (- x y)))
-> hikizan
(print-methods-of-class 'abc) -> Id methods are: t")
(define
"print-time"
(expr nil)
:documentation
"形式 : print-time &opt universal-time
ユニバーサルタイム形式の時刻 universal-time を改行なしに文字列で
プリントし、nil を返す。universal-time の既定値は、
(get-universal-time) の返す値。"
:example
"(print-time) とすると、3-Jul-85 13:50:35 がプリントされる。")
(define
"probe-file"
#'probe-file
:documentation
"形式 : probe-file file
file が存在しなければ nil を返し、あれば、そのパス名を返す。
file があるファイルに結合され、オープンされたストリームを指定されれば、
結合されたファイル名を生成する。関数 truename,open 参照。"
:example
"(probe-file \"abc.tao\") -> \"Ho::bs:<dire>abc.tao\"
(probe-file \"cba.tao\") -> nil")
(define
"process"
(expr nil)
:documentation
"形式 : process job-number
job-number のプロセスを返す。"
:example
"(process 4) -> {udo}1137949")
(define
"process-allow-schedule"
(subr nil)
:documentation
"形式 : process-allow-schedule
通常に処理を行っているプロセスを直ちに処理待ち行列に並ばせ、
その待ち行列の先頭のプロセスをポップして、それに処理を行わせる。"
:example
"")
(define
"process-fork"
(exprdyn nil)
:documentation
"形式 : process-fork name func args &key :standard-input
:standard-output :completion-message
:bottom-bias :shared-variables :survive
名前が name のプロセスを生成し、それをフォークし、処理を行わせる。
つまり、プロセスにおいて、関数 func を引数リスト args に適用して
実行させる。キーワード引数 :standard-input と :standard-output は、
各々、フォークプロセスの *standard-input* と *standard-output* を
指定する。リターン値は、フォークプロセス。
フォークプロセスの属性リストは、親プロセスでフォークされたことを示す
属性 forked を持つ。キーワード引数の既定値は次のようになる。
:standard-input は null-stream
:standard-output は null-stream
:completion-message は t
:bottom-bias は nil
:shared-variables は nil
:survive は nil
フォークプロセスが完了したら、ターミナルベルを鳴らし、
\"fork process completed! name with: retur-value of form\" を表示する。"
:example
"(de receive-fun ()
(loop (&aux x)
(!x (receive-mail box-0))
(:until (string= x \"owari1\"))
(write x)))
(de send-fun ()
(send-mail box-0 \"aho\")
(sleep 2)
(send-mail box-0 \"owari\"))
(!box-0 (make-instance 'mailbox))
(!process1
(process-fork 'test1 'receive-fun '()
:standard-output *standard-oupt*))
(!process2
(process-fork 'test2 'send-fun '()))
->
\"aho\"
Fork process completed! test2 with: \"owari\"
Fork process completed! test1 with: \"owari\"")
(define
"process-interrupt"
(expr nil)
:documentation
"形式 : process-interrupt process func args flag
process を中断させる。中断が受け入れられれば、中断前のプロセスの環境で、
関数 func をリスト args に適用する。
ここで、フォーム (apply func args) を form とする。
flag の値が t なら、たとえ process が処理可能な状態でなく待ち状態でも、
ただちに割り込みフォーム form を実行する。
待ち状態のプロセスは、bas:del-proc-from-all-queue により abort され、
そこで割り込みフォームが評価される。しかしながら flag の値が nil なら、
form で指された割り込みフォームは、プロセスが次に処理を行う時に実行され
る。後者では、割り込みフォームの評価が計算状態を壊さなければ、現在進行
中の計算は、その割り込みフォームの評価が終わった後も処理を続ける。"
:example
"(de initial-fun (&aux term-no out-stream)
(!term-no [[sys:current-process :login] :terno])
(!out-stream (cdr (nthv (* term-no 2) sys:terno-table)))
(loop (sleep 1) (write 'test out-stream)))
(de int-form (&aux term-no out-stream)
(!term-no [[sys:current-process :login] :terno])
(!out-stream (cdr (nthv (* term-no 2) sys:terno-table)))
(write \"interrupt succeeded!!\" out-stream)))
(!process1
(make-process
'abc
:priority (1- [sys:current-process :priority])
:readtable *readtable*
:interprocess-closure nil
:initial-function 'initial-fun
:bottom (max2 4 (1-
[sys:current-process sys:bottom-stack-block#])))))
(process-preset process1 'initial-fun '())
(sleep 5)
(process-interrupt process1 'int-form '() t)
(sleep 5)
(process-kill process1)
->
test
test
test
test
test
\"interrupt succeeded!!\"
test
test
test
test
test
(initial-fun int-form {udo}53040process
({udo}53040process)
t {udo}53040process t
({udo}53040process))")
(define
"process-kill"
(expr nil)
:documentation
"形式 : process-kill process
process を取り除く。process は、リセットされ、直ちに停止され、
プロセスキューとプロセスプールから除かれる。
process が占有している全てのセマフォを開放し、process がオープンした
全てのファイルを棄却する。"
:example
"(process-kill process1) -> {udo}53040process")
(define
"process-peep"
(expr nil)
:documentation
"形式 : process-peep process &opt func args
process が、その環境で、関数 func をリスト args に適用する。
リターン値は、func が返す値。func が省略されると関数 backtraceが使わ
れる。ゆえに、別のプロセスに影響を与えることなく、その環境スタックを
見ることができる。"
:example
"")
(define
"process-preset"
(expr nil)
:documentation
"形式 : process-preset process func &rest args
process の初期関数を関数 func に、その関数の初期引数を引数 args に
セットする。process は、その時リセットされるので、そこに現れる計算は、
全て消去される。そして、func を args に適用することによりあらためて始
める。内部的に関数 process-reset を使っている。"
:example
"(de initial-fun (&aux term-no out-stream)
(!term-no [[sys:current-process :login] :terno])
(!out-stream (cdr (nthv (* term-no 2) sys:terno-table)))
(loop (sleep 1) (write 'test out-stream)))
(!process1
(make-process
'abc
:priority (1- [sys:current-process :priority])
:readtable *readtable*
:interprocess-closure nil
:bottom (max2 4 (1-
[sys:current-process sys:bottom-stack-block#])))))
(process-preset process1 'initial-fun '())
(sleep 20)
(process-kill process1)
->
test
....
test
(process-kill process1)
(initial-fun {udo}1168763process
({udo}1165112process {udo}1168763)
t {udo}1168763process)")
(define
"process-reset"
(expr nil)
:documentation
"形式 : process-reset process
process に現行の計算を止めさせ、その初期関数を初期引数に適用し、
再スタートさせる。process が占めている全てのセマフォは開放され、
process がオープンしている全てのファイルは棄却される。
つまり、それらのファイルに加えられた修正は、すべて棄てられて無効になる。
関数 unwind-protect は、この関数に対しては働かない。"
:example
"(de initial-fun (&aux term-no out-stream)
(!term-no [[sys:current-process :login] :terno])
(!out-stream (cdr (nthv (* term-no 2) sys:terno-table)))
(loop (sleep 1) (write 'test out-stream)))
(!process1
(make-process
'abc
:priority (1- [sys:current-process :priority])
:readtable *readtable*
:interprocess-closure nil
:initial-function 'initial-fun
:bottom (max2 4 (1-
[sys:current-process sys:bottom-stack-block#])))))
(process-reset prcess1)
(sleep 20)
(process-kill process1)
->
test
....
test
(initial-fun {udo}1160649process
({udo}1160649process)
t ({udo}116064process))")
(define
"tao.sys:process-stop"
(subr nil)
:documentation
"カレントプロセスの処理を停止させる。"
:example
"")
(define
"proclaim"
#'proclaim
:documentation
"形式 : proclaim decl
宣言子 decl にグローバルな宣言を与える。"
:example
"(proclaim '(special x)) 変数 x をスペシャル変数として定義
(proclaim '(type float tolerance))
tolerance の動的な値は常に浮動小数点数になることを定義
(proclaim '(inline floor))
floor はコンパイラによってインラインに開かれてコード化される
ことを定義")
(define
"prog"
(macro (binds &body tags-and-forms)
(let ((value (gensym "value")))
`(block cl:nil
(let (,value
,@binds)
(declare (dynamic-extent ,value))
(tagbody ,@(butlast tags-and-forms)
(setq ,value (multiple-value-list ,@(last tags-and-forms))))
(values-list ,value)))))
:documentation
"形式 : prog &rest [exit-id] var-list form1 form2 ... formN
nil に束縛された var-list 内の変数で form1 form2 ... formN を
逐次評価する。var-list 内の変数は prog 内で部分的に有効な一時的な変数。
prog を formN が (return) や (return var) の実行なしで評価するなら、
formN の値を返す。prog は (return var) が評価されると、var の値を返す。
prog は (return) が評価されると、{undef}0 を返す。formi がアトムなら、
評価されず、go タグとして解釈される。"
:example
"(prog (x) (return x)) -> nil
(prog (x) (!x 1) (+ x 3) x) -> 4 (last x is not evaluated)
(prog (x y z) (!x 1) (!y (x + 1))
(!z (y + 1)) (list x y z)) -> (1 2 3)
(prog (x)
(!x 1)
loop1 (do-some-work x)
(dec x)
(cond ((x = 100) (return)) (t (go loop1))) )
-> {undef}0 (value is not relevant)
exit-id はオプション。
これは非局所脱出の場所を指示するのに使用。
(prog outer-loop (x y)
...
(prog (u v) ... (return var outer-loop) ...)
... )
(return var outer-loop) が実行されると、評価の制御は
(prog outer-loop ...) の外に出る。")
(define
"common:prog"
(cl-macro prog)
:documentation
"形式 : common:prog ((var1 val-form1) (var2 val-form2) ...)
form1 form2 ...
フォーム val-form1 val-form2 ... を順に評価する。
次に、変数 var1 var2 ... を各々、val-form1 val-form2 ... の評価結果
に同時に束縛する。そして、フォーム form1 form2 ... を順に評価し、nil
を返す。val-formi は省略可能で、その場合は vari は nil となる。"
:example