Fork me on GitHub
#beginners
<
2016-10-06
>
jacoelho07:10:08

I was trying to get my head around records and defprotocol, is it possible to define operators like + - for the new types?

gregnwosu13:10:00

how can i configure dependencies that are only used when testing?

val_waeselynck13:10:14

@gregnwosu check out leiningen profiles

plexus14:10:29

@jacoelho those operations aren't part of a protocol. You might be able to do something by implementing your own subclass of java.lang.Number

rackdon14:10:23

Is there any possibility to read a file in clojurescript?

val_waeselynck14:10:31

@jacoelho I think it's either impossible or has serious drawbacks, otherwise core.matrix would use this technique

val_waeselynck14:10:38

if you're running on Node, everything that's available in Node is available to cljs

val_waeselynck14:10:28

if you're in the browser, you can't really access the filesystem

rackdon14:10:51

is in the browser

val_waeselynck14:10:23

@rackdon you can't anymore than in JavaScript, so AFAIK no you can't 😕

val_waeselynck14:10:29

you can perform upload

petterik14:10:27

You can access files in clojurescript at compile time with macros

cycle33715:10:12

I'm just reading a book here and I see older version of core.async then I went on github to find out core.async is using clojure 1.6.0

cycle33715:10:31

is this still in use amongst clojurians ?

cycle33715:10:53

seems a bit old

seancorfield15:10:44

core.async is compatible with later versions of Clojure. The version a library "depends" usually just indicates how far back it offers support.

seancorfield15:10:41

As of the start of 2016, about 20% of users were still on Clojure 1.6 http://blog.cognitect.com/blog/2016/1/28/state-of-clojure-2015-survey-results#clj

seancorfield15:10:42

I expect that’s shifted now to most folks being on 1.8.0 (nearly a year later) and some of us already have 1.9.0 Alpha builds in production.

seancorfield15:10:28

But note that in that survey there were still a chunk of folks using 1.5.1!

cycle33715:10:41

oh thanks for the link and precious info @seancorfield

cycle33715:10:44

yeah but when you see the library including a version like 1.5.1 or 1.6.0 doesn't it make you wonder if it's compatible with latest ?

seancorfield15:10:40

Most of the Contrib libraries have a CI matrix of versions, e.g., http://build.clojure.org/job/java.data-test-matrix/

seancorfield15:10:02

(core.async doesn’t, but it’s an interesting beast from a testing point of view)

seancorfield15:10:34

And if you look at core.async’s Change Log you can see the latest version included a bug fix for Clojure 1.9 so you can tell it’s tested against that https://github.com/clojure/core.async#changelog

seancorfield15:10:12

So, no, seeing an "old" version of Clojure in a library that has active commits and ongoing maintenance doesn’t make me wonder if it’s compatible with latest — it just gives me confidence that they’re still supporting older versions as well.

seancorfield15:10:31

If there are no recent commits then, sure, you might want to be concerned.

cycle33715:10:35

thanks sean

cycle33715:10:30

it didn't crossed my mind to checkout changelog

seancorfield15:10:52

core.async is very heavily used so a lack of compatibility with recent Clojure builds would be a "Big Deal(tm)"...

josh_tackett20:10:52

Anyone know an xml to json library?

donaldball20:10:52

I reckon most people would use clojure.data.xml to parse the xml into persistent data structures and probably cheshire to emit json from the persistent data structures

seancorfield21:10:29

(feels like you asked that before @josh_tackett ? or maybe it was someone else)

josh_tackett21:10:42

I did, hoping for a better crowd this time

josh_tackett21:10:46

I didn’t get an answer last time

seancorfield21:10:05

You got the same answer last time. I said to go XML -> Clojure data structures -> JSON.

josh_tackett21:10:07

@seancorfield sure, do you have libraries that will do that?

seancorfield21:10:07

And that’s partly because there are several possible JSON interpretations for any given XML structure / format so you can’t really expect to go automatically straight from XML to JSON — you need to interpret how the XML is structured (in a data structure) first.

seancorfield21:10:17

I recommended clojure.data.xml to parse the XML and probably clojure.data.json to produce JSON — both are Contrib libraries — but Cheshire is a more capable (and faster) JSON parsing/emitting library.

seancorfield21:10:55

In the middle, you’ll have to massage the Clojure representation of the raw XML into a structure that suits whatever JSON purpose you have downstream.

seancorfield21:10:00

As an example <a b="42"><c>something</c><d e="x"/><f g="y"><h/></f></a> — how would you represent a mixture of attributes and nested data in general in JSON? There are several possibilities.

Drew Verlee23:10:38

what do the numbers mean in :message "java.lang.RuntimeException: Map literal must contain an even number of forms, compiling:(res/jobs/current_value.clj:16:89)” i assume one indicates the line number

Drew Verlee23:10:51

im 99 percent sure its the first one 🙂. but what does the 89 indicate?

Drew Verlee23:10:26

yea, that makes sense