This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-09
Channels
- # beginners (41)
- # boot (4)
- # cider (36)
- # cljsrn (9)
- # clojure (365)
- # clojure-dev (1)
- # clojure-dusseldorf (1)
- # clojure-nl (1)
- # clojure-russia (3)
- # clojure-spain (1)
- # clojure-spec (19)
- # clojure-uk (1)
- # clojurescript (159)
- # code-reviews (7)
- # core-async (51)
- # cursive (2)
- # datascript (1)
- # datomic (1)
- # emacs (5)
- # figwheel (3)
- # hoplon (18)
- # incanter (1)
- # lein-figwheel (1)
- # leiningen (3)
- # lumo (145)
- # off-topic (26)
- # onyx (21)
- # re-frame (2)
- # reagent (45)
- # rum (4)
- # uncomplicate (10)
- # untangled (23)
- # yada (6)
if anybody is looking for more clojure katas to learn from I just ported the first set of 16 javascript katas from http://freecodecamp.com to clojure and put them on codewars at https://www.codewars.com/collections/unofficial-fcc-challenges-basic-algorithm-scripting
(defmacro def-sdk-fn [name spec body]
`(defn ~name
([& args]
(if true
(e/wrong-number-of-args-error)
(js/console.info "lawl")))))
Produces the error: ERROR: Can't use qualified name as parameter: cxengage-javascript-sdk.macros/args at line 15
you need to use args#
` tries to fully qualify things
ugh - the bot interprets too much - the input was
`(foo)
okay I think that was a missing link in my head! thanks @noisesmith, works great now
what args# does is generate a temporary local symbol that will be unique
(but match another usage of args# in the same scope)
which is something I'll need to do whenever needing to output function arguments in a macro
or let bindings
or loop bindings
or for bindings, etc.
@noisesmith I just had to do some let
bindings and same deal, makes more sense now. thanks.
I'm wanting to call a cljs
fn inside my macro... does the cljs
namespace have to be a cljc
namespace in order for that to be possible?
you can use reader-macros for clj/cljs in a cljc file - but remember a macro doesn't have to find the thing it compiles to, it just needs to emit the right forms
it's neccessary that the thing the macro refers to exist when it is expanded though, or you'll get a compiler error
` is syntax-quote, ' is quote, and is unquote and @ is unquote-splicing
thanks! back to brave-clojure for a bit for me, so I can try and not gloss over those details this time.. ><
@polymeris works for me in 1.9.482
+cljs.user=> (t/is (thrown? js/Object 1))
FAIL in () (at evalmachine.<anonymous>:14:4)
expected: (thrown? js/Object 1)
actual: nil
nil
+cljs.user=> (t/is (thrown? js/Object (throw (js/Object.)))
+ #_=> )
#js {}
you can't require thrown? - it's a special syntax of is, it isn't defined anywhere
(well it's defined as part of the is macro, but isn't bound anywhere, is what I mean)