Fork me on GitHub
#clojurescript
<
2020-01-06
>
alexmiller15:01:42

if anyone has opinions on cljs-related questions in the state of clojure survey, would welcome your feedback on questions just asked in #clojure-survey

folcon15:01:53

@alexmiller are you asking about cljc dev btw?

alexmiller15:01:43

generally, asking about all Clojure/ClojureScript development, but there is no specific question regarding cljc right now. if you have a more specific idea, please take it to #clojure-survey to discuss

dehli18:01:46

Hello; does anyone know why the following code behaves the way it does?

(def class (js/eval "class MyClass {}; MyClass;"))
(new class) ;; Works

(new (js/eval "class MyClass {}; MyClass;")) ;; Execution error (TypeError) at (<cljs repl>:1). eval is not a constructor
It's stemming from me wanting to do the following code:
(def ^:private code-that-works
  (let [ctr (gobj/get AWS "S3")]
    (new ctr (clj->js {:signatureVersion "v4"}))))

(def ^:private code-that-doesnt-work
  (new (gobj/get AWS "S3") 
       (clj->js {:signatureVersion "v4"})))

hiredman18:01:29

new working with anything other than a literal constant symbol is likely undefined behavior

dehli18:01:14

Thanks @hiredman!

dnolen18:01:52

@dehli new has to be given some symbol, but can be local, so you could assign the result of the eval to a let binding and that should probably work