Skip to content

Commit 7ed7d12

Browse files
committed
Use OR=
1 parent ac8567d commit 7ed7d12

File tree

11 files changed

+38
-37
lines changed

11 files changed

+38
-37
lines changed

apps/news/blog.arc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
; A blog for news.arc
22
; For the standalone blog example by PG, see blog.arc from arc3.1
33

4-
(= postdir* (+ srvdir* "posts/") blog-maxid* 0 posts* (table))
4+
(= postdir* (+ srvdir* "posts/"))
5+
6+
(or= blog-maxid* 0
7+
posts* (table))
58

69
(deftem post id nil by nil title nil text nil)
710

apps/news/news.arc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@
180180
(def author (u i) (is u i!by))
181181

182182

183-
(= stories* nil ranked-stories* nil comments* nil
184-
items* (table) url->story* (table)
185-
maxid* 0 initload* 15000)
183+
(or= stories* nil ranked-stories* nil comments* nil
184+
items* (table) url->story* (table)
185+
maxid* 0 initload* 15000)
186186

187187
; The dir expression yields stories in order of file creation time
188188
; (because arc infile truncates), so could just rev the list instead of
@@ -233,7 +233,7 @@
233233
(def register-url (i url)
234234
(= (url->story* (canonical-url url)) i!id))
235235

236-
(= stemmable-sites* (table))
236+
(or= stemmable-sites* (table))
237237

238238
(def canonical-url (url)
239239
(if (stemmable-sites* (sitename url))
@@ -268,7 +268,7 @@
268268
(set i!dead)
269269
(save-item i)))
270270

271-
(= kill-log* nil)
271+
(or= kill-log* nil)
272272

273273
(def log-kill (i how)
274274
(push (list i!id how) kill-log*))
@@ -416,7 +416,7 @@
416416
background-color: #" (hexrep (main-color user)) ";"
417417
"}"))))
418418

419-
(= pagefns* nil)
419+
(or= pagefns* nil)
420420

421421
; page top
422422

@@ -573,7 +573,7 @@
573573
(newslog ip user ',name ,@parms)
574574
,@body)))))
575575

576-
(= newsop-names* nil)
576+
(or= newsop-names* nil)
577577

578578
(mac newsop args
579579
`(do (pushnew ',(car args) newsop-names*)
@@ -1051,7 +1051,7 @@
10511051

10521052
(= user-changetime* 120 editor-changetime* 1440)
10531053

1054-
(= everchange* (table) noedit* (table))
1054+
(or= everchange* (table) noedit* (table))
10551055

10561056
(def canedit (user i)
10571057
(or (admin user)
@@ -1685,7 +1685,7 @@
16851685
(do (note-baditem user ip)
16861686
(pr "No such item.")))))
16871687

1688-
(= baditemreqs* (table) baditem-threshold* 1/100)
1688+
(or= baditemreqs* (table) baditem-threshold* 1/100)
16891689

16901690
; Something looking at a lot of deleted items is probably the bad sort
16911691
; of crawler. Throttle it for this server invocation.
@@ -1730,7 +1730,7 @@
17301730
(mem 'commentable i!keys))))
17311731

17321732

1733-
(= displayfn* (table))
1733+
(or= displayfn* (table))
17341734

17351735
(= (displayfn* 'story) (fn (n i user here inlist)
17361736
(display-story n i user here)))
@@ -1773,7 +1773,7 @@
17731773

17741774
(def editable-type (i) (fieldfn* i!type))
17751775

1776-
(= fieldfn* (table))
1776+
(or= fieldfn* (table))
17771777

17781778
(= (fieldfn* 'story)
17791779
(fn (user s)

arc.arc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,7 +2880,7 @@ of 'x' by calling 'self'."
28802880
(def write (x (o port (stdout)))
28812881
(swrite serialize.x port))
28822882

2883-
(= hooks* (table))
2883+
(or= hooks* (table))
28842884

28852885
(def hook (name . args)
28862886
(aif (hooks* name) (apply it args)))
@@ -2905,7 +2905,7 @@ Useful in higher-order functions, or to index into lists, strings, tables, etc."
29052905
(map get.2 '((a b c) (1 2 3) (p q r)))
29062906
(c 3 r))
29072907

2908-
(= savers* (table))
2908+
(or= savers* (table))
29092909

29102910
(mac fromdisk (var file init load save)
29112911
(w/uniq (gf gv)

lib/app.arc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
; idea: a bidirectional table, so don't need two vars (and sets)
3232

33-
(= cookie->user* (table) user->cookie* (table) logins* (table))
33+
(or= cookie->user* (table) user->cookie* (table) logins* (table))
3434

3535
(def get-user (req)
3636
"Gets the user id string associated with 'req'.
@@ -258,7 +258,7 @@ Returns nil if no logged-in user."
258258
(link "Try logging in now." "/")))))
259259
(single-input "New password: " 'p 20 "update" t)))
260260

261-
(= good-logins* (queue) bad-logins* (queue))
261+
(or= good-logins* (queue) bad-logins* (queue))
262262

263263
(def good-login (user pw ip)
264264
(let record (list (seconds) ip user)
@@ -279,7 +279,7 @@ Returns nil if no logged-in user."
279279
;prepending this (stdin)= for backwards compatibility with previous hashes
280280
(+ "(stdin)= " ($.bytes->hex-string ($.sha512 ($.string->bytes/utf-8 str)))))
281281

282-
(= dc-usernames* (table))
282+
(or= dc-usernames* (table))
283283

284284
(def username-taken (user)
285285
(when (empty dc-usernames*)

lib/brackets.arc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
; avoid redefinition warning
2-
($ (namespace-undefine-variable! (ac-global-name '%brackets)))
32

43
(def -mbf-argsym (e)
54
(and (begins string.e "_")
@@ -23,7 +22,7 @@
2322
; treats any symbols starting with '_' as args, ordered alphabetically
2423
; e.g. _1, _2, _3, or _a, _b, _c, etc.
2524
; treats __ as the rest arg
26-
(mac %brackets body
25+
(remac %brackets body
2726
(let args '__
2827
(each arg (dedup:sort > -mbf-argsyms.body)
2928
(pushnew arg args))

lib/declare.arc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
22

3-
(= declare-fns* (table))
3+
(or= declare-fns* (table))
44

55
(defs decl-idfn (old new args) new
66
decl-bool (old new args) (no:no new))

lib/html.arc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
darkblue (color 0 0 120)
2929
)
3030

31-
(= opmeths* (table))
31+
(or= opmeths* (table))
3232

3333
(mac opmeth args
3434
`(opmeths* (list ,@args)))

lib/ppr.arc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
(= pprsyms* (fill-table (table)
2-
'(quote "'"
3-
quasiquote "`"
4-
unquote ","
5-
unquote-splicing ",@")))
1+
(or= pprsyms* (fill-table (table)
2+
'(quote "'"
3+
quasiquote "`"
4+
unquote ","
5+
unquote-splicing ",@")))
66

77
(def sp ((o n 1))
88
" Print a number of spaces. "
@@ -143,7 +143,7 @@
143143
(indent-block (nthcdr 2 xs) (+ col (len "(suite "))))
144144
(indent-block (cdr xs) (+ col (len "(suite "))))))
145145

146-
(= indent-rules*
146+
(or= indent-rules*
147147
(fill-table (table)
148148
`(if ,(indent-if (len "if"))
149149
aif ,(indent-if (len "aif"))

lib/prompt.arc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
(fn () (map eval exprs)))
100100
(prompt-page user "Error: No application " app " for user " user))))
101101

102-
(wipe repl-history*)
102+
(or= repl-history* nil)
103103

104104
(defop repl req
105105
(if (admin (get-user req))

lib/srv.arc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
; To adjust this while running, adjust the req-window* time, not
2727
; req-limit*, because algorithm doesn't enforce decreases in the latter.
2828

29-
req-times* (table)
3029
req-limit* 30
3130
req-window* 10 ;10
3231
dos-window* 2 ;2
3332
)
34-
33+
(or= req-times* (table))
3534

3635
(def serve ((o port 8080))
3736
(wipe quitsrv*)
@@ -65,8 +64,8 @@
6564
; a thread to handle it. also arrange to kill that thread
6665
; if it has not completed in threadlife* seconds.
6766

68-
(= threadlife* 30 requests* 0 requests/ip* (table)
69-
throttle-ips* (table) ignore-ips* (table) spurned* (table))
67+
(or= threadlife* 30 requests* 0 requests/ip* (table)
68+
throttle-ips* (table) ignore-ips* (table) spurned* (table))
7069

7170
(def accept-request-with-deadline (s)
7271
(with ((in out ip) (socket-accept s)
@@ -332,7 +331,7 @@
332331

333332
;; extending the server with new ops
334333

335-
(= srvops* (table) redirector* (table) optimes* (table) opcounts* (table))
334+
(or= srvops* (table) redirector* (table) optimes* (table) opcounts* (table))
336335

337336
(def save-optime (name elapsed)
338337
; this is the place to put a/b testing
@@ -392,7 +391,7 @@ stdout, returns a url to redirect requests to after processing."
392391
it)))
393392
""))
394393

395-
(= fns* (table) fnids* nil timed-fnids* nil)
394+
(or= fns* (table) fnids* nil timed-fnids* nil)
396395

397396
; count on huge (expt 64 10) size of fnid space to avoid clashes
398397

@@ -600,7 +599,7 @@ stdout, returns a url to redirect requests to after processing."
600599

601600
; only unique per server invocation
602601

603-
(= unique-ids* (table))
602+
(or= unique-ids* (table))
604603

605604
(def unique-id ((o len 8))
606605
(let id (sym (rand-string (max 5 len)))
@@ -661,7 +660,7 @@ stdout, returns a url to redirect requests to after processing."
661660

662661
; Background Threads
663662

664-
(= bgthreads* (table) pending-bgthreads* nil)
663+
(or= bgthreads* (table) pending-bgthreads* nil)
665664

666665
(def new-bgthread (id f sec)
667666
(aif (bgthreads* id) (break-thread it))

0 commit comments

Comments
 (0)