This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-15
Channels
- # aws-lambda (3)
- # beginners (17)
- # boot (65)
- # cider (3)
- # cljs-dev (7)
- # cljsrn (82)
- # clojure (82)
- # clojure-italy (1)
- # clojure-russia (25)
- # clojure-spec (56)
- # clojure-uk (5)
- # clojurescript (52)
- # css (2)
- # datomic (6)
- # emacs (1)
- # hoplon (9)
- # jobs-discuss (5)
- # leiningen (8)
- # mount (2)
- # nginx (1)
- # off-topic (2)
- # om (1)
- # om-next (9)
- # perun (13)
- # portland-or (1)
- # re-frame (13)
- # reagent (20)
- # remote-jobs (2)
- # ring (5)
- # spacemacs (1)
- # specter (10)
- # untangled (5)
- # yada (6)
@leov дада cider == emacs. Хз чо как про вим вааще
если он встречает данные, которые он не знает, он кидает эксепшн и останавливается, можно ли как-то передать на этот случай хендлер чтобы просто "заглушку" вставить и продолжить дальше?
@andre а как же:
TaggedValues
It is possible that Transit encoded data will contain a semantic type that a processing application does not have a read handler for. In that case, the encoded value cannot be decoded and is returned as an instance of a special TaggedValue type with two properties, a tag and a value (details vary by programming language). TaggedValues can be inspected by application code if required. If a TaggedValue instance is written with Transit, the tag and value are used for the encoded form. ensuring that TaggedValues roundtrip correctly.
я делаю визуально отображение в виде дерева структур данных cljs, и передаю их на визуализацию через сокет, там транзит
ну вот когда в данных есть левак какой-то от js , то write транзита вылетал с эксепшеном
привет, а подскажите best practice, нужна функция которая принимает 1 обяз. аргумент + допустим 2 опциональных, в разных комбинациях, какой вариант лучше?
;;1
(defn some-func
([required]
(some-func required nil nil))
([required opt1]
(some-func required opt1 nil))
([required opt1 opt2]
(println "do smthing" required opt1 opt2)))
;;2
(defn some-func1
([required]
(some-func1 required nil))
([required {:keys [:opt1 :opt2]}]
(println "do smthing" required opt1 opt2)))
;;3
(defn some-func2 [required & [opt1 opt2]]
(println "do smthing" required opt1 opt2))
;;4 что-то еще?
меня напрягает что nil надо будет явно передать если захочу (some-func2 nil "opt2 val")
такое еще есть
(defn configure [val & {:keys [debug verbose]
:or {debug false, verbose false}}]
(println "val =" val " debug =" debug " verbose =" verbose))
(configure 10)
;;val = 10 debug = false verbose = false
(configure 5 :debug true)
;;val = 5 debug = true verbose = false
;; Note that any order is ok for the kwargs
(configure 12 :verbose true :debug true)
;;val = 12 debug = true verbose = true
The use of keyword arguments has fallen in and out of fashion in the Clojure community over the years. They are now mostly used when presenting interfaces that people are expected to type at the REPL or the outermost layers of an API. In general, inner layers of the code find it easier to pass options as an explicit map.