Fork me on GitHub
#clojure
<
2018-05-27
>
cryptowanderer02:05:47

Hey everyone! Courtesy of our open bounty system at Status, we have built a pretty cool new clj-rn library and need a little bit of help building out the other, nicer-to-have parts. So, if you'd like to lend a hand (and earn some cryptocurrency while you're at it, though this is likely not the major motivation for folks around here), please take a look: https://github.com/status-im/clj-rn/issues

seancorfield05:05:29

@andy489 That seems more appropriate for either #clojurescript or #react-native ... and feels a bit spammy to me /admin (I'm not well-disposed to cryptocurrency folks, so I may just be overly sensitive)

seancorfield05:05:59

Or #jobs since you're paying people to do work...

dominicm11:05:12

(defn get-fn-reference
  [kw]
  (let [kns (namespace kw)
        snm (symbol (name kw))]
    (some-> kns
            symbol
            find-ns
            (ns-resolve snm)
            deref)))

(defmacro x
  [body]
  (let [a# (get-fn-reference body)]
    `(quote ~a#)))

(= (x clojure.core/not=)
   (get-fn-reference 'clojure.core/not=))
I'm struggling to understand why these are not equivalent. It's as if a new not= object is created at read-time. The fn version consistently returns the same hex code, whereas the macro variant returns a new version each time.

dominicm11:05:47

(defmacro x
  [body]
  `~(get-fn-reference body))
Even shorter version of x which exhibits the same behaviour.

tristefigure11:05:39

It's each time a new instance of the class clojure.core$not_EQ_

tristefigure11:05:00

add class just under deref and you will get the desired behavior

tristefigure11:05:35

not sure it this resolves you broader problem

dominicm11:05:39

@tristefigure Why does (get-fn-reference 'clojure.core/not=) always return the same value?

tristefigure11:05:59

Notice how the value change when you restart the repl

dominicm11:05:32

Yes, what does that mean though?

tristefigure11:05:27

Notice how (defn fx [] (x clojure.core/not=)) called multipled time return the same value

tristefigure11:05:13

This is because the macro is expanded only once in this case, when the fn is defined, whereas in your test the macro is expanded each time

tristefigure11:05:49

not sure why symbols are bound to a new instance of the fn classes though

dominicm11:05:45

The symbols bound to new instance of the fn class is what I'm confused about.

tristefigure11:05:53

Maybe try your luck on #clojure-dev, I don't know Clojure's internals well enough

dominicm11:05:09

I shall repeat my question there, thanks for your help up to here 🙂

skrat11:05:08

anyone familiar with compojure-api and schema validation can help with a request validation problem?

ikitommi13:05:46

What's the problem?

jgh11:05:46

what frameworks would you guys recommend to do server-side page rendering?

skrat12:05:08

@jgh compojure + hiccup

jgh12:05:47

ah cool, this looks great

seancorfield17:05:46

@jgh While Hiccup is great for producing HTML-as-data and then rendering it, it can be hard for designers etc to work with. We've adopted Selmer for that reason: it can use "plain" HTML templates with {{value}} substitutions and {% if ... %} conditionals etc /cc @skrat

jgh17:05:04

oh interesting, ok

jgh17:05:17

ill check that one out too

seancorfield17:05:50

We have page fragment templates in our database (a CMS) and our non-programmer staff can edit them easily -- including our translators (we render pages in over a dozen languages).

seancorfield17:05:47

We use Hiccup where no designers/translators are going to touch the HTML. And we use Hiccup for XML generation too.