This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-23
Channels
- # 100-days-of-code (1)
- # adventofcode (13)
- # aleph (1)
- # beginners (48)
- # boot (10)
- # calva (52)
- # cider (18)
- # cljsrn (23)
- # clojure (68)
- # clojure-uk (9)
- # clojurescript (5)
- # cursive (3)
- # datomic (4)
- # figwheel (7)
- # fulcro (14)
- # hoplon (2)
- # leiningen (5)
- # lumo (3)
- # off-topic (87)
- # overtone (5)
- # reitit (5)
- # rum (8)
- # shadow-cljs (7)
- # spacemacs (15)
(remove empty? '(() (println "hello") 2)))
Results in an error. Don't know how to create ISeq from: java.lang.Long
Should it?the docs for empty?
say that it only works on collections, so an error makes sense to me
@jayzawrotny You probably want (remove (comp empty? seq) '(() (println "hello") 2))
?
Er, no, not quite..
Maybe this
user=> (remove #(and (sequential? %) (empty? %)) '(() (println "hello") 2))
((println "hello") 2)
user=>
Thanks, that is what I was thinking. It was an unexpected behavior that took a while for me to find so I was curious how others felt about it.
Howdy. newbie question here. I'm playing with azure bots and i need to respond to the bot in 15 seconds or less regardless of how long it takes me to process. (15 seconds is not configurable) I've tried futures but they didn't fire all the time. I tried agents but it seems to wait for everything to be done. What can i do or try?
You can also try tea-time https://github.com/aphyr/tea-time/blob/master/README.md if you don't want to do interrop
Hey I'm trying to write a macro that converts something of the form [:or f1 f2 [:and f3 f4]] -> (or-perm f1 f2 (and-perm f3 f4)). It works as expected on inputs of the form (:or f1 f2) and [:or f1 f2], but not on inputs such as '(:or f1 f2) in the latter case it outputs '(or-perm f1 f2) instead of the desired (or-perm f1 f2). I'm having trouble understanding why.
@henri.schmidt '(..)
is shorthand for (quote (..))
and that's what the macro receives.
So it's as if you passed in ['quote [..]]
Thank you @seancorfield
That will create lists with the values of isAuthenticated?
and isSchmidt73?
and then eval will call those values as functions.
What is the value that isSchmidt73?
evaluates too? i.e., what is returned from perm/from-claims
?
So ((perm/from-claims {:user "schmidt73"}) {})
is what you're evaluating here.
And that fails as-is? (ignore the eval
/`list` stuff for now)
Which maybe its a symbol lookup namespacing error, but I'm very new to clojure so I have no idea.
You should almost never need eval
...
Try to do everything with plain functions. Macros really are only for 1) syntactic sugar (on top of functions) and 2) for constructs where you don't want the semantic of function evaluation (i.e., you don't want arguments evaluated).
It was just a lot to write (def perms (perm/or isSchmidit73 isOliveBoi)) and then (wrap-handler perms handler) around all my handlers that need authentication
I think your problem is that your eval
above is working with the values of those symbols instead of the symbols themselves
(eval (list 'isSchmidt73 {}))
-- does that work?
I guess this would be helpful reading: https://www.braveclojure.com/read-and-eval/
Consider this:
(def foo 42)
(eval (list 'foo {})) ;=> (eval '(foo {}))
(eval (list foo {})) ;=> (eval '(42 {}))
does that help explain it?But here we have (eval '(isAuth? {})) giving a result and (eval '(isSchmidt? {})) giving an error
You said this (eval (list 'isSchmidt73? {}))
worked, yes?
That's the same as (eval '(isSchmidt73? {}))
What will not work is (eval (list isSchmidt73? {}))
Also, thank you so much for all of your help. I'm doing a better job understanding this stuff now.
is there a way to make a top level var within a macro expansion that works with AOT? I don’t even know if I’m using all these words right … but like this: https://gist.github.com/eyston/21a7b05cfaf1fbee886a205941e2d3bd
this makes the var but its unbound when AOT … which makes sense, but I’m wondering if I can abuse something to make it have the value 😜
hm the gist didn’t expand, its
(defmacro macro-def
[k v]
(intern *ns* k v))
(when false
(macro-def foo "bar"))
(defn -main
[]
(println foo))
@henri.schmidt Hard to say without seeing the source of from-claims
I suspect...
@hueyp I think the issue is the way *ns*
is evaluated in different contexts. Add the following above the defmacro
: (def my-ns *ns*)
and then change the intern
call to use my-ns
instead.