[ANN] Clojure 1.9.0-alpha4

1,007 views
Skip to first unread message

Stuart Halloway

unread,
May 31, 2016, 11:42:00 AM5/31/16
to clo...@googlegroups.com
Clojure 1.9.0-alpha4 is now available.

Try it via

- Leiningen: [org.clojure/clojure "1.9.0-alpha4"]

1.9.0-alpha4 includes the following changes since 1.9.0-alpha3:

- fix describe empty cat
- improve update-in perf
- optimize seq (&) destructuring

Rich Hickey

unread,
Jun 1, 2016, 10:17:14 AM6/1/16
to clo...@googlegroups.com
To give people an idea of the update-in and seq destructuring improvements:

(let [d3 {:a {:b {:c 2}}}]
(dotimes [_ 10]
(time (dotimes [_ 10000000]
(update-in d3 [:a :b :c] inc)))))

;;;;;;;;;;; 1.9 alpha3 ;;;;;;;;;;;;;;
user=> "Elapsed time: 6489.189065 msecs"
"Elapsed time: 6501.518961 msecs"
"Elapsed time: 6479.994554 msecs"
"Elapsed time: 6477.236659 msecs"
"Elapsed time: 6490.542382 msecs"
"Elapsed time: 6494.044657 msecs"
"Elapsed time: 6475.188285 msecs"
"Elapsed time: 6498.734628 msecs"
"Elapsed time: 6486.312312 msecs"
"Elapsed time: 6476.566904 msecs"
nil

;;;;;;;;;;; 1.9 alpha4 ;;;;;;;;;;;;;;
user=> "Elapsed time: 1613.631053 msecs"
"Elapsed time: 1614.271583 msecs"
"Elapsed time: 1607.393994 msecs"
"Elapsed time: 1605.966032 msecs"
"Elapsed time: 1605.731867 msecs"
"Elapsed time: 1605.836779 msecs"
"Elapsed time: 1617.090363 msecs"
"Elapsed time: 1611.065741 msecs"
"Elapsed time: 1611.249945 msecs"
"Elapsed time: 1624.351585 msecs"
nil

(let [v (into [] (range 1000000))]
(dotimes [_ 10]
(time (dotimes [_ 10]
(loop [[x & xs] v]
(if xs
(recur xs)
x))))))

;;;;;;;;;;; 1.9 alpha3 ;;;;;;;;;;;;;;
user=> "Elapsed time: 1531.858419 msecs"
"Elapsed time: 1521.997662 msecs"
"Elapsed time: 1499.931748 msecs"
"Elapsed time: 1499.745901 msecs"
"Elapsed time: 1496.63342 msecs"
"Elapsed time: 1499.363234 msecs"
"Elapsed time: 1506.309383 msecs"
"Elapsed time: 1514.943316 msecs"
"Elapsed time: 1534.90731 msecs"
"Elapsed time: 1524.550125 msecs"
nil
;;;;;;;;;;; 1.9 alpha4 ;;;;;;;;;;;;;;
user=> "Elapsed time: 155.544283 msecs"
"Elapsed time: 131.861647 msecs"
"Elapsed time: 141.774727 msecs"
"Elapsed time: 238.939786 msecs"
"Elapsed time: 294.832594 msecs"
"Elapsed time: 278.476703 msecs"
"Elapsed time: 133.259029 msecs"
"Elapsed time: 139.917267 msecs"
"Elapsed time: 137.444001 msecs"
"Elapsed time: 147.852057 msecs”
nil


The code now produced for [x & xs] style destructuring is now as good as the best first/next code you could write by hand, while the code produced for [x y z] destructuring of indexed items is the same (fast, indexed) as always.

Rich
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Isaac Zeng

unread,
Jun 1, 2016, 12:12:04 PM6/1/16
to Clojure
That really cool

Frank Castellucci

unread,
Jun 1, 2016, 7:49:00 PM6/1/16
to Clojure

How was this accomplished?

Ghadi Shayban

unread,
Jun 2, 2016, 12:52:04 PM6/2/16
to Clojure
Let bindings from thbe macroexpansion of (let [[x & xs] v] ...)

;; old macroexpand
[G__1       v
 vec__2     G__1
 x          (nth vec__2 0 nil)
 xs         (nthnext vec__2 1)]

;; new macroexpand
[G__6       v
 vec__7     G__6
 seq__8    (seq vec__7)
 first__9  (first seq__8)
 seq__8    (next seq__8)
 x         first__9
 xs        seq__8]

676c...@gmail.com

unread,
Jun 4, 2016, 2:28:24 AM6/4/16
to Clojure
This isn’t only an optimisation but also a change in behaviour, isn’t
it?

Clojure 1.9.0-alpha3:

user=> (let [[x & xs] #{1 2 3}] x)
UnsupportedOperationException nth not supported on this type: PersistentHashSet  clojure.lang.RT.nthFrom (RT.java:948)

Clojure 1.9.0-alpha4:

user=> (let [[x & xs] #{1 2 3}] x)
1

Perhaps the documentation needs to be updated?
http://clojure.org/reference/special_forms#_vector_binding_destructuring


--
David

Atamert Ölçgen

unread,
Jun 4, 2016, 2:33:47 AM6/4/16
to clo...@googlegroups.com
On Sat, Jun 4, 2016 at 9:28 AM, <676c...@gmail.com> wrote:
This isn’t only an optimisation but also a change in behaviour, isn’t
it?

Clojure 1.9.0-alpha3:

user=> (let [[x & xs] #{1 2 3}] x)
UnsupportedOperationException nth not supported on this type: PersistentHashSet  clojure.lang.RT.nthFrom (RT.java:948)

Clojure 1.9.0-alpha4:

user=> (let [[x & xs] #{1 2 3}] x)
1

I hope this will be considered a regression and the old behavior will be restored.

 

Perhaps the documentation needs to be updated?
http://clojure.org/reference/special_forms#_vector_binding_destructuring


--
David

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kind Regards,
Atamert Ölçgen

◻◼◻
◻◻◼
◼◼◼

www.muhuk.com

Alex Miller

unread,
Jun 4, 2016, 8:22:38 AM6/4/16
to Clojure
Why?

Alan Forrester

unread,
Jun 4, 2016, 8:28:55 AM6/4/16
to clo...@googlegroups.com
What are you asking “Why?” about? You haven’t quoted anything so it’s not clear what you’re asking about.

Alan

On 4 Jun 2016, at 13:22, Alex Miller <al...@puredanger.com> wrote:

> Why?

Nicola Mometto

unread,
Jun 4, 2016, 8:33:20 AM6/4/16
to clo...@googlegroups.com
How is this a regression?

It doesn't cause any code that used to work to stop working.

The fact that tail destructuring now causes non-sequential collections to be destructured by sequential destructuring should be just considered an instance of GIGO and an implementation detail.
signature.asc

Atamert Ölçgen

unread,
Jun 4, 2016, 12:32:09 PM6/4/16
to clo...@googlegroups.com
Hi Alex,

On Sat, Jun 4, 2016 at 3:22 PM, Alex Miller <al...@puredanger.com> wrote:
Why?

Because unordered collections shouldn't have heads defined.

Is (first #{3 1 2}) => 3? or 2? or 1?

(I just tried it in a REPL and it is apparently 1.)

 

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Raison

unread,
Jun 4, 2016, 4:15:45 PM6/4/16
to Clojure
I support this change. Not only is it closer to the GIGO philosophy, but "let x in S" is actually a very reasonable use-case. Sometimes I just want an element from a set and I don't care about which particular one.

Your code may break if you're using try/catch to handle sets in a special way, but I can't imagine a situation where using clojure.core/set? wouldn't be simpler and more appropriate.
Reply all
Reply to author
Forward
0 new messages