Fork me on GitHub
Roman Liutikov16:11:12

Shouldn’t cljs interop with iterable JS objects such as Set and Map via iterator protocol? So (first (js/Set. #js [1 2 3])) ;; 1 would be possible. Clojure allows (first (HashSet.))


extending the seq abstraction to iterables would be pretty cool

Alex Miller (Clojure team)17:11:16

oh, this is cljs, nvm! :)

Roman Liutikov17:11:45

there’s es6-iterator-seq indeed

Roman Liutikov17:11:27

but since Clojure already works with Java collections maybe cljs should be on par as well


There is some really wired lists like that for me just works with (for [i (range (.-length x))] (aget x i))

Roman Liutikov17:11:36

@souenzzo For array-like collections in js one can use cljs.core/array-seq

Roman Liutikov18:11:35

iterables are different, though many array-like collection types in browser env might have been already upgraded to iterator protocol (Array for sure)


@roman01la the issue is that CLJS in theory generates ES3 code. that didn't have Map/Set, so if the protocols were extended onto those it wouldn't be ES3 anymore. not sure that it should either. could do it in a simple library.


Could do existence checks


that doesn't play well with :advanced

Roman Liutikov21:11:16

Maybe it's fine to include this code even if it's not used


@roman01la there's no specific reason other than it hasn't been requested - I think it just means adding a new branch to seq


we don't care about the specific types of course - just whether it's iterable - has "@@iterator" property or the actual iterator symbol


@thheller re: var lifting support - I think that's definitely not something we intend to support in any direct kind of way.


it would let reify generate better code but I guess that doesn't matter much


yeah - not a pressing a concern