Fork me on GitHub
#hoplon
<
2017-02-07
>
chromalchemy10:02:08

@thedavidmeister In your debugging function (defn prnr [v] (prn v) v) what does the last v do?

thedavidmeister10:02:30

returns v instead of nil

thedavidmeister10:02:21

@chromalchemy makes it easier to chain

thedavidmeister10:02:36

(-> a foo bar prnr baz)

chromalchemy11:02:49

Oh, ok, I see now. Thanks

chromalchemy11:02:40

I've never gotten comfortable with a standard repl, and followed Micha's advice to just use reload+console. Make sense cause all your namespaces and state are already loaded.

chromalchemy11:02:22

But i found myself restructuring my code a lot just to test and experiment with values

chromalchemy11:02:19

Came up with this to try and keep the repl-ish testing separate from my "canonical" code, (but I dont think it really does much :thinking_face:)

chromalchemy11:02:51

(defelem eval
 [{:keys [clear?] :as   attr}]
 (let [exprs (dissoc attr :x)]
  (div
   :clear-console? 
    (if (nil? clear?) (.clear js/console))
   :print-expression-name-and-value
    (for [fn-vec (into [] exprs)]
     (do (.log js/console (title-string-fn (first fn-vec)))
         (.log js/console (second fn-vec)))))))
(eval :fn1-title (fn1) :fn2-title (fn2) ;;; etc...

chromalchemy11:02:27

(cell= (eval  :clear? true :fn-title (myfn)))
Keeps refreshing the printout in place in the console. Helpful when testing time or ui based dynamic data (cells).

chromalchemy11:02:14

I wanted to print out the actual function code to, to see everthing in one glance in the console. But I couldn't figure out how to execute a function, and print the forms of that function as a side effect (if it's even possible)

thedavidmeister13:02:41

i think the way i approach things is different

thedavidmeister13:02:18

i've tried to make it so restructuring code to test/experiment with values is A Good Thing

thedavidmeister13:02:24

then i use automated tests and a library of "patterns", which is basically just a bunch of example values in a GUI, to make sure things work properly