Reader literal for clojure.lang.PersistentQueue?

765 views
Skip to first unread message

Sean Corfield

unread,
Apr 16, 2012, 2:23:08 PM4/16/12
to cloju...@googlegroups.com
Now that we have reader literals, would it be useful to have a
built-in reader literal for this type?

#queue [] ;; create an empty clojure.lang.PersistentQueue
#queue [1 2 3 4]
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Phil Hagelberg

unread,
Apr 16, 2012, 2:41:21 PM4/16/12
to cloju...@googlegroups.com
On Mon, Apr 16, 2012 at 11:23 AM, Sean Corfield <seanco...@gmail.com> wrote:
> Now that we have reader literals, would it be useful to have a
> built-in reader literal for this type?
>
> #queue [] ;; create an empty clojure.lang.PersistentQueue
> #queue [1 2 3 4]

Personally I much prefer the queue-fish representation:

user=> (conj (conj clojure.lang.PersistentQueue/EMPTY 12) 9)
<-(12 9)-<

-Phil

Mark Engelberg

unread,
Apr 16, 2012, 3:07:37 PM4/16/12
to cloju...@googlegroups.com
On Mon, Apr 16, 2012 at 11:23 AM, Sean Corfield <seanco...@gmail.com> wrote:
Now that we have reader literals, would it be useful to have a
built-in reader literal for this type?

#queue [] ;; create an empty clojure.lang.PersistentQueue
#queue [1 2 3 4]

+1 

Stuart Sierra

unread,
Apr 16, 2012, 3:49:20 PM4/16/12
to cloju...@googlegroups.com
Nice. You can, of course, add your own data reader symbol (namespaced) that creates PersistentQueue.

The <-(1 2 3)-< syntax would require more changes to the reader. Don't hold your breath.
-S

Sean Corfield

unread,
Apr 16, 2012, 10:13:26 PM4/16/12
to cloju...@googlegroups.com
On Mon, Apr 16, 2012 at 12:49 PM, Stuart Sierra
<the.stua...@gmail.com> wrote:
> Nice. You can, of course, add your own data reader symbol (namespaced) that
> creates PersistentQueue.

Indeed. And I may well do so for my code. But it seems that
PersistentQueue is common enough that a standard, built-in literal
syntax might be warranted?

Brian Taylor

unread,
Apr 17, 2012, 7:56:23 AM4/17/12
to cloju...@googlegroups.com
Are there reader literals in the Clojurescript reader yet?

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To post to this group, send email to cloju...@googlegroups.com.
To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.


Stuart Sierra

unread,
Apr 18, 2012, 1:12:20 PM4/18/12
to cloju...@googlegroups.com
On Tuesday, April 17, 2012 7:56:23 AM UTC-4, Brian Taylor wrote:
Are there reader literals in the Clojurescript reader yet?

No. Needs a patch.

Fogus

unread,
Apr 27, 2012, 10:32:54 AM4/27/12
to cloju...@googlegroups.com
I've created a case for this at http://dev.clojure.org/jira/browse/CLJ-976

There is an open question stating:

Should the queue literal evaluate its arguments? 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]

I would appreciate feedback on the ticket itself.  Thank you.

Reply all
Reply to author
Forward
0 new messages