This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-16
Channels
- # beginners (48)
- # cider (21)
- # clara (6)
- # cljdoc (3)
- # cljs-dev (11)
- # cljsrn (5)
- # clojure (30)
- # clojure-canada (1)
- # clojure-dusseldorf (2)
- # clojure-italy (10)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-russia (8)
- # clojure-spain (18)
- # clojure-uk (39)
- # clojurescript (84)
- # core-async (17)
- # cursive (22)
- # data-science (27)
- # datomic (27)
- # docker (3)
- # editors (5)
- # emacs (2)
- # figwheel-main (18)
- # fulcro (54)
- # hoplon (3)
- # hyperfiddle (2)
- # immutant (4)
- # jobs (1)
- # jobs-discuss (1)
- # lein-figwheel (7)
- # leiningen (3)
- # lumo (1)
- # onyx (5)
- # re-frame (64)
- # reagent (5)
- # reitit (7)
- # ring-swagger (6)
- # shadow-cljs (118)
- # specter (23)
- # tools-deps (38)
@dottedmag для таких вещей подойдут макросы типа with-something
. Каждый такой макрос оборачивает тело в try
и в секции finally
делает откат. В итоге получается
(with-step1 a b c
(with-step2 foo bar
(with-step3 duno lol
(do-my-sfuff arg1 arg2))))
если макрос должен передать открытый им порт, то можно забиндить его внутренним let
например
(with-opened-port my-port connection-params
;; now my-port is bound to the open port)
например
(defmacro with-driver
[type opt bind & body]
`(client/with-pool {}
(let [~bind (boot-driver ~type ~opt)]
(try
[email protected]
(finally
(quit ~bind))))))
@igrishaev См выше: я хочу в месте, где do-my-stuff
вернуться из функции, а потом позвать закрывающую отдельно.