Making Cons implement IPersistentList will solve all cases except when 
list* gets only one argument. This is problematic. The source looks like 
this:

(defn list*
  "Creates a new list containing the items prepended to the rest, the
  last of which will be treated as a sequence."
  {:added "1.0"
   :static true}
  ([args] (seq args))
  ([a args] (cons a args))
  ([a b args] (cons a (cons b args)))
  ([a b c args] (cons a (cons b (cons c args))))
  ([a b c d & more]
     (cons a (cons b (cons c (cons d (spread more)))))))

Calling 'seq' in the first case means that with calls like: (list* {:a 1}) 
we get clojure.lang.PersistentArrayMap$Seq and not a List. In theory, we 
could do just (apply list args) here, but apply itself also uses list* in 
its implementation. Luckily, it doesn't use the one-argument version of 
list*, so we could probably declare 'apply' above the 'list*' in the 
'core.clj' source and then use it there... Does it seem reasonably?

Marek

On Thursday, December 27, 2012 3:28:04 AM UTC+1, Tom Jack wrote:
>
> A small bug in ClojureScript was related to this: 
> https://github.com/clojure/clojurescript/commit/88b36c177ebd1bb49dbd874a9d13652fd1de4027
>
> It looks like the only thing missing to make Cons implement 
> IPersistentList is IPersistentStack. Why not implement it?
>
> On Wednesday, December 26, 2012 4:13:38 PM UTC-6, Ben wrote:
>>
>> On Wed, Dec 26, 2012 at 2:07 PM, Stephen Compall 
>> <stephen...@gmail.com> wrote: 
>> > On Wed, 2012-12-26 at 12:35 -0800, Marek Šrank wrote: 
>> >> ...however, its docstring says: "Creates a new list containing the 
>> items 
>> >> prepended to the rest, the last of which will be treated as a 
>> sequence." 
>> > 
>> > List is almost always colloquial, not literally IPersistentList. 
>> > 
>> > I would be in favor of eliminating list?, really, in favor of 
>> > seq?/sequential?/seqable?. 
>>
>> Given that lists and (e.g.) vectors behave differently in some 
>> circumstances (as the first argument to conj, for instance), it seems 
>> desirable to be able to tell what one's got on one's hands. 
>>
>> -- 
>> Ben Wolfson 
>> "Human kind has used its intelligence to vary the flavour of drinks, 
>> which may be sweet, aromatic, fermented or spirit-based. ... Family 
>> and social life also offer numerous other occasions to consume drinks 
>> for pleasure." [Larousse, "Drink" entry] 
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to