From 91cbdb69daf66e7077255fd69b206ef4d3ac4eab Mon Sep 17 00:00:00 2001 From: Sebastian Crane Date: Thu, 24 Mar 2022 21:51:06 +0000 Subject: [PATCH] Simplify the system start and restart functions This commit changes the binding name of system/start's argument to _ (since it is currently not used within the function), and simplifies the system/restart function by not swapping the system Var's content with nil before filling it with the new-created system state. Eventually, these changes will be reverted when the initialisation of the system is separated from the starting of that system, which will mean that system/start will read its argument and that system/restart will have to reinitialise the system state before restarting it. Signed-off-by: Sebastian Crane --- src/system.clj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/system.clj b/src/system.clj index b8cee5e..f882c20 100644 --- a/src/system.clj +++ b/src/system.clj @@ -34,7 +34,7 @@ (yaml/parse-stream datafile)) (catch Exception e nil))) -(defn start [system] +(defn start [_] (let [config (load-config "config.yaml") state (atom (load-state (:data-file config))) irc (irc/new-irc-connection state config)] @@ -52,8 +52,7 @@ (defn restart [system-var] (do - (alter-var-root system-var stop) - (alter-var-root system-var (constantly nil)) + (stop (deref system-var)) (alter-var-root system-var start))) (defn -main [& args]