diff --git a/apps/news/blog.arc b/apps/news/blog.arc index 7208cba6f..48d364dc4 100644 --- a/apps/news/blog.arc +++ b/apps/news/blog.arc @@ -1,7 +1,10 @@ ; A blog for news.arc ; For the standalone blog example by PG, see blog.arc from arc3.1 -(= postdir* (+ srvdir* "posts/") blog-maxid* 0 posts* (table)) +(= postdir* (+ srvdir* "posts/")) + +(or= blog-maxid* 0 + posts* (table)) (deftem post id nil by nil title nil text nil) diff --git a/apps/news/news.arc b/apps/news/news.arc index 1aa4ffdb0..e2f436e3b 100644 --- a/apps/news/news.arc +++ b/apps/news/news.arc @@ -180,9 +180,9 @@ (def author (u i) (is u i!by)) -(= stories* nil ranked-stories* nil comments* nil - items* (table) url->story* (table) - maxid* 0 initload* 15000) +(or= stories* nil ranked-stories* nil comments* nil + items* (table) url->story* (table) + maxid* 0 initload* 15000) ; The dir expression yields stories in order of file creation time ; (because arc infile truncates), so could just rev the list instead of @@ -233,7 +233,7 @@ (def register-url (i url) (= (url->story* (canonical-url url)) i!id)) -(= stemmable-sites* (table)) +(or= stemmable-sites* (table)) (def canonical-url (url) (if (stemmable-sites* (sitename url)) @@ -268,7 +268,7 @@ (set i!dead) (save-item i))) -(= kill-log* nil) +(or= kill-log* nil) (def log-kill (i how) (push (list i!id how) kill-log*)) @@ -416,7 +416,7 @@ background-color: #" (hexrep (main-color user)) ";" "}")))) -(= pagefns* nil) +(or= pagefns* nil) ; page top @@ -573,7 +573,7 @@ (newslog ip user ',name ,@parms) ,@body))))) -(= newsop-names* nil) +(or= newsop-names* nil) (mac newsop args `(do (pushnew ',(car args) newsop-names*) @@ -1051,7 +1051,7 @@ (= user-changetime* 120 editor-changetime* 1440) -(= everchange* (table) noedit* (table)) +(or= everchange* (table) noedit* (table)) (def canedit (user i) (or (admin user) @@ -1685,7 +1685,7 @@ (do (note-baditem user ip) (pr "No such item."))))) -(= baditemreqs* (table) baditem-threshold* 1/100) +(or= baditemreqs* (table) baditem-threshold* 1/100) ; Something looking at a lot of deleted items is probably the bad sort ; of crawler. Throttle it for this server invocation. @@ -1730,7 +1730,7 @@ (mem 'commentable i!keys)))) -(= displayfn* (table)) +(or= displayfn* (table)) (= (displayfn* 'story) (fn (n i user here inlist) (display-story n i user here))) @@ -1773,7 +1773,7 @@ (def editable-type (i) (fieldfn* i!type)) -(= fieldfn* (table)) +(or= fieldfn* (table)) (= (fieldfn* 'story) (fn (user s) diff --git a/arc.arc b/arc.arc index 85334e859..abc1830fa 100644 --- a/arc.arc +++ b/arc.arc @@ -2880,7 +2880,7 @@ of 'x' by calling 'self'." (def write (x (o port (stdout))) (swrite serialize.x port)) -(= hooks* (table)) +(or= hooks* (table)) (def hook (name . args) (aif (hooks* name) (apply it args))) @@ -2905,7 +2905,7 @@ Useful in higher-order functions, or to index into lists, strings, tables, etc." (map get.2 '((a b c) (1 2 3) (p q r))) (c 3 r)) -(= savers* (table)) +(or= savers* (table)) (mac fromdisk (var file init load save) (w/uniq (gf gv) diff --git a/lib/app.arc b/lib/app.arc index 052d64770..52cee0bce 100644 --- a/lib/app.arc +++ b/lib/app.arc @@ -30,7 +30,7 @@ ; idea: a bidirectional table, so don't need two vars (and sets) -(= cookie->user* (table) user->cookie* (table) logins* (table)) +(or= cookie->user* (table) user->cookie* (table) logins* (table)) (def get-user (req) "Gets the user id string associated with 'req'. @@ -258,7 +258,7 @@ Returns nil if no logged-in user." (link "Try logging in now." "/"))))) (single-input "New password: " 'p 20 "update" t))) -(= good-logins* (queue) bad-logins* (queue)) +(or= good-logins* (queue) bad-logins* (queue)) (def good-login (user pw ip) (let record (list (seconds) ip user) @@ -279,7 +279,7 @@ Returns nil if no logged-in user." ;prepending this (stdin)= for backwards compatibility with previous hashes (+ "(stdin)= " ($.bytes->hex-string ($.sha512 ($.string->bytes/utf-8 str))))) -(= dc-usernames* (table)) +(or= dc-usernames* (table)) (def username-taken (user) (when (empty dc-usernames*) diff --git a/lib/brackets.arc b/lib/brackets.arc index 4c169e72f..321c648e6 100644 --- a/lib/brackets.arc +++ b/lib/brackets.arc @@ -1,5 +1,4 @@ ; avoid redefinition warning -($ (namespace-undefine-variable! (ac-global-name '%brackets))) (def -mbf-argsym (e) (and (begins string.e "_") @@ -23,7 +22,7 @@ ; treats any symbols starting with '_' as args, ordered alphabetically ; e.g. _1, _2, _3, or _a, _b, _c, etc. ; treats __ as the rest arg -(mac %brackets body +(remac %brackets body (let args '__ (each arg (dedup:sort > -mbf-argsyms.body) (pushnew arg args)) diff --git a/lib/declare.arc b/lib/declare.arc index 49ac9457a..266551955 100644 --- a/lib/declare.arc +++ b/lib/declare.arc @@ -1,6 +1,6 @@ ; by twilightsentry@gmail.com -(= declare-fns* (table)) +(or= declare-fns* (table)) (defs decl-idfn (old new args) new decl-bool (old new args) (no:no new)) diff --git a/lib/html.arc b/lib/html.arc index e0535b3f8..ffe421fbe 100644 --- a/lib/html.arc +++ b/lib/html.arc @@ -28,7 +28,7 @@ darkblue (color 0 0 120) ) -(= opmeths* (table)) +(or= opmeths* (table)) (mac opmeth args `(opmeths* (list ,@args))) diff --git a/lib/ppr.arc b/lib/ppr.arc index 595045add..3b961bd35 100644 --- a/lib/ppr.arc +++ b/lib/ppr.arc @@ -1,8 +1,8 @@ -(= pprsyms* (fill-table (table) - '(quote "'" - quasiquote "`" - unquote "," - unquote-splicing ",@"))) +(or= pprsyms* (fill-table (table) + '(quote "'" + quasiquote "`" + unquote "," + unquote-splicing ",@"))) (def sp ((o n 1)) " Print a number of spaces. " @@ -143,7 +143,7 @@ (indent-block (nthcdr 2 xs) (+ col (len "(suite ")))) (indent-block (cdr xs) (+ col (len "(suite ")))))) -(= indent-rules* +(or= indent-rules* (fill-table (table) `(if ,(indent-if (len "if")) aif ,(indent-if (len "aif")) diff --git a/lib/prompt.arc b/lib/prompt.arc index fe4d0552f..3bbc7df55 100644 --- a/lib/prompt.arc +++ b/lib/prompt.arc @@ -99,7 +99,7 @@ (fn () (map eval exprs))) (prompt-page user "Error: No application " app " for user " user)))) -(wipe repl-history*) +(or= repl-history* nil) (defop repl req (if (admin (get-user req)) diff --git a/lib/srv.arc b/lib/srv.arc index f612b480f..f5fc469d3 100644 --- a/lib/srv.arc +++ b/lib/srv.arc @@ -26,12 +26,11 @@ ; To adjust this while running, adjust the req-window* time, not ; req-limit*, because algorithm doesn't enforce decreases in the latter. - req-times* (table) req-limit* 30 req-window* 10 ;10 dos-window* 2 ;2 ) - +(or= req-times* (table)) (def serve ((o port 8080)) (wipe quitsrv*) @@ -65,8 +64,8 @@ ; a thread to handle it. also arrange to kill that thread ; if it has not completed in threadlife* seconds. -(= threadlife* 30 requests* 0 requests/ip* (table) - throttle-ips* (table) ignore-ips* (table) spurned* (table)) +(or= threadlife* 30 requests* 0 requests/ip* (table) + throttle-ips* (table) ignore-ips* (table) spurned* (table)) (def accept-request-with-deadline (s) (with ((in out ip) (socket-accept s) @@ -332,7 +331,7 @@ ;; extending the server with new ops -(= srvops* (table) redirector* (table) optimes* (table) opcounts* (table)) +(or= srvops* (table) redirector* (table) optimes* (table) opcounts* (table)) (def save-optime (name elapsed) ; this is the place to put a/b testing @@ -392,7 +391,7 @@ stdout, returns a url to redirect requests to after processing." it))) "")) -(= fns* (table) fnids* nil timed-fnids* nil) +(or= fns* (table) fnids* nil timed-fnids* nil) ; count on huge (expt 64 10) size of fnid space to avoid clashes @@ -600,7 +599,7 @@ stdout, returns a url to redirect requests to after processing." ; only unique per server invocation -(= unique-ids* (table)) +(or= unique-ids* (table)) (def unique-id ((o len 8)) (let id (sym (rand-string (max 5 len))) @@ -661,7 +660,7 @@ stdout, returns a url to redirect requests to after processing." ; Background Threads -(= bgthreads* (table) pending-bgthreads* nil) +(or= bgthreads* (table) pending-bgthreads* nil) (def new-bgthread (id f sec) (aif (bgthreads* id) (break-thread it)) diff --git a/lib/tem.arc b/lib/tem.arc index 442190701..47397db42 100644 --- a/lib/tem.arc +++ b/lib/tem.arc @@ -1,6 +1,6 @@ ($:require (only-in racket vector-map)) -(= templates* (table)) +(or= templates* (table)) (mac deftem (tem . fields) "Defines a _template_, a table with defaults defined for various keys.