Clojure

Implement reader literal and print support for PersistentQueue data structure

Details

  • Patch:
    Code and Test
  • Approval:
    Triaged

Description

Clojure's PersistentQueue structure has been in the language for quite some time now and has found its way into a fair share of codebases. However, the creation of queues is a two step operation often of the form:

(conj clojure.lang.PersistentQueue/EMPTY :a :b :c)

;=> #<PersistentQueue clojure.lang.PersistentQueue@78d5f6bc>

A better experience might be the following:

#queue [:a :b :c]

;=> #queue [:a :b :c]

(pop #queue [:a :b :c])

;=> #queue [:b :c]

This syntax is proposed and discussed in the Clojure-dev group at https://groups.google.com/forum/?fromgroups#!topic/clojure-dev/GQqus5Wycno

Open question: Should the queue literal's arguments eval? The implications of this are illustrated below:

;; non-eval case
#queue [1 2 (+ 1 2)]

;=> #queue [1 2 (+ 1 2)]


;; eval case
#queue [1 2 (+ 1 2)]

;=> #queue [1 2 3]

The answer to this open question will determine the implementation.

Activity

Fogus made changes -
Field Original Value New Value
Description Clojure's PersistentQueue structure has been in the language for quite some time now and has found its way into a fair share of codebases. However, the creation of queues is a two step operation often of the form:

{noformat}
(conj clojure.lang.PersistentQueue/EMPTY :a :b :c)

;=> #<PersistentQueue clojure.lang.PersistentQueue@78d5f6bc>
{noformat}

A better experience might be the following:

{noformat}
#queue [:a :b :c]

;=> #queue [:a :b :c]

(pop #queue [:a :b :c])

;=> #queue [:b :c]
{noformat}

This syntax is proposed and discussed in the Clojure-dev group at https://groups.google.com/forum/?fromgroups#!topic/clojure-dev/GQqus5Wycno

Open question: Should the queue literal evaluate its arguments? The implications of this are illustrated below:

{noformat}
;; non-eval case
#queue [1 2 (+ 1 2)]

;=> #queue [1 2 (+ 1 2)]


;; eval case
#queue [1 2 (+ 1 2)]

;=> #queue [1 2 3]
{noformat}

The answer to this open question will determine the implementation as either a tagged literal or within the Reader itself.
Clojure's PersistentQueue structure has been in the language for quite some time now and has found its way into a fair share of codebases. However, the creation of queues is a two step operation often of the form:

{noformat}
(conj clojure.lang.PersistentQueue/EMPTY :a :b :c)

;=> #<PersistentQueue clojure.lang.PersistentQueue@78d5f6bc>
{noformat}

A better experience might be the following:

{noformat}
#queue [:a :b :c]

;=> #queue [:a :b :c]

(pop #queue [:a :b :c])

;=> #queue [:b :c]
{noformat}

This syntax is proposed and discussed in the Clojure-dev group at https://groups.google.com/forum/?fromgroups#!topic/clojure-dev/GQqus5Wycno

Open question: Should the queue literal's arguments eval? The implications of this are illustrated below:

{noformat}
;; non-eval case
#queue [1 2 (+ 1 2)]

;=> #queue [1 2 (+ 1 2)]


;; eval case
#queue [1 2 (+ 1 2)]

;=> #queue [1 2 3]
{noformat}

The answer to this open question will determine the implementation.
Fogus made changes -
Attachment CLJ-976-queue-literal-tagged-parse-support-only.diff [ 11116 ]
Fogus made changes -
Patch Code and Test [ 10002 ]
Attachment CLJ-976-queue-literal-eval.diff [ 11166 ]
Fogus made changes -
Attachment CLJ-976-queue-literal-eval.diff [ 11166 ]
Fogus made changes -
Attachment CLJ-976-queue-literal-tagged-parse-support-only.diff [ 11116 ]
Fogus made changes -
Attachment CLJ-976-queue-literal-eval.diff [ 11200 ]
Fogus made changes -
Waiting On richhickey
Assignee Fogus [ fogus ]
Fogus made changes -
Waiting On richhickey
Approval Vetted [ 10003 ]
Assignee Fogus [ fogus ]
Fogus made changes -
Fogus made changes -
Approval Vetted [ 10003 ] Test [ 10013 ]
Fogus made changes -
Assignee Fogus [ fogus ]
Stuart Sierra made changes -
Assignee Stuart Sierra [ stuart.sierra ]
Stuart Sierra made changes -
Assignee Stuart Sierra [ stuart.sierra ] Fogus [ fogus ]
Stuart Sierra made changes -
Approval Test [ 10013 ] Incomplete [ 10006 ]
Andy Fingerhut made changes -
Approval Incomplete [ 10006 ] Test [ 10013 ]
Rich Hickey made changes -
Fix Version/s Release 1.5 [ 10150 ]
Andy Fingerhut made changes -
Attachment clj-976-queue-literal-eval-and-synquote-patch-v2.txt [ 11537 ]
Andy Fingerhut made changes -
Andy Fingerhut made changes -
Attachment clj-976-queue-literal-eval-and-synquote-patch-v2.txt [ 11537 ]
Alex Miller made changes -
Approval Test [ 10013 ] Vetted [ 10003 ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Triaged [ 10120 ]

People

Vote (3)
Watch (5)

Dates

  • Created:
    Updated: