This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-25
Channels
- # admin-announcements (3)
- # alda (2)
- # beginners (10)
- # boot (44)
- # cider (31)
- # cljs-dev (5)
- # cljsjs (2)
- # cljsrn (17)
- # clojure (181)
- # clojure-austin (2)
- # clojure-brasil (18)
- # clojure-canada (1)
- # clojure-conj (5)
- # clojure-dev (11)
- # clojure-gamedev (30)
- # clojure-russia (380)
- # clojure-spec (50)
- # clojure-uk (35)
- # clojurescript (146)
- # clojutre (1)
- # component (1)
- # cursive (62)
- # datomic (27)
- # dirac (7)
- # editors (23)
- # emacs (7)
- # events (34)
- # funcool (22)
- # hoplon (134)
- # jobs (22)
- # jobs-rus (7)
- # juxt (1)
- # kekkonen (1)
- # lein-figwheel (54)
- # leiningen (7)
- # luminus (2)
- # off-topic (5)
- # om (4)
- # onyx (27)
- # proton (5)
- # protorepl (2)
- # re-frame (16)
- # reagent (29)
- # rethinkdb (2)
- # schema (1)
- # untangled (61)
- # yada (9)
@onetom i bet that’s why my boot reload doesn’t really work
@thedavidmeister i've prepared a minimal repo where you can play with reload
https://github.com/onetom/boot-reloadable-hoplon
(i used it to debug an error thrown from (reload :on-jsload true)
, but it turned out i was using boot-hoplon
0.2.2 instead of the latest 0.2.4, so there is no example of defonce
in it yet)
@jumblerg i've also prepared a reload example specifically for hoplon ui: https://github.com/addplus/hoplon-ui-reload-example
i would be curious what do you think about this approach of having a cell as the content of body which i reset!
on namespace reloads
Hello everyone, Im using ~
unquote in a formula cell to hoist another cell up, but I’d like to use this inside a macro, how can I prevent the macro from hoisting the cell until later in the formula cell?
seems like an extra
` does the trick? …. apparently not
@micha Is there an example somewhere which shows macro expansion in a formula context?
@flyboarder how do you mean?
javelin fully expands all macros in the formula before it does its own work, is that what you mean?
So to avoid evaluation of some-other-value I am using a macro
oh ok, do you have another idea?
no, it uses pred, which will fail if pred is nil
the above will work, but if I try to use it in a function and pass in my route-params they are evaluated and it calls (fbdb/get-in (fb/post) (:id route-params))
which fails because route-params is nil at first
the whole get-in thing will throw an error if it doesnt get non-nil params
right but in a function call (fbdb/get-in (fb/post) (:id route-params))
is passed in as an arg, which evals it anyway, I was trying to write a macro to guard it
but the macro screws up my reset! because the cell is a value then
@dm3 I havnt used add-watch before
(with-let [fbc (j/cell nil)]
(add-watch pred
(fn [_ _ old new] ;; not sure about args
(when new
(fbdb/listen-once ref (str/...) #(reset! fbc (db->clj %))))))
@dm3 interesting, ill have to play with that
@dm3 that will only watch one of that arguments tho right
I may not be able to guarantee that my incoming arguments are cells
@micha ^ do you mean in my function or in the macro version?
so (when (and pred ref) (stuff in here will not evaluate unless ref and pred are both not nil))
shoudl work
ah right, slight miss communication, ref is only either a value or throws an error, I would need to make this a macro to delay ref
evaluation no?
if it’s a function it throws the error before entering my func
right, ok so just to summarize, in a formula cell I can do this to eval things before the formula (cell= ~(things to pre eval))
but I cannot do that inside a macro (defmacro blah (cell= ~(things to pre eval)))
and I think thats whats happening which is why its a value not a cell anymore
so if your macro will macroexpand its arguments before it generates its code you will be safe
the macro doesn't know or care about macros in its arguments, just like a function doesn't know or care about the functions that might be evaluating to the values it gets as its arguments
That seems to be the way I default my thinking, why doesnt it just do this!?
however, if you can't solve the specific problem you have without macros first, then macros won't help you
You’d think there should be a way to specify if I want my argument evaluated when it is passed to my function, instead of either yes it’s evaluated (func) or no it’s not (macro)
like partial argument eval
right because it’s all at compile time
we just leverage the similarity of the two languages to make some things act as if you could write macros in the same language
but like in clj you can make a macro that uses a function defined in the same namespace
@micha ok so trying to use formula
this returns a function, which takes cells?
and the things you have to do to hardcode the solution will be the exact same things the macro will need to do, later
lol well it works so long as I dont put it in a function, this tells me my issue is when the arguments are evaluated
thats basically what im trying to do but im using ~
in my formula which doesnt work once it’s a macro
cant I delay ~
so it’s done by the formula not the macro?
right cell= is what is in my current version
I will try to hardcode it as a formula
version
and go from there
^ in a let
(hfb/fbwhen-cell (:id route-params) (fbdb/get-in (fb/post) [(keyword (:id route-params))]))
thats the issue, arg2 (fbdb/get-in (fb/post) [(keyword (:id route-params))])
needs to wait before it can eval
route-params
not to be nil
it throws an error
well any non-nil value isnt valid logic
so even if I catch the error I need to replace it with something
that something needs to exist in db
yeah it seems that if I want to implement this as a function, I need to sanitize the argument inside and out of the function
like sanitize it outside to stop the error, and then again inside so make sure im not getting passed nil
yeah but thats how the firebase library works
^ good point, lol I can just do whatever with it 😛
@micha had a few 💡 makes much more sense now thanks!