This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path059stream.wart
69 lines (53 loc) · 1.43 KB
/
059stream.wart
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
def (close f) :case (isa infile f)
close_infile.f
def (close f) :case (isa outfile f)
close_outfile.f
def (close f) :case (isa socket f)
close_socket.f
mac (with `infile name ... body)
`(between (bind stdin (infile ,name)) :and (close&unbind stdin)
,@body)
mac (with `outfile name ... body)
`(between (bind stdout (outfile ,name)) :and (close&unbind stdout)
,@body)
mac (with `instring s ... body)
`(between (bind stdin (instring ,s)) :and (close&unbind stdin)
,@body)
mac (with `outstring ... body)
`(between (bind stdout (outstring)) :and (close&unbind stdout)
,@body
outstring_buffer.stdout)
mac (with `stdin fd ... body)
`(between (bind stdin ,fd) :and (close&unbind stdin)
,@body)
mac (with `stdout fd ... body)
`(between (bind stdout ,fd) :and (close&unbind stdout)
,@body)
def (ern ... args)
(with stdout stderr
(prn @args))
def (prrn ... args)
prn @args ""
def (infile fd) :case num?.fd
infd.fd
def (outfile fd) :case num?.fd
outfd.fd
def (infile s) :case (isa socket s)
infd+fd.s
def (outfile s) :case (isa socket s)
outfd+fd.s
mac (drain expr eof)
`(collect+awhile ,expr
yield.it)
def (pr ... args) :case ~single?.args
(map pr args)
car.args
# print with timestamp
def (log ... args)
(prntime)
(prn @args)
# during debugging, print a value with a distinguishing label
def (dbg msg ... args)
(pr msg) # don't return the label like prn would
(prn @args)