Reader literal for clojure.lang.PersistentQueue?

已查看 765 次
跳至第一个未读帖子

Sean Corfield

未读,
2012年4月16日 14:23:082012/4/16
收件人 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

未读,
2012年4月16日 14:41:212012/4/16
收件人 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

未读,
2012年4月16日 15:07:372012/4/16
收件人 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

未读,
2012年4月16日 15:49:202012/4/16
收件人 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

未读,
2012年4月16日 22:13:262012/4/16
收件人 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

未读,
2012年4月17日 07:56:232012/4/17
收件人 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

未读,
2012年4月18日 13:12:202012/4/18
收件人 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

未读,
2012年4月27日 10:32:542012/4/27
收件人 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.

回复全部
回复作者
转发
0 个新帖子