Fork me on GitHub
#beginners
<
2019-04-28
>
Joel19:04:54

is there a null pointer safe version of this? '' (.. this getEventData getCustomer getUserGuid) ''

Joel19:04:10

maybe a way to supply default?

Ivan Koz19:04:21

don't call if something is nil?

mfikes19:04:17

Hrm. some-> could be useful here...

Ivan Koz19:04:04

(if nil
  true
  false)

(or nil 5)

Ivan Koz19:04:29

it really depends which value is possibly nil

Ivan Koz19:04:20

some-> will work but make sure there is no side effects, which will be strange for java

Joel19:04:06

right: don't call if something is nil in the chain

Joel19:04:23

it should short-circuit and give nil or possibly a default

Joel19:04:29

ill look at some->

Joel19:04:55

maybe should be some->> ?

Joel20:04:08

I'm just using getters so no side effect on java side.

lilactown20:04:02

(some-> this
   (.getEventData)
   (.getCustomer)
   (.getUserGuid))
would probably work?

Joel20:04:33

i didn't need parenthesis on getters, but yes that did work.

respatialized20:04:52

I remember reading somewhere in Clojurians not too long ago that core.spec had changed Clojure to such a degree that it demanded a change to many intros to the language. Can anyone point me towards a "spec-centric" tour/intro of Clojure?

Eric Ervin20:04:08

Getting Clojure has a spec chapter

👍 4
markmarkmark21:04:08

probably the change that they were referring to is the fact that you need spec on the classpath to use the clojure jar now. So you would have to(it would be easier to) use something like the clj tool, whereas before something like java -jar /path/to/clojure-1.x.0.jar used to be sufficient.

Alex Miller (Clojure team)20:04:08

I don't think it's true that spec demanded a change to existing intros. spec is almost entirely an ala carte usage and could be totally ignored for intro purposes.

Alex Miller (Clojure team)20:04:28

The 3rd ed of Programming Clojure does include a spec chapter though.

Ivan Koz20:04:09

can't wait to read it ^

Alex Miller (Clojure team)20:04:20

destined to be somewhat wrong when spec 2 comes out :)

Ivan Koz20:04:11

@alexmiller do you think its worth it to jump onto spec 2 skipping current version?

Eric Ervin20:04:30

spec 2 specific boogaloo

Alex Miller (Clojure team)21:04:44

no, it's still actively changing

Alex Miller (Clojure team)21:04:51

which is why there is no released version

Ivan Koz21:04:06

Any unofficial predictions based on your experience when it will be ready?

seancorfield21:04:55

I'll do my usual drive-by comment that we have a branch of our code at work that runs on Spec2 (so our transition will be as painless as possible) 🙂

🚗 4
Ivan Koz21:04:46

your drive-by comments are always on point 😉

seancorfield21:04:53

Elsewhere I believe Alex said they hoped to have it released before Conj (November) but it could be anywhere from "a few" to "six months or so" 🙂

seancorfield21:04:22

I think it depends on what you're building. If you're just experimenting and learning Clojure and focusing on the clojure.spec part, then playing with Spec2 so you can compare it to Spec1 and see the shift in thinking is worthwhile.

seancorfield21:04:57

If you're building product, you probably don't want to bet on Spec2 just yet, unless you're comfortable living on the very bleeding edge (like we do).

4
seancorfield21:04:14

But also, if you're not really going deep in clojure.spec, using Spec1 is fine for now.

Alex Miller (Clojure team)21:04:26

the only people that should be actively using spec 2 are people wanting to give bleeding edge feedback while we develop

Alex Miller (Clojure team)21:04:50

that's a small group of people, but their feedback has been really helpful and we greatly appreciate it

seancorfield21:04:37

I think a number of folks who've watched Rich's "Maybe Not" talk would find Spec2 and the evolution of schema/`select` edifying 🙂

seancorfield21:04:04

But, yeah, it's still changing a lot and that's to be expected.