Hacker News new | past | comments | ask | show | jobs | submit login

Take

   (elem "countries" (elem 0))
Inside out elem 0 has to return a function since it doesn't have enough to do anything. I'm not sure why 0 couldn't be a key necessitating a different function to differentiate but whatever.

Elem countries has to return json and one can imagine using the json in the first position like a map in clojure and taking a fn in following position. This would mean that on net it would be exactly the same as.

    (elem 0 (elem countries))



It really ends up being called like this: ((elem "countries" (elem 0)) JSON)

Yours is more akin to (elem 0 (elem "countries" json))

and you can see that the hierarchy of the query is now inverted in respect to the json. This is what I like about the continuation based approach, a big query will be readable because it fits the data very well.


Is it more readable than

    (->> JSON 
        (elem "countries")
        first)


This looks very readable and matches the structure of the json too.

To me it's basically the same readability wise with proper indentation.

Though with deeply nested data and a lot of map functions I think you'd have a lot of unnecessary (->> JSON ...). But those can probably be eliminated with another macro.

Also, there's the pipe function in jql which basically lets you do this.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: